BuddyPress - Version 1.1.3

Version Description

Download this release

Release Info

Developer apeatling
Plugin Icon 128x128 BuddyPress
Version 1.1.3
Comparing to
See all releases

Code changes from version 1.1.2 to 1.1.3

Files changed (212) hide show
  1. bp-activity.php +58 -52
  2. bp-activity/bp-activity-classes.php +80 -80
  3. bp-activity/bp-activity-filters.php +2 -2
  4. bp-activity/bp-activity-templatetags.php +55 -58
  5. bp-activity/bp-activity-widgets.php +10 -10
  6. bp-activity/deprecated/bp-activity-deprecated.php +17 -17
  7. bp-activity/deprecated/css/structure.css +0 -0
  8. bp-activity/deprecated/images/rss.png +0 -0
  9. bp-activity/feeds/bp-activity-friends-feed.php +0 -0
  10. bp-activity/feeds/bp-activity-personal-feed.php +0 -0
  11. bp-activity/feeds/bp-activity-sitewide-feed.php +0 -0
  12. bp-blogs.php +109 -105
  13. bp-blogs/admin-tabs/admin.css +0 -0
  14. bp-blogs/admin-tabs/bp-blogs-comments-tab.php +0 -0
  15. bp-blogs/admin-tabs/bp-blogs-posts-tab.php +0 -0
  16. bp-blogs/admin-tabs/bp-blogs-tab.php +0 -0
  17. bp-blogs/bp-blogs-classes.php +17 -17
  18. bp-blogs/bp-blogs-templatetags.php +1 -1
  19. bp-blogs/bp-blogs-widgets.php +0 -0
  20. bp-blogs/deprecated/bp-blogs-deprecated.php +0 -0
  21. bp-blogs/deprecated/css/structure.css +0 -0
  22. bp-blogs/deprecated/js/directory-blogs.js +0 -0
  23. bp-core.php +216 -218
  24. bp-core/bp-core-activation.php +77 -35
  25. bp-core/bp-core-admin.php +50 -50
  26. bp-core/bp-core-adminbar.php +58 -58
  27. bp-core/bp-core-avatars.php +98 -82
  28. bp-core/bp-core-catchuri.php +29 -29
  29. bp-core/bp-core-classes.php +84 -84
  30. bp-core/bp-core-cssjs.php +22 -22
  31. bp-core/bp-core-notifications.php +16 -16
  32. bp-core/bp-core-settings.php +38 -38
  33. bp-core/bp-core-signup.php +43 -47
  34. bp-core/bp-core-templatetags.php +296 -287
  35. bp-core/bp-core-widgets.php +30 -30
  36. bp-core/css/widget-members.css +0 -0
  37. bp-core/deprecated/bp-core-deprecated.php +104 -154
  38. bp-core/deprecated/css/admin-bar.css +0 -0
  39. bp-core/deprecated/css/structure.css +0 -0
  40. bp-core/deprecated/images/accept_button_side.gif +0 -0
  41. bp-core/deprecated/images/add_button_side.gif +0 -0
  42. bp-core/deprecated/images/add_friend_button.gif +0 -0
  43. bp-core/deprecated/images/admin-menu-arrow.gif +0 -0
  44. bp-core/deprecated/images/admin_bar_back.gif +0 -0
  45. bp-core/deprecated/images/admin_bar_logo.gif +0 -0
  46. bp-core/deprecated/images/ajax-loader.gif +0 -0
  47. bp-core/deprecated/images/blog.png +0 -0
  48. bp-core/deprecated/images/button_back.gif +0 -0
  49. bp-core/deprecated/images/check_button_side.gif +0 -0
  50. bp-core/deprecated/images/loading_button_side.gif +0 -0
  51. bp-core/deprecated/images/logout_bullet.gif +0 -0
  52. bp-core/deprecated/images/member.png +0 -0
  53. bp-core/deprecated/images/nav_bullet.gif +0 -0
  54. bp-core/deprecated/images/reject_button_side.gif +0 -0
  55. bp-core/deprecated/images/remove_button_side.gif +0 -0
  56. bp-core/deprecated/images/remove_friend_button.gif +0 -0
  57. bp-core/deprecated/images/requested_friend_button.gif +0 -0
  58. bp-core/deprecated/images/view_button_side.gif +0 -0
  59. bp-core/deprecated/js/directory-members.js +0 -0
  60. bp-core/deprecated/js/general.js +0 -0
  61. bp-core/deprecated/js/jquery/jquery.livequery.pack.js +0 -0
  62. bp-core/deprecated/js/jquery/jquery.tablednd.js +0 -0
  63. bp-core/images/Jcrop.gif +0 -0
  64. bp-core/images/admin_menu_icon.png +0 -0
  65. bp-core/images/mystery-man.jpg +0 -0
  66. bp-core/js/admin-bar.js +0 -0
  67. bp-core/js/widget-members.js +0 -0
  68. bp-forums.php +64 -64
  69. bp-forums/bb-config.php +0 -0
  70. bp-forums/bbpress/bb-admin/admin-base.php +1 -5
  71. bp-forums/bbpress/bb-admin/admin.php +1 -9
  72. bp-forums/bbpress/bb-admin/includes/class.bb-install.php +0 -3
  73. bp-forums/bbpress/bb-admin/includes/defaults.bb-schema.php +27 -43
  74. bp-forums/bbpress/bb-admin/includes/functions.bb-admin.php +2 -21
  75. bp-forums/bbpress/bb-admin/includes/functions.bb-recount.php +0 -262
  76. bp-forums/bbpress/bb-admin/includes/functions.bb-upgrade.php +7 -20
  77. bp-forums/bbpress/bb-admin/index.php +18 -22
  78. bp-forums/bbpress/bb-admin/tools-recount.php +132 -27
  79. bp-forums/bbpress/bb-cron.php +14 -11
  80. bp-forums/bbpress/bb-includes/backpress/functions.formatting.php +4 -6
  81. bp-forums/bbpress/bb-includes/backpress/functions.kses.php +64 -705
  82. bp-forums/bbpress/bb-includes/class.bp-options.php +3 -0
  83. bp-forums/bbpress/bb-includes/functions.bb-core.php +31 -66
  84. bp-forums/bbpress/bb-includes/functions.bb-deprecated.php +2 -5
  85. bp-forums/bbpress/bb-includes/functions.bb-meta.php +1 -1
  86. bp-forums/bbpress/bb-includes/functions.bb-pluggable.php +14 -15
  87. bp-forums/bbpress/bb-includes/functions.bb-posts.php +0 -1
  88. bp-forums/bbpress/bb-includes/functions.bb-template.php +9 -8
  89. bp-forums/bbpress/bb-includes/functions.bb-users.php +40 -78
  90. bp-forums/bbpress/bb-includes/js/jquery/interface.js +1 -2
  91. bp-forums/bbpress/bb-login.php +60 -104
  92. bp-forums/bbpress/bb-templates/kakumei-blue/style.css +0 -2
  93. bp-forums/bbpress/bb-templates/kakumei/favorites.php +1 -1
  94. bp-forums/bbpress/bb-templates/kakumei/forum.php +2 -2
  95. bp-forums/bbpress/bb-templates/kakumei/front-page.php +2 -2
  96. bp-forums/bbpress/bb-templates/kakumei/post-form.php +2 -2
  97. bp-forums/bbpress/bb-templates/kakumei/style.css +1 -16
  98. bp-forums/bbpress/bb-templates/kakumei/tag-single.php +1 -1
  99. bp-forums/bbpress/bb-templates/kakumei/view.php +2 -2
  100. bp-forums/bbpress/rss.php +1 -1
  101. bp-forums/bp-forums-admin.php +30 -30
  102. bp-forums/bp-forums-bbpress.php +17 -17
  103. bp-forums/bp-forums-filters.php +2 -2
  104. bp-forums/bp-forums-templatetags.php +111 -111
  105. bp-forums/deprecated/images/closed.png +0 -0
  106. bp-friends.php +125 -126
  107. bp-friends/bp-friends-classes.php +79 -79
  108. bp-friends/bp-friends-notifications.php +13 -13
  109. bp-friends/bp-friends-templatetags.php +50 -50
  110. bp-friends/deprecated/bp-friends-deprecated.php +0 -0
  111. bp-friends/deprecated/css/structure.css +0 -0
  112. bp-friends/deprecated/images/ajax-loader.gif +0 -0
  113. bp-friends/deprecated/js/general.js +0 -0
  114. bp-groups.php +463 -459
  115. bp-groups/bp-groups-admin.php +10 -10
  116. bp-groups/bp-groups-classes.php +325 -316
  117. bp-groups/bp-groups-filters.php +5 -5
  118. bp-groups/bp-groups-notifications.php +40 -40
  119. bp-groups/bp-groups-templatetags.php +284 -284
  120. bp-groups/bp-groups-widgets.php +19 -19
  121. bp-groups/deprecated/bp-groups-deprecated.php +108 -108
  122. bp-groups/deprecated/css/structure.css +0 -0
  123. bp-groups/deprecated/images/ajax-loader.gif +0 -0
  124. bp-groups/deprecated/images/none-thumbnail.gif +0 -0
  125. bp-groups/deprecated/images/none.gif +0 -0
  126. bp-groups/deprecated/js/directory-groups.js +0 -0
  127. bp-groups/deprecated/js/general.js +0 -0
  128. bp-groups/js/widget-groups.js +0 -0
  129. bp-languages/buddypress.pot +0 -0
  130. bp-loader.php +6 -6
  131. bp-messages.php +84 -84
  132. bp-messages/bp-messages-classes.php +131 -131
  133. bp-messages/bp-messages-cssjs.php +5 -5
  134. bp-messages/bp-messages-filters.php +0 -0
  135. bp-messages/bp-messages-notifications.php +11 -11
  136. bp-messages/bp-messages-templatetags.php +89 -89
  137. bp-messages/css/autocomplete/jquery.autocompletefb.css +0 -0
  138. bp-messages/deprecated/bp-messages-deprecated.php +41 -41
  139. bp-messages/deprecated/css/structure.css +0 -0
  140. bp-messages/deprecated/images/ajax-loader.gif +0 -0
  141. bp-messages/deprecated/images/email.gif +0 -0
  142. bp-messages/deprecated/images/email_draft.gif +0 -0
  143. bp-messages/deprecated/images/email_open.gif +0 -0
  144. bp-messages/deprecated/images/email_sent.gif +0 -0
  145. bp-messages/deprecated/images/loading.gif +0 -0
  146. bp-messages/deprecated/images/nav_bullet.gif +0 -0
  147. bp-messages/deprecated/images/warning.gif +0 -0
  148. bp-messages/deprecated/js/general.js +0 -0
  149. bp-messages/js/autocomplete/jquery.autocomplete.js +0 -0
  150. bp-messages/js/autocomplete/jquery.autocompletefb.js +0 -0
  151. bp-messages/js/autocomplete/jquery.bgiframe.min.js +0 -0
  152. bp-messages/js/autocomplete/jquery.dimensions.js +0 -0
  153. bp-status.php +24 -24
  154. bp-status/bp-status-filters.php +0 -0
  155. bp-status/bp-status-templatetags.php +21 -21
  156. bp-status/bp-status-widgets.php +0 -0
  157. bp-themes/bp-default/_inc/css/adminbar.css +2 -2
  158. bp-themes/bp-default/_inc/css/screen.css +176 -173
  159. bp-themes/bp-default/_inc/images/accept_button.gif +0 -0
  160. bp-themes/bp-default/_inc/images/accept_button_side.gif +0 -0
  161. bp-themes/bp-default/_inc/images/activity_bullet.gif +0 -0
  162. bp-themes/bp-default/_inc/images/add_button_side.gif +0 -0
  163. bp-themes/bp-default/_inc/images/add_friend_button.gif +0 -0
  164. bp-themes/bp-default/_inc/images/add_friend_icon.gif +0 -0
  165. bp-themes/bp-default/_inc/images/admin-menu-arrow.gif +0 -0
  166. bp-themes/bp-default/_inc/images/admin_bar_back.gif +0 -0
  167. bp-themes/bp-default/_inc/images/admin_bar_logo.gif +0 -0
  168. bp-themes/bp-default/_inc/images/admin_menu_icon.png +0 -0
  169. bp-themes/bp-default/_inc/images/ajax-loader.gif +0 -0
  170. bp-themes/bp-default/_inc/images/arrowback_icon.gif +0 -0
  171. bp-themes/bp-default/_inc/images/background.gif +0 -0
  172. bp-themes/bp-default/_inc/images/background_blog.gif +0 -0
  173. bp-themes/bp-default/_inc/images/blog.png +0 -0
  174. bp-themes/bp-default/_inc/images/blog_bullet.gif +0 -0
  175. bp-themes/bp-default/_inc/images/blogadmin_icon.gif +0 -0
  176. bp-themes/bp-default/_inc/images/bp_logo.gif +0 -0
  177. bp-themes/bp-default/_inc/images/button_back.gif +0 -0
  178. bp-themes/bp-default/_inc/images/centercol_header_back.gif +0 -0
  179. bp-themes/bp-default/_inc/images/check_button_side.gif +0 -0
  180. bp-themes/bp-default/_inc/images/closed.png +0 -0
  181. bp-themes/bp-default/_inc/images/comments_icon.gif +0 -0
  182. bp-themes/bp-default/_inc/images/content_back.gif +0 -0
  183. bp-themes/bp-default/_inc/images/content_header.gif +0 -0
  184. bp-themes/bp-default/_inc/images/create_account_button.gif +0 -0
  185. bp-themes/bp-default/_inc/images/cross_bullet.gif +0 -0
  186. bp-themes/bp-default/_inc/images/error_back.gif +0 -0
  187. bp-themes/bp-default/_inc/images/error_icon.gif +0 -0
  188. bp-themes/bp-default/_inc/images/forum_bullet.gif +0 -0
  189. bp-themes/bp-default/_inc/images/friends_bullet.gif +0 -0
  190. bp-themes/bp-default/_inc/images/group_header.gif +0 -0
  191. bp-themes/bp-default/_inc/images/groups_bullet.gif +0 -0
  192. bp-themes/bp-default/_inc/images/info_icon.gif +0 -0
  193. bp-themes/bp-default/_inc/images/invite_bullet.gif +0 -0
  194. bp-themes/bp-default/_inc/images/item_list_back.gif +0 -0
  195. bp-themes/bp-default/_inc/images/leftcol_header_back.gif +0 -0
  196. bp-themes/bp-default/_inc/images/leftmenu_group_header.gif +0 -0
  197. bp-themes/bp-default/_inc/images/loading_button_side.gif +0 -0
  198. bp-themes/bp-default/_inc/images/logo.gif +0 -0
  199. bp-themes/bp-default/_inc/images/logout_bullet.gif +0 -0
  200. bp-themes/bp-default/_inc/images/member.png +0 -0
  201. bp-themes/bp-default/_inc/images/message_thread_back.gif +0 -0
  202. bp-themes/bp-default/_inc/images/message_thread_unread_back.gif +0 -0
  203. bp-themes/bp-default/_inc/images/messages_bullet.gif +0 -0
  204. bp-themes/bp-default/_inc/images/mystery-man.jpg +0 -0
  205. bp-themes/bp-default/_inc/images/nav_bullet.gif +0 -0
  206. bp-themes/bp-default/_inc/images/navitem_selected_back.gif +0 -0
  207. bp-themes/bp-default/_inc/images/notice_back.gif +0 -0
  208. bp-themes/bp-default/_inc/images/optionnavitem_selected_back.gif +0 -0
  209. bp-themes/bp-default/_inc/images/optionsbar_header_arrow.gif +0 -0
  210. bp-themes/bp-default/_inc/images/optionsbar_header_noarrow.gif +0 -0
  211. bp-themes/bp-default/_inc/images/profile_bullet.gif +0 -0
  212. bp-themes/bp-default/_inc/images/quotes_background.gif → bp +0 -0
bp-activity.php CHANGED
@@ -13,14 +13,14 @@ require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-filters.php' );
13
 
14
  /* Include deprecated functions if settings allow */
15
  if ( !defined( 'BP_IGNORE_DEPRECATED' ) )
16
- require ( BP_PLUGIN_DIR . '/bp-activity/deprecated/bp-activity-deprecated.php' );
17
-
18
  function bp_activity_install() {
19
  global $wpdb, $bp;
20
-
21
  if ( !empty($wpdb->charset) )
22
  $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
23
-
24
  $sql[] = "CREATE TABLE {$bp->activity->table_name} (
25
  id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
26
  user_id bigint(20) NOT NULL,
@@ -40,11 +40,11 @@ function bp_activity_install() {
40
 
41
  require_once( ABSPATH . 'wp-admin/upgrade-functions.php' );
42
  dbDelta($sql);
43
-
44
  /* Drop the old sitewide and user activity tables */
45
  $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->base_prefix}bp_activity_user_activity" );
46
  $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->base_prefix}bp_activity_sitewide" );
47
-
48
  /* TODO: Rename the old user activity cached table */
49
  //$wpdb->query( "RENAME TABLE {$wpdb->base_prefix}bp_activity_user_activity_cached TO {$bp->activity->table_name}" );
50
 
@@ -56,21 +56,21 @@ function bp_activity_setup_globals() {
56
 
57
  /* Internal identifier */
58
  $bp->activity->id = 'activity';
59
-
60
  $bp->activity->table_name = $wpdb->base_prefix . 'bp_activity_user_activity_cached';
61
  $bp->activity->slug = BP_ACTIVITY_SLUG;
62
-
63
  /* Register this in the active components array */
64
  $bp->active_components[$bp->activity->slug] = $bp->activity->id;
65
-
66
  do_action( 'bp_activity_setup_globals' );
67
  }
68
  add_action( 'plugins_loaded', 'bp_activity_setup_globals', 5 );
69
  add_action( 'admin_menu', 'bp_activity_setup_globals', 2 );
70
 
71
- function bp_activity_check_installed() {
72
  global $wpdb, $bp;
73
-
74
  if ( get_site_option('bp-activity-db-version') < BP_ACTIVITY_DB_VERSION )
75
  bp_activity_install();
76
  }
@@ -80,7 +80,7 @@ function bp_activity_setup_root_component() {
80
  /* Register 'activity' as a root component (for RSS feed use) */
81
  bp_core_add_root_component( BP_ACTIVITY_SLUG );
82
  }
83
- add_action( 'plugins_loaded', 'bp_activity_setup_root_component', 2 );
84
 
85
  function bp_activity_setup_nav() {
86
  global $bp;
@@ -99,7 +99,7 @@ function bp_activity_setup_nav() {
99
  $bp->bp_options_title = __( 'My Activity', 'buddypress' );
100
  } else {
101
  $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) );
102
- $bp->bp_options_title = $bp->displayed_user->fullname;
103
  }
104
  }
105
 
@@ -119,12 +119,18 @@ add_action( 'admin_menu', 'bp_activity_setup_nav' );
119
 
120
  function bp_activity_screen_my_activity() {
121
  do_action( 'bp_activity_screen_my_activity' );
122
- bp_core_load_template( apply_filters( 'bp_activity_template_my_activity', 'activity/just-me' ) );
123
  }
124
 
125
  function bp_activity_screen_friends_activity() {
 
 
 
 
 
 
126
  do_action( 'bp_activity_screen_friends_activity' );
127
- bp_core_load_template( apply_filters( 'bp_activity_template_friends_activity', 'activity/my-friends' ) );
128
  }
129
 
130
 
@@ -147,25 +153,25 @@ function bp_activity_action_delete_activity() {
147
 
148
  /* Check the nonce */
149
  check_admin_referer( 'bp_activity_delete_link' );
150
-
151
  $activity_id = $bp->action_variables[0];
152
-
153
  /* Check access */
154
  if ( !is_site_admin() ) {
155
  $activity = new BP_Activity_Activity( $activity_id );
156
-
157
  if ( $activity->user_id != $bp->loggedin_user->id )
158
  return false;
159
  }
160
-
161
  /* Now delete the activity item */
162
  if ( bp_activity_delete_by_activity_id( $activity_id ) )
163
  bp_core_add_message( __( 'Activity deleted', 'buddypress' ) );
164
  else
165
  bp_core_add_message( __( 'There was an error when deleting that activity', 'buddypress' ), 'error' );
166
-
167
  do_action( 'bp_activity_action_delete_activity', $activity_id );
168
-
169
  bp_core_redirect( $_SERVER['HTTP_REFERER'] );
170
  }
171
  add_action( 'wp', 'bp_activity_action_delete_activity', 3 );
@@ -186,11 +192,11 @@ function bp_activity_action_sitewide_feed() {
186
  add_action( 'wp', 'bp_activity_action_sitewide_feed', 3 );
187
 
188
  function bp_activity_action_personal_feed() {
189
- global $bp, $wp_query;
190
 
191
  if ( $bp->current_component != $bp->activity->slug || !$bp->displayed_user->id || $bp->current_action != 'feed' )
192
  return false;
193
-
194
  $wp_query->is_404 = false;
195
  status_header( 200 );
196
 
@@ -205,11 +211,11 @@ function bp_activity_action_friends_feed() {
205
  if ( $bp->current_component != $bp->activity->slug || !$bp->displayed_user->id || $bp->current_action != 'my-friends' || $bp->action_variables[0] != 'feed' )
206
  return false;
207
 
208
- $wp_query->is_404 = false;
209
  status_header( 200 );
210
 
211
  include_once( 'bp-activity/feeds/bp-activity-friends-feed.php' );
212
- die;
213
  }
214
  add_action( 'wp', 'bp_activity_action_friends_feed', 3 );
215
 
@@ -225,13 +231,13 @@ add_action( 'wp', 'bp_activity_action_friends_feed', 3 );
225
 
226
  function bp_activity_add( $args = '' ) {
227
  global $bp, $wpdb;
228
-
229
  $defaults = array(
230
  'content' => false, // The content of the activity item
231
  'primary_link' => false, // The primary URL for this item in RSS feeds
232
  'component_name' => false, // The name/ID of the component e.g. groups, profile, mycomponent
233
  'component_action' => false, // The component action e.g. new_wire_post, profile_updated
234
-
235
  'user_id' => $bp->loggedin_user->id, // Optional: The user to record the activity for, can be false if this activity is not for a user.
236
  'item_id' => false, // Optional: The ID of the specific item being recorded, e.g. a blog_id, or wire_post_id
237
  'secondary_item_id' => false, // Optional: A second ID used to further filter e.g. a comment_id
@@ -241,7 +247,7 @@ function bp_activity_add( $args = '' ) {
241
 
242
  $r = wp_parse_args( $args, $defaults );
243
  extract( $r, EXTR_SKIP );
244
-
245
  /* Insert the "time-since" placeholder */
246
  if ( $content )
247
  $content = bp_activity_add_timesince_placeholder( $content );
@@ -256,12 +262,12 @@ function bp_activity_add( $args = '' ) {
256
  $activity->secondary_item_id = $secondary_item_id;
257
  $activity->date_recorded = $recorded_time;
258
  $activity->hide_sitewide = $hide_sitewide;
259
-
260
  if ( !$activity->save() )
261
  return false;
262
 
263
  do_action( 'bp_activity_add', $args );
264
-
265
  return true;
266
  }
267
 
@@ -295,7 +301,7 @@ function bp_activity_delete_by_activity_id( $activity_id ) {
295
 
296
  do_action( 'bp_activity_delete_by_activity_id', $activity_id );
297
 
298
- return true;
299
  }
300
 
301
  function bp_activity_delete_by_content( $user_id, $content, $component_name, $component_action ) {
@@ -315,13 +321,13 @@ function bp_activity_delete_for_user_by_component( $user_id, $component_name ) {
315
  return false;
316
 
317
  do_action( 'bp_activity_delete_for_user_by_component', $user_id, $component_name );
318
-
319
  return true;
320
  }
321
 
322
  function bp_activity_add_timesince_placeholder( $content ) {
323
  /* Check a time-since span doesn't already exist */
324
- if ( false === strpos( $content, '<span class="time-since">' ) ) {
325
  if ( !$pos = strpos( $content, '<blockquote' ) ) {
326
  if ( !$pos = strpos( $content, '<div' ) ) {
327
  if ( !$pos = strpos( $content, '<ul' ) ) {
@@ -330,37 +336,37 @@ function bp_activity_add_timesince_placeholder( $content ) {
330
  }
331
  }
332
  }
333
-
334
  if ( (int) $pos ) {
335
  $before = substr( $content, 0, (int) $pos );
336
  $after = substr( $content, (int) $pos, strlen( $content ) );
337
-
338
  $content = $before . ' <span class="time-since">%s</span>' . $after;
339
  }
340
 
341
  return apply_filters( 'bp_activity_add_timesince_placeholder', $content );
342
  }
343
 
344
- function bp_activity_set_action( $component_id, $key, $value ) {
345
- global $bp;
346
 
347
- if ( empty( $component_id ) || empty( $key ) || empty( $value ) )
348
- return false;
349
 
350
- $bp->activity->actions->{$component_id}->{$key} = apply_filters( 'bp_activity_set_action', array(
351
- 'key' => $key,
352
- 'value' => $value
353
- ), $component_id, $key, $value );
354
- }
355
 
356
- function bp_activity_get_action( $component_id, $key ) {
357
- global $bp;
358
 
359
- if ( empty( $component_id ) || empty( $key ) )
360
- return false;
361
 
362
- return apply_filters( 'bp_activity_get_action', $bp->activity->actions->{$component_id}->{$key}, $component_id, $key );
363
- }
364
 
365
  function bp_activity_check_exists_by_content( $content ) {
366
  /* Insert the "time-since" placeholder to match the existing content in the DB */
@@ -388,7 +394,7 @@ function bp_activity_get_friends_activity( $user_id, $max_items = 30, $max_items
388
  function bp_activity_remove_data( $user_id ) {
389
  // Clear the user's activity from the sitewide stream and clear their activity tables
390
  BP_Activity_Activity::delete_for_user( $user_id );
391
-
392
  do_action( 'bp_activity_remove_data', $user_id );
393
  }
394
  add_action( 'wpmu_delete_user', 'bp_activity_remove_data' );
@@ -397,7 +403,7 @@ add_action( 'make_spam_user', 'bp_activity_remove_data' );
397
 
398
  /* Ordering function - don't call this directly */
399
  function bp_activity_order_by_date( $a, $b ) {
400
- return apply_filters( 'bp_activity_order_by_date', strcasecmp( $b['date_recorded'], $a['date_recorded'] ) );
401
  }
402
 
403
  ?>
13
 
14
  /* Include deprecated functions if settings allow */
15
  if ( !defined( 'BP_IGNORE_DEPRECATED' ) )
16
+ require ( BP_PLUGIN_DIR . '/bp-activity/deprecated/bp-activity-deprecated.php' );
17
+
18
  function bp_activity_install() {
19
  global $wpdb, $bp;
20
+
21
  if ( !empty($wpdb->charset) )
22
  $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
23
+
24
  $sql[] = "CREATE TABLE {$bp->activity->table_name} (
25
  id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
26
  user_id bigint(20) NOT NULL,
40
 
41
  require_once( ABSPATH . 'wp-admin/upgrade-functions.php' );
42
  dbDelta($sql);
43
+
44
  /* Drop the old sitewide and user activity tables */
45
  $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->base_prefix}bp_activity_user_activity" );
46
  $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->base_prefix}bp_activity_sitewide" );
47
+
48
  /* TODO: Rename the old user activity cached table */
49
  //$wpdb->query( "RENAME TABLE {$wpdb->base_prefix}bp_activity_user_activity_cached TO {$bp->activity->table_name}" );
50
 
56
 
57
  /* Internal identifier */
58
  $bp->activity->id = 'activity';
59
+
60
  $bp->activity->table_name = $wpdb->base_prefix . 'bp_activity_user_activity_cached';
61
  $bp->activity->slug = BP_ACTIVITY_SLUG;
62
+
63
  /* Register this in the active components array */
64
  $bp->active_components[$bp->activity->slug] = $bp->activity->id;
65
+
66
  do_action( 'bp_activity_setup_globals' );
67
  }
68
  add_action( 'plugins_loaded', 'bp_activity_setup_globals', 5 );
69
  add_action( 'admin_menu', 'bp_activity_setup_globals', 2 );
70
 
71
+ function bp_activity_check_installed() {
72
  global $wpdb, $bp;
73
+
74
  if ( get_site_option('bp-activity-db-version') < BP_ACTIVITY_DB_VERSION )
75
  bp_activity_install();
76
  }
80
  /* Register 'activity' as a root component (for RSS feed use) */
81
  bp_core_add_root_component( BP_ACTIVITY_SLUG );
82
  }
83
+ add_action( 'plugins_loaded', 'bp_activity_setup_root_component' );
84
 
85
  function bp_activity_setup_nav() {
86
  global $bp;
99
  $bp->bp_options_title = __( 'My Activity', 'buddypress' );
100
  } else {
101
  $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) );
102
+ $bp->bp_options_title = $bp->displayed_user->fullname;
103
  }
104
  }
105
 
119
 
120
  function bp_activity_screen_my_activity() {
121
  do_action( 'bp_activity_screen_my_activity' );
122
+ bp_core_load_template( apply_filters( 'bp_activity_template_my_activity', 'activity/just-me' ) );
123
  }
124
 
125
  function bp_activity_screen_friends_activity() {
126
+ global $bp;
127
+
128
+ /* Make sure delete links do not show for friends activity items */
129
+ if ( !is_site_admin() )
130
+ $bp->is_item_admin = false;
131
+
132
  do_action( 'bp_activity_screen_friends_activity' );
133
+ bp_core_load_template( apply_filters( 'bp_activity_template_friends_activity', 'activity/my-friends' ) );
134
  }
135
 
136
 
153
 
154
  /* Check the nonce */
155
  check_admin_referer( 'bp_activity_delete_link' );
156
+
157
  $activity_id = $bp->action_variables[0];
158
+
159
  /* Check access */
160
  if ( !is_site_admin() ) {
161
  $activity = new BP_Activity_Activity( $activity_id );
162
+
163
  if ( $activity->user_id != $bp->loggedin_user->id )
164
  return false;
165
  }
166
+
167
  /* Now delete the activity item */
168
  if ( bp_activity_delete_by_activity_id( $activity_id ) )
169
  bp_core_add_message( __( 'Activity deleted', 'buddypress' ) );
170
  else
171
  bp_core_add_message( __( 'There was an error when deleting that activity', 'buddypress' ), 'error' );
172
+
173
  do_action( 'bp_activity_action_delete_activity', $activity_id );
174
+
175
  bp_core_redirect( $_SERVER['HTTP_REFERER'] );
176
  }
177
  add_action( 'wp', 'bp_activity_action_delete_activity', 3 );
192
  add_action( 'wp', 'bp_activity_action_sitewide_feed', 3 );
193
 
194
  function bp_activity_action_personal_feed() {
195
+ global $bp, $wp_query;
196
 
197
  if ( $bp->current_component != $bp->activity->slug || !$bp->displayed_user->id || $bp->current_action != 'feed' )
198
  return false;
199
+
200
  $wp_query->is_404 = false;
201
  status_header( 200 );
202
 
211
  if ( $bp->current_component != $bp->activity->slug || !$bp->displayed_user->id || $bp->current_action != 'my-friends' || $bp->action_variables[0] != 'feed' )
212
  return false;
213
 
214
+ $wp_query->is_404 = false;
215
  status_header( 200 );
216
 
217
  include_once( 'bp-activity/feeds/bp-activity-friends-feed.php' );
218
+ die;
219
  }
220
  add_action( 'wp', 'bp_activity_action_friends_feed', 3 );
221
 
231
 
232
  function bp_activity_add( $args = '' ) {
233
  global $bp, $wpdb;
234
+
235
  $defaults = array(
236
  'content' => false, // The content of the activity item
237
  'primary_link' => false, // The primary URL for this item in RSS feeds
238
  'component_name' => false, // The name/ID of the component e.g. groups, profile, mycomponent
239
  'component_action' => false, // The component action e.g. new_wire_post, profile_updated
240
+
241
  'user_id' => $bp->loggedin_user->id, // Optional: The user to record the activity for, can be false if this activity is not for a user.
242
  'item_id' => false, // Optional: The ID of the specific item being recorded, e.g. a blog_id, or wire_post_id
243
  'secondary_item_id' => false, // Optional: A second ID used to further filter e.g. a comment_id
247
 
248
  $r = wp_parse_args( $args, $defaults );
249
  extract( $r, EXTR_SKIP );
250
+
251
  /* Insert the "time-since" placeholder */
252
  if ( $content )
253
  $content = bp_activity_add_timesince_placeholder( $content );
262
  $activity->secondary_item_id = $secondary_item_id;
263
  $activity->date_recorded = $recorded_time;
264
  $activity->hide_sitewide = $hide_sitewide;
265
+
266
  if ( !$activity->save() )
267
  return false;
268
 
269
  do_action( 'bp_activity_add', $args );
270
+
271
  return true;
272
  }
273
 
301
 
302
  do_action( 'bp_activity_delete_by_activity_id', $activity_id );
303
 
304
+ return true;
305
  }
306
 
307
  function bp_activity_delete_by_content( $user_id, $content, $component_name, $component_action ) {
321
  return false;
322
 
323
  do_action( 'bp_activity_delete_for_user_by_component', $user_id, $component_name );
324
+
325
  return true;
326
  }
327
 
328
  function bp_activity_add_timesince_placeholder( $content ) {
329
  /* Check a time-since span doesn't already exist */
330
+ if ( false === strpos( $content, '<span class="time-since">' ) ) {
331
  if ( !$pos = strpos( $content, '<blockquote' ) ) {
332
  if ( !$pos = strpos( $content, '<div' ) ) {
333
  if ( !$pos = strpos( $content, '<ul' ) ) {
336
  }
337
  }
338
  }
339
+
340
  if ( (int) $pos ) {
341
  $before = substr( $content, 0, (int) $pos );
342
  $after = substr( $content, (int) $pos, strlen( $content ) );
343
+
344
  $content = $before . ' <span class="time-since">%s</span>' . $after;
345
  }
346
 
347
  return apply_filters( 'bp_activity_add_timesince_placeholder', $content );
348
  }
349
 
350
+ function bp_activity_set_action( $component_id, $key, $value ) {
351
+ global $bp;
352
 
353
+ if ( empty( $component_id ) || empty( $key ) || empty( $value ) )
354
+ return false;
355
 
356
+ $bp->activity->actions->{$component_id}->{$key} = apply_filters( 'bp_activity_set_action', array(
357
+ 'key' => $key,
358
+ 'value' => $value
359
+ ), $component_id, $key, $value );
360
+ }
361
 
362
+ function bp_activity_get_action( $component_id, $key ) {
363
+ global $bp;
364
 
365
+ if ( empty( $component_id ) || empty( $key ) )
366
+ return false;
367
 
368
+ return apply_filters( 'bp_activity_get_action', $bp->activity->actions->{$component_id}->{$key}, $component_id, $key );
369
+ }
370
 
371
  function bp_activity_check_exists_by_content( $content ) {
372
  /* Insert the "time-since" placeholder to match the existing content in the DB */
394
  function bp_activity_remove_data( $user_id ) {
395
  // Clear the user's activity from the sitewide stream and clear their activity tables
396
  BP_Activity_Activity::delete_for_user( $user_id );
397
+
398
  do_action( 'bp_activity_remove_data', $user_id );
399
  }
400
  add_action( 'wpmu_delete_user', 'bp_activity_remove_data' );
403
 
404
  /* Ordering function - don't call this directly */
405
  function bp_activity_order_by_date( $a, $b ) {
406
+ return apply_filters( 'bp_activity_order_by_date', strcasecmp( $b['date_recorded'], $a['date_recorded'] ) );
407
  }
408
 
409
  ?>
bp-activity/bp-activity-classes.php CHANGED
@@ -10,21 +10,21 @@ Class BP_Activity_Activity {
10
  var $component_action;
11
  var $date_recorded;
12
  var $hide_sitewide = false;
13
-
14
  function bp_activity_activity( $id = false ) {
15
  global $bp;
16
-
17
  if ( $id ) {
18
  $this->id = $id;
19
  $this->populate();
20
  }
21
  }
22
-
23
  function populate() {
24
  global $wpdb, $bp;
25
-
26
  $activity = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE id = %d", $this->id ) );
27
-
28
  $this->id = $activity->id;
29
  $this->item_id = $activity->item_id;
30
  $this->secondary_item_id = $activity->secondary_item_id;
@@ -36,15 +36,15 @@ Class BP_Activity_Activity {
36
  $this->date_recorded = $activity->date_recorded;
37
  $this->hide_sitewide = $activity->hide_sitewide;
38
  }
39
-
40
  function save() {
41
  global $wpdb, $bp, $current_user;
42
-
43
  do_action( 'bp_activity_before_save', $this );
44
 
45
  if ( !$this->component_name || !$this->component_action )
46
  return false;
47
-
48
  /***
49
  * Before v1.1 of BuddyPress, activity content was calculated at a later point. This is no longer the
50
  * case, to to be backwards compatible we need to fetch content here to continue.
@@ -53,18 +53,18 @@ Class BP_Activity_Activity {
53
  if ( function_exists( $bp->{$this->component_name}->format_activity_function ) ) {
54
  if ( !$fetched_content = call_user_func( $bp->{$this->component_name}->format_activity_function, $this->item_id, $this->user_id, $this->component_action, $this->secondary_item_id, $this->for_secondary_user ) )
55
  return false;
56
-
57
  $this->content = $fetched_content['content'];
58
  $this->primary_link = $fetched_content['primary_link'];
59
  }
60
  }
61
-
62
  if ( !$this->primary_link )
63
  $this->primary_link = $bp->loggedin_user->domain;
64
-
65
  if ( $existing_activity_id = $this->exists() )
66
  BP_Activity_Activity::delete_by_activity_id( $existing_activity_id );
67
-
68
  /* If we have an existing ID, update the activity item, otherwise insert it. */
69
  if ( $this->id ) {
70
  if ( $wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET user_id = %d, component_name = %s, component_action = %s, content = %s, primary_link = %s, date_recorded = FROM_UNIXTIME(%d), item_id = %s, secondary_item_id = %s, hide_sitewide = %d WHERE id = %d", $this->user_id, $this->component_name, $this->component_action, $this->content, $this->primary_link, $this->date_recorded, $this->item_id, $this->secondary_item_id, $this->hide_sitewide, $this->id ) ) ) {
@@ -80,103 +80,103 @@ Class BP_Activity_Activity {
80
 
81
  return false;
82
  }
83
-
84
  function exists() {
85
  global $wpdb, $bp;
86
-
87
  /* This doesn't seem to be working correctly at the moment, so it is disabled [TODO] */
88
  return false;
89
-
90
  /* If we have an item id, try and match on that, if not do a content match */
91
  if ( $this->item_id ) {
92
  if ( $this->secondary_item_id )
93
  $secondary_sql = $wpdb->prepare( " AND secondary_item_id = %s", $secondary_item_id );
94
-
95
- return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE user_id = %d AND item_id = %s{$secondary_sql} AND component_name = %s AND component_action = %s", $this->user_id, $this->item_id, $this->component_name, $this->component_action ) );
96
  } else {
97
- return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE user_id = %d AND content = %s AND component_name = %s AND component_action = %s", $this->user_id, $this->content, $this->component_name, $this->component_action ) );
98
  }
99
  }
100
-
101
- /* Static Functions */
102
 
103
  function delete( $item_id, $component_name, $component_action, $user_id = false, $secondary_item_id = false ) {
104
  global $wpdb, $bp;
105
 
106
  if ( $secondary_item_id )
107
  $secondary_sql = $wpdb->prepare( "AND secondary_item_id = %s", $secondary_item_id );
108
-
109
  if ( $component_action )
110
  $component_action_sql = $wpdb->prepare( "AND component_action = %s", $component_action );
111
-
112
  if ( $user_id )
113
  $user_sql = $wpdb->prepare( "AND user_id = %d", $user_id );
114
 
115
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE item_id = %s {$secondary_sql} AND component_name = %s {$component_action_sql} {$user_sql}", $item_id, $component_name ) );
116
  }
117
-
118
  function delete_by_item_id( $item_id, $component_name, $component_action, $user_id = false, $secondary_item_id = false ) {
119
  return BP_Activity_Activity::delete( $item_id, $component_name, $component_action, $user_id, $secondary_item_id );
120
  }
121
 
122
  function delete_by_activity_id( $activity_id ) {
123
  global $bp, $wpdb;
124
-
125
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE id = %d", $activity_id ) );
126
  }
127
-
128
  function delete_by_content( $user_id, $content, $component_name, $component_action ) {
129
  global $bp, $wpdb;
130
-
131
- return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE user_id = %d AND content = %s AND component_name = %s AND component_action = %s", $user_id, $content, $component_name, $component_action ) );
132
  }
133
-
134
  function delete_for_user_by_component( $user_id, $component_name ) {
135
  global $bp, $wpdb;
136
-
137
- return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE user_id = %d AND component_name = %s", $user_id, $component_name ) );
138
  }
139
-
140
  function delete_for_user( $user_id ) {
141
  global $wpdb, $bp;
142
 
143
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE user_id = %d", $user_id ) );
144
  }
145
-
146
  function get_activity_for_user( $user_id, $max_items, $limit, $page, $filter ) {
147
  global $wpdb, $bp;
148
-
149
  if ( $limit && $page )
150
  $pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
151
 
152
  if ( $max_items )
153
  $max_sql = $wpdb->prepare( "LIMIT %d", $max_items );
154
-
155
  /* Sort out filtering */
156
  if ( $filter )
157
  $filter_sql = BP_Activity_Activity::get_filter_sql( $filter );
158
-
159
  if ( $limit && $page && $max_items )
160
  $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE user_id = %d $filter_sql ORDER BY date_recorded DESC $pag_sql", $user_id ) );
161
  else
162
  $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE user_id = %d $filter_sql ORDER BY date_recorded DESC $pag_sql $max_sql", $user_id ) );
163
-
164
- $total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->activity->table_name} WHERE user_id = %d $filter_sql ORDER BY date_recorded DESC $max_sql", $user_id ) );
165
-
166
  return array( 'activities' => $activities, 'total' => (int)$total_activities );
167
  }
168
-
169
  function get_activity_for_friends( $user_id, $max_items, $max_items_per_friend, $limit, $page, $filter ) {
170
  global $wpdb, $bp;
171
-
172
  // TODO: Max items per friend not yet implemented.
173
-
174
  if ( !function_exists('friends_get_friend_user_ids') )
175
  return false;
176
 
177
  if ( $limit && $page )
178
  $pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
179
-
180
  if ( $max_items )
181
  $max_sql = $wpdb->prepare( "LIMIT %d", $max_items );
182
 
@@ -188,28 +188,28 @@ Class BP_Activity_Activity {
188
 
189
  if ( !$friend_ids )
190
  return false;
191
-
192
  $friend_ids = implode( ',', $friend_ids );
193
-
194
  if ( $limit && $page && $max_items )
195
- $activities = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT id, user_id, content, primary_link, date_recorded, component_name, component_action FROM {$bp->activity->table_name} WHERE user_id IN ({$friend_ids}) $filter_sql ORDER BY date_recorded DESC $pag_sql" ) );
196
  else
197
- $activities = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT id, user_id, content, primary_link, date_recorded, component_name, component_action FROM {$bp->activity->table_name} WHERE user_id IN ({$friend_ids}) $filter_sql ORDER BY date_recorded DESC $pag_sql $max_sql" ) );
 
 
198
 
199
- $total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(user_id) FROM {$bp->activity->table_name} WHERE user_id IN ({$friend_ids}) $filter_sql ORDER BY date_recorded DESC $max_sql" ) );
200
-
201
  return array( 'activities' => $activities, 'total' => (int)$total_activities );
202
  }
203
-
204
  function get_sitewide_activity( $max, $limit, $page, $filter ) {
205
  global $wpdb, $bp;
206
-
207
  if ( $limit && $page )
208
  $pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
209
-
210
  if ( $max )
211
  $max_sql = $wpdb->prepare( "LIMIT %d", $max );
212
-
213
  /* Sort out filtering */
214
  if ( $filter )
215
  $filter_sql = BP_Activity_Activity::get_filter_sql( $filter );
@@ -219,20 +219,20 @@ Class BP_Activity_Activity {
219
  else
220
  $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE hide_sitewide = 0 $filter_sql ORDER BY date_recorded DESC $pag_sql $max_sql" ) );
221
 
222
- $total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->activity->table_name} WHERE hide_sitewide = 0 $filter_sql ORDER BY date_recorded DESC $max_sql" ) );
223
 
224
  return array( 'activities' => $activities, 'total' => (int)$total_activities );
225
  }
226
-
227
  function get_recorded_component_names() {
228
  global $wpdb, $bp;
229
-
230
  return $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT component_name FROM {$bp->activity->table_name} ORDER BY component_name ASC" ) );
231
  }
232
-
233
  function get_sitewide_items_for_feed( $limit = 35 ) {
234
  global $wpdb, $bp;
235
-
236
  $activities = bp_activity_get_sitewide_activity( $limit );
237
  for ( $i = 0; $i < count($activities); $i++ ) {
238
  $title = explode( '<span', $activities[$i]['content'] );
@@ -243,89 +243,89 @@ Class BP_Activity_Activity {
243
  $activity_feed[$i]['pubdate'] = $activities[$i]['date_recorded'];
244
  }
245
 
246
- return $activity_feed;
247
  }
248
-
249
  function get_filter_sql( $filter_array ) {
250
  global $wpdb;
251
-
252
  if ( !empty( $filter_array['object'] ) ) {
253
  $object_filter = explode( ',', $filter_array['object'] );
254
  $object_sql = ' AND ( ';
255
-
256
  $counter = 1;
257
  foreach( (array) $object_filter as $object ) {
258
  $object_sql .= $wpdb->prepare( "component_name = %s", trim( $object ) );
259
-
260
  if ( $counter != count( $object_filter ) )
261
  $object_sql .= ' || ';
262
-
263
  $counter++;
264
  }
265
-
266
  $object_sql .= ' )';
267
  }
268
 
269
  if ( !empty( $filter_array['action'] ) ) {
270
  $action_filter = explode( ',', $filter_array['action'] );
271
  $action_sql = ' AND ( ';
272
-
273
  $counter = 1;
274
  foreach( (array) $action_filter as $action ) {
275
  $action_sql .= $wpdb->prepare( "component_action = %s", trim( $action ) );
276
-
277
  if ( $counter != count( $action_filter ) )
278
  $action_sql .= ' || ';
279
-
280
  $counter++;
281
  }
282
-
283
  $action_sql .= ' )';
284
  }
285
 
286
  if ( !empty( $filter_array['primary_id'] ) ) {
287
  $pid_filter = explode( ',', $filter_array['primary_id'] );
288
  $pid_sql = ' AND ( ';
289
-
290
  $counter = 1;
291
  foreach( (array) $pid_filter as $pid ) {
292
  $pid_sql .= $wpdb->prepare( "item_id = %s", trim( $pid ) );
293
-
294
  if ( $counter != count( $pid_filter ) )
295
  $pid_sql .= ' || ';
296
-
297
  $counter++;
298
  }
299
-
300
  $pid_sql .= ' )';
301
  }
302
 
303
  if ( !empty( $filter_array['secondary_id'] ) ) {
304
  $sid_filter = explode( ',', $filter_array['secondary_id'] );
305
  $sid_sql = ' AND ( ';
306
-
307
  $counter = 1;
308
  foreach( (array) $sid_filter as $sid ) {
309
  $sid_sql .= $wpdb->prepare( "secondary_item_id = %s", trim( $sid ) );
310
-
311
  if ( $counter != count( $sid_filter ) )
312
  $sid_sql .= ' || ';
313
-
314
  $counter++;
315
  }
316
-
317
  $sid_sql .= ' )';
318
  }
319
-
320
  return $object_sql . $action_sql . $pid_sql . $sid_sql;
321
  }
322
-
323
  function get_last_updated() {
324
  global $bp, $wpdb;
325
-
326
  return $wpdb->get_var( $wpdb->prepare( "SELECT date_recorded FROM {$bp->activity->table_name} ORDER BY date_recorded ASC LIMIT 1" ) );
327
  }
328
-
329
  function check_exists_by_content( $content ) {
330
  global $wpdb, $bp;
331
 
10
  var $component_action;
11
  var $date_recorded;
12
  var $hide_sitewide = false;
13
+
14
  function bp_activity_activity( $id = false ) {
15
  global $bp;
16
+
17
  if ( $id ) {
18
  $this->id = $id;
19
  $this->populate();
20
  }
21
  }
22
+
23
  function populate() {
24
  global $wpdb, $bp;
25
+
26
  $activity = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE id = %d", $this->id ) );
27
+
28
  $this->id = $activity->id;
29
  $this->item_id = $activity->item_id;
30
  $this->secondary_item_id = $activity->secondary_item_id;
36
  $this->date_recorded = $activity->date_recorded;
37
  $this->hide_sitewide = $activity->hide_sitewide;
38
  }
39
+
40
  function save() {
41
  global $wpdb, $bp, $current_user;
42
+
43
  do_action( 'bp_activity_before_save', $this );
44
 
45
  if ( !$this->component_name || !$this->component_action )
46
  return false;
47
+
48
  /***
49
  * Before v1.1 of BuddyPress, activity content was calculated at a later point. This is no longer the
50
  * case, to to be backwards compatible we need to fetch content here to continue.
53
  if ( function_exists( $bp->{$this->component_name}->format_activity_function ) ) {
54
  if ( !$fetched_content = call_user_func( $bp->{$this->component_name}->format_activity_function, $this->item_id, $this->user_id, $this->component_action, $this->secondary_item_id, $this->for_secondary_user ) )
55
  return false;
56
+
57
  $this->content = $fetched_content['content'];
58
  $this->primary_link = $fetched_content['primary_link'];
59
  }
60
  }
61
+
62
  if ( !$this->primary_link )
63
  $this->primary_link = $bp->loggedin_user->domain;
64
+
65
  if ( $existing_activity_id = $this->exists() )
66
  BP_Activity_Activity::delete_by_activity_id( $existing_activity_id );
67
+
68
  /* If we have an existing ID, update the activity item, otherwise insert it. */
69
  if ( $this->id ) {
70
  if ( $wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET user_id = %d, component_name = %s, component_action = %s, content = %s, primary_link = %s, date_recorded = FROM_UNIXTIME(%d), item_id = %s, secondary_item_id = %s, hide_sitewide = %d WHERE id = %d", $this->user_id, $this->component_name, $this->component_action, $this->content, $this->primary_link, $this->date_recorded, $this->item_id, $this->secondary_item_id, $this->hide_sitewide, $this->id ) ) ) {
80
 
81
  return false;
82
  }
83
+
84
  function exists() {
85
  global $wpdb, $bp;
86
+
87
  /* This doesn't seem to be working correctly at the moment, so it is disabled [TODO] */
88
  return false;
89
+
90
  /* If we have an item id, try and match on that, if not do a content match */
91
  if ( $this->item_id ) {
92
  if ( $this->secondary_item_id )
93
  $secondary_sql = $wpdb->prepare( " AND secondary_item_id = %s", $secondary_item_id );
94
+
95
+ return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE user_id = %d AND item_id = %s{$secondary_sql} AND component_name = %s AND component_action = %s", $this->user_id, $this->item_id, $this->component_name, $this->component_action ) );
96
  } else {
97
+ return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE user_id = %d AND content = %s AND component_name = %s AND component_action = %s", $this->user_id, $this->content, $this->component_name, $this->component_action ) );
98
  }
99
  }
100
+
101
+ /* Static Functions */
102
 
103
  function delete( $item_id, $component_name, $component_action, $user_id = false, $secondary_item_id = false ) {
104
  global $wpdb, $bp;
105
 
106
  if ( $secondary_item_id )
107
  $secondary_sql = $wpdb->prepare( "AND secondary_item_id = %s", $secondary_item_id );
108
+
109
  if ( $component_action )
110
  $component_action_sql = $wpdb->prepare( "AND component_action = %s", $component_action );
111
+
112
  if ( $user_id )
113
  $user_sql = $wpdb->prepare( "AND user_id = %d", $user_id );
114
 
115
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE item_id = %s {$secondary_sql} AND component_name = %s {$component_action_sql} {$user_sql}", $item_id, $component_name ) );
116
  }
117
+
118
  function delete_by_item_id( $item_id, $component_name, $component_action, $user_id = false, $secondary_item_id = false ) {
119
  return BP_Activity_Activity::delete( $item_id, $component_name, $component_action, $user_id, $secondary_item_id );
120
  }
121
 
122
  function delete_by_activity_id( $activity_id ) {
123
  global $bp, $wpdb;
124
+
125
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE id = %d", $activity_id ) );
126
  }
127
+
128
  function delete_by_content( $user_id, $content, $component_name, $component_action ) {
129
  global $bp, $wpdb;
130
+
131
+ return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE user_id = %d AND content = %s AND component_name = %s AND component_action = %s", $user_id, $content, $component_name, $component_action ) );
132
  }
133
+
134
  function delete_for_user_by_component( $user_id, $component_name ) {
135
  global $bp, $wpdb;
136
+
137
+ return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE user_id = %d AND component_name = %s", $user_id, $component_name ) );
138
  }
139
+
140
  function delete_for_user( $user_id ) {
141
  global $wpdb, $bp;
142
 
143
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE user_id = %d", $user_id ) );
144
  }
145
+
146
  function get_activity_for_user( $user_id, $max_items, $limit, $page, $filter ) {
147
  global $wpdb, $bp;
148
+
149
  if ( $limit && $page )
150
  $pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
151
 
152
  if ( $max_items )
153
  $max_sql = $wpdb->prepare( "LIMIT %d", $max_items );
154
+
155
  /* Sort out filtering */
156
  if ( $filter )
157
  $filter_sql = BP_Activity_Activity::get_filter_sql( $filter );
158
+
159
  if ( $limit && $page && $max_items )
160
  $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE user_id = %d $filter_sql ORDER BY date_recorded DESC $pag_sql", $user_id ) );
161
  else
162
  $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE user_id = %d $filter_sql ORDER BY date_recorded DESC $pag_sql $max_sql", $user_id ) );
163
+
164
+ $total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->activity->table_name} WHERE user_id = %d $filter_sql ORDER BY date_recorded DESC $max_sql", $user_id ) );
165
+
166
  return array( 'activities' => $activities, 'total' => (int)$total_activities );
167
  }
168
+
169
  function get_activity_for_friends( $user_id, $max_items, $max_items_per_friend, $limit, $page, $filter ) {
170
  global $wpdb, $bp;
171
+
172
  // TODO: Max items per friend not yet implemented.
173
+
174
  if ( !function_exists('friends_get_friend_user_ids') )
175
  return false;
176
 
177
  if ( $limit && $page )
178
  $pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
179
+
180
  if ( $max_items )
181
  $max_sql = $wpdb->prepare( "LIMIT %d", $max_items );
182
 
188
 
189
  if ( !$friend_ids )
190
  return false;
191
+
192
  $friend_ids = implode( ',', $friend_ids );
193
+
194
  if ( $limit && $page && $max_items )
195
+ $activities = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT id, user_id, content, primary_link, date_recorded, component_name, component_action FROM {$bp->activity->table_name} WHERE user_id IN ({$friend_ids}) $filter_sql ORDER BY date_recorded DESC $pag_sql" ) );
196
  else
197
+ $activities = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT id, user_id, content, primary_link, date_recorded, component_name, component_action FROM {$bp->activity->table_name} WHERE user_id IN ({$friend_ids}) $filter_sql ORDER BY date_recorded DESC $pag_sql $max_sql" ) );
198
+
199
+ $total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT user_id) FROM {$bp->activity->table_name} WHERE user_id IN ({$friend_ids}) $filter_sql ORDER BY date_recorded DESC $max_sql" ) );
200
 
 
 
201
  return array( 'activities' => $activities, 'total' => (int)$total_activities );
202
  }
203
+
204
  function get_sitewide_activity( $max, $limit, $page, $filter ) {
205
  global $wpdb, $bp;
206
+
207
  if ( $limit && $page )
208
  $pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
209
+
210
  if ( $max )
211
  $max_sql = $wpdb->prepare( "LIMIT %d", $max );
212
+
213
  /* Sort out filtering */
214
  if ( $filter )
215
  $filter_sql = BP_Activity_Activity::get_filter_sql( $filter );
219
  else
220
  $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE hide_sitewide = 0 $filter_sql ORDER BY date_recorded DESC $pag_sql $max_sql" ) );
221
 
222
+ $total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->activity->table_name} WHERE hide_sitewide = 0 $filter_sql ORDER BY date_recorded DESC $max_sql" ) );
223
 
224
  return array( 'activities' => $activities, 'total' => (int)$total_activities );
225
  }
226
+
227
  function get_recorded_component_names() {
228
  global $wpdb, $bp;
229
+
230
  return $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT component_name FROM {$bp->activity->table_name} ORDER BY component_name ASC" ) );
231
  }
232
+
233
  function get_sitewide_items_for_feed( $limit = 35 ) {
234
  global $wpdb, $bp;
235
+
236
  $activities = bp_activity_get_sitewide_activity( $limit );
237
  for ( $i = 0; $i < count($activities); $i++ ) {
238
  $title = explode( '<span', $activities[$i]['content'] );
243
  $activity_feed[$i]['pubdate'] = $activities[$i]['date_recorded'];
244
  }
245
 
246
+ return $activity_feed;
247
  }
248
+
249
  function get_filter_sql( $filter_array ) {
250
  global $wpdb;
251
+
252
  if ( !empty( $filter_array['object'] ) ) {
253
  $object_filter = explode( ',', $filter_array['object'] );
254
  $object_sql = ' AND ( ';
255
+
256
  $counter = 1;
257
  foreach( (array) $object_filter as $object ) {
258
  $object_sql .= $wpdb->prepare( "component_name = %s", trim( $object ) );
259
+
260
  if ( $counter != count( $object_filter ) )
261
  $object_sql .= ' || ';
262
+
263
  $counter++;
264
  }
265
+
266
  $object_sql .= ' )';
267
  }
268
 
269
  if ( !empty( $filter_array['action'] ) ) {
270
  $action_filter = explode( ',', $filter_array['action'] );
271
  $action_sql = ' AND ( ';
272
+
273
  $counter = 1;
274
  foreach( (array) $action_filter as $action ) {
275
  $action_sql .= $wpdb->prepare( "component_action = %s", trim( $action ) );
276
+
277
  if ( $counter != count( $action_filter ) )
278
  $action_sql .= ' || ';
279
+
280
  $counter++;
281
  }
282
+
283
  $action_sql .= ' )';
284
  }
285
 
286
  if ( !empty( $filter_array['primary_id'] ) ) {
287
  $pid_filter = explode( ',', $filter_array['primary_id'] );
288
  $pid_sql = ' AND ( ';
289
+
290
  $counter = 1;
291
  foreach( (array) $pid_filter as $pid ) {
292
  $pid_sql .= $wpdb->prepare( "item_id = %s", trim( $pid ) );
293
+
294
  if ( $counter != count( $pid_filter ) )
295
  $pid_sql .= ' || ';
296
+
297
  $counter++;
298
  }
299
+
300
  $pid_sql .= ' )';
301
  }
302
 
303
  if ( !empty( $filter_array['secondary_id'] ) ) {
304
  $sid_filter = explode( ',', $filter_array['secondary_id'] );
305
  $sid_sql = ' AND ( ';
306
+
307
  $counter = 1;
308
  foreach( (array) $sid_filter as $sid ) {
309
  $sid_sql .= $wpdb->prepare( "secondary_item_id = %s", trim( $sid ) );
310
+
311
  if ( $counter != count( $sid_filter ) )
312
  $sid_sql .= ' || ';
313
+
314
  $counter++;
315
  }
316
+
317
  $sid_sql .= ' )';
318
  }
319
+
320
  return $object_sql . $action_sql . $pid_sql . $sid_sql;
321
  }
322
+
323
  function get_last_updated() {
324
  global $bp, $wpdb;
325
+
326
  return $wpdb->get_var( $wpdb->prepare( "SELECT date_recorded FROM {$bp->activity->table_name} ORDER BY date_recorded ASC LIMIT 1" ) );
327
  }
328
+
329
  function check_exists_by_content( $content ) {
330
  global $wpdb, $bp;
331
 
bp-activity/bp-activity-filters.php CHANGED
@@ -14,12 +14,12 @@ add_filter( 'bp_get_activity_content', 'stripslashes_deep' );
14
 
15
  function bp_activity_filter_kses( $content ) {
16
  global $allowedtags;
17
-
18
  $activity_allowedtags = $allowedtags;
19
  $activity_allowedtags['span'] = array();
20
  $activity_allowedtags['span']['class'] = array();
21
  $activity_allowedtags['a']['class'] = array();
22
- $activity_allowedtags['img'] = array();
23
  $activity_allowedtags['img']['src'] = array();
24
  $activity_allowedtags['img']['alt'] = array();
25
  $activity_allowedtags['img']['class'] = array();
14
 
15
  function bp_activity_filter_kses( $content ) {
16
  global $allowedtags;
17
+
18
  $activity_allowedtags = $allowedtags;
19
  $activity_allowedtags['span'] = array();
20
  $activity_allowedtags['span']['class'] = array();
21
  $activity_allowedtags['a']['class'] = array();
22
+ $activity_allowedtags['img'] = array();
23
  $activity_allowedtags['img']['src'] = array();
24
  $activity_allowedtags['img']['alt'] = array();
25
  $activity_allowedtags['img']['class'] = array();
bp-activity/bp-activity-templatetags.php CHANGED
@@ -7,9 +7,9 @@ class BP_Activity_Template {
7
  var $activities;
8
  var $activity;
9
  var $activity_type;
10
-
11
  var $in_the_loop;
12
-
13
  var $pag_page;
14
  var $pag_num;
15
  var $pag_links;
@@ -25,20 +25,20 @@ class BP_Activity_Template {
25
 
26
  if ( $type == 'sitewide' )
27
  $this->activities = bp_activity_get_sitewide_activity( $max, $this->pag_num, $this->pag_page, $filter );
28
-
29
  if ( $type == 'personal' )
30
  $this->activities = bp_activity_get_user_activity( $user_id, $max, $this->pag_num, $this->pag_page, $filter );
31
 
32
  if ( $type == 'friends' && ( bp_is_home() || is_site_admin() || $bp->loggedin_user->id == $user_id ) )
33
  $this->activities = bp_activity_get_friends_activity( $user_id, $max, false, $this->pag_num, $this->pag_page, $filter );
34
-
35
  if ( !$max || $max >= (int)$this->activities['total'] )
36
  $this->total_activity_count = (int)$this->activities['total'];
37
  else
38
  $this->total_activity_count = (int)$max;
39
-
40
  $this->activities = $this->activities['activities'];
41
-
42
  if ( $max ) {
43
  if ( $max >= count($this->activities) )
44
  $this->activity_count = count($this->activities);
@@ -47,7 +47,7 @@ class BP_Activity_Template {
47
  } else {
48
  $this->activity_count = count($this->activities);
49
  }
50
-
51
  $this->full_name = $bp->displayed_user->fullname;
52
 
53
  if ( (int) $this->total_activity_count && (int) $this->pag_num ) {
@@ -62,29 +62,29 @@ class BP_Activity_Template {
62
  ));
63
  }
64
  }
65
-
66
  function has_activities() {
67
  if ( $this->activity_count )
68
  return true;
69
-
70
  return false;
71
  }
72
-
73
  function next_activity() {
74
  $this->current_activity++;
75
  $this->activity = $this->activities[$this->current_activity];
76
-
77
  return $this->activity;
78
  }
79
-
80
  function rewind_activities() {
81
  $this->current_activity = -1;
82
  if ( $this->activity_count > 0 ) {
83
  $this->activity = $this->activities[0];
84
  }
85
  }
86
-
87
- function user_activities() {
88
  if ( $this->current_activity + 1 < $this->activity_count ) {
89
  return true;
90
  } elseif ( $this->current_activity + 1 == $this->activity_count ) {
@@ -96,13 +96,13 @@ class BP_Activity_Template {
96
  $this->in_the_loop = false;
97
  return false;
98
  }
99
-
100
  function the_activity() {
101
  global $activity;
102
 
103
  $this->in_the_loop = true;
104
  $this->activity = $this->next_activity();
105
-
106
  if ( is_array( $this->activity ) )
107
  $this->activity = (object) $this->activity;
108
 
@@ -113,9 +113,9 @@ class BP_Activity_Template {
113
 
114
  function bp_has_activities( $args = '' ) {
115
  global $bp, $activities_template;
116
-
117
  /* Note: any params used for filtering can be a single value, or multiple values comma separated. */
118
-
119
  $defaults = array(
120
  'type' => 'sitewide',
121
  'per_page' => 25,
@@ -137,13 +137,13 @@ function bp_has_activities( $args = '' ) {
137
  if ( $per_page > $max )
138
  $per_page = $max;
139
  }
140
-
141
  if ( isset( $_GET['afilter'] ) )
142
  $filter = array( 'object' => $_GET['afilter'] );
143
  else
144
  $filter = array( 'object' => $object, 'action' => $action, 'primary_id' => $primary_id, 'secondary_id' => $secondary_id );
145
-
146
- $activities_template = new BP_Activity_Template( $type, $user_id, $per_page, $max, $filter );
147
  return apply_filters( 'bp_has_activities', $activities_template->has_activities(), &$activities_template );
148
  }
149
 
@@ -159,7 +159,7 @@ function bp_the_activity() {
159
 
160
  function bp_activity_pagination_count() {
161
  global $bp, $activities_template;
162
-
163
  $from_num = intval( ( $activities_template->pag_page - 1 ) * $activities_template->pag_num ) + 1;
164
  $to_num = ( $from_num + ( $activities_template->pag_num - 1 ) > $activities_template->total_activity_count ) ? $activities_template->total_activity_count : $from_num + ( $activities_template->pag_num - 1) ;
165
 
@@ -172,13 +172,13 @@ function bp_activity_pagination_links() {
172
  }
173
  function bp_get_activity_pagination_links() {
174
  global $activities_template;
175
-
176
  return apply_filters( 'bp_get_activity_pagination_links', $activities_template->pag_links );
177
  }
178
 
179
  function bp_activities_title() {
180
  global $bp_activity_title;
181
-
182
  echo bp_get_activities_title();
183
  }
184
  function bp_get_activities_title() {
@@ -189,12 +189,12 @@ function bp_activities_title() {
189
 
190
  function bp_activities_no_activity() {
191
  global $bp_activity_no_activity;
192
-
193
  echo bp_get_activities_no_activity();
194
  }
195
  function bp_get_activities_no_activity() {
196
  global $bp_activity_no_activity;
197
-
198
  return apply_filters( 'bp_get_activities_no_activity', $bp_activity_no_activity );
199
  }
200
 
@@ -217,12 +217,12 @@ function bp_activity_avatar( $args = '' ) {
217
  'width' => 20,
218
  'height' => 20,
219
  'class' => 'avatar',
220
- 'alt' => __( 'Avatar', 'buddypress' )
221
  );
222
 
223
  $r = wp_parse_args( $args, $defaults );
224
  extract( $r, EXTR_SKIP );
225
-
226
  $item_id = false;
227
  if ( (int)$activities_template->activity->user_id )
228
  $item_id = $activities_template->activity->user_id;
@@ -234,10 +234,10 @@ function bp_activity_avatar( $args = '' ) {
234
  $object = 'group';
235
  if ( $bp->blogs->id == $activities_template->activity->component_name && !(int) $activities_template->activity->user_id )
236
  $object = 'blog';
237
-
238
  $object = apply_filters( 'bp_get_activity_avatar_object_' . $activities_template->activity->component_name, $object );
239
-
240
- return apply_filters( 'bp_get_group_avatar', bp_core_fetch_avatar( array( 'item_id' => $item_id, 'object' => $object, 'type' => $type, 'alt' => $alt, 'class' => $class, 'width' => $width, 'height' => $height ) ) );
241
  }
242
 
243
  function bp_activity_content() {
@@ -247,22 +247,19 @@ function bp_activity_content() {
247
  global $activities_template, $allowed_tags, $bp;
248
 
249
  if ( bp_is_home() && $activities_template->activity_type == 'personal' )
250
- $content = bp_activity_content_filter( $activities_template->activity->content, $activities_template->activity->date_recorded, $activities_template->full_name );
251
  else
252
  $content = bp_activity_content_filter( $activities_template->activity->content, $activities_template->activity->date_recorded, $activities_template->full_name, true, false, false );
253
 
254
- /* Add 'the_content' filter to activity to allow existing plugins to replace text as they would on post text. (extra smilies etc) */
255
- $content = apply_filters( 'the_content', $content );
256
-
257
  return apply_filters( 'bp_get_activity_content', $content );
258
  }
259
 
260
  function bp_activity_content_filter( $content, $date_recorded, $full_name, $insert_time = true, $filter_words = true, $filter_you = true ) {
261
  global $activities_template, $bp;
262
-
263
  if ( !$content )
264
  return false;
265
-
266
  /* Split the content so we don't evaluate and replace text on content we don't want to */
267
  $content = explode( '%s', $content );
268
 
@@ -272,7 +269,7 @@ function bp_activity_content_filter( $content, $date_recorded, $full_name, $inse
272
  /* Insert the time since */
273
  if ( $insert_time )
274
  $content[0] = bp_activity_insert_time_since( $content[0], $date_recorded );
275
-
276
  // The "You" and "Your" conversion is only done in english, if a translation file is present
277
  // then do not translate as it causes problems in other languages.
278
  if ( '' == get_locale() ) {
@@ -283,19 +280,19 @@ function bp_activity_content_filter( $content, $date_recorded, $full_name, $inse
283
 
284
  /* Remove the 'You' and replace if with the persons name */
285
  if ( $filter_you && $full_name != '' ) {
286
- $content[0] = preg_replace( "/{$full_name}[<]/", 'You<', $content[0], 1 );
287
  }
288
  }
289
 
290
  /* Add the delete link if the user has permission on this item */
291
  if ( ( $activities_template->activity->user_id == $bp->loggedin_user->id ) || $bp->is_item_admin || is_site_admin() )
292
- $content[1] = '</span> <span class="activity-delete-link">' . bp_get_activity_delete_link() . '</span>' . $content[1];
293
-
294
  $content_new = '';
295
-
296
  for ( $i = 0; $i < count($content); $i++ )
297
  $content_new .= $content[$i];
298
-
299
  return apply_filters( 'bp_activity_content_filter', $content_new );
300
  }
301
 
@@ -305,7 +302,7 @@ function bp_activity_insert_time_since( $content, $date ) {
305
 
306
  // Make sure we don't have any URL encoding in links when trying to insert the time.
307
  $content = urldecode($content);
308
-
309
  return apply_filters( 'bp_activity_insert_time_since', @sprintf( $content, @sprintf( __( '&nbsp; %s ago', 'buddypress' ), bp_core_time_since( strtotime( $date ) ) ) ) );
310
  }
311
 
@@ -314,7 +311,7 @@ function bp_activity_css_class() {
314
  }
315
  function bp_get_activity_css_class() {
316
  global $activities_template;
317
-
318
  return apply_filters( 'bp_get_activity_css_class', $activities_template->activity->component_name );
319
  }
320
 
@@ -332,26 +329,26 @@ function bp_activity_filter_links( $args = false ) {
332
  }
333
  function bp_get_activity_filter_links( $args = false ) {
334
  global $activities_template, $bp;
335
-
336
  $defaults = array(
337
  'style' => 'list'
338
  );
339
 
340
  $r = wp_parse_args( $args, $defaults );
341
  extract( $r, EXTR_SKIP );
342
-
343
  /* Fetch the names of components that have activity recorded in the DB */
344
  $component_names = BP_Activity_Activity::get_recorded_component_names();
345
-
346
  if ( !$component_names )
347
  return false;
348
-
349
  foreach ( (array) $component_names as $component_name ) {
350
  if ( isset( $_GET['afilter'] ) && $component_name == $_GET['afilter'] )
351
  $selected = ' class="selected"';
352
  else
353
  unset($selected);
354
-
355
  $component_name = attribute_escape( $component_name );
356
 
357
  switch ( $style ) {
@@ -371,15 +368,15 @@ function bp_activity_filter_links( $args = false ) {
371
  $after = '</span>';
372
  break;
373
  }
374
-
375
  $link = add_query_arg( 'afilter', $component_name );
376
  $link = remove_query_arg( 'acpage' , $link );
377
 
378
  $link = apply_filters( 'bp_get_activity_filter_link_href', $link, $component_name );
379
-
380
  /* Make sure all core internal component names are translatable */
381
  $translatable_component_names = array( __( 'profile', 'buddypress'), __( 'friends', 'buddypress' ), __( 'groups', 'buddypress' ), __( 'status', 'buddypress' ), __( 'blogs', 'buddypress' ) );
382
-
383
  $component_links[] = $before . '<a href="' . attribute_escape( $link ) . '">' . ucwords( __( $component_name, 'buddypress' ) ) . '</a>' . $after;
384
  }
385
 
@@ -387,7 +384,7 @@ function bp_activity_filter_links( $args = false ) {
387
 
388
  if ( isset( $_GET['afilter'] ) )
389
  $component_links[] = '<' . $tag . ' id="afilter-clear"><a href="' . attribute_escape( $link ) . '"">' . __( 'Clear Filter', 'buddypress' ) . '</a></' . $tag . '>';
390
-
391
  return apply_filters( 'bp_get_activity_filter_links', implode( "\n", $component_links ) );
392
  }
393
 
@@ -409,7 +406,7 @@ function bp_activities_member_rss_link() {
409
  if ( ( $bp->current_component == $bp->profile->slug ) || 'just-me' == $bp->current_action )
410
  return apply_filters( 'bp_get_activities_member_rss_link', $bp->displayed_user->domain . $bp->activity->slug . '/feed' );
411
  else
412
- return apply_filters( 'bp_get_activities_member_rss_link', $bp->displayed_user->domain . $bp->activity->slug . '/my-friends/feed' );
413
  }
414
 
415
  /* Template tags for RSS feed output */
@@ -420,7 +417,7 @@ function bp_activity_feed_item_guid() {
420
  function bp_get_activity_feed_item_guid() {
421
  global $activities_template;
422
 
423
- return apply_filters( 'bp_get_activity_feed_item_title', md5( $activities_template->activity->date_recorded . '-' . $activities_template->activity->content ) );
424
  }
425
 
426
  function bp_activity_feed_item_title() {
@@ -452,12 +449,12 @@ function bp_activity_feed_item_date() {
452
  }
453
 
454
  function bp_activity_feed_item_description() {
455
- echo bp_get_activity_feed_item_description();
456
  }
457
  function bp_get_activity_feed_item_description() {
458
  global $activities_template;
459
 
460
- return apply_filters( 'bp_get_activity_feed_item_description', html_entity_decode( str_replace( '%s', '', $activities_template->activity->content ), ENT_COMPAT, 'UTF-8' ) );
461
  }
462
 
463
  ?>
7
  var $activities;
8
  var $activity;
9
  var $activity_type;
10
+
11
  var $in_the_loop;
12
+
13
  var $pag_page;
14
  var $pag_num;
15
  var $pag_links;
25
 
26
  if ( $type == 'sitewide' )
27
  $this->activities = bp_activity_get_sitewide_activity( $max, $this->pag_num, $this->pag_page, $filter );
28
+
29
  if ( $type == 'personal' )
30
  $this->activities = bp_activity_get_user_activity( $user_id, $max, $this->pag_num, $this->pag_page, $filter );
31
 
32
  if ( $type == 'friends' && ( bp_is_home() || is_site_admin() || $bp->loggedin_user->id == $user_id ) )
33
  $this->activities = bp_activity_get_friends_activity( $user_id, $max, false, $this->pag_num, $this->pag_page, $filter );
34
+
35
  if ( !$max || $max >= (int)$this->activities['total'] )
36
  $this->total_activity_count = (int)$this->activities['total'];
37
  else
38
  $this->total_activity_count = (int)$max;
39
+
40
  $this->activities = $this->activities['activities'];
41
+
42
  if ( $max ) {
43
  if ( $max >= count($this->activities) )
44
  $this->activity_count = count($this->activities);
47
  } else {
48
  $this->activity_count = count($this->activities);
49
  }
50
+
51
  $this->full_name = $bp->displayed_user->fullname;
52
 
53
  if ( (int) $this->total_activity_count && (int) $this->pag_num ) {
62
  ));
63
  }
64
  }
65
+
66
  function has_activities() {
67
  if ( $this->activity_count )
68
  return true;
69
+
70
  return false;
71
  }
72
+
73
  function next_activity() {
74
  $this->current_activity++;
75
  $this->activity = $this->activities[$this->current_activity];
76
+
77
  return $this->activity;
78
  }
79
+
80
  function rewind_activities() {
81
  $this->current_activity = -1;
82
  if ( $this->activity_count > 0 ) {
83
  $this->activity = $this->activities[0];
84
  }
85
  }
86
+
87
+ function user_activities() {
88
  if ( $this->current_activity + 1 < $this->activity_count ) {
89
  return true;
90
  } elseif ( $this->current_activity + 1 == $this->activity_count ) {
96
  $this->in_the_loop = false;
97
  return false;
98
  }
99
+
100
  function the_activity() {
101
  global $activity;
102
 
103
  $this->in_the_loop = true;
104
  $this->activity = $this->next_activity();
105
+
106
  if ( is_array( $this->activity ) )
107
  $this->activity = (object) $this->activity;
108
 
113
 
114
  function bp_has_activities( $args = '' ) {
115
  global $bp, $activities_template;
116
+
117
  /* Note: any params used for filtering can be a single value, or multiple values comma separated. */
118
+
119
  $defaults = array(
120
  'type' => 'sitewide',
121
  'per_page' => 25,
137
  if ( $per_page > $max )
138
  $per_page = $max;
139
  }
140
+
141
  if ( isset( $_GET['afilter'] ) )
142
  $filter = array( 'object' => $_GET['afilter'] );
143
  else
144
  $filter = array( 'object' => $object, 'action' => $action, 'primary_id' => $primary_id, 'secondary_id' => $secondary_id );
145
+
146
+ $activities_template = new BP_Activity_Template( $type, $user_id, $per_page, $max, $filter );
147
  return apply_filters( 'bp_has_activities', $activities_template->has_activities(), &$activities_template );
148
  }
149
 
159
 
160
  function bp_activity_pagination_count() {
161
  global $bp, $activities_template;
162
+
163
  $from_num = intval( ( $activities_template->pag_page - 1 ) * $activities_template->pag_num ) + 1;
164
  $to_num = ( $from_num + ( $activities_template->pag_num - 1 ) > $activities_template->total_activity_count ) ? $activities_template->total_activity_count : $from_num + ( $activities_template->pag_num - 1) ;
165
 
172
  }
173
  function bp_get_activity_pagination_links() {
174
  global $activities_template;
175
+
176
  return apply_filters( 'bp_get_activity_pagination_links', $activities_template->pag_links );
177
  }
178
 
179
  function bp_activities_title() {
180
  global $bp_activity_title;
181
+
182
  echo bp_get_activities_title();
183
  }
184
  function bp_get_activities_title() {
189
 
190
  function bp_activities_no_activity() {
191
  global $bp_activity_no_activity;
192
+
193
  echo bp_get_activities_no_activity();
194
  }
195
  function bp_get_activities_no_activity() {
196
  global $bp_activity_no_activity;
197
+
198
  return apply_filters( 'bp_get_activities_no_activity', $bp_activity_no_activity );
199
  }
200
 
217
  'width' => 20,
218
  'height' => 20,
219
  'class' => 'avatar',
220
+ 'alt' => __( 'Avatar', 'buddypress' )
221
  );
222
 
223
  $r = wp_parse_args( $args, $defaults );
224
  extract( $r, EXTR_SKIP );
225
+
226
  $item_id = false;
227
  if ( (int)$activities_template->activity->user_id )
228
  $item_id = $activities_template->activity->user_id;
234
  $object = 'group';
235
  if ( $bp->blogs->id == $activities_template->activity->component_name && !(int) $activities_template->activity->user_id )
236
  $object = 'blog';
237
+
238
  $object = apply_filters( 'bp_get_activity_avatar_object_' . $activities_template->activity->component_name, $object );
239
+
240
+ return apply_filters( 'bp_get_activity_avatar', bp_core_fetch_avatar( array( 'item_id' => $item_id, 'object' => $object, 'type' => $type, 'alt' => $alt, 'class' => $class, 'width' => $width, 'height' => $height ) ) );
241
  }
242
 
243
  function bp_activity_content() {
247
  global $activities_template, $allowed_tags, $bp;
248
 
249
  if ( bp_is_home() && $activities_template->activity_type == 'personal' )
250
+ $content = bp_activity_content_filter( $activities_template->activity->content, $activities_template->activity->date_recorded, $activities_template->full_name );
251
  else
252
  $content = bp_activity_content_filter( $activities_template->activity->content, $activities_template->activity->date_recorded, $activities_template->full_name, true, false, false );
253
 
 
 
 
254
  return apply_filters( 'bp_get_activity_content', $content );
255
  }
256
 
257
  function bp_activity_content_filter( $content, $date_recorded, $full_name, $insert_time = true, $filter_words = true, $filter_you = true ) {
258
  global $activities_template, $bp;
259
+
260
  if ( !$content )
261
  return false;
262
+
263
  /* Split the content so we don't evaluate and replace text on content we don't want to */
264
  $content = explode( '%s', $content );
265
 
269
  /* Insert the time since */
270
  if ( $insert_time )
271
  $content[0] = bp_activity_insert_time_since( $content[0], $date_recorded );
272
+
273
  // The "You" and "Your" conversion is only done in english, if a translation file is present
274
  // then do not translate as it causes problems in other languages.
275
  if ( '' == get_locale() ) {
280
 
281
  /* Remove the 'You' and replace if with the persons name */
282
  if ( $filter_you && $full_name != '' ) {
283
+ $content[0] = preg_replace( "/{$full_name}[<]/", 'You<', $content[0], 1 );
284
  }
285
  }
286
 
287
  /* Add the delete link if the user has permission on this item */
288
  if ( ( $activities_template->activity->user_id == $bp->loggedin_user->id ) || $bp->is_item_admin || is_site_admin() )
289
+ $content[1] = '</span> <span class="activity-delete-link">' . bp_get_activity_delete_link() . '</span>' . $content[1];
290
+
291
  $content_new = '';
292
+
293
  for ( $i = 0; $i < count($content); $i++ )
294
  $content_new .= $content[$i];
295
+
296
  return apply_filters( 'bp_activity_content_filter', $content_new );
297
  }
298
 
302
 
303
  // Make sure we don't have any URL encoding in links when trying to insert the time.
304
  $content = urldecode($content);
305
+
306
  return apply_filters( 'bp_activity_insert_time_since', @sprintf( $content, @sprintf( __( '&nbsp; %s ago', 'buddypress' ), bp_core_time_since( strtotime( $date ) ) ) ) );
307
  }
308
 
311
  }
312
  function bp_get_activity_css_class() {
313
  global $activities_template;
314
+
315
  return apply_filters( 'bp_get_activity_css_class', $activities_template->activity->component_name );
316
  }
317
 
329
  }
330
  function bp_get_activity_filter_links( $args = false ) {
331
  global $activities_template, $bp;
332
+
333
  $defaults = array(
334
  'style' => 'list'
335
  );
336
 
337
  $r = wp_parse_args( $args, $defaults );
338
  extract( $r, EXTR_SKIP );
339
+
340
  /* Fetch the names of components that have activity recorded in the DB */
341
  $component_names = BP_Activity_Activity::get_recorded_component_names();
342
+
343
  if ( !$component_names )
344
  return false;
345
+
346
  foreach ( (array) $component_names as $component_name ) {
347
  if ( isset( $_GET['afilter'] ) && $component_name == $_GET['afilter'] )
348
  $selected = ' class="selected"';
349
  else
350
  unset($selected);
351
+
352
  $component_name = attribute_escape( $component_name );
353
 
354
  switch ( $style ) {
368
  $after = '</span>';
369
  break;
370
  }
371
+
372
  $link = add_query_arg( 'afilter', $component_name );
373
  $link = remove_query_arg( 'acpage' , $link );
374
 
375
  $link = apply_filters( 'bp_get_activity_filter_link_href', $link, $component_name );
376
+
377
  /* Make sure all core internal component names are translatable */
378
  $translatable_component_names = array( __( 'profile', 'buddypress'), __( 'friends', 'buddypress' ), __( 'groups', 'buddypress' ), __( 'status', 'buddypress' ), __( 'blogs', 'buddypress' ) );
379
+
380
  $component_links[] = $before . '<a href="' . attribute_escape( $link ) . '">' . ucwords( __( $component_name, 'buddypress' ) ) . '</a>' . $after;
381
  }
382
 
384
 
385
  if ( isset( $_GET['afilter'] ) )
386
  $component_links[] = '<' . $tag . ' id="afilter-clear"><a href="' . attribute_escape( $link ) . '"">' . __( 'Clear Filter', 'buddypress' ) . '</a></' . $tag . '>';
387
+
388
  return apply_filters( 'bp_get_activity_filter_links', implode( "\n", $component_links ) );
389
  }
390
 
406
  if ( ( $bp->current_component == $bp->profile->slug ) || 'just-me' == $bp->current_action )
407
  return apply_filters( 'bp_get_activities_member_rss_link', $bp->displayed_user->domain . $bp->activity->slug . '/feed' );
408
  else
409
+ return apply_filters( 'bp_get_activities_member_rss_link', $bp->displayed_user->domain . $bp->activity->slug . '/my-friends/feed' );
410
  }
411
 
412
  /* Template tags for RSS feed output */
417
  function bp_get_activity_feed_item_guid() {
418
  global $activities_template;
419
 
420
+ return apply_filters( 'bp_get_activity_feed_item_guid', md5( $activities_template->activity->date_recorded . '-' . $activities_template->activity->content ) );
421
  }
422
 
423
  function bp_activity_feed_item_title() {
449
  }
450
 
451
  function bp_activity_feed_item_description() {
452
+ echo bp_get_activity_feed_item_description();
453
  }
454
  function bp_get_activity_feed_item_description() {
455
  global $activities_template;
456
 
457
+ return apply_filters( 'bp_get_activity_feed_item_description', html_entity_decode( str_replace( '%s', '', $activities_template->activity->content ), ENT_COMPAT, 'UTF-8' ) );
458
  }
459
 
460
  ?>
bp-activity/bp-activity-widgets.php CHANGED
@@ -13,15 +13,15 @@ class BP_Activity_Widget extends WP_Widget {
13
 
14
  function widget($args, $instance) {
15
  global $bp;
16
-
17
  extract( $args );
18
-
19
  echo $before_widget;
20
  echo $before_title
21
- . $widget_name .
22
- ' <a class="rss-image" href="' . bp_get_sitewide_activity_feed_link() . '" title="' . __( 'Site Wide Activity RSS Feed', 'buddypress' ) . '">' . __( '[RSS]', 'buddypress' ) . '</a>'
23
  . $after_title; ?>
24
-
25
  <?php if ( bp_has_activities( 'type=sitewide&max=' . $instance['max_items'] . '&per_page=' . $instance['per_page'] ) ) : ?>
26
 
27
  <?php if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) : ?>
@@ -29,17 +29,17 @@ class BP_Activity_Widget extends WP_Widget {
29
  <div class="pag-count" id="activity-count">
30
  <?php bp_activity_pagination_count() ?>
31
  </div>
32
-
33
  <div class="pagination-links" id="activity-pag">
34
  &nbsp; <?php bp_activity_pagination_links() ?>
35
  </div>
36
  </div>
37
-
38
  <ul id="activity-filter-links">
39
  <?php bp_activity_filter_links() ?>
40
  </ul>
41
  <?php endif; ?>
42
-
43
  <ul id="site-wide-stream" class="activity-list">
44
  <?php while ( bp_activities() ) : bp_the_activity(); ?>
45
  <li class="<?php bp_activity_css_class() ?>">
@@ -48,7 +48,7 @@ class BP_Activity_Widget extends WP_Widget {
48
  <?php bp_activity_avatar() ?>
49
  </div>
50
  <?php endif; ?>
51
-
52
  <?php bp_activity_content() ?>
53
  </li>
54
  <?php endwhile; ?>
@@ -60,7 +60,7 @@ class BP_Activity_Widget extends WP_Widget {
60
  <?php _e('There has been no recent site activity.', 'buddypress') ?>
61
  </div>
62
  <?php endif;?>
63
-
64
  <?php echo $after_widget; ?>
65
  <?php
66
  }
13
 
14
  function widget($args, $instance) {
15
  global $bp;
16
+
17
  extract( $args );
18
+
19
  echo $before_widget;
20
  echo $before_title
21
+ . $widget_name .
22
+ ' <a class="rss-image" href="' . bp_get_sitewide_activity_feed_link() . '" title="' . __( 'Site Wide Activity RSS Feed', 'buddypress' ) . '">' . __( '[RSS]', 'buddypress' ) . '</a>'
23
  . $after_title; ?>
24
+
25
  <?php if ( bp_has_activities( 'type=sitewide&max=' . $instance['max_items'] . '&per_page=' . $instance['per_page'] ) ) : ?>
26
 
27
  <?php if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) : ?>
29
  <div class="pag-count" id="activity-count">
30
  <?php bp_activity_pagination_count() ?>
31
  </div>
32
+
33
  <div class="pagination-links" id="activity-pag">
34
  &nbsp; <?php bp_activity_pagination_links() ?>
35
  </div>
36
  </div>
37
+
38
  <ul id="activity-filter-links">
39
  <?php bp_activity_filter_links() ?>
40
  </ul>
41
  <?php endif; ?>
42
+
43
  <ul id="site-wide-stream" class="activity-list">
44
  <?php while ( bp_activities() ) : bp_the_activity(); ?>
45
  <li class="<?php bp_activity_css_class() ?>">
48
  <?php bp_activity_avatar() ?>
49
  </div>
50
  <?php endif; ?>
51
+
52
  <?php bp_activity_content() ?>
53
  </li>
54
  <?php endwhile; ?>
60
  <?php _e('There has been no recent site activity.', 'buddypress') ?>
61
  </div>
62
  <?php endif;?>
63
+
64
  <?php echo $after_widget; ?>
65
  <?php
66
  }
bp-activity/deprecated/bp-activity-deprecated.php CHANGED
@@ -3,7 +3,7 @@
3
  * Deprecated Activity Stream Functionality
4
  *
5
  * This file contains functions that are deprecated.
6
- * You should not under any circumstance use these functions as they are
7
  * either no longer valid, or have been replaced with something much more awesome.
8
  *
9
  * If you are using functions in this file you should slap the back of your head
@@ -12,9 +12,9 @@
12
  *
13
  * Of course, things will still work if you use these functions but you will
14
  * be the laughing stock of the BuddyPress community. We will all point and laugh at
15
- * you. You'll also be making things harder for yourself in the long run,
16
  * and you will miss out on lovely performance and functionality improvements.
17
- *
18
  * If you've checked you are not using any deprecated functions and finished your little
19
  * dance, you can add the following line to your wp-config.php file to prevent any of
20
  * these old functions from being loaded:
@@ -24,59 +24,59 @@
24
 
25
  function bp_activity_deprecated_globals() {
26
  global $bp;
27
-
28
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
29
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
30
  return $template;
31
 
32
  $bp->activity->image_base = BP_PLUGIN_URL . '/bp-activity/images';
33
  }
34
- add_action( 'plugins_loaded', 'bp_activity_deprecated_globals', 5 );
35
  add_action( 'admin_menu', 'bp_activity_deprecated_globals', 2 );
36
 
37
  /* DEPRECATED - use bp_activity_add() */
38
  function bp_activity_record( $item_id, $component_name, $component_action, $is_private, $secondary_item_id = false, $user_id = false, $secondary_user_id = false, $recorded_time = false ) {
39
  global $bp, $wpdb;
40
-
41
  if ( !$user_id )
42
  $user_id = $bp->loggedin_user->id;
43
 
44
  if ( !$recorded_time )
45
  $recorded_time = time();
46
-
47
  $args = compact( 'user_id', 'content', 'component_name', 'component_action', 'item_id', 'secondary_item_id', 'recorded_time' );
48
  bp_activity_add( $args );
49
-
50
  if ( $secondary_user_id ) {
51
  $hide_sitewide = true;
52
  $args = compact( 'user_id', 'content', 'component_name', 'component_action', 'item_id', 'secondary_item_id', 'recorded_time', 'hide_sitewide' );
53
  bp_activity_add( $args );
54
  }
55
-
56
  do_action( 'bp_activity_record', $item_id, $component_name, $component_action, $is_private, $secondary_item_id, $user_id, $secondary_user_id );
57
-
58
  return true;
59
  }
60
 
61
  /* DEPRECATED - use bp_activity_delete_by_item_id() */
62
- function bp_activity_delete( $item_id, $component_name, $component_action, $user_id, $secondary_item_id ) {
63
  if ( !bp_activity_delete_by_item_id( array( 'item_id' => $item_id, 'component_name' => $component_name, 'component_action' => $component_action, 'user_id' => $user_id, 'secondary_item_id' => $secondary_item_id ) ) )
64
  return false;
65
-
66
  do_action( 'bp_activity_delete', $item_id, $component_name, $component_action, $user_id, $secondary_item_id );
67
-
68
  return true;
69
  }
70
 
71
  /* DEPRECATED - use the activity template loop directly */
72
  function bp_activity_get_list( $user_id, $title, $no_activity, $limit = false ) {
73
  global $bp_activity_user_id, $bp_activity_limit, $bp_activity_title, $bp_activity_no_activity;
74
-
75
  $bp_activity_user_id = $user_id;
76
  $bp_activity_limit = $limit;
77
  $bp_activity_title = $title;
78
  $bp_activity_no_activity = $no_activity;
79
-
80
  locate_template( array( '/activity/activity-list.php' ), true );
81
  }
82
 
@@ -86,9 +86,9 @@ function bp_activity_add_structure_css() {
86
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
87
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
88
  return $template;
89
-
90
  /* Enqueue the structure CSS file to give basic positional formatting for components */
91
- wp_enqueue_style( 'bp-activity-structure', BP_PLUGIN_URL . '/bp-activity/deprecated/css/structure.css' );
92
  }
93
  add_action( 'bp_styles', 'bp_activity_add_structure_css' );
94
 
3
  * Deprecated Activity Stream Functionality
4
  *
5
  * This file contains functions that are deprecated.
6
+ * You should not under any circumstance use these functions as they are
7
  * either no longer valid, or have been replaced with something much more awesome.
8
  *
9
  * If you are using functions in this file you should slap the back of your head
12
  *
13
  * Of course, things will still work if you use these functions but you will
14
  * be the laughing stock of the BuddyPress community. We will all point and laugh at
15
+ * you. You'll also be making things harder for yourself in the long run,
16
  * and you will miss out on lovely performance and functionality improvements.
17
+ *
18
  * If you've checked you are not using any deprecated functions and finished your little
19
  * dance, you can add the following line to your wp-config.php file to prevent any of
20
  * these old functions from being loaded:
24
 
25
  function bp_activity_deprecated_globals() {
26
  global $bp;
27
+
28
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
29
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
30
  return $template;
31
 
32
  $bp->activity->image_base = BP_PLUGIN_URL . '/bp-activity/images';
33
  }
34
+ add_action( 'plugins_loaded', 'bp_activity_deprecated_globals', 5 );
35
  add_action( 'admin_menu', 'bp_activity_deprecated_globals', 2 );
36
 
37
  /* DEPRECATED - use bp_activity_add() */
38
  function bp_activity_record( $item_id, $component_name, $component_action, $is_private, $secondary_item_id = false, $user_id = false, $secondary_user_id = false, $recorded_time = false ) {
39
  global $bp, $wpdb;
40
+
41
  if ( !$user_id )
42
  $user_id = $bp->loggedin_user->id;
43
 
44
  if ( !$recorded_time )
45
  $recorded_time = time();
46
+
47
  $args = compact( 'user_id', 'content', 'component_name', 'component_action', 'item_id', 'secondary_item_id', 'recorded_time' );
48
  bp_activity_add( $args );
49
+
50
  if ( $secondary_user_id ) {
51
  $hide_sitewide = true;
52
  $args = compact( 'user_id', 'content', 'component_name', 'component_action', 'item_id', 'secondary_item_id', 'recorded_time', 'hide_sitewide' );
53
  bp_activity_add( $args );
54
  }
55
+
56
  do_action( 'bp_activity_record', $item_id, $component_name, $component_action, $is_private, $secondary_item_id, $user_id, $secondary_user_id );
57
+
58
  return true;
59
  }
60
 
61
  /* DEPRECATED - use bp_activity_delete_by_item_id() */
62
+ function bp_activity_delete( $item_id, $component_name, $component_action, $user_id, $secondary_item_id ) {
63
  if ( !bp_activity_delete_by_item_id( array( 'item_id' => $item_id, 'component_name' => $component_name, 'component_action' => $component_action, 'user_id' => $user_id, 'secondary_item_id' => $secondary_item_id ) ) )
64
  return false;
65
+
66
  do_action( 'bp_activity_delete', $item_id, $component_name, $component_action, $user_id, $secondary_item_id );
67
+
68
  return true;
69
  }
70
 
71
  /* DEPRECATED - use the activity template loop directly */
72
  function bp_activity_get_list( $user_id, $title, $no_activity, $limit = false ) {
73
  global $bp_activity_user_id, $bp_activity_limit, $bp_activity_title, $bp_activity_no_activity;
74
+
75
  $bp_activity_user_id = $user_id;
76
  $bp_activity_limit = $limit;
77
  $bp_activity_title = $title;
78
  $bp_activity_no_activity = $no_activity;
79
+
80
  locate_template( array( '/activity/activity-list.php' ), true );
81
  }
82
 
86
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
87
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
88
  return $template;
89
+
90
  /* Enqueue the structure CSS file to give basic positional formatting for components */
91
+ wp_enqueue_style( 'bp-activity-structure', BP_PLUGIN_URL . '/bp-activity/deprecated/css/structure.css' );
92
  }
93
  add_action( 'bp_styles', 'bp_activity_add_structure_css' );
94
 
bp-activity/deprecated/css/structure.css CHANGED
File without changes
bp-activity/deprecated/images/rss.png CHANGED
File without changes
bp-activity/feeds/bp-activity-friends-feed.php CHANGED
File without changes
bp-activity/feeds/bp-activity-personal-feed.php CHANGED
File without changes
bp-activity/feeds/bp-activity-sitewide-feed.php CHANGED
File without changes
bp-blogs.php CHANGED
@@ -12,14 +12,14 @@ require ( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-widgets.php' );
12
 
13
  /* Include deprecated functions if settings allow */
14
  if ( !defined( 'BP_IGNORE_DEPRECATED' ) )
15
- require ( BP_PLUGIN_DIR . '/bp-blogs/deprecated/bp-blogs-deprecated.php' );
16
-
17
  function bp_blogs_install() {
18
  global $wpdb, $bp;
19
-
20
  if ( !empty($wpdb->charset) )
21
  $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
22
-
23
  $sql[] = "CREATE TABLE {$bp->blogs->table_name} (
24
  id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
25
  user_id bigint(20) NOT NULL,
@@ -51,7 +51,7 @@ function bp_blogs_install() {
51
  KEY comment_id (comment_id),
52
  KEY comment_post_id (comment_post_id)
53
  ) {$charset_collate};";
54
-
55
  $sql[] = "CREATE TABLE {$bp->blogs->table_name_blogmeta} (
56
  id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
57
  blog_id bigint(20) NOT NULL,
@@ -60,42 +60,42 @@ function bp_blogs_install() {
60
  KEY blog_id (blog_id),
61
  KEY meta_key (meta_key)
62
  ) {$charset_collate};";
63
-
64
-
65
  require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
66
 
67
  dbDelta($sql);
68
 
69
  // On first installation - record all existing blogs in the system.
70
  if ( !(int)get_site_option( 'bp-blogs-first-install') ) {
71
-
72
  bp_blogs_record_existing_blogs();
73
  add_site_option( 'bp-blogs-first-install', 1 );
74
-
75
  } else {
76
-
77
- // Import blog titles and descriptions into the blogmeta table
78
  if ( get_site_option( 'bp-blogs-version' ) <= '0.1.5' ) {
79
  $blog_ids = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM " . $bp->blogs->table_name ) );
80
 
81
  for ( $i = 0; $i < count($blog_ids); $i++ ) {
82
  $name = get_blog_option( $blog_ids[$i], 'blogname' );
83
  $desc = get_blog_option( $blog_ids[$i], 'blogdescription' );
84
-
85
  bp_blogs_update_blogmeta( $blog_ids[$i], 'name', $name );
86
  bp_blogs_update_blogmeta( $blog_ids[$i], 'description', $desc );
87
  bp_blogs_update_blogmeta( $blog_ids[$i], 'last_activity', time() );
88
  }
89
  }
90
-
91
  }
92
-
93
  update_site_option( 'bp-blogs-db-version', BP_BLOGS_DB_VERSION );
94
  }
95
 
96
- function bp_blogs_check_installed() {
97
  global $wpdb, $bp, $userdata;
98
-
99
  if ( is_site_admin() ) {
100
  /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
101
  if ( get_site_option('bp-blogs-db-version') < BP_BLOGS_DB_VERSION )
@@ -106,27 +106,27 @@ add_action( 'admin_menu', 'bp_blogs_check_installed' );
106
 
107
  function bp_blogs_setup_globals() {
108
  global $bp, $wpdb;
109
-
110
  /* For internal identification */
111
  $bp->blogs->id = 'blogs';
112
-
113
  $bp->blogs->table_name = $wpdb->base_prefix . 'bp_user_blogs';
114
  $bp->blogs->table_name_blog_posts = $wpdb->base_prefix . 'bp_user_blogs_posts';
115
  $bp->blogs->table_name_blog_comments = $wpdb->base_prefix . 'bp_user_blogs_comments';
116
  $bp->blogs->table_name_blogmeta = $wpdb->base_prefix . 'bp_user_blogs_blogmeta';
117
  $bp->blogs->format_notification_function = 'bp_blogs_format_notifications';
118
  $bp->blogs->slug = BP_BLOGS_SLUG;
119
-
120
  /* Register this in the active components array */
121
  $bp->active_components[$bp->blogs->slug] = $bp->blogs->id;
122
 
123
  do_action( 'bp_blogs_setup_globals' );
124
  }
125
- add_action( 'plugins_loaded', 'bp_blogs_setup_globals', 5 );
126
  add_action( 'admin_menu', 'bp_blogs_setup_globals', 2 );
127
 
128
  function bp_blogs_setup_root_component() {
129
- /* Register 'groups' as a root component */
130
  bp_core_add_root_component( BP_BLOGS_SLUG );
131
  }
132
  add_action( 'plugins_loaded', 'bp_blogs_setup_root_component', 2 );
@@ -135,19 +135,19 @@ add_action( 'plugins_loaded', 'bp_blogs_setup_root_component', 2 );
135
  * bp_blogs_setup_nav()
136
  *
137
  * Adds "Blog" to the navigation arrays for the current and logged in user.
138
- *
139
  * @package BuddyPress Blogs
140
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
141
  * @uses bp_is_home() Checks to see if the current user being viewed is the logged in user
142
  */
143
  function bp_blogs_setup_nav() {
144
  global $bp;
145
-
146
  /* Add 'Blogs' to the main navigation */
147
  bp_core_new_nav_item( array( 'name' => __( 'Blogs', 'buddypress' ), 'slug' => $bp->blogs->slug, 'position' => 30, 'screen_function' => 'bp_blogs_screen_my_blogs', 'default_subnav_slug' => 'my-blogs', 'item_css_id' => $bp->blogs->id ) );
148
-
149
  $blogs_link = $bp->loggedin_user->domain . $bp->blogs->slug . '/';
150
-
151
  /* Add the subnav items to the blogs nav item */
152
  bp_core_new_subnav_item( array( 'name' => __( 'My Blogs', 'buddypress' ), 'slug' => 'my-blogs', 'parent_url' => $blogs_link, 'parent_slug' => $bp->blogs->slug, 'screen_function' => 'bp_blogs_screen_my_blogs', 'position' => 10, 'item_css_id' => 'my-blogs-list' ) );
153
  bp_core_new_subnav_item( array( 'name' => __( 'Recent Posts', 'buddypress' ), 'slug' => 'recent-posts', 'parent_url' => $blogs_link, 'parent_slug' => $bp->blogs->slug, 'screen_function' => 'bp_blogs_screen_recent_posts', 'position' => 20 ) );
@@ -158,15 +158,15 @@ function bp_blogs_setup_nav() {
158
  if ( 'blogs' == $bp->current_component ) {
159
  if ( bp_is_home() ) {
160
  if ( function_exists('xprofile_setup_nav') ) {
161
- $bp->bp_options_title = __('My Blogs', 'buddypress');
162
  }
163
  } else {
164
  /* If we are not viewing the logged in user, set up the current users avatar and name */
165
  $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) );
166
- $bp->bp_options_title = $bp->displayed_user->fullname;
167
  }
168
  }
169
-
170
  do_action( 'bp_blogs_setup_nav' );
171
  }
172
  add_action( 'plugins_loaded', 'bp_blogs_setup_nav' );
@@ -177,7 +177,7 @@ function bp_blogs_directory_blogs_setup() {
177
 
178
  if ( $bp->current_component == $bp->blogs->slug && empty( $bp->current_action ) ) {
179
  $bp->is_directory = true;
180
-
181
  do_action( 'bp_blogs_directory_blogs_setup' );
182
  bp_core_load_template( apply_filters( 'bp_blogs_template_directory_blogs_setup', 'directories/blogs/index' ) );
183
  }
@@ -195,7 +195,7 @@ add_action( 'wp', 'bp_blogs_directory_blogs_setup', 2 );
195
 
196
  function bp_blogs_screen_my_blogs() {
197
  do_action( 'bp_blogs_screen_my_blogs' );
198
- bp_core_load_template( apply_filters( 'bp_blogs_template_my_blogs', 'blogs/my-blogs' ) );
199
  }
200
 
201
  function bp_blogs_screen_recent_posts() {
@@ -223,7 +223,7 @@ function bp_blogs_screen_create_a_blog() {
223
 
224
  function bp_blogs_register_activity_actions() {
225
  global $bp;
226
-
227
  if ( !function_exists( 'bp_activity_set_action' ) )
228
  return false;
229
 
@@ -237,15 +237,15 @@ add_action( 'plugins_loaded', 'bp_blogs_register_activity_actions' );
237
 
238
  function bp_blogs_record_activity( $args = '' ) {
239
  global $bp;
240
-
241
  if ( !function_exists( 'bp_activity_add' ) )
242
  return false;
243
-
244
  /* Because blog, comment, and blog post code execution happens before anything else
245
  we may need to manually instantiate the activity component globals */
246
  if ( !$bp->activity && function_exists('bp_activity_setup_globals') )
247
  bp_activity_setup_globals();
248
-
249
  $defaults = array(
250
  'user_id' => $bp->loggedin_user->id,
251
  'content' => false,
@@ -259,19 +259,19 @@ function bp_blogs_record_activity( $args = '' ) {
259
  );
260
 
261
  $r = wp_parse_args( $args, $defaults );
262
- extract( $r, EXTR_SKIP );
263
-
264
  return bp_activity_add( array( 'user_id' => $user_id, 'content' => $content, 'primary_link' => $primary_link, 'component_name' => $component_name, 'component_action' => $component_action, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) );
265
  }
266
 
267
  function bp_blogs_delete_activity( $args = true ) {
268
  if ( function_exists('bp_activity_delete_by_item_id') ) {
269
  extract($args);
270
-
271
- bp_activity_delete_by_item_id( array(
272
- 'item_id' => $item_id,
273
  'component_name' => $component_name,
274
- 'component_action' => $component_action,
275
  'user_id' => $user_id,
276
  'secondary_item_id' => $secondary_item_id
277
  ) );
@@ -291,7 +291,7 @@ function bp_blogs_record_existing_blogs() {
291
  global $wpdb;
292
 
293
  $blog_ids = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM {$wpdb->base_prefix}blogs WHERE public = 1 AND mature = 0 AND spam = 0 AND deleted = 0" ) );
294
-
295
  if ( $blog_ids ) {
296
  foreach( $blog_ids as $blog_id ) {
297
  $users = get_users_of_blog( $blog_id );
@@ -310,67 +310,67 @@ function bp_blogs_record_existing_blogs() {
310
 
311
  function bp_blogs_record_blog( $blog_id, $user_id, $no_activity = true ) {
312
  global $bp;
313
-
314
  if ( !$user_id )
315
  $user_id = $bp->loggedin_user->id;
316
-
317
  $name = get_blog_option( $blog_id, 'blogname' );
318
  $description = get_blog_option( $blog_id, 'blogdescription' );
319
-
320
  $recorded_blog = new BP_Blogs_Blog;
321
  $recorded_blog->user_id = $user_id;
322
  $recorded_blog->blog_id = $blog_id;
323
 
324
  $recorded_blog_id = $recorded_blog->save();
325
-
326
  bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'name', $name );
327
  bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'description', $description );
328
  bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'last_activity', time() );
329
-
330
  /* Only record this activity if the blog is public */
331
  if ( (int)$_POST['blog_public'] || !$no_activity ) {
332
  /* Record this in activity streams */
333
  bp_blogs_record_activity( array(
334
  'user_id' => $recorded_blog->user_id,
335
- 'content' => apply_filters( 'bp_blogs_activity_created_blog', sprintf( __( '%s created the blog %s', 'buddypress'), bp_core_get_userlink( $recorded_blog->user_id ), '<a href="' . get_blog_option( $recorded_blog->blog_id, 'siteurl' ) . '">' . attribute_escape( $name ) . '</a>' ), &$recorded_blog, $name, $description ),
336
  'primary_link' => apply_filters( 'bp_blogs_activity_created_blog_primary_link', get_blog_option( $recorded_blog->blog_id, 'siteurl' ), $recorded_blog->blog_id ),
337
  'component_action' => 'new_blog',
338
  'item_id' => $recorded_blog->blog_id
339
  ) );
340
  }
341
-
342
  do_action( 'bp_blogs_new_blog', &$recorded_blog, $is_private, $is_recorded );
343
  }
344
  add_action( 'wpmu_new_blog', 'bp_blogs_record_blog', 10, 2 );
345
 
346
  function bp_blogs_record_post( $post_id, $post, $user_id = false ) {
347
  global $bp, $wpdb;
348
-
349
  $post_id = (int)$post_id;
350
  $blog_id = (int)$wpdb->blogid;
351
-
352
  if ( !$user_id )
353
  $user_id = (int)$post->post_author;
354
-
355
  /* This is to stop infinate loops with Donncha's sitewide tags plugin */
356
  if ( (int)get_site_option( 'tags_blog_id' ) == (int)$blog_id )
357
  return false;
358
-
359
  /* Don't record this if it's not a post */
360
  if ( $post->post_type != 'post' )
361
  return false;
362
-
363
  if ( !$is_recorded = BP_Blogs_Post::is_recorded( $post_id, $blog_id, $user_id ) ) {
364
  if ( 'publish' == $post->post_status && '' == $post->post_password ) {
365
-
366
  $recorded_post = new BP_Blogs_Post;
367
  $recorded_post->user_id = $user_id;
368
  $recorded_post->blog_id = $blog_id;
369
  $recorded_post->post_id = $post_id;
370
  $recorded_post->date_created = strtotime( $post->post_date );
371
-
372
  $recorded_post_id = $recorded_post->save();
373
-
374
  bp_blogs_update_blogmeta( $recorded_post->blog_id, 'last_activity', time() );
375
 
376
  if ( (int)get_blog_option( $blog_id, 'blog_public' ) ) {
@@ -379,10 +379,10 @@ function bp_blogs_record_post( $post_id, $post, $user_id = false ) {
379
 
380
  $activity_content = sprintf( __( '%s wrote a new blog post: %s', 'buddypress' ), bp_core_get_userlink( (int)$post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' );
381
  $activity_content .= "<blockquote>" . bp_create_excerpt( $post->post_content ) . "</blockquote>";
382
-
383
  bp_blogs_record_activity( array(
384
  'user_id' => (int)$post->post_author,
385
- 'content' => apply_filters( 'bp_blogs_activity_new_post', $activity_content, &$post, $post_permalink ),
386
  'primary_link' => apply_filters( 'bp_blogs_activity_new_post_primary_link', $post_permalink, $post_id ),
387
  'component_action' => 'new_blog_post',
388
  'item_id' => $recorded_post_id,
@@ -398,28 +398,28 @@ function bp_blogs_record_post( $post_id, $post, $user_id = false ) {
398
 
399
  /* Delete the recorded post if the status is not published or it is password protected */
400
  if ( 'publish' != $post->post_status || '' != $post->post_password ) {
401
- return bp_blogs_remove_post( $post_id, $blog_id, $existing_post );
402
-
403
  /* If the post author has changed, delete the post and re-add it. */
404
  } else if ( (int)$existing_post->user_id != (int)$post->post_author ) {
405
  // Delete the existing recorded post
406
  bp_blogs_remove_post( $post_id, $blog_id, $existing_post );
407
-
408
  // Re-record the post with the new author.
409
- bp_blogs_record_post( $post_id );
410
  }
411
 
412
  if ( (int)get_blog_option( $blog_id, 'blog_public' ) ) {
413
- /* Now re-record the post in the activity streams */
414
  $post_permalink = bp_post_get_permalink( $post, $blog_id );
415
 
416
  $activity_content = sprintf( __( '%s wrote a new blog post: %s', 'buddypress' ), bp_core_get_userlink( (int)$post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' );
417
  $activity_content .= "<blockquote>" . bp_create_excerpt( $post->post_content ) . "</blockquote>";
418
-
419
  /* Record this in activity streams */
420
  bp_blogs_record_activity( array(
421
  'user_id' => (int)$post->post_author,
422
- 'content' => apply_filters( 'bp_blogs_activity_new_post', $activity_content, &$post, $post_permalink ),
423
  'primary_link' => apply_filters( 'bp_blogs_activity_new_post_primary_link', $post_permalink, $post_id ),
424
  'component_action' => 'new_blog_post',
425
  'item_id' => $existing_post->id,
@@ -434,20 +434,24 @@ add_action( 'save_post', 'bp_blogs_record_post', 10, 2 );
434
 
435
  function bp_blogs_record_comment( $comment_id, $is_approved ) {
436
  global $wpdb, $bp;
437
-
438
  if ( !$is_approved )
439
  return false;
440
-
441
  $comment = get_comment($comment_id);
442
  $comment->post = get_post( $comment->comment_post_ID );
443
-
444
  /* Get the user_id from the author email. */
445
  $user = get_user_by_email( $comment->comment_author_email );
446
  $user_id = (int)$user->ID;
447
-
448
  if ( !$user_id )
449
  return false;
450
 
 
 
 
 
451
  $recorded_comment = new BP_Blogs_Comment;
452
  $recorded_comment->user_id = $user_id;
453
  $recorded_comment->blog_id = $wpdb->blogid;
@@ -456,19 +460,19 @@ function bp_blogs_record_comment( $comment_id, $is_approved ) {
456
  $recorded_comment->date_created = strtotime( $comment->comment_date );
457
 
458
  $recorded_commment_id = $recorded_comment->save();
459
-
460
  bp_blogs_update_blogmeta( $recorded_comment->blog_id, 'last_activity', time() );
461
 
462
  if ( (int)get_blog_option( $recorded_comment->blog_id, 'blog_public' ) ) {
463
  /* Record in activity streams */
464
  $comment_link = bp_post_get_permalink( $comment->post, $recorded_comment->blog_id );
465
- $activity_content = sprintf( __( '%s commented on the blog post %s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . $comment_link . '#comment-' . $comment->comment_ID . '">' . $comment->post->post_title . '</a>' );
466
  $activity_content .= '<blockquote>' . bp_create_excerpt( $comment->comment_content ) . '</blockquote>';
467
 
468
  /* Record this in activity streams */
469
  bp_blogs_record_activity( array(
470
  'user_id' => $recorded_comment->user_id,
471
- 'content' => apply_filters( 'bp_blogs_activity_new_comment', $activity_content, &$comment, &$recorded_comment, $comment_link ),
472
  'primary_link' => apply_filters( 'bp_blogs_activity_new_comment_primary_link', $comment_link, &$comment, &$recorded_comment ),
473
  'component_action' => 'new_blog_comment',
474
  'item_id' => $comment_id,
@@ -483,31 +487,31 @@ add_action( 'comment_post', 'bp_blogs_record_comment', 10, 2 );
483
 
484
  function bp_blogs_approve_comment( $comment_id, $comment_status ) {
485
  global $bp, $wpdb;
486
-
487
  if ( 'approve' != $comment_status )
488
  return false;
489
 
490
  $recorded_comment = bp_blogs_record_comment( $comment_id, true );
491
  $comment = get_comment($comment_id);
492
  $comment->post = get_post( $comment->comment_post_ID );
493
-
494
  bp_blogs_delete_activity( array( 'item_id' => $comment_id, 'secondary_item_id' => $recorded_comment->blog_id, 'component_name' => $bp->blogs->slug, 'component_action' => 'new_blog_comment' ) );
495
 
496
  if ( (int)get_blog_option( $recorded_comment->blog_id, 'blog_public' ) ) {
497
  /* Record in activity streams */
498
  $comment_link = bp_post_get_permalink( $comment->post, $recorded_comment->blog_id );
499
- $activity_content = sprintf( __( '%s commented on the blog post %s', 'buddypress' ), bp_core_get_userlink( $recorded_comment->user_id ), '<a href="' . $comment_link . '#comment-' . $comment->comment_ID . '">' . $comment->post->post_title . '</a>' );
500
  $activity_content .= '<blockquote>' . bp_create_excerpt( $comment->comment_content ) . '</blockquote>';
501
 
502
  /* Record this in activity streams */
503
  bp_blogs_record_activity( array(
504
  'user_id' => $recorded_comment->user_id,
505
- 'content' => apply_filters( 'bp_blogs_activity_new_comment', $activity_content, &$comment, &$recorded_comment, $comment_link ),
506
  'primary_link' => apply_filters( 'bp_blogs_activity_new_comment_primary_link', $comment_link, &$comment, &$recorded_comment ),
507
  'component_action' => 'new_blog_comment',
508
  'item_id' => $comment_id,
509
  'secondary_item_id' => $recorded_comment->blog_id,
510
- 'recorded_time' => $recorded_comment->date_created
511
  ) );
512
  }
513
  }
@@ -515,7 +519,7 @@ add_action( 'wp_set_comment_status', 'bp_blogs_approve_comment', 10, 2 );
515
 
516
  function bp_blogs_unapprove_comment( $comment_id, $comment_status ) {
517
  if ( 'spam' == $comment_status || 'hold' == $comment_status || 'delete' == $comment_status )
518
- bp_blogs_remove_comment( $comment_id );
519
  }
520
  add_action( 'wp_set_comment_status', 'bp_blogs_unapprove_comment', 10, 2 );
521
 
@@ -537,17 +541,17 @@ function bp_blogs_remove_blog( $blog_id ) {
537
  $blog_id = (int)$blog_id;
538
 
539
  BP_Blogs_Blog::delete_blog_for_all( $blog_id );
540
-
541
  // Delete activity stream item
542
  bp_blogs_delete_activity( array( 'item_id' => $blog_id, 'component_name' => $bp->blogs->slug, 'component_action' => 'new_blog' ) );
543
-
544
  do_action( 'bp_blogs_remove_blog', $blog_id );
545
  }
546
  add_action( 'delete_blog', 'bp_blogs_remove_blog' );
547
 
548
  function bp_blogs_remove_blog_for_user( $user_id, $blog_id ) {
549
  global $current_user;
550
-
551
  $blog_id = (int)$blog_id;
552
  $user_id = (int)$user_id;
553
 
@@ -564,16 +568,16 @@ function bp_blogs_remove_post( $post_id, $blog_id = false, $existing_post = fals
564
  global $current_blog, $bp;
565
 
566
  $post_id = (int)$post_id;
567
-
568
  if ( !$blog_id )
569
  $blog_id = (int)$current_blog->blog_id;
570
-
571
  if ( !$existing_post )
572
  $existing_post = new BP_Blogs_Post( null, $blog_id, $post_id );
573
 
574
  // Delete post from the bp_blogs table
575
  BP_Blogs_Post::delete( $post_id, $blog_id );
576
-
577
  // Delete activity stream item
578
  bp_blogs_delete_activity( array( 'item_id' => $existing_post->id, 'component_name' => $bp->blogs->slug, 'component_action' => 'new_blog_post' ) );
579
 
@@ -585,7 +589,7 @@ function bp_blogs_remove_comment( $comment_id ) {
585
  global $wpdb, $bp;
586
 
587
  $recorded_comment = new BP_Blogs_Comment( false, $wpdb->blogid, $comment_id );
588
- BP_Blogs_Comment::delete( $comment_id, $wpdb->blogid );
589
 
590
  // Delete activity stream item
591
  bp_blogs_delete_activity( array( 'item_id' => $comment_id, 'secondary_item_id' => $recorded_comment->blog_id, 'component_name' => $bp->blogs->slug, 'component_action' => 'new_blog_comment' ) );
@@ -596,10 +600,10 @@ add_action( 'delete_comment', 'bp_blogs_remove_comment' );
596
 
597
  function bp_blogs_remove_data_for_blog( $blog_id ) {
598
  global $bp;
599
-
600
  /* If this is regular blog, delete all data for that blog. */
601
  BP_Blogs_Blog::delete_blog_for_all( $blog_id );
602
- BP_Blogs_Post::delete_posts_for_blog( $blog_id );
603
  BP_Blogs_Comment::delete_comments_for_blog( $blog_id );
604
 
605
  // Delete activity stream item
@@ -623,10 +627,10 @@ function bp_blogs_get_comments_for_user( $user_id ) {
623
 
624
  function bp_blogs_get_latest_posts( $blog_id = null, $limit = 5 ) {
625
  global $bp;
626
-
627
  if ( !is_numeric( $limit ) )
628
  $limit = 5;
629
-
630
  return BP_Blogs_Post::get_latest_posts( $blog_id, $limit );
631
  }
632
 
@@ -644,11 +648,11 @@ function bp_blogs_get_all_posts( $limit = null, $page = null ) {
644
 
645
  function bp_blogs_total_post_count( $blog_id ) {
646
  return BP_Blogs_Post::total_post_count( $blog_id );
647
- }
648
 
649
  function bp_blogs_total_comment_count( $blog_id, $post_id = false ) {
650
  return BP_Blogs_Post::total_comment_count( $blog_id, $post_id );
651
- }
652
 
653
  function bp_blogs_is_blog_hidden( $blog_id ) {
654
  return BP_Blogs_Blog::is_hidden( $blog_id );
@@ -656,7 +660,7 @@ function bp_blogs_is_blog_hidden( $blog_id ) {
656
 
657
  function bp_blogs_redirect_to_random_blog() {
658
  global $bp, $wpdb;
659
-
660
  if ( $bp->current_component == $bp->blogs->slug && isset( $_GET['random-blog'] ) ) {
661
  $blog = bp_blogs_get_random_blog();
662
 
@@ -675,25 +679,25 @@ add_action( 'wp', 'bp_blogs_redirect_to_random_blog', 6 );
675
 
676
  function bp_blogs_delete_blogmeta( $blog_id, $meta_key = false, $meta_value = false ) {
677
  global $wpdb, $bp;
678
-
679
  if ( !is_numeric( $blog_id ) )
680
  return false;
681
-
682
  $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
683
 
684
  if ( is_array($meta_value) || is_object($meta_value) )
685
  $meta_value = serialize($meta_value);
686
-
687
  $meta_value = trim( $meta_value );
688
 
689
  if ( !$meta_key ) {
690
- $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d", $blog_id ) );
691
  } else if ( $meta_value ) {
692
  $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d AND meta_key = %s AND meta_value = %s", $blog_id, $meta_key, $meta_value ) );
693
  } else {
694
  $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d AND meta_key = %s", $blog_id, $meta_key ) );
695
  }
696
-
697
  // TODO need to look into using this.
698
  // wp_cache_delete($group_id, 'groups');
699
 
@@ -702,7 +706,7 @@ function bp_blogs_delete_blogmeta( $blog_id, $meta_key = false, $meta_value = fa
702
 
703
  function bp_blogs_get_blogmeta( $blog_id, $meta_key = '') {
704
  global $wpdb, $bp;
705
-
706
  $blog_id = (int) $blog_id;
707
 
708
  if ( !$blog_id )
@@ -710,10 +714,10 @@ function bp_blogs_get_blogmeta( $blog_id, $meta_key = '') {
710
 
711
  if ( !empty($meta_key) ) {
712
  $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
713
-
714
  // TODO need to look into using this.
715
  //$user = wp_cache_get($user_id, 'users');
716
-
717
  // Check the cached user object
718
  //if ( false !== $user && isset($user->$meta_key) )
719
  // $metas = array($user->$meta_key);
@@ -740,15 +744,15 @@ function bp_blogs_get_blogmeta( $blog_id, $meta_key = '') {
740
 
741
  function bp_blogs_update_blogmeta( $blog_id, $meta_key, $meta_value ) {
742
  global $wpdb, $bp;
743
-
744
  if ( !is_numeric( $blog_id ) )
745
  return false;
746
-
747
  $meta_key = preg_replace( '|[^a-z0-9_]|i', '', $meta_key );
748
 
749
  if ( is_string($meta_value) )
750
  $meta_value = stripslashes($wpdb->escape($meta_value));
751
-
752
  $meta_value = maybe_serialize($meta_value);
753
 
754
  if (empty($meta_value)) {
@@ -756,7 +760,7 @@ function bp_blogs_update_blogmeta( $blog_id, $meta_key, $meta_value ) {
756
  }
757
 
758
  $cur = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d AND meta_key = %s", $blog_id, $meta_key ) );
759
-
760
  if ( !$cur ) {
761
  $wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->blogs->table_name_blogmeta} ( blog_id, meta_key, meta_value ) VALUES ( %d, %s, %s )", $blog_id, $meta_key, $meta_value ) );
762
  } else if ( $cur->meta_value != $meta_value ) {
@@ -774,7 +778,7 @@ function bp_blogs_update_blogmeta( $blog_id, $meta_key, $meta_value ) {
774
  function bp_blogs_remove_data( $user_id ) {
775
  /* If this is regular blog, delete all data for that blog. */
776
  BP_Blogs_Blog::delete_blogs_for_user( $user_id );
777
- BP_Blogs_Post::delete_posts_for_user( $user_id );
778
  BP_Blogs_Comment::delete_comments_for_user( $user_id );
779
 
780
  do_action( 'bp_blogs_remove_data', $user_id );
12
 
13
  /* Include deprecated functions if settings allow */
14
  if ( !defined( 'BP_IGNORE_DEPRECATED' ) )
15
+ require ( BP_PLUGIN_DIR . '/bp-blogs/deprecated/bp-blogs-deprecated.php' );
16
+
17
  function bp_blogs_install() {
18
  global $wpdb, $bp;
19
+
20
  if ( !empty($wpdb->charset) )
21
  $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
22
+
23
  $sql[] = "CREATE TABLE {$bp->blogs->table_name} (
24
  id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
25
  user_id bigint(20) NOT NULL,
51
  KEY comment_id (comment_id),
52
  KEY comment_post_id (comment_post_id)
53
  ) {$charset_collate};";
54
+
55
  $sql[] = "CREATE TABLE {$bp->blogs->table_name_blogmeta} (
56
  id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
57
  blog_id bigint(20) NOT NULL,
60
  KEY blog_id (blog_id),
61
  KEY meta_key (meta_key)
62
  ) {$charset_collate};";
63
+
64
+
65
  require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
66
 
67
  dbDelta($sql);
68
 
69
  // On first installation - record all existing blogs in the system.
70
  if ( !(int)get_site_option( 'bp-blogs-first-install') ) {
71
+
72
  bp_blogs_record_existing_blogs();
73
  add_site_option( 'bp-blogs-first-install', 1 );
74
+
75
  } else {
76
+
77
+ // Import blog titles and descriptions into the blogmeta table
78
  if ( get_site_option( 'bp-blogs-version' ) <= '0.1.5' ) {
79
  $blog_ids = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM " . $bp->blogs->table_name ) );
80
 
81
  for ( $i = 0; $i < count($blog_ids); $i++ ) {
82
  $name = get_blog_option( $blog_ids[$i], 'blogname' );
83
  $desc = get_blog_option( $blog_ids[$i], 'blogdescription' );
84
+
85
  bp_blogs_update_blogmeta( $blog_ids[$i], 'name', $name );
86
  bp_blogs_update_blogmeta( $blog_ids[$i], 'description', $desc );
87
  bp_blogs_update_blogmeta( $blog_ids[$i], 'last_activity', time() );
88
  }
89
  }
90
+
91
  }
92
+
93
  update_site_option( 'bp-blogs-db-version', BP_BLOGS_DB_VERSION );
94
  }
95
 
96
+ function bp_blogs_check_installed() {
97
  global $wpdb, $bp, $userdata;
98
+
99
  if ( is_site_admin() ) {
100
  /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
101
  if ( get_site_option('bp-blogs-db-version') < BP_BLOGS_DB_VERSION )
106
 
107
  function bp_blogs_setup_globals() {
108
  global $bp, $wpdb;
109
+
110
  /* For internal identification */
111
  $bp->blogs->id = 'blogs';
112
+
113
  $bp->blogs->table_name = $wpdb->base_prefix . 'bp_user_blogs';
114
  $bp->blogs->table_name_blog_posts = $wpdb->base_prefix . 'bp_user_blogs_posts';
115
  $bp->blogs->table_name_blog_comments = $wpdb->base_prefix . 'bp_user_blogs_comments';
116
  $bp->blogs->table_name_blogmeta = $wpdb->base_prefix . 'bp_user_blogs_blogmeta';
117
  $bp->blogs->format_notification_function = 'bp_blogs_format_notifications';
118
  $bp->blogs->slug = BP_BLOGS_SLUG;
119
+
120
  /* Register this in the active components array */
121
  $bp->active_components[$bp->blogs->slug] = $bp->blogs->id;
122
 
123
  do_action( 'bp_blogs_setup_globals' );
124
  }
125
+ add_action( 'plugins_loaded', 'bp_blogs_setup_globals', 5 );
126
  add_action( 'admin_menu', 'bp_blogs_setup_globals', 2 );
127
 
128
  function bp_blogs_setup_root_component() {
129
+ /* Register 'blogs' as a root component */
130
  bp_core_add_root_component( BP_BLOGS_SLUG );
131
  }
132
  add_action( 'plugins_loaded', 'bp_blogs_setup_root_component', 2 );
135
  * bp_blogs_setup_nav()
136
  *
137
  * Adds "Blog" to the navigation arrays for the current and logged in user.
138
+ *
139
  * @package BuddyPress Blogs
140
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
141
  * @uses bp_is_home() Checks to see if the current user being viewed is the logged in user
142
  */
143
  function bp_blogs_setup_nav() {
144
  global $bp;
145
+
146
  /* Add 'Blogs' to the main navigation */
147
  bp_core_new_nav_item( array( 'name' => __( 'Blogs', 'buddypress' ), 'slug' => $bp->blogs->slug, 'position' => 30, 'screen_function' => 'bp_blogs_screen_my_blogs', 'default_subnav_slug' => 'my-blogs', 'item_css_id' => $bp->blogs->id ) );
148
+
149
  $blogs_link = $bp->loggedin_user->domain . $bp->blogs->slug . '/';
150
+
151
  /* Add the subnav items to the blogs nav item */
152
  bp_core_new_subnav_item( array( 'name' => __( 'My Blogs', 'buddypress' ), 'slug' => 'my-blogs', 'parent_url' => $blogs_link, 'parent_slug' => $bp->blogs->slug, 'screen_function' => 'bp_blogs_screen_my_blogs', 'position' => 10, 'item_css_id' => 'my-blogs-list' ) );
153
  bp_core_new_subnav_item( array( 'name' => __( 'Recent Posts', 'buddypress' ), 'slug' => 'recent-posts', 'parent_url' => $blogs_link, 'parent_slug' => $bp->blogs->slug, 'screen_function' => 'bp_blogs_screen_recent_posts', 'position' => 20 ) );
158
  if ( 'blogs' == $bp->current_component ) {
159
  if ( bp_is_home() ) {
160
  if ( function_exists('xprofile_setup_nav') ) {
161
+ $bp->bp_options_title = __('My Blogs', 'buddypress');
162
  }
163
  } else {
164
  /* If we are not viewing the logged in user, set up the current users avatar and name */
165
  $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) );
166
+ $bp->bp_options_title = $bp->displayed_user->fullname;
167
  }
168
  }
169
+
170
  do_action( 'bp_blogs_setup_nav' );
171
  }
172
  add_action( 'plugins_loaded', 'bp_blogs_setup_nav' );
177
 
178
  if ( $bp->current_component == $bp->blogs->slug && empty( $bp->current_action ) ) {
179
  $bp->is_directory = true;
180
+
181
  do_action( 'bp_blogs_directory_blogs_setup' );
182
  bp_core_load_template( apply_filters( 'bp_blogs_template_directory_blogs_setup', 'directories/blogs/index' ) );
183
  }
195
 
196
  function bp_blogs_screen_my_blogs() {
197
  do_action( 'bp_blogs_screen_my_blogs' );
198
+ bp_core_load_template( apply_filters( 'bp_blogs_template_my_blogs', 'blogs/my-blogs' ) );
199
  }
200
 
201
  function bp_blogs_screen_recent_posts() {
223
 
224
  function bp_blogs_register_activity_actions() {
225
  global $bp;
226
+
227
  if ( !function_exists( 'bp_activity_set_action' ) )
228
  return false;
229
 
237
 
238
  function bp_blogs_record_activity( $args = '' ) {
239
  global $bp;
240
+
241
  if ( !function_exists( 'bp_activity_add' ) )
242
  return false;
243
+
244
  /* Because blog, comment, and blog post code execution happens before anything else
245
  we may need to manually instantiate the activity component globals */
246
  if ( !$bp->activity && function_exists('bp_activity_setup_globals') )
247
  bp_activity_setup_globals();
248
+
249
  $defaults = array(
250
  'user_id' => $bp->loggedin_user->id,
251
  'content' => false,
259
  );
260
 
261
  $r = wp_parse_args( $args, $defaults );
262
+ extract( $r, EXTR_SKIP );
263
+
264
  return bp_activity_add( array( 'user_id' => $user_id, 'content' => $content, 'primary_link' => $primary_link, 'component_name' => $component_name, 'component_action' => $component_action, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) );
265
  }
266
 
267
  function bp_blogs_delete_activity( $args = true ) {
268
  if ( function_exists('bp_activity_delete_by_item_id') ) {
269
  extract($args);
270
+
271
+ bp_activity_delete_by_item_id( array(
272
+ 'item_id' => $item_id,
273
  'component_name' => $component_name,
274
+ 'component_action' => $component_action,
275
  'user_id' => $user_id,
276
  'secondary_item_id' => $secondary_item_id
277
  ) );
291
  global $wpdb;
292
 
293
  $blog_ids = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM {$wpdb->base_prefix}blogs WHERE public = 1 AND mature = 0 AND spam = 0 AND deleted = 0" ) );
294
+
295
  if ( $blog_ids ) {
296
  foreach( $blog_ids as $blog_id ) {
297
  $users = get_users_of_blog( $blog_id );
310
 
311
  function bp_blogs_record_blog( $blog_id, $user_id, $no_activity = true ) {
312
  global $bp;
313
+
314
  if ( !$user_id )
315
  $user_id = $bp->loggedin_user->id;
316
+
317
  $name = get_blog_option( $blog_id, 'blogname' );
318
  $description = get_blog_option( $blog_id, 'blogdescription' );
319
+
320
  $recorded_blog = new BP_Blogs_Blog;
321
  $recorded_blog->user_id = $user_id;
322
  $recorded_blog->blog_id = $blog_id;
323
 
324
  $recorded_blog_id = $recorded_blog->save();
325
+
326
  bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'name', $name );
327
  bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'description', $description );
328
  bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'last_activity', time() );
329
+
330
  /* Only record this activity if the blog is public */
331
  if ( (int)$_POST['blog_public'] || !$no_activity ) {
332
  /* Record this in activity streams */
333
  bp_blogs_record_activity( array(
334
  'user_id' => $recorded_blog->user_id,
335
+ 'content' => apply_filters( 'bp_blogs_activity_created_blog', sprintf( __( '%s created the blog %s', 'buddypress'), bp_core_get_userlink( $recorded_blog->user_id ), '<a href="' . get_blog_option( $recorded_blog->blog_id, 'siteurl' ) . '">' . attribute_escape( $name ) . '</a>' ), &$recorded_blog, $name, $description ),
336
  'primary_link' => apply_filters( 'bp_blogs_activity_created_blog_primary_link', get_blog_option( $recorded_blog->blog_id, 'siteurl' ), $recorded_blog->blog_id ),
337
  'component_action' => 'new_blog',
338
  'item_id' => $recorded_blog->blog_id
339
  ) );
340
  }
341
+
342
  do_action( 'bp_blogs_new_blog', &$recorded_blog, $is_private, $is_recorded );
343
  }
344
  add_action( 'wpmu_new_blog', 'bp_blogs_record_blog', 10, 2 );
345
 
346
  function bp_blogs_record_post( $post_id, $post, $user_id = false ) {
347
  global $bp, $wpdb;
348
+
349
  $post_id = (int)$post_id;
350
  $blog_id = (int)$wpdb->blogid;
351
+
352
  if ( !$user_id )
353
  $user_id = (int)$post->post_author;
354
+
355
  /* This is to stop infinate loops with Donncha's sitewide tags plugin */
356
  if ( (int)get_site_option( 'tags_blog_id' ) == (int)$blog_id )
357
  return false;
358
+
359
  /* Don't record this if it's not a post */
360
  if ( $post->post_type != 'post' )
361
  return false;
362
+
363
  if ( !$is_recorded = BP_Blogs_Post::is_recorded( $post_id, $blog_id, $user_id ) ) {
364
  if ( 'publish' == $post->post_status && '' == $post->post_password ) {
365
+
366
  $recorded_post = new BP_Blogs_Post;
367
  $recorded_post->user_id = $user_id;
368
  $recorded_post->blog_id = $blog_id;
369
  $recorded_post->post_id = $post_id;
370
  $recorded_post->date_created = strtotime( $post->post_date );
371
+
372
  $recorded_post_id = $recorded_post->save();
373
+
374
  bp_blogs_update_blogmeta( $recorded_post->blog_id, 'last_activity', time() );
375
 
376
  if ( (int)get_blog_option( $blog_id, 'blog_public' ) ) {
379
 
380
  $activity_content = sprintf( __( '%s wrote a new blog post: %s', 'buddypress' ), bp_core_get_userlink( (int)$post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' );
381
  $activity_content .= "<blockquote>" . bp_create_excerpt( $post->post_content ) . "</blockquote>";
382
+
383
  bp_blogs_record_activity( array(
384
  'user_id' => (int)$post->post_author,
385
+ 'content' => apply_filters( 'bp_blogs_activity_new_post', $activity_content, &$post, $post_permalink ),
386
  'primary_link' => apply_filters( 'bp_blogs_activity_new_post_primary_link', $post_permalink, $post_id ),
387
  'component_action' => 'new_blog_post',
388
  'item_id' => $recorded_post_id,
398
 
399
  /* Delete the recorded post if the status is not published or it is password protected */
400
  if ( 'publish' != $post->post_status || '' != $post->post_password ) {
401
+ return bp_blogs_remove_post( $post_id, $blog_id, $existing_post );
402
+
403
  /* If the post author has changed, delete the post and re-add it. */
404
  } else if ( (int)$existing_post->user_id != (int)$post->post_author ) {
405
  // Delete the existing recorded post
406
  bp_blogs_remove_post( $post_id, $blog_id, $existing_post );
407
+
408
  // Re-record the post with the new author.
409
+ bp_blogs_record_post( $post_id );
410
  }
411
 
412
  if ( (int)get_blog_option( $blog_id, 'blog_public' ) ) {
413
+ /* Now re-record the post in the activity streams */
414
  $post_permalink = bp_post_get_permalink( $post, $blog_id );
415
 
416
  $activity_content = sprintf( __( '%s wrote a new blog post: %s', 'buddypress' ), bp_core_get_userlink( (int)$post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' );
417
  $activity_content .= "<blockquote>" . bp_create_excerpt( $post->post_content ) . "</blockquote>";
418
+
419
  /* Record this in activity streams */
420
  bp_blogs_record_activity( array(
421
  'user_id' => (int)$post->post_author,
422
+ 'content' => apply_filters( 'bp_blogs_activity_new_post', $activity_content, &$post, $post_permalink ),
423
  'primary_link' => apply_filters( 'bp_blogs_activity_new_post_primary_link', $post_permalink, $post_id ),
424
  'component_action' => 'new_blog_post',
425
  'item_id' => $existing_post->id,
434
 
435
  function bp_blogs_record_comment( $comment_id, $is_approved ) {
436
  global $wpdb, $bp;
437
+
438
  if ( !$is_approved )
439
  return false;
440
+
441
  $comment = get_comment($comment_id);
442
  $comment->post = get_post( $comment->comment_post_ID );
443
+
444
  /* Get the user_id from the author email. */
445
  $user = get_user_by_email( $comment->comment_author_email );
446
  $user_id = (int)$user->ID;
447
+
448
  if ( !$user_id )
449
  return false;
450
 
451
+ /* If this is a password protected post, don't record the comment */
452
+ if ( !empty( $post->post_password ) )
453
+ return false;
454
+
455
  $recorded_comment = new BP_Blogs_Comment;
456
  $recorded_comment->user_id = $user_id;
457
  $recorded_comment->blog_id = $wpdb->blogid;
460
  $recorded_comment->date_created = strtotime( $comment->comment_date );
461
 
462
  $recorded_commment_id = $recorded_comment->save();
463
+
464
  bp_blogs_update_blogmeta( $recorded_comment->blog_id, 'last_activity', time() );
465
 
466
  if ( (int)get_blog_option( $recorded_comment->blog_id, 'blog_public' ) ) {
467
  /* Record in activity streams */
468
  $comment_link = bp_post_get_permalink( $comment->post, $recorded_comment->blog_id );
469
+ $activity_content = sprintf( __( '%s commented on the blog post %s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . $comment_link . '#comment-' . $comment->comment_ID . '">' . $comment->post->post_title . '</a>' );
470
  $activity_content .= '<blockquote>' . bp_create_excerpt( $comment->comment_content ) . '</blockquote>';
471
 
472
  /* Record this in activity streams */
473
  bp_blogs_record_activity( array(
474
  'user_id' => $recorded_comment->user_id,
475
+ 'content' => apply_filters( 'bp_blogs_activity_new_comment', $activity_content, &$comment, &$recorded_comment, $comment_link ),
476
  'primary_link' => apply_filters( 'bp_blogs_activity_new_comment_primary_link', $comment_link, &$comment, &$recorded_comment ),
477
  'component_action' => 'new_blog_comment',
478
  'item_id' => $comment_id,
487
 
488
  function bp_blogs_approve_comment( $comment_id, $comment_status ) {
489
  global $bp, $wpdb;
490
+
491
  if ( 'approve' != $comment_status )
492
  return false;
493
 
494
  $recorded_comment = bp_blogs_record_comment( $comment_id, true );
495
  $comment = get_comment($comment_id);
496
  $comment->post = get_post( $comment->comment_post_ID );
497
+
498
  bp_blogs_delete_activity( array( 'item_id' => $comment_id, 'secondary_item_id' => $recorded_comment->blog_id, 'component_name' => $bp->blogs->slug, 'component_action' => 'new_blog_comment' ) );
499
 
500
  if ( (int)get_blog_option( $recorded_comment->blog_id, 'blog_public' ) ) {
501
  /* Record in activity streams */
502
  $comment_link = bp_post_get_permalink( $comment->post, $recorded_comment->blog_id );
503
+ $activity_content = sprintf( __( '%s commented on the blog post %s', 'buddypress' ), bp_core_get_userlink( $recorded_comment->user_id ), '<a href="' . $comment_link . '#comment-' . $comment->comment_ID . '">' . $comment->post->post_title . '</a>' );
504
  $activity_content .= '<blockquote>' . bp_create_excerpt( $comment->comment_content ) . '</blockquote>';
505
 
506
  /* Record this in activity streams */
507
  bp_blogs_record_activity( array(
508
  'user_id' => $recorded_comment->user_id,
509
+ 'content' => apply_filters( 'bp_blogs_activity_new_comment', $activity_content, &$comment, &$recorded_comment, $comment_link ),
510
  'primary_link' => apply_filters( 'bp_blogs_activity_new_comment_primary_link', $comment_link, &$comment, &$recorded_comment ),
511
  'component_action' => 'new_blog_comment',
512
  'item_id' => $comment_id,
513
  'secondary_item_id' => $recorded_comment->blog_id,
514
+ 'recorded_time' => $recorded_comment->date_created
515
  ) );
516
  }
517
  }
519
 
520
  function bp_blogs_unapprove_comment( $comment_id, $comment_status ) {
521
  if ( 'spam' == $comment_status || 'hold' == $comment_status || 'delete' == $comment_status )
522
+ bp_blogs_remove_comment( $comment_id );
523
  }
524
  add_action( 'wp_set_comment_status', 'bp_blogs_unapprove_comment', 10, 2 );
525
 
541
  $blog_id = (int)$blog_id;
542
 
543
  BP_Blogs_Blog::delete_blog_for_all( $blog_id );
544
+
545
  // Delete activity stream item
546
  bp_blogs_delete_activity( array( 'item_id' => $blog_id, 'component_name' => $bp->blogs->slug, 'component_action' => 'new_blog' ) );
547
+
548
  do_action( 'bp_blogs_remove_blog', $blog_id );
549
  }
550
  add_action( 'delete_blog', 'bp_blogs_remove_blog' );
551
 
552
  function bp_blogs_remove_blog_for_user( $user_id, $blog_id ) {
553
  global $current_user;
554
+
555
  $blog_id = (int)$blog_id;
556
  $user_id = (int)$user_id;
557
 
568
  global $current_blog, $bp;
569
 
570
  $post_id = (int)$post_id;
571
+
572
  if ( !$blog_id )
573
  $blog_id = (int)$current_blog->blog_id;
574
+
575
  if ( !$existing_post )
576
  $existing_post = new BP_Blogs_Post( null, $blog_id, $post_id );
577
 
578
  // Delete post from the bp_blogs table
579
  BP_Blogs_Post::delete( $post_id, $blog_id );
580
+
581
  // Delete activity stream item
582
  bp_blogs_delete_activity( array( 'item_id' => $existing_post->id, 'component_name' => $bp->blogs->slug, 'component_action' => 'new_blog_post' ) );
583
 
589
  global $wpdb, $bp;
590
 
591
  $recorded_comment = new BP_Blogs_Comment( false, $wpdb->blogid, $comment_id );
592
+ BP_Blogs_Comment::delete( $comment_id, $wpdb->blogid );
593
 
594
  // Delete activity stream item
595
  bp_blogs_delete_activity( array( 'item_id' => $comment_id, 'secondary_item_id' => $recorded_comment->blog_id, 'component_name' => $bp->blogs->slug, 'component_action' => 'new_blog_comment' ) );
600
 
601
  function bp_blogs_remove_data_for_blog( $blog_id ) {
602
  global $bp;
603
+
604
  /* If this is regular blog, delete all data for that blog. */
605
  BP_Blogs_Blog::delete_blog_for_all( $blog_id );
606
+ BP_Blogs_Post::delete_posts_for_blog( $blog_id );
607
  BP_Blogs_Comment::delete_comments_for_blog( $blog_id );
608
 
609
  // Delete activity stream item
627
 
628
  function bp_blogs_get_latest_posts( $blog_id = null, $limit = 5 ) {
629
  global $bp;
630
+
631
  if ( !is_numeric( $limit ) )
632
  $limit = 5;
633
+
634
  return BP_Blogs_Post::get_latest_posts( $blog_id, $limit );
635
  }
636
 
648
 
649
  function bp_blogs_total_post_count( $blog_id ) {
650
  return BP_Blogs_Post::total_post_count( $blog_id );
651
+ }
652
 
653
  function bp_blogs_total_comment_count( $blog_id, $post_id = false ) {
654
  return BP_Blogs_Post::total_comment_count( $blog_id, $post_id );
655
+ }
656
 
657
  function bp_blogs_is_blog_hidden( $blog_id ) {
658
  return BP_Blogs_Blog::is_hidden( $blog_id );
660
 
661
  function bp_blogs_redirect_to_random_blog() {
662
  global $bp, $wpdb;
663
+
664
  if ( $bp->current_component == $bp->blogs->slug && isset( $_GET['random-blog'] ) ) {
665
  $blog = bp_blogs_get_random_blog();
666
 
679
 
680
  function bp_blogs_delete_blogmeta( $blog_id, $meta_key = false, $meta_value = false ) {
681
  global $wpdb, $bp;
682
+
683
  if ( !is_numeric( $blog_id ) )
684
  return false;
685
+
686
  $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
687
 
688
  if ( is_array($meta_value) || is_object($meta_value) )
689
  $meta_value = serialize($meta_value);
690
+
691
  $meta_value = trim( $meta_value );
692
 
693
  if ( !$meta_key ) {
694
+ $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d", $blog_id ) );
695
  } else if ( $meta_value ) {
696
  $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d AND meta_key = %s AND meta_value = %s", $blog_id, $meta_key, $meta_value ) );
697
  } else {
698
  $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d AND meta_key = %s", $blog_id, $meta_key ) );
699
  }
700
+
701
  // TODO need to look into using this.
702
  // wp_cache_delete($group_id, 'groups');
703
 
706
 
707
  function bp_blogs_get_blogmeta( $blog_id, $meta_key = '') {
708
  global $wpdb, $bp;
709
+
710
  $blog_id = (int) $blog_id;
711
 
712
  if ( !$blog_id )
714
 
715
  if ( !empty($meta_key) ) {
716
  $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
717
+
718
  // TODO need to look into using this.
719
  //$user = wp_cache_get($user_id, 'users');
720
+
721
  // Check the cached user object
722
  //if ( false !== $user && isset($user->$meta_key) )
723
  // $metas = array($user->$meta_key);
744
 
745
  function bp_blogs_update_blogmeta( $blog_id, $meta_key, $meta_value ) {
746
  global $wpdb, $bp;
747
+
748
  if ( !is_numeric( $blog_id ) )
749
  return false;
750
+
751
  $meta_key = preg_replace( '|[^a-z0-9_]|i', '', $meta_key );
752
 
753
  if ( is_string($meta_value) )
754
  $meta_value = stripslashes($wpdb->escape($meta_value));
755
+
756
  $meta_value = maybe_serialize($meta_value);
757
 
758
  if (empty($meta_value)) {
760
  }
761
 
762
  $cur = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d AND meta_key = %s", $blog_id, $meta_key ) );
763
+
764
  if ( !$cur ) {
765
  $wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->blogs->table_name_blogmeta} ( blog_id, meta_key, meta_value ) VALUES ( %d, %s, %s )", $blog_id, $meta_key, $meta_value ) );
766
  } else if ( $cur->meta_value != $meta_value ) {
778
  function bp_blogs_remove_data( $user_id ) {
779
  /* If this is regular blog, delete all data for that blog. */
780
  BP_Blogs_Blog::delete_blogs_for_user( $user_id );
781
+ BP_Blogs_Post::delete_posts_for_user( $user_id );
782
  BP_Blogs_Comment::delete_comments_for_user( $user_id );
783
 
784
  do_action( 'bp_blogs_remove_data', $user_id );
bp-blogs/admin-tabs/admin.css CHANGED
File without changes
bp-blogs/admin-tabs/bp-blogs-comments-tab.php CHANGED
File without changes
bp-blogs/admin-tabs/bp-blogs-posts-tab.php CHANGED
File without changes
bp-blogs/admin-tabs/bp-blogs-tab.php CHANGED
File without changes
bp-blogs/bp-blogs-classes.php CHANGED
@@ -64,7 +64,7 @@ Class BP_Blogs_Blog {
64
  function exists() {
65
  global $bp, $wpdb;
66
 
67
- return $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->blogs->table_name} WHERE user_id = %d AND blog_id = %d", $this->user_id, $this->blog_id ) );
68
  }
69
 
70
  /* Static Functions */
@@ -153,9 +153,9 @@ Class BP_Blogs_Blog {
153
 
154
  // If the user is logged in return the blog count including their hidden blogs.
155
  if ( !bp_is_home() )
156
- return $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(b.blog_id) FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.public = 1 AND wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND user_id = %d", $user_id) );
157
  else
158
- return $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(b.blog_id) FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND user_id = %d", $user_id) );
159
  }
160
 
161
  function get_all( $limit = null, $page = null ) {
@@ -166,7 +166,7 @@ Class BP_Blogs_Blog {
166
 
167
  if ( $limit && $page ) {
168
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
169
- $total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(bm.blog_id) FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE wb.public = 1 AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 AND bm.meta_key = 'last_activity' ORDER BY CONVERT(bm.meta_value, SIGNED) DESC" ) );
170
  }
171
 
172
  $paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT bm.blog_id FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE wb.public = 1 AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 AND bm.meta_key = 'last_activity' ORDER BY CONVERT(bm.meta_value, SIGNED) DESC {$pag_sql}" ) );
@@ -184,7 +184,7 @@ Class BP_Blogs_Blog {
184
 
185
  if ( $limit && $page ) {
186
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
187
- $total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(bm.blog_id) FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE bm.meta_key = 'name' AND bm.meta_value LIKE '$letter%%' AND wb.public = 1 AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY bm.meta_value ASC" ) );
188
  }
189
 
190
  $paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT bm.blog_id FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE bm.meta_key = 'name' AND bm.meta_value LIKE '$letter%%' AND wb.public = 1 AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY bm.meta_value ASC{$pag_sql}" ) );
@@ -202,7 +202,7 @@ Class BP_Blogs_Blog {
202
 
203
  if ( $limit && $page ) {
204
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
205
- $total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(bm.blog_id) FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE ( ( bm.meta_key = 'name' OR bm.meta_key = 'description' ) AND bm.meta_value LIKE '%%$filter%%' ) AND wb.public = 1 AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY meta_value ASC" ) );
206
  }
207
 
208
  $paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT bm.blog_id FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE ( ( bm.meta_key = 'name' OR bm.meta_key = 'description' ) AND bm.meta_value LIKE '%%$filter%%' ) AND wb.public = 1 AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY meta_value ASC{$pag_sql}" ) );
@@ -218,7 +218,7 @@ Class BP_Blogs_Blog {
218
 
219
  if ( $limit && $page ) {
220
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
221
- $total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(b.blog_id) FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.public = 1 AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY rand()" ) );
222
  }
223
 
224
  $paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b.blog_id FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.public = 1 AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY rand() {$pag_sql}" ) );
@@ -234,7 +234,7 @@ Class BP_Blogs_Blog {
234
 
235
  if ( $limit && $page ) {
236
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
237
- $total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(bm.blog_id) FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE wb.public = 1 AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 AND bm.meta_key = 'last_activity' ORDER BY CONVERT(bm.meta_value, SIGNED) DESC" ) );
238
  }
239
 
240
  $paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT bm.blog_id FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE wb.public = 1 AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 AND bm.meta_key = 'last_activity' ORDER BY CONVERT(bm.meta_value, SIGNED) DESC {$pag_sql}" ) );
@@ -250,7 +250,7 @@ Class BP_Blogs_Blog {
250
 
251
  if ( $limit && $page ) {
252
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
253
- $total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(wb.blog_id) FROM {$wpdb->base_prefix}blogs wb WHERE wb.public = 1 AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 ORDER BY wb.registered DESC" ) );
254
  }
255
 
256
  $paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT wb.blog_id FROM {$wpdb->base_prefix}blogs wb WHERE wb.public = 1 AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 ORDER BY wb.registered DESC {$pag_sql}" ) );
@@ -407,10 +407,10 @@ Class BP_Blogs_Post {
407
  // Show a logged in user their posts on private blogs, but not anyone else.
408
  if ( !bp_is_home() ) {
409
  $post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT p.post_id, p.blog_id FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.user_id = %d ORDER BY p.date_created DESC", $user_id) );
410
- $total_post_count = $wpdb->get_var( $wpdb->prepare( "SELECT count(p.post_id) FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.user_id = %d", $user_id) );
411
  } else {
412
  $post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT p.post_id, p.blog_id FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.user_id = %d ORDER BY p.date_created DESC", $user_id) );
413
- $total_post_count = $wpdb->get_var( $wpdb->prepare( "SELECT count(p.post_id) FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.user_id = %d", $user_id) );
414
  }
415
 
416
  for ( $i = 0; $i < count($post_ids); $i++ ) {
@@ -439,7 +439,7 @@ Class BP_Blogs_Post {
439
  if ( !$user_id )
440
  $user_id = $current_user->ID;
441
 
442
- return $wpdb->get_var( $wpdb->prepare( "SELECT count(post_id) FROM {$bp->blogs->table_name_blog_posts} WHERE user_id = %d", $user_id ) );
443
  }
444
 
445
  function is_recorded( $post_id, $blog_id, $user_id = null ) {
@@ -463,7 +463,7 @@ Class BP_Blogs_Post {
463
  if ( !$blog_id )
464
  return false;
465
 
466
- return $wpdb->get_var( $wpdb->prepare( "SELECT count(post_id) FROM {$bp->blogs->table_name_blog_posts} WHERE blog_id = %d", $blog_id ) );
467
  }
468
 
469
  function get_all() {
@@ -600,10 +600,10 @@ Class BP_Blogs_Comment {
600
  // Show the logged in user their comments on hidden blogs, but not to anyone else.
601
  if ( !bp_is_home() ) {
602
  $comment_ids = $wpdb->get_results( $wpdb->prepare( "SELECT c.comment_id, c.blog_id FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d ORDER BY c.date_created ASC", $user_id) );
603
- $total_comment_count = $wpdb->get_var( $wpdb->prepare( "SELECT count(c.comment_id) FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d", $user_id) );
604
  } else {
605
  $comment_ids = $wpdb->get_results( $wpdb->prepare( "SELECT c.comment_id, c.blog_id FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d ORDER BY c.date_created ASC", $user_id) );
606
- $total_comment_count = $wpdb->get_var( $wpdb->prepare( "SELECT count(c.comment_id) FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d", $user_id) );
607
  }
608
 
609
  for ( $i = 0; $i < count($comment_ids); $i++ ) {
@@ -632,7 +632,7 @@ Class BP_Blogs_Comment {
632
  if ( !$user_id )
633
  $user_id = $current_user->ID;
634
 
635
- return $wpdb->get_var( $wpdb->prepare( "SELECT count(comment_id) FROM {$bp->blogs->table_name_blog_comments} WHERE user_id = %d", $user_id ) );
636
  }
637
 
638
  function total_comment_count( $blog_id, $post_id ) {
@@ -644,7 +644,7 @@ Class BP_Blogs_Comment {
644
  if ( $post_id )
645
  $post_sql = $wpdb->prepare( " AND comment_post_id = %d", $post_id );
646
 
647
- return $wpdb->get_var( $wpdb->prepare( "SELECT count(comment_id) WHERE blog_id = %d{$post_sql}", $blog_id ) );
648
  }
649
 
650
 
64
  function exists() {
65
  global $bp, $wpdb;
66
 
67
+ return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->blogs->table_name} WHERE user_id = %d AND blog_id = %d", $this->user_id, $this->blog_id ) );
68
  }
69
 
70
  /* Static Functions */
153
 
154
  // If the user is logged in return the blog count including their hidden blogs.
155
  if ( !bp_is_home() )
156
+ return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.public = 1 AND wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND user_id = %d", $user_id) );
157
  else
158
+ return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND user_id = %d", $user_id) );
159
  }
160
 
161
  function get_all( $limit = null, $page = null ) {
166
 
167
  if ( $limit && $page ) {
168
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
169
+ $total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT bm.blog_id) FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE wb.public = 1 AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 AND bm.meta_key = 'last_activity' ORDER BY CONVERT(bm.meta_value, SIGNED) DESC" ) );
170
  }
171
 
172
  $paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT bm.blog_id FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE wb.public = 1 AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 AND bm.meta_key = 'last_activity' ORDER BY CONVERT(bm.meta_value, SIGNED) DESC {$pag_sql}" ) );
184
 
185
  if ( $limit && $page ) {
186
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
187
+ $total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT bm.blog_id) FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE bm.meta_key = 'name' AND bm.meta_value LIKE '$letter%%' AND wb.public = 1 AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY bm.meta_value ASC" ) );
188
  }
189
 
190
  $paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT bm.blog_id FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE bm.meta_key = 'name' AND bm.meta_value LIKE '$letter%%' AND wb.public = 1 AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY bm.meta_value ASC{$pag_sql}" ) );
202
 
203
  if ( $limit && $page ) {
204
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
205
+ $total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT bm.blog_id) FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE ( ( bm.meta_key = 'name' OR bm.meta_key = 'description' ) AND bm.meta_value LIKE '%%$filter%%' ) AND wb.public = 1 AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY meta_value ASC" ) );
206
  }
207
 
208
  $paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT bm.blog_id FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE ( ( bm.meta_key = 'name' OR bm.meta_key = 'description' ) AND bm.meta_value LIKE '%%$filter%%' ) AND wb.public = 1 AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY meta_value ASC{$pag_sql}" ) );
218
 
219
  if ( $limit && $page ) {
220
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
221
+ $total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.public = 1 AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY rand()" ) );
222
  }
223
 
224
  $paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b.blog_id FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.public = 1 AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY rand() {$pag_sql}" ) );
234
 
235
  if ( $limit && $page ) {
236
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
237
+ $total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT bm.blog_id) FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE wb.public = 1 AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 AND bm.meta_key = 'last_activity' ORDER BY CONVERT(bm.meta_value, SIGNED) DESC" ) );
238
  }
239
 
240
  $paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT bm.blog_id FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE wb.public = 1 AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 AND bm.meta_key = 'last_activity' ORDER BY CONVERT(bm.meta_value, SIGNED) DESC {$pag_sql}" ) );
250
 
251
  if ( $limit && $page ) {
252
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
253
+ $total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT wb.blog_id) FROM {$wpdb->base_prefix}blogs wb WHERE wb.public = 1 AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 ORDER BY wb.registered DESC" ) );
254
  }
255
 
256
  $paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT wb.blog_id FROM {$wpdb->base_prefix}blogs wb WHERE wb.public = 1 AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 ORDER BY wb.registered DESC {$pag_sql}" ) );
407
  // Show a logged in user their posts on private blogs, but not anyone else.
408
  if ( !bp_is_home() ) {
409
  $post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT p.post_id, p.blog_id FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.user_id = %d ORDER BY p.date_created DESC", $user_id) );
410
+ $total_post_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(p.post_id) FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.user_id = %d", $user_id) );
411
  } else {
412
  $post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT p.post_id, p.blog_id FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.user_id = %d ORDER BY p.date_created DESC", $user_id) );
413
+ $total_post_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(p.post_id) FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.user_id = %d", $user_id) );
414
  }
415
 
416
  for ( $i = 0; $i < count($post_ids); $i++ ) {
439
  if ( !$user_id )
440
  $user_id = $current_user->ID;
441
 
442
+ return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(post_id) FROM {$bp->blogs->table_name_blog_posts} WHERE user_id = %d", $user_id ) );
443
  }
444
 
445
  function is_recorded( $post_id, $blog_id, $user_id = null ) {
463
  if ( !$blog_id )
464
  return false;
465
 
466
+ return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(post_id) FROM {$bp->blogs->table_name_blog_posts} WHERE blog_id = %d", $blog_id ) );
467
  }
468
 
469
  function get_all() {
600
  // Show the logged in user their comments on hidden blogs, but not to anyone else.
601
  if ( !bp_is_home() ) {
602
  $comment_ids = $wpdb->get_results( $wpdb->prepare( "SELECT c.comment_id, c.blog_id FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d ORDER BY c.date_created ASC", $user_id) );
603
+ $total_comment_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(c.comment_id) FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d", $user_id) );
604
  } else {
605
  $comment_ids = $wpdb->get_results( $wpdb->prepare( "SELECT c.comment_id, c.blog_id FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d ORDER BY c.date_created ASC", $user_id) );
606
+ $total_comment_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(c.comment_id) FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d", $user_id) );
607
  }
608
 
609
  for ( $i = 0; $i < count($comment_ids); $i++ ) {
632
  if ( !$user_id )
633
  $user_id = $current_user->ID;
634
 
635
+ return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(comment_id) FROM {$bp->blogs->table_name_blog_comments} WHERE user_id = %d", $user_id ) );
636
  }
637
 
638
  function total_comment_count( $blog_id, $post_id ) {
644
  if ( $post_id )
645
  $post_sql = $wpdb->prepare( " AND comment_post_id = %d", $post_id );
646
 
647
+ return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(comment_id) WHERE blog_id = %d{$post_sql}", $blog_id ) );
648
  }
649
 
650
 
bp-blogs/bp-blogs-templatetags.php CHANGED
@@ -1003,7 +1003,7 @@ function bp_comment_content() {
1003
  $content = $comments_template->comment->comment_content;
1004
  $content = apply_filters('the_content', $content);
1005
  $content = str_replace(']]>', ']]&gt;', $content);
1006
- echo apply_filters( 'bp_get_comment_content', $content );
1007
  }
1008
 
1009
  function bp_comment_date( $date_format = null, $deprecated = true ) {
1003
  $content = $comments_template->comment->comment_content;
1004
  $content = apply_filters('the_content', $content);
1005
  $content = str_replace(']]>', ']]&gt;', $content);
1006
+ return apply_filters( 'bp_get_comment_content', $content );
1007
  }
1008
 
1009
  function bp_comment_date( $date_format = null, $deprecated = true ) {
bp-blogs/bp-blogs-widgets.php CHANGED
File without changes
bp-blogs/deprecated/bp-blogs-deprecated.php CHANGED
File without changes
bp-blogs/deprecated/css/structure.css CHANGED
File without changes
bp-blogs/deprecated/js/directory-blogs.js CHANGED
File without changes
bp-core.php CHANGED
@@ -3,10 +3,10 @@
3
  /* Define the current version number for checking if DB tables are up to date. */
4
  define( 'BP_CORE_DB_VERSION', '1800' );
5
 
6
- /***
7
- * Define the path and url of the BuddyPress plugins directory.
8
- * It is important to use plugins_url() core function to obtain
9
- * the correct scheme used (http or https).
10
  */
11
  define( 'BP_PLUGIN_DIR', WP_PLUGIN_DIR . '/buddypress' );
12
  define( 'BP_PLUGIN_URL', plugins_url( $path = '/buddypress' ) );
@@ -65,7 +65,7 @@ if ( !defined( 'BP_SEARCH_SLUG' ) )
65
  /* Define the slug for the search page */
66
  if ( !defined( 'BP_HOME_BLOG_SLUG' ) )
67
  define( 'BP_HOME_BLOG_SLUG', 'blog' );
68
-
69
  /* Register BuddyPress themes contained within the theme folder */
70
  if ( function_exists( 'register_theme_folder' ) )
71
  register_theme_folder( 'buddypress/bp-themes' );
@@ -93,33 +93,33 @@ function bp_core_setup_globals() {
93
  global $current_user, $current_component, $current_action, $current_blog;
94
  global $displayed_user_id;
95
  global $action_variables;
96
-
97
  $current_user = wp_get_current_user();
98
 
99
- /* The domain for the root of the site where the main blog resides */
100
  $bp->root_domain = bp_core_get_root_domain();
101
-
102
  /* The user ID of the user who is currently logged in. */
103
  $bp->loggedin_user->id = $current_user->ID;
104
 
105
  /* The domain for the user currently logged in. eg: http://domain.com/members/andy */
106
  $bp->loggedin_user->domain = bp_core_get_user_domain($current_user->ID);
107
-
108
  /* The user id of the user currently being viewed, set in /bp-core/bp-core-catchuri.php */
109
  $bp->displayed_user->id = $displayed_user_id;
110
-
111
  /* The domain for the user currently being displayed */
112
  $bp->displayed_user->domain = bp_core_get_user_domain($displayed_user_id);
113
-
114
  /* The component being used eg: http://domain.com/members/andy/ [profile] */
115
  $bp->current_component = $current_component; // type: string
116
-
117
  /* The current action for the component eg: http://domain.com/members/andy/profile/ [edit] */
118
  $bp->current_action = $current_action; // type: string
119
-
120
  /* The action variables for the current action eg: http://domain.com/members/andy/profile/edit/ [group] / [6] */
121
  $bp->action_variables = $action_variables; // type: array
122
-
123
  /* Only used where a component has a sub item, e.g. groups: http://domain.com/members/andy/groups/ [my-group] / home - manipulated in the actual component not in catch uri code.*/
124
  $bp->current_item = ''; // type: string
125
 
@@ -134,24 +134,24 @@ function bp_core_setup_globals() {
134
 
135
  /* Sets up the array container for the component navigation rendered by bp_get_nav() */
136
  $bp->bp_nav = array();
137
-
138
  /* Sets up the array container for the component options navigation rendered by bp_get_options_nav() */
139
  $bp->bp_options_nav = array();
140
-
141
  /* Sets up container used for the title of the current component option and rendered by bp_get_options_title() */
142
  $bp->bp_options_title = '';
143
-
144
  /* Sets up container used for the avatar of the current component being viewed. Rendered by bp_get_options_avatar() */
145
  $bp->bp_options_avatar = '';
146
-
147
  /* Contains an array of all the active components. The key is the slug, value the internal ID of the component */
148
  $bp->active_components = array();
149
-
150
  /* Fetches the default Gravatar image to use if the user/group/blog has no avatar or gravatar */
151
  $bp->grav_default->user = apply_filters( 'bp_user_gravatar_default', get_site_option( 'user-avatar-default' ) );
152
  $bp->grav_default->group = apply_filters( 'bp_group_gravatar_default', 'identicon' );
153
  $bp->grav_default->blog = apply_filters( 'bp_blog_gravatar_default', 'identicon' );
154
-
155
  /* Fetch the full name for the logged in and current user */
156
  $bp->loggedin_user->fullname = bp_core_get_user_displayname( $bp->loggedin_user->id );
157
  $bp->displayed_user->fullname = bp_core_get_user_displayname( $bp->displayed_user->id );
@@ -161,7 +161,7 @@ function bp_core_setup_globals() {
161
  generic variable so it can be used in other components. It can also be modified, so when viewing a group
162
  'is_item_admin' would be 1 if they are a group admin, 0 if they are not. */
163
  $bp->is_item_admin = bp_is_home();
164
-
165
  /* Used to determine if the logged in user is a moderator for the current content. */
166
  $bp->is_item_mod = false;
167
 
@@ -169,7 +169,7 @@ function bp_core_setup_globals() {
169
 
170
  if ( !$bp->current_component )
171
  $bp->current_component = $bp->default_component;
172
-
173
  do_action( 'bp_core_setup_globals' );
174
  }
175
  add_action( 'plugins_loaded', 'bp_core_setup_globals', 5 );
@@ -182,7 +182,7 @@ add_action( '_admin_menu', 'bp_core_setup_globals', 2 ); // must be _admin_menu
182
  * Adds the core URIs that should run in the root of the installation.
183
  *
184
  * For example: http://example.org/search or http://example.org/members
185
- *
186
  * @package BuddyPress Core
187
  * @uses bp_core_add_root_component() Adds a slug to the root components global variable.
188
  */
@@ -201,7 +201,7 @@ add_action( 'plugins_loaded', 'bp_core_setup_root_uris', 2 );
201
  * bp_core_install()
202
  *
203
  * Installs the core DB tables for BuddyPress.
204
- *
205
  * @package BuddyPress Core
206
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
207
  * @global $wpdb WordPress DB access object.
@@ -210,10 +210,10 @@ add_action( 'plugins_loaded', 'bp_core_setup_root_uris', 2 );
210
  */
211
  function bp_core_install() {
212
  global $wpdb, $bp;
213
-
214
  if ( !empty($wpdb->charset) )
215
  $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
216
-
217
  $sql[] = "CREATE TABLE {$bp->core->table_name_notifications} (
218
  id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
219
  user_id bigint(20) NOT NULL,
@@ -234,10 +234,10 @@ function bp_core_install() {
234
 
235
  require_once( ABSPATH . 'wp-admin/upgrade-functions.php' );
236
  dbDelta( $sql );
237
-
238
  /* Add names of root components to the banned blog list to avoid conflicts */
239
  bp_core_add_illegal_names();
240
-
241
  update_site_option( 'bp-core-db-version', BP_CORE_DB_VERSION );
242
  }
243
 
@@ -245,7 +245,7 @@ function bp_core_install() {
245
  * bp_core_check_installed()
246
  *
247
  * Checks to make sure the database tables are set up for the core component.
248
- *
249
  * @package BuddyPress Core
250
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
251
  * @global $wpdb WordPress DB access object.
@@ -259,7 +259,7 @@ function bp_core_check_installed() {
259
 
260
  if ( !is_site_admin() )
261
  return false;
262
-
263
  require ( BP_PLUGIN_DIR . '/bp-core/bp-core-admin.php' );
264
 
265
  /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
@@ -272,7 +272,7 @@ add_action( 'admin_menu', 'bp_core_check_installed' );
272
  * bp_core_add_admin_menu()
273
  *
274
  * Adds the "BuddyPress" admin submenu item to the Site Admin tab.
275
- *
276
  * @package BuddyPress Core
277
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
278
  * @global $wpdb WordPress DB access object.
@@ -280,11 +280,9 @@ add_action( 'admin_menu', 'bp_core_check_installed' );
280
  * @uses add_submenu_page() WP function to add a submenu item
281
  */
282
  function bp_core_add_admin_menu() {
283
- global $wpdb, $bp, $menu;
284
-
285
  if ( !is_site_admin() )
286
  return false;
287
-
288
  /* Add the administration tab under the "Site Admin" tab for site administrators */
289
  bp_core_add_admin_menu_page( array(
290
  'menu_title' => __( 'BuddyPress', 'buddypress' ),
@@ -293,7 +291,7 @@ function bp_core_add_admin_menu() {
293
  'function' => 'bp_core_admin_settings',
294
  'position' => 2
295
  ) );
296
-
297
  add_submenu_page( 'bp-general-settings', __( 'General Settings', 'buddypress'), __( 'General Settings', 'buddypress' ), 'manage_options', 'bp-general-settings', 'bp_core_admin_settings' );
298
  add_submenu_page( 'bp-general-settings', __( 'Component Setup', 'buddypress'), __( 'Component Setup', 'buddypress' ), 'manage_options', 'bp-component-setup', 'bp_core_admin_component_setup' );
299
  }
@@ -304,7 +302,7 @@ add_action( 'admin_menu', 'bp_core_add_admin_menu' );
304
  *
305
  * Checks to see if a component's URL should be in the root, not under a member page:
306
  * eg: http://domain.com/groups/the-group NOT http://domain.com/members/andy/groups/the-group
307
- *
308
  * @package BuddyPress Core
309
  * @return true if root component, else false.
310
  */
@@ -318,7 +316,7 @@ function bp_core_is_root_component( $component_name ) {
318
  * bp_core_setup_nav()
319
  *
320
  * Sets up the profile navigation item if the Xprofile component is not installed.
321
- *
322
  * @package BuddyPress Core
323
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
324
  * @uses bp_core_new_nav_item() Adds a navigation item to the top level buddypress navigation
@@ -328,8 +326,8 @@ function bp_core_is_root_component( $component_name ) {
328
  */
329
  function bp_core_setup_nav() {
330
  global $bp;
331
-
332
- /***
333
  * If the extended profiles component is disabled, we need to revert to using the
334
  * built in WordPress profile information
335
  */
@@ -339,7 +337,7 @@ function bp_core_setup_nav() {
339
  $bp->active_components[$bp->core->profile->slug] = $bp->core->profile->slug;
340
 
341
  /* Add 'Profile' to the main navigation */
342
- bp_core_new_nav_item( array(
343
  'name' => __('Profile', 'buddypress'),
344
  'slug' => $bp->core->profile->slug,
345
  'position' => 20,
@@ -348,7 +346,7 @@ function bp_core_setup_nav() {
348
  ) );
349
 
350
  $profile_link = $bp->loggedin_user->domain . '/profile/';
351
-
352
  /* Add the subnav items to the profile */
353
  bp_core_new_subnav_item( array(
354
  'name' => __( 'Public', 'buddypress' ),
@@ -357,17 +355,17 @@ function bp_core_setup_nav() {
357
  'parent_slug' => $bp->core->profile->slug,
358
  'screen_function' => 'bp_core_catch_profile_uri'
359
  ) );
360
-
361
 
362
  if ( 'profile' == $bp->current_component ) {
363
  if ( bp_is_home() ) {
364
  $bp->bp_options_title = __('My Profile', 'buddypress');
365
  } else {
366
  $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) );
367
- $bp->bp_options_title = $bp->displayed_user->fullname;
368
  }
369
  }
370
- }
371
  }
372
  add_action( 'plugins_loaded', 'bp_core_setup_nav' );
373
  add_action( 'admin_menu', 'bp_core_setup_nav' );
@@ -396,7 +394,7 @@ add_action( 'admin_menu', 'bp_core_setup_nav' );
396
  *
397
  * Listens to the $bp component and action variables to determine if the user is viewing the members
398
  * directory page. If they are, it will set up the directory and load the members directory template.
399
- *
400
  * @package BuddyPress Core
401
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
402
  * @uses wp_enqueue_script() Loads a JS script into the header of the page.
@@ -420,23 +418,23 @@ add_action( 'wp', 'bp_core_action_directory_members', 2 );
420
  * When a site admin selects "Mark as Spammer/Not Spammer" from the admin menu
421
  * this action will fire and mark or unmark the user and their blogs as spam.
422
  * Must be a site admin for this function to run.
423
- *
424
  * @package BuddyPress Core
425
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
426
  */
427
  function bp_core_action_set_spammer_status() {
428
  global $bp;
429
-
430
  if ( !is_site_admin() || bp_is_home() || !$bp->displayed_user->id )
431
  return false;
432
-
433
  if ( 'admin' == $bp->current_component && ( 'mark-spammer' == $bp->current_action || 'unmark-spammer' == $bp->current_action ) ) {
434
  /* Check the nonce */
435
  check_admin_referer( 'mark-unmark-spammer' );
436
 
437
  /* Get the functions file */
438
  require( ABSPATH . 'wp-admin/includes/mu.php' );
439
-
440
  if ( 'mark-spammer' == $bp->current_action )
441
  $is_spam = 1;
442
  else
@@ -444,29 +442,29 @@ function bp_core_action_set_spammer_status() {
444
 
445
  /* Get the blogs for the user */
446
  $blogs = get_blogs_of_user( $bp->displayed_user->id, true );
447
-
448
  foreach ( (array) $blogs as $key => $details ) {
449
  /* Do not mark the main or current root blog as spam */
450
- if ( 1 == $details->userblog_id || BP_ROOT_BLOG == $details->userblog_id )
451
- continue;
452
-
453
  /* Update the blog status */
454
  update_blog_status( $details->userblog_id, 'spam', $is_spam );
455
-
456
  /* Fire the standard WPMU hook */
457
  do_action( 'make_spam_blog', $details->userblog_id );
458
  }
459
-
460
  /* Finally, mark this user as a spammer */
461
  update_user_status( $bp->displayed_user->id, 'spam', $is_spam, 1 );
462
-
463
  if ( $is_spam )
464
  bp_core_add_message( __( 'User marked as spammer. Spam users are visible only to site admins.', 'buddypress' ) );
465
  else
466
  bp_core_add_message( __( 'User removed as spammer.', 'buddypress' ) );
467
-
468
  do_action( 'bp_core_action_set_spammer_status' );
469
-
470
  bp_core_redirect( wp_get_referer() );
471
  }
472
  }
@@ -476,31 +474,31 @@ add_action( 'wp', 'bp_core_action_set_spammer_status', 3 );
476
  * bp_core_action_delete_user()
477
  *
478
  * Allows a site admin to delete a user from the adminbar menu.
479
- *
480
  * @package BuddyPress Core
481
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
482
  */
483
  function bp_core_action_delete_user() {
484
  global $bp;
485
-
486
  if ( !is_site_admin() || bp_is_home() || !$bp->displayed_user->id )
487
  return false;
488
-
489
  if ( 'admin' == $bp->current_component && 'delete-user' == $bp->current_action ) {
490
  /* Check the nonce */
491
  check_admin_referer( 'delete-user' );
492
 
493
  $errors = false;
494
-
495
  if ( bp_core_delete_account( $bp->displayed_user->id ) ) {
496
  bp_core_add_message( sprintf( __( '%s has been deleted from the system.', 'buddypress' ), $bp->displayed_user->fullname ) );
497
  } else {
498
  bp_core_add_message( sprintf( __( 'There was an error deleting %s from the system. Please try again.', 'buddypress' ), $bp->displayed_user->fullname ), 'error' );
499
  $errors = true;
500
  }
501
-
502
  do_action( 'bp_core_action_set_spammer_status', $errors );
503
-
504
  if ( $errors )
505
  bp_core_redirect( $bp->displayed_user->domain );
506
  else
@@ -524,7 +522,7 @@ add_action( 'wp', 'bp_core_action_delete_user', 3 );
524
  *
525
  * Returns the domain for the passed user:
526
  * e.g. http://domain.com/members/andy/
527
- *
528
  * @package BuddyPress Core
529
  * @global $current_user WordPress global variable containing current logged in user information
530
  * @param user_id The ID of the user.
@@ -532,21 +530,21 @@ add_action( 'wp', 'bp_core_action_delete_user', 3 );
532
  */
533
  function bp_core_get_user_domain( $user_id ) {
534
  global $bp;
535
-
536
  if ( !$user_id ) return;
537
-
538
  $ud = get_userdata($user_id);
539
-
540
  if ( defined( 'BP_ENABLE_USERNAME_COMPATIBILITY_MODE' ) )
541
  $username = $ud->user_login;
542
  else
543
  $username = $ud->user_nicename;
544
-
545
  /* If we are using a members slug, include it. */
546
  if ( !defined( 'BP_ENABLE_ROOT_PROFILES' ) )
547
  return apply_filters( 'bp_core_get_user_domain', $bp->root_domain . '/' . BP_MEMBERS_SLUG . '/' . $username . '/' );
548
  else
549
- return apply_filters( 'bp_core_get_user_domain', $bp->root_domain . '/' . $username . '/' );
550
  }
551
 
552
  /**
@@ -554,14 +552,14 @@ function bp_core_get_user_domain( $user_id ) {
554
  *
555
  * Returns the domain for the root blog.
556
  * eg: http://domain.com/ OR https://domain.com
557
- *
558
  * @package BuddyPress Core
559
  * @uses get_blog_option() WordPress function to fetch blog meta.
560
  * @return $domain The domain URL for the blog.
561
  */
562
  function bp_core_get_root_domain() {
563
  global $current_blog;
564
-
565
  if ( defined( 'BP_ENABLE_MULTIBLOG' ) )
566
  $domain = get_blog_option( $current_blog->blog_id, 'siteurl' );
567
  else
@@ -575,7 +573,7 @@ function bp_core_get_root_domain() {
575
  *
576
  * Returns the user id for the user that is currently being displayed.
577
  * eg: http://andy.domain.com/ or http://domain.com/andy/
578
- *
579
  * @package BuddyPress Core
580
  * @global $current_blog WordPress global containing information and settings for the current blog being viewed.
581
  * @uses bp_core_get_userid_from_user_login() Returns the user id for the username passed
@@ -589,7 +587,7 @@ function bp_core_get_displayed_userid( $user_login ) {
589
  * bp_core_new_nav_item()
590
  *
591
  * Adds a navigation item to the main navigation array used in BuddyPress themes.
592
- *
593
  * @package BuddyPress Core
594
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
595
  */
@@ -613,11 +611,11 @@ function bp_core_new_nav_item( $args = '' ) {
613
  /* If we don't have the required info we need, don't create this subnav item */
614
  if ( empty($name) || empty($slug) )
615
  return false;
616
-
617
  /* If this is for site admins only and the user is not one, don't create the subnav item */
618
  if ( $site_admin_only && !is_site_admin() )
619
  return false;
620
-
621
  if ( empty( $item_css_id ) )
622
  $item_css_id = $slug;
623
 
@@ -636,7 +634,7 @@ function bp_core_new_nav_item( $args = '' ) {
636
  */
637
  if ( !$show_for_displayed_user && !bp_is_home() )
638
  return false;
639
-
640
  /***
641
  * If we are not viewing a user, and this is a root component, don't attach the
642
  * default subnav function so we can display a directory or something else.
@@ -659,13 +657,13 @@ function bp_core_new_nav_item( $args = '' ) {
659
  * bp_core_new_nav_default()
660
  *
661
  * Modify the default subnav item to load when a top level nav item is clicked.
662
- *
663
  * @package BuddyPress Core
664
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
665
  */
666
  function bp_core_new_nav_default( $args = '' ) {
667
  global $bp;
668
-
669
  $defaults = array(
670
  'parent_slug' => false, // Slug of the parent
671
  'screen_function' => false, // The name of the function to run when clicked
@@ -691,16 +689,16 @@ function bp_core_new_nav_default( $args = '' ) {
691
  *
692
  * We can only sort nav items by their position integer at a later point in time, once all
693
  * plugins have registered their navigation items.
694
- *
695
  * @package BuddyPress Core
696
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
697
  */
698
  function bp_core_sort_nav_items() {
699
  global $bp;
700
-
701
  if ( empty( $bp->bp_nav ) || !is_array( $bp->bp_nav ) )
702
  return false;
703
-
704
  foreach ( $bp->bp_nav as $slug => $nav_item ) {
705
  if ( empty( $temp[$nav_item['position']]) )
706
  $temp[$nav_item['position']] = $nav_item;
@@ -709,13 +707,13 @@ function bp_core_sort_nav_items() {
709
  do {
710
  $nav_item['position']++;
711
  } while ( !empty( $temp[$nav_item['position']] ) );
712
-
713
  $temp[$nav_item['position']] = $nav_item;
714
  }
715
  }
716
-
717
  ksort( $temp );
718
- $bp->bp_nav = &$temp;
719
  }
720
  add_action( 'wp_head', 'bp_core_sort_nav_items' );
721
 
@@ -723,7 +721,7 @@ add_action( 'wp_head', 'bp_core_sort_nav_items' );
723
  * bp_core_remove_nav_item()
724
  *
725
  * Removes a navigation item from the main navigation array.
726
- *
727
  * @package BuddyPress Core
728
  * @param $slug The slug of the sub navigation item.
729
  */
@@ -737,7 +735,7 @@ function bp_core_remove_nav_item( $slug ) {
737
  * bp_core_new_subnav_item()
738
  *
739
  * Adds a navigation item to the sub navigation array used in BuddyPress themes.
740
- *
741
  * @package BuddyPress Core
742
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
743
  */
@@ -755,21 +753,21 @@ function bp_core_new_subnav_item( $args = '' ) {
755
  'position' => 90, // Index of where this nav item should be positioned
756
  'screen_function' => false // The name of the function to run when clicked
757
  );
758
-
759
  $r = wp_parse_args( $args, $defaults );
760
  extract( $r, EXTR_SKIP );
761
 
762
  /* If we don't have the required info we need, don't create this subnav item */
763
  if ( empty($name) || empty($slug) || empty($parent_slug) || empty($parent_url) || empty($screen_function) )
764
  return false;
765
-
766
  /* If this is for site admins only and the user is not one, don't create the subnav item */
767
  if ( $site_admin_only && !is_site_admin() )
768
  return false;
769
-
770
  if ( empty( $item_css_id ) )
771
  $item_css_id = $slug;
772
-
773
  $bp->bp_options_nav[$parent_slug][$slug] = array(
774
  'name' => $name,
775
  'link' => $parent_url . $slug . '/',
@@ -778,7 +776,7 @@ function bp_core_new_subnav_item( $args = '' ) {
778
  'position' => $position,
779
  'user_has_access' => $user_has_access
780
  );
781
-
782
  if ( ( $bp->current_action == $slug && $bp->current_component == $parent_slug ) && $user_has_access ) {
783
  if ( !is_object( $screen_function[0] ) )
784
  add_action( 'wp', $screen_function, 3 );
@@ -792,11 +790,11 @@ function bp_core_sort_subnav_items() {
792
 
793
  if ( empty( $bp->bp_options_nav ) || !is_array( $bp->bp_options_nav ) )
794
  return false;
795
-
796
  foreach ( $bp->bp_options_nav as $parent_slug => $subnav_items ) {
797
  if ( !is_array( $subnav_items ) )
798
  continue;
799
-
800
  foreach ( $subnav_items as $subnav_item ) {
801
  if ( empty( $temp[$subnav_item['position']]) )
802
  $temp[$subnav_item['position']] = $subnav_item;
@@ -805,7 +803,7 @@ function bp_core_sort_subnav_items() {
805
  do {
806
  $subnav_item['position']++;
807
  } while ( !empty( $temp[$subnav_item['position']] ) );
808
-
809
  $temp[$subnav_item['position']] = $subnav_item;
810
  }
811
  }
@@ -820,14 +818,14 @@ add_action( 'wp_head', 'bp_core_sort_subnav_items' );
820
  * bp_core_remove_subnav_item()
821
  *
822
  * Removes a navigation item from the sub navigation array used in BuddyPress themes.
823
- *
824
  * @package BuddyPress Core
825
  * @param $parent_id The id of the parent navigation item.
826
  * @param $slug The slug of the sub navigation item.
827
  */
828
  function bp_core_remove_subnav_item( $parent_id, $slug ) {
829
  global $bp;
830
-
831
  unset( $bp->bp_options_nav[$parent_id][$slug] );
832
  }
833
 
@@ -835,7 +833,7 @@ function bp_core_remove_subnav_item( $parent_id, $slug ) {
835
  * bp_core_reset_subnav_items()
836
  *
837
  * Clear the subnav items for a specific nav item.
838
- *
839
  * @package BuddyPress Core
840
  * @param $parent_id The id of the parent navigation item.
841
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
@@ -855,7 +853,7 @@ function bp_core_reset_subnav_items($parent_slug) {
855
  * bp_core_load_template( 'profile/edit-profile' );
856
  * Loads:
857
  * wp-content/member-themes/[activated_theme]/profile/edit-profile.php
858
- *
859
  * @package BuddyPress Core
860
  * @param $username str Username to check.
861
  * @global $wpdb WordPress DB access object.
@@ -882,7 +880,7 @@ function bp_core_load_template( $template, $skip_blog_check = false ) {
882
  * Friends: http://domain.com/members/andy/friends
883
  * http://community.domain.com/members/andy/friends
884
  * http://domain.com/wpmu/members/andy/friends
885
- *
886
  * @package BuddyPress Core
887
  * @param $slug str The slug of the component
888
  * @global $bp BuddyPress global settings
@@ -897,7 +895,7 @@ function bp_core_add_root_component( $slug ) {
897
  * bp_core_get_random_member()
898
  *
899
  * Returns the user_id for a user based on their username.
900
- *
901
  * @package BuddyPress Core
902
  * @param $username str Username to check.
903
  * @global $wpdb WordPress DB access object.
@@ -906,13 +904,13 @@ function bp_core_add_root_component( $slug ) {
906
  */
907
  function bp_core_get_random_member() {
908
  global $bp, $wpdb;
909
-
910
  if ( isset( $_GET['random-member'] ) ) {
911
  $user = BP_Core_User::get_random_users(1);
912
-
913
  $ud = get_userdata( $user['users'][0]->user_id );
914
-
915
- bp_core_redirect( bp_core_get_user_domain( $user['users'][0]->user_id ) );
916
  }
917
  }
918
  add_action( 'wp', 'bp_core_get_random_member' );
@@ -921,7 +919,7 @@ add_action( 'wp', 'bp_core_get_random_member' );
921
  * bp_core_get_userid()
922
  *
923
  * Returns the user_id for a user based on their username.
924
- *
925
  * @package BuddyPress Core
926
  * @param $username str Username to check.
927
  * @global $wpdb WordPress DB access object.
@@ -930,16 +928,16 @@ add_action( 'wp', 'bp_core_get_random_member' );
930
  */
931
  function bp_core_get_userid( $username ) {
932
  global $wpdb;
933
-
934
  if ( !empty( $username ) )
935
- return apply_filters( 'bp_core_get_userid', $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . CUSTOM_USER_TABLE . " WHERE user_login = %s", $username ) ) );
936
  }
937
 
938
  /**
939
  * bp_core_get_username()
940
  *
941
  * Returns the username for a user based on their user id.
942
- *
943
  * @package BuddyPress Core
944
  * @param $uid int User ID to check.
945
  * @global $userdata WordPress user data for the current logged in user.
@@ -949,14 +947,14 @@ function bp_core_get_userid( $username ) {
949
  */
950
  function bp_core_get_username( $uid ) {
951
  global $userdata;
952
-
953
  if ( $uid == $userdata->ID )
954
  $username = __( 'You', 'buddypress' );
955
-
956
  if ( !$ud = get_userdata($uid) )
957
  return false;
958
-
959
- $username = $ud->user_login;
960
 
961
  return apply_filters( 'bp_core_get_username', $username );
962
  }
@@ -965,7 +963,7 @@ function bp_core_get_username( $uid ) {
965
  * bp_core_get_userurl()
966
  *
967
  * Returns the URL with no HTML markup for a user based on their user id.
968
- *
969
  * @package BuddyPress Core
970
  * @param $uid int User ID to check.
971
  * @global $userdata WordPress user data for the current logged in user.
@@ -975,7 +973,7 @@ function bp_core_get_username( $uid ) {
975
  */
976
  function bp_core_get_userurl( $uid ) {
977
  global $bp;
978
-
979
  if ( !is_numeric($uid) )
980
  return false;
981
 
@@ -986,7 +984,7 @@ function bp_core_get_userurl( $uid ) {
986
  * bp_core_get_user_email()
987
  *
988
  * Returns the email address for the user based on user ID
989
- *
990
  * @package BuddyPress Core
991
  * @param $uid int User ID to check.
992
  * @uses get_userdata() WordPress function to fetch the userdata for a user ID
@@ -1004,10 +1002,10 @@ function bp_core_get_user_email( $uid ) {
1004
  * Returns a HTML formatted link for a user with the user's full name as the link text.
1005
  * eg: <a href="http://andy.domain.com/">Andy Peatling</a>
1006
  * Optional parameters will return just the name, or just the URL, or disable "You" text when
1007
- * user matches the logged in user.
1008
  *
1009
  * [NOTES: This function needs to be cleaned up or split into separate functions]
1010
- *
1011
  * @package BuddyPress Core
1012
  * @param $uid int User ID to check.
1013
  * @param $no_anchor bool Disable URL and HTML and just return full name. Default false.
@@ -1022,32 +1020,32 @@ function bp_core_get_user_email( $uid ) {
1022
  */
1023
  function bp_core_get_userlink( $user_id, $no_anchor = false, $just_link = false, $deprecated = false, $with_s = false ) {
1024
  global $userdata;
1025
-
1026
  $ud = get_userdata($user_id);
1027
-
1028
  if ( !$ud )
1029
  return false;
1030
 
1031
- if ( function_exists('bp_fetch_user_fullname') ) {
1032
  $display_name = bp_core_get_user_displayname( $user_id );
1033
-
1034
  if ( $with_s )
1035
  $display_name = sprintf( __( "%s's", 'buddypress' ), $display_name );
1036
-
1037
  } else {
1038
  $display_name = $ud->display_name;
1039
  }
1040
-
1041
  if ( $no_anchor )
1042
  return $display_name;
1043
 
1044
  if ( !$url = bp_core_get_userurl($user_id) )
1045
  return false;
1046
-
1047
  if ( $just_link )
1048
  return $url;
1049
 
1050
- return '<a href="' . $url . '">' . $display_name . '</a>';
1051
  }
1052
 
1053
 
@@ -1056,7 +1054,7 @@ function bp_core_get_userlink( $user_id, $no_anchor = false, $just_link = false,
1056
  *
1057
  * Fetch the display name for a user. This will use the "Name" field in xprofile if it is installed.
1058
  * Otherwise, it will fall back to the normal WP display_name, or user_nicename, depending on what has been set.
1059
- *
1060
  * @package BuddyPress Core
1061
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
1062
  * @uses wp_cache_get() Will try and fetch the value from the cache, rather than querying the DB again.
@@ -1067,10 +1065,10 @@ function bp_core_get_userlink( $user_id, $no_anchor = false, $just_link = false,
1067
  */
1068
  function bp_core_get_user_displayname( $user_id ) {
1069
  global $bp;
1070
-
1071
  if ( !$user_id )
1072
  return false;
1073
-
1074
  if ( !$fullname = wp_cache_get( 'bp_user_fullname_' . $user_id, 'bp' ) ) {
1075
  if ( function_exists('xprofile_install') ) {
1076
  $fullname = xprofile_get_field_data( 1, $user_id );
@@ -1087,16 +1085,16 @@ function bp_core_get_user_displayname( $user_id ) {
1087
  }
1088
  } else {
1089
  $ud = get_userdata($user_id);
1090
-
1091
  if ( !empty( $ud->display_name ) )
1092
  $fullname = $ud->display_name;
1093
  else
1094
  $fullname = $ud->user_nicename;
1095
  }
1096
-
1097
  wp_cache_set( 'bp_user_fullname_' . $user_id, $fullname, 'bp' );
1098
  }
1099
-
1100
  return apply_filters( 'bp_core_get_user_displayname', $fullname );
1101
  }
1102
  add_filter( 'bp_core_get_user_displayname', 'strip_tags', 1 );
@@ -1108,7 +1106,7 @@ add_filter( 'bp_core_get_user_displayname', 'stripslashes' );
1108
  * bp_core_get_userlink_by_email()
1109
  *
1110
  * Returns the user link for the user based on user email address
1111
- *
1112
  * @package BuddyPress Core
1113
  * @param $email str The email address for the user.
1114
  * @uses bp_core_get_userlink() BuddyPress function to get a userlink by user ID.
@@ -1124,7 +1122,7 @@ function bp_core_get_userlink_by_email( $email ) {
1124
  * bp_core_get_userlink_by_username()
1125
  *
1126
  * Returns the user link for the user based on user's username
1127
- *
1128
  * @package BuddyPress Core
1129
  * @param $username str The username for the user.
1130
  * @uses bp_core_get_userlink() BuddyPress function to get a userlink by user ID.
@@ -1132,8 +1130,8 @@ function bp_core_get_userlink_by_email( $email ) {
1132
  */
1133
  function bp_core_get_userlink_by_username( $username ) {
1134
  global $wpdb;
1135
-
1136
- $user_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . CUSTOM_USER_TABLE . " WHERE user_login = %s", $username ) );
1137
  return apply_filters( 'bp_core_get_userlink_by_username', bp_core_get_userlink( $user_id, false, false, true ) );
1138
  }
1139
 
@@ -1148,8 +1146,8 @@ function bp_core_get_userlink_by_username( $username ) {
1148
  */
1149
  function bp_core_is_user_spammer( $user_id ) {
1150
  global $wpdb;
1151
-
1152
- return apply_filters( 'bp_core_is_user_spammer', (int) $wpdb->get_var( $wpdb->prepare( "SELECT spam FROM " . CUSTOM_USER_TABLE . " WHERE ID = %d", $user_id ) ) );
1153
  }
1154
 
1155
  /**
@@ -1163,8 +1161,8 @@ function bp_core_is_user_spammer( $user_id ) {
1163
  */
1164
  function bp_core_is_user_deleted( $user_id ) {
1165
  global $wpdb;
1166
-
1167
- return apply_filters( 'bp_core_is_user_spammer', (int) $wpdb->get_var( $wpdb->prepare( "SELECT deleted FROM " . CUSTOM_USER_TABLE . " WHERE ID = %d", $user_id ) ) );
1168
  }
1169
 
1170
  /**
@@ -1173,13 +1171,13 @@ function bp_core_is_user_deleted( $user_id ) {
1173
  function bp_core_format_time( $time, $just_date = false ) {
1174
  if ( !$time )
1175
  return false;
1176
-
1177
  $date = date( "F j, Y ", $time );
1178
-
1179
  if ( !$just_date ) {
1180
  $date .= __('at', 'buddypress') . date( ' g:iA', $time );
1181
  }
1182
-
1183
  return $date;
1184
  }
1185
 
@@ -1188,19 +1186,19 @@ function bp_core_format_time( $time, $just_date = false ) {
1188
  * bp_core_add_message()
1189
  *
1190
  * Adds a feedback (error/success) message to the WP cookie so it can be displayed after the page reloads.
1191
- *
1192
  * @package BuddyPress Core
1193
  */
1194
  function bp_core_add_message( $message, $type = false ) {
1195
  global $bp;
1196
-
1197
  if ( !$type )
1198
  $type = 'success';
1199
-
1200
  /* Send the values to the cookie for page reload display */
1201
  @setcookie( 'bp-message', $message, time()+60*60*24, COOKIEPATH );
1202
  @setcookie( 'bp-message-type', $type, time()+60*60*24, COOKIEPATH );
1203
-
1204
  /***
1205
  * Send the values to the $bp global so we can still output messages
1206
  * without a page reload
@@ -1217,7 +1215,7 @@ function bp_core_add_message( $message, $type = false ) {
1217
  *
1218
  * After the message is displayed, it removes the message vars from the cookie so that the message
1219
  * is not shown to the user multiple times.
1220
- *
1221
  * @package BuddyPress Core
1222
  * @global $bp_message The message text
1223
  * @global $bp_message_type The type of message (error/success)
@@ -1228,12 +1226,12 @@ function bp_core_setup_message() {
1228
 
1229
  if ( empty( $bp->template_message ) )
1230
  $bp->template_message = $_COOKIE['bp-message'];
1231
-
1232
  if ( empty( $bp->template_message_type ) )
1233
  $bp->template_message_type = $_COOKIE['bp-message-type'];
1234
 
1235
  add_action( 'template_notices', 'bp_core_render_message' );
1236
-
1237
  @setcookie( 'bp-message', false, time() - 1000, COOKIEPATH );
1238
  @setcookie( 'bp-message-type', false, time() - 1000, COOKIEPATH );
1239
  }
@@ -1244,13 +1242,13 @@ add_action( 'wp', 'bp_core_setup_message' );
1244
  *
1245
  * Renders a feedback message (either error or success message) to the theme template.
1246
  * The hook action 'template_notices' is used to call this function, it is not called directly.
1247
- *
1248
  * @package BuddyPress Core
1249
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
1250
  */
1251
  function bp_core_render_message() {
1252
  global $bp;
1253
-
1254
  if ( $bp->template_message ) {
1255
  $type = ( 'success' == $bp->template_message_type ) ? 'updated' : 'error';
1256
  ?>
@@ -1259,20 +1257,20 @@ function bp_core_render_message() {
1259
  </div>
1260
  <?php
1261
  do_action( 'bp_core_render_message' );
1262
- }
1263
  }
1264
 
1265
  /**
1266
  * bp_core_time_since()
1267
  *
1268
  * Based on function created by Dunstan Orchard - http://1976design.com
1269
- *
1270
  * This function will return an English representation of the time elapsed
1271
  * since a given date.
1272
  * eg: 2 hours and 50 minutes
1273
  * eg: 4 days
1274
  * eg: 4 weeks and 6 days
1275
- *
1276
  * @package BuddyPress Core
1277
  * @param $older_date int Unix timestamp of date you want to calculate the time since for
1278
  * @param $newer_date int Unix timestamp of date to compare older date to. Default false (current time).
@@ -1290,16 +1288,16 @@ function bp_core_time_since( $older_date, $newer_date = false ) {
1290
  array( 60 , __( 'minute', 'buddypress' ), __( 'minutes', 'buddypress' ) ),
1291
  array( 1, __( 'second', 'buddypress' ), __( 'seconds', 'buddypress' ) )
1292
  );
1293
-
1294
  $older_date = strtotime( gmdate( 'Y-m-d H:i:s', $older_date ) );
1295
 
1296
  /* $newer_date will equal false if we want to know the time elapsed between a date and the current time */
1297
  /* $newer_date will have a value if we want to work out time elapsed between two known dates */
1298
  $newer_date = ( !$newer_date ) ? ( strtotime( gmdate( 'Y-m-d H:i:s' ) ) + ( 60*60*0 ) ) : $newer_date;
1299
-
1300
  /* Difference in seconds */
1301
  $since = $newer_date - $older_date;
1302
-
1303
  if ( 0 > $since )
1304
  return __( '[Use GMT Timezone]', 'buddypress' );
1305
 
@@ -1326,9 +1324,9 @@ function bp_core_time_since( $older_date, $newer_date = false ) {
1326
  if ( $i + 2 < $j ) {
1327
  $seconds2 = $chunks[$i + 1][0];
1328
  $name2 = $chunks[$i + 1][1];
1329
-
1330
  //if ( $chunks[$i + 1][1] == __( 'second', 'buddypress' ) ) return $output;
1331
-
1332
  if ( ( $count2 = floor( ( $since - ( $seconds * $count ) ) / $seconds2 ) ) != 0 ) {
1333
  /* Add to output var */
1334
  $output .= ( 1 == $count2 ) ? _c( ',|Separator in time since', 'buddypress' ) . ' 1 '. $chunks[$i + 1][1] : _c( ',|Separator in time since', 'buddypress' ) . ' ' . $count2 . ' ' . $chunks[$i + 1][2];
@@ -1348,19 +1346,19 @@ function bp_core_time_since( $older_date, $newer_date = false ) {
1348
  * Record user activity to the database. Many functions use a "last active" feature to
1349
  * show the length of time since the user was last active.
1350
  * This function will update that time as a usermeta setting for the user every 5 minutes.
1351
- *
1352
  * @package BuddyPress Core
1353
  * @global $userdata WordPress user data for the current logged in user.
1354
  * @uses update_usermeta() WordPress function to update user metadata in the usermeta table.
1355
  */
1356
  function bp_core_record_activity() {
1357
  global $bp;
1358
-
1359
  if ( !is_user_logged_in() )
1360
  return false;
1361
-
1362
  $activity = get_usermeta( $bp->loggedin_user->id, 'last_activity' );
1363
-
1364
  if ( '' == $activity || time() >= strtotime( '+5 minutes', $activity ) )
1365
  update_usermeta( $bp->loggedin_user->id, 'last_activity', time() );
1366
  }
@@ -1371,7 +1369,7 @@ add_action( 'wp_head', 'bp_core_record_activity' );
1371
  * bp_core_get_last_activity()
1372
  *
1373
  * Formats last activity based on time since date given.
1374
- *
1375
  * @package BuddyPress Core
1376
  * @param last_activity_date The date of last activity.
1377
  * @param $before The text to prepend to the activity time since figure.
@@ -1383,14 +1381,14 @@ function bp_core_get_last_activity( $last_activity_date, $string ) {
1383
  $last_active = __( 'not recently active', 'buddypress' );
1384
  } else {
1385
  if ( strstr( $last_activity_date, '-' ) ) {
1386
- $last_active = bp_core_time_since( strtotime( $last_activity_date ) );
1387
  } else {
1388
- $last_active = bp_core_time_since( $last_activity_date );
1389
  }
1390
-
1391
  $last_active = sprintf( $string, $last_active );
1392
  }
1393
-
1394
  return $last_active;
1395
  }
1396
 
@@ -1399,7 +1397,7 @@ function bp_core_get_last_activity( $last_activity_date, $string ) {
1399
  * bp_core_get_all_posts_for_user()
1400
  *
1401
  * Fetch every post that is authored by the given user for the current blog.
1402
- *
1403
  * @package BuddyPress Core
1404
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
1405
  * @global $wpdb WordPress user data for the current logged in user.
@@ -1407,10 +1405,10 @@ function bp_core_get_last_activity( $last_activity_date, $string ) {
1407
  */
1408
  function bp_core_get_all_posts_for_user( $user_id = null ) {
1409
  global $bp, $wpdb;
1410
-
1411
  if ( !$user_id )
1412
  $user_id = $bp->displayed_user->id;
1413
-
1414
  return $wpdb->get_col( $wpdb->prepare( "SELECT post_id FROM $wpdb->posts WHERE post_author = %d AND post_status = 'publish' AND post_type = 'post'", $user_id ) );
1415
  }
1416
 
@@ -1419,14 +1417,14 @@ function bp_core_get_all_posts_for_user( $user_id = null ) {
1419
  * bp_core_get_site_path()
1420
  *
1421
  * Get the path of of the current site.
1422
- *
1423
  * @package BuddyPress Core
1424
  * @global $comment WordPress comment global for the current comment.
1425
  * @uses bp_core_get_userlink_by_email() Fetches a userlink via email address.
1426
  */
1427
  function bp_core_get_site_path() {
1428
  global $current_site;
1429
-
1430
  return $current_site->path;
1431
  }
1432
 
@@ -1434,7 +1432,7 @@ function bp_core_get_site_path() {
1434
  * bp_core_redirect()
1435
  *
1436
  * Performs a status safe wp_redirect() that is compatible with bp_catch_uri()
1437
- *
1438
  * @package BuddyPress Core
1439
  * @global $bp_no_status_set Makes sure that there are no conflicts with status_header() called in bp_core_do_catch_uri()
1440
  * @uses get_themes()
@@ -1442,11 +1440,11 @@ function bp_core_get_site_path() {
1442
  */
1443
  function bp_core_redirect( $location, $status = 302 ) {
1444
  global $bp_no_status_set;
1445
-
1446
- // Make sure we don't call status_header() in bp_core_do_catch_uri()
1447
  // as this conflicts with wp_redirect()
1448
  $bp_no_status_set = true;
1449
-
1450
  wp_redirect( $location, $status );
1451
  die;
1452
  }
@@ -1455,7 +1453,7 @@ function bp_core_redirect( $location, $status = 302 ) {
1455
  * bp_core_referrer()
1456
  *
1457
  * Returns the referrer URL without the http(s)://
1458
- *
1459
  * @package BuddyPress Core
1460
  * @return The referrer URL
1461
  */
@@ -1472,16 +1470,16 @@ function bp_core_referrer() {
1472
  * blog names on a subdirectory installation.
1473
  *
1474
  * For example, it would stop someone creating a blog with the slug "groups".
1475
- *
1476
  * @package BuddyPress Core
1477
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
1478
  */
1479
  function bp_core_add_illegal_names() {
1480
  global $bp;
1481
-
1482
  $current = maybe_unserialize( get_site_option( 'illegal_names' ) );
1483
  $bp_illegal_names = $bp->root_components;
1484
-
1485
  if ( is_array( $current ) ) {
1486
  foreach( $bp_illegal_names as $bp_illegal_name ) {
1487
  if ( !in_array( $bp_illegal_name, $current ) )
@@ -1500,7 +1498,7 @@ function bp_core_add_illegal_names() {
1500
  * bp_core_email_from_name_filter()
1501
  *
1502
  * Sets the "From" name in emails sent to the name of the site and not "WordPress"
1503
- *
1504
  * @package BuddyPress Core
1505
  * @uses get_blog_option() fetches the value for a meta_key in the wp_X_options table
1506
  * @return The blog name for the root blog
@@ -1515,7 +1513,7 @@ add_filter( 'wp_mail_from_name', 'bp_core_email_from_name_filter' );
1515
  * bp_core_email_from_name_filter()
1516
  *
1517
  * Sets the "From" address in emails sent
1518
- *
1519
  * @package BuddyPress Core
1520
  * @global $current_site Object containing current site metadata
1521
  * @return noreply@sitedomain email address
@@ -1531,7 +1529,7 @@ add_filter( 'wp_mail_from', 'bp_core_email_from_address_filter' );
1531
  * bp_core_delete_account()
1532
  *
1533
  * Allows a user to completely remove their account from the system
1534
- *
1535
  * @package BuddyPress Core
1536
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
1537
  * @uses check_admin_referer() Checks for a valid security nonce.
@@ -1545,7 +1543,7 @@ function bp_core_delete_account( $user_id = false ) {
1545
  $user_id = $bp->loggedin_user->id;
1546
 
1547
  /* Make sure account deletion is not disabled */
1548
- if ( ( '' != get_site_option( 'bp-disable-account-deletion' ) || (int) get_site_option( 'bp-disable-account-deletion' ) ) && !is_site_admin() )
1549
  return false;
1550
 
1551
  /* Site admins should not be allowed to be deleted */
@@ -1563,7 +1561,7 @@ function bp_core_delete_account( $user_id = false ) {
1563
  * bp_core_search_site()
1564
  *
1565
  * A javascript free implementation of the search functions in BuddyPress
1566
- *
1567
  * @package BuddyPress Core
1568
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
1569
  * @param $slug The slug to redirect to for searching.
@@ -1574,7 +1572,7 @@ function bp_core_action_search_site( $slug = false ) {
1574
  if ( $bp->current_component == BP_SEARCH_SLUG ) {
1575
  $search_terms = $_POST['search-terms'];
1576
  $search_which = $_POST['search-which'];
1577
-
1578
  if ( !$slug || empty( $slug ) ) {
1579
  switch ( $search_which ) {
1580
  case 'members': default:
@@ -1595,9 +1593,9 @@ function bp_core_action_search_site( $slug = false ) {
1595
  break;
1596
  }
1597
  }
1598
-
1599
  $search_url = apply_filters( 'bp_core_search_site', site_url( $slug . $var . urlencode($search_terms) ), $search_terms );
1600
-
1601
  bp_core_redirect( $search_url );
1602
  }
1603
  }
@@ -1606,15 +1604,15 @@ add_action( 'init', 'bp_core_action_search_site', 5 );
1606
 
1607
  /**
1608
  * bp_core_ucfirst()
1609
- *
1610
  * Localization safe ucfirst() support.
1611
- *
1612
  * @package BuddyPress Core
1613
  */
1614
  function bp_core_ucfirst( $str ) {
1615
  if ( function_exists( 'mb_strtoupper' ) && function_exists( 'mb_substr' ) ) {
1616
  $fc = mb_strtoupper( mb_substr( $str, 0, 1 ) );
1617
- return $fc.mb_substr( $str, 1 );
1618
  } else {
1619
  return ucfirst( $str );
1620
  }
@@ -1623,9 +1621,9 @@ function bp_core_ucfirst( $str ) {
1623
 
1624
  /**
1625
  * bp_core_strip_username_spaces()
1626
- *
1627
  * Strips spaces from usernames that are created using add_user() and wp_insert_user()
1628
- *
1629
  * @package BuddyPress Core
1630
  */
1631
  function bp_core_strip_username_spaces( $username ) {
@@ -1636,28 +1634,28 @@ add_action( 'pre_user_login', 'bp_core_strip_username_spaces' );
1636
 
1637
  /**
1638
  * bp_core_clear_cache()
1639
- * REQUIRES WP-SUPER-CACHE
1640
- *
1641
  * When wp-super-cache is installed this function will clear cached pages
1642
  * so that success/error messages are not cached, or time sensitive content.
1643
- *
1644
  * @package BuddyPress Core
1645
  */
1646
  function bp_core_clear_cache() {
1647
  global $cache_path, $cache_filename;
1648
-
1649
  if ( function_exists( 'prune_super_cache' ) ) {
1650
  do_action( 'bp_core_clear_cache' );
1651
-
1652
- return prune_super_cache( $cache_path, true );
1653
  }
1654
  }
1655
 
1656
  /**
1657
  * bp_core_print_generation_time()
1658
- *
1659
  * Prints the generation time in the footer of the site.
1660
- *
1661
  * @package BuddyPress Core
1662
  */
1663
  function bp_core_print_generation_time() {
@@ -1670,9 +1668,9 @@ add_action( 'wp_footer', 'bp_core_print_generation_time' );
1670
 
1671
  /**
1672
  * bp_core_add_admin_menu_page()
1673
- *
1674
  * A better version of add_admin_menu_page() that allows positioning of menus.
1675
- *
1676
  * @package BuddyPress Core
1677
  */
1678
  function bp_core_add_admin_menu_page( $args = '' ) {
@@ -1690,7 +1688,7 @@ function bp_core_add_admin_menu_page( $args = '' ) {
1690
 
1691
  $r = wp_parse_args( $args, $defaults );
1692
  extract( $r, EXTR_SKIP );
1693
-
1694
  $file = plugin_basename( $file );
1695
 
1696
  $admin_page_hooks[$file] = sanitize_title( $menu_title );
@@ -1707,7 +1705,7 @@ function bp_core_add_admin_menu_page( $args = '' ) {
1707
  do {
1708
  $position++;
1709
  } while ( !empty( $menu[$position] ) );
1710
-
1711
  $menu[$position] = array ( $menu_title, $access_level, $file, $page_title, 'menu-top ' . $hookname, $hookname, $icon_url );
1712
 
1713
  $_registered_pages[$hookname] = true;
@@ -1720,14 +1718,14 @@ function bp_core_add_admin_menu_page( $args = '' ) {
1720
  *
1721
  * When a user logs in, check if they have been marked as a spammer. If then simply
1722
  * redirect them to the home page and stop them from logging in.
1723
- *
1724
  * @package BuddyPress Core
1725
  * @param $username The username of the user
1726
  * @uses delete_usermeta() deletes a row from the wp_usermeta table based on meta_key
1727
  */
1728
  function bp_core_boot_spammer( $auth_obj, $username ) {
1729
  global $bp;
1730
-
1731
  $user = get_userdatabylogin( $username );
1732
 
1733
  if ( (int)$user->spam )
@@ -1739,7 +1737,7 @@ add_filter( 'authenticate', 'bp_core_boot_spammer', 11, 2 );
1739
  * bp_core_remove_data()
1740
  *
1741
  * Deletes usermeta for the user when the user is deleted.
1742
- *
1743
  * @package BuddyPress Core
1744
  * @param $user_id The user id for the user to delete usermeta for
1745
  * @uses delete_usermeta() deletes a row from the wp_usermeta table based on meta_key
@@ -1757,19 +1755,19 @@ add_action( 'make_spam_user', 'bp_core_remove_data', 1 );
1757
 
1758
  /**
1759
  * bp_load_buddypress_textdomain()
1760
- *
1761
  * Load the buddypress translation file for current language
1762
- *
1763
  * @package BuddyPress Core
1764
  */
1765
  function bp_core_load_buddypress_textdomain() {
1766
  $locale = apply_filters( 'buddypress_locale', get_locale() );
1767
  $mofile = BP_PLUGIN_DIR . "/bp-languages/buddypress-$locale.mo";
1768
-
1769
  if ( file_exists( $mofile ) )
1770
  load_textdomain( 'buddypress', $mofile );
1771
  }
1772
- add_action ( 'plugins_loaded', 'bp_core_load_buddypress_textdomain', 9 );
1773
 
1774
  function bp_core_add_ajax_hook() {
1775
  /* Theme only, we already have the wp_ajax_ hook firing in wp-admin */
@@ -1780,9 +1778,9 @@ add_action( 'init', 'bp_core_add_ajax_hook' );
1780
 
1781
  /**
1782
  * bp_core_update_message()
1783
- *
1784
  * Add an extra update message to the update plugin notification.
1785
- *
1786
  * @package BuddyPress Core
1787
  */
1788
  function bp_core_update_message() {
@@ -1792,9 +1790,9 @@ add_action( 'in_plugin_update_message-buddypress/bp-loader.php', 'bp_core_update
1792
 
1793
  /**
1794
  * bp_core_clear_user_object_cache()
1795
- *
1796
  * Clears all cached objects for a user, or a user is part of.
1797
- *
1798
  * @package BuddyPress Core
1799
  */
1800
  function bp_core_clear_user_object_cache( $user_id ) {
3
  /* Define the current version number for checking if DB tables are up to date. */
4
  define( 'BP_CORE_DB_VERSION', '1800' );
5
 
6
+ /***
7
+ * Define the path and url of the BuddyPress plugins directory.
8
+ * It is important to use plugins_url() core function to obtain
9
+ * the correct scheme used (http or https).
10
  */
11
  define( 'BP_PLUGIN_DIR', WP_PLUGIN_DIR . '/buddypress' );
12
  define( 'BP_PLUGIN_URL', plugins_url( $path = '/buddypress' ) );
65
  /* Define the slug for the search page */
66
  if ( !defined( 'BP_HOME_BLOG_SLUG' ) )
67
  define( 'BP_HOME_BLOG_SLUG', 'blog' );
68
+
69
  /* Register BuddyPress themes contained within the theme folder */
70
  if ( function_exists( 'register_theme_folder' ) )
71
  register_theme_folder( 'buddypress/bp-themes' );
93
  global $current_user, $current_component, $current_action, $current_blog;
94
  global $displayed_user_id;
95
  global $action_variables;
96
+
97
  $current_user = wp_get_current_user();
98
 
99
+ /* The domain for the root of the site where the main blog resides */
100
  $bp->root_domain = bp_core_get_root_domain();
101
+
102
  /* The user ID of the user who is currently logged in. */
103
  $bp->loggedin_user->id = $current_user->ID;
104
 
105
  /* The domain for the user currently logged in. eg: http://domain.com/members/andy */
106
  $bp->loggedin_user->domain = bp_core_get_user_domain($current_user->ID);
107
+
108
  /* The user id of the user currently being viewed, set in /bp-core/bp-core-catchuri.php */
109
  $bp->displayed_user->id = $displayed_user_id;
110
+
111
  /* The domain for the user currently being displayed */
112
  $bp->displayed_user->domain = bp_core_get_user_domain($displayed_user_id);
113
+
114
  /* The component being used eg: http://domain.com/members/andy/ [profile] */
115
  $bp->current_component = $current_component; // type: string
116
+
117
  /* The current action for the component eg: http://domain.com/members/andy/profile/ [edit] */
118
  $bp->current_action = $current_action; // type: string
119
+
120
  /* The action variables for the current action eg: http://domain.com/members/andy/profile/edit/ [group] / [6] */
121
  $bp->action_variables = $action_variables; // type: array
122
+
123
  /* Only used where a component has a sub item, e.g. groups: http://domain.com/members/andy/groups/ [my-group] / home - manipulated in the actual component not in catch uri code.*/
124
  $bp->current_item = ''; // type: string
125
 
134
 
135
  /* Sets up the array container for the component navigation rendered by bp_get_nav() */
136
  $bp->bp_nav = array();
137
+
138
  /* Sets up the array container for the component options navigation rendered by bp_get_options_nav() */
139
  $bp->bp_options_nav = array();
140
+
141
  /* Sets up container used for the title of the current component option and rendered by bp_get_options_title() */
142
  $bp->bp_options_title = '';
143
+
144
  /* Sets up container used for the avatar of the current component being viewed. Rendered by bp_get_options_avatar() */
145
  $bp->bp_options_avatar = '';
146
+
147
  /* Contains an array of all the active components. The key is the slug, value the internal ID of the component */
148
  $bp->active_components = array();
149
+
150
  /* Fetches the default Gravatar image to use if the user/group/blog has no avatar or gravatar */
151
  $bp->grav_default->user = apply_filters( 'bp_user_gravatar_default', get_site_option( 'user-avatar-default' ) );
152
  $bp->grav_default->group = apply_filters( 'bp_group_gravatar_default', 'identicon' );
153
  $bp->grav_default->blog = apply_filters( 'bp_blog_gravatar_default', 'identicon' );
154
+
155
  /* Fetch the full name for the logged in and current user */
156
  $bp->loggedin_user->fullname = bp_core_get_user_displayname( $bp->loggedin_user->id );
157
  $bp->displayed_user->fullname = bp_core_get_user_displayname( $bp->displayed_user->id );
161
  generic variable so it can be used in other components. It can also be modified, so when viewing a group
162
  'is_item_admin' would be 1 if they are a group admin, 0 if they are not. */
163
  $bp->is_item_admin = bp_is_home();
164
+
165
  /* Used to determine if the logged in user is a moderator for the current content. */
166
  $bp->is_item_mod = false;
167
 
169
 
170
  if ( !$bp->current_component )
171
  $bp->current_component = $bp->default_component;
172
+
173
  do_action( 'bp_core_setup_globals' );
174
  }
175
  add_action( 'plugins_loaded', 'bp_core_setup_globals', 5 );
182
  * Adds the core URIs that should run in the root of the installation.
183
  *
184
  * For example: http://example.org/search or http://example.org/members
185
+ *
186
  * @package BuddyPress Core
187
  * @uses bp_core_add_root_component() Adds a slug to the root components global variable.
188
  */
201
  * bp_core_install()
202
  *
203
  * Installs the core DB tables for BuddyPress.
204
+ *
205
  * @package BuddyPress Core
206
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
207
  * @global $wpdb WordPress DB access object.
210
  */
211
  function bp_core_install() {
212
  global $wpdb, $bp;
213
+
214
  if ( !empty($wpdb->charset) )
215
  $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
216
+
217
  $sql[] = "CREATE TABLE {$bp->core->table_name_notifications} (
218
  id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
219
  user_id bigint(20) NOT NULL,
234
 
235
  require_once( ABSPATH . 'wp-admin/upgrade-functions.php' );
236
  dbDelta( $sql );
237
+
238
  /* Add names of root components to the banned blog list to avoid conflicts */
239
  bp_core_add_illegal_names();
240
+
241
  update_site_option( 'bp-core-db-version', BP_CORE_DB_VERSION );
242
  }
243
 
245
  * bp_core_check_installed()
246
  *
247
  * Checks to make sure the database tables are set up for the core component.
248
+ *
249
  * @package BuddyPress Core
250
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
251
  * @global $wpdb WordPress DB access object.
259
 
260
  if ( !is_site_admin() )
261
  return false;
262
+
263
  require ( BP_PLUGIN_DIR . '/bp-core/bp-core-admin.php' );
264
 
265
  /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
272
  * bp_core_add_admin_menu()
273
  *
274
  * Adds the "BuddyPress" admin submenu item to the Site Admin tab.
275
+ *
276
  * @package BuddyPress Core
277
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
278
  * @global $wpdb WordPress DB access object.
280
  * @uses add_submenu_page() WP function to add a submenu item
281
  */
282
  function bp_core_add_admin_menu() {
 
 
283
  if ( !is_site_admin() )
284
  return false;
285
+
286
  /* Add the administration tab under the "Site Admin" tab for site administrators */
287
  bp_core_add_admin_menu_page( array(
288
  'menu_title' => __( 'BuddyPress', 'buddypress' ),
291
  'function' => 'bp_core_admin_settings',
292
  'position' => 2
293
  ) );
294
+
295
  add_submenu_page( 'bp-general-settings', __( 'General Settings', 'buddypress'), __( 'General Settings', 'buddypress' ), 'manage_options', 'bp-general-settings', 'bp_core_admin_settings' );
296
  add_submenu_page( 'bp-general-settings', __( 'Component Setup', 'buddypress'), __( 'Component Setup', 'buddypress' ), 'manage_options', 'bp-component-setup', 'bp_core_admin_component_setup' );
297
  }
302
  *
303
  * Checks to see if a component's URL should be in the root, not under a member page:
304
  * eg: http://domain.com/groups/the-group NOT http://domain.com/members/andy/groups/the-group
305
+ *
306
  * @package BuddyPress Core
307
  * @return true if root component, else false.
308
  */
316
  * bp_core_setup_nav()
317
  *
318
  * Sets up the profile navigation item if the Xprofile component is not installed.
319
+ *
320
  * @package BuddyPress Core
321
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
322
  * @uses bp_core_new_nav_item() Adds a navigation item to the top level buddypress navigation
326
  */
327
  function bp_core_setup_nav() {
328
  global $bp;
329
+
330
+ /***
331
  * If the extended profiles component is disabled, we need to revert to using the
332
  * built in WordPress profile information
333
  */
337
  $bp->active_components[$bp->core->profile->slug] = $bp->core->profile->slug;
338
 
339
  /* Add 'Profile' to the main navigation */
340
+ bp_core_new_nav_item( array(
341
  'name' => __('Profile', 'buddypress'),
342
  'slug' => $bp->core->profile->slug,
343
  'position' => 20,
346
  ) );
347
 
348
  $profile_link = $bp->loggedin_user->domain . '/profile/';
349
+
350
  /* Add the subnav items to the profile */
351
  bp_core_new_subnav_item( array(
352
  'name' => __( 'Public', 'buddypress' ),
355
  'parent_slug' => $bp->core->profile->slug,
356
  'screen_function' => 'bp_core_catch_profile_uri'
357
  ) );
358
+
359
 
360
  if ( 'profile' == $bp->current_component ) {
361
  if ( bp_is_home() ) {
362
  $bp->bp_options_title = __('My Profile', 'buddypress');
363
  } else {
364
  $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) );
365
+ $bp->bp_options_title = $bp->displayed_user->fullname;
366
  }
367
  }
368
+ }
369
  }
370
  add_action( 'plugins_loaded', 'bp_core_setup_nav' );
371
  add_action( 'admin_menu', 'bp_core_setup_nav' );
394
  *
395
  * Listens to the $bp component and action variables to determine if the user is viewing the members
396
  * directory page. If they are, it will set up the directory and load the members directory template.
397
+ *
398
  * @package BuddyPress Core
399
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
400
  * @uses wp_enqueue_script() Loads a JS script into the header of the page.
418
  * When a site admin selects "Mark as Spammer/Not Spammer" from the admin menu
419
  * this action will fire and mark or unmark the user and their blogs as spam.
420
  * Must be a site admin for this function to run.
421
+ *
422
  * @package BuddyPress Core
423
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
424
  */
425
  function bp_core_action_set_spammer_status() {
426
  global $bp;
427
+
428
  if ( !is_site_admin() || bp_is_home() || !$bp->displayed_user->id )
429
  return false;
430
+
431
  if ( 'admin' == $bp->current_component && ( 'mark-spammer' == $bp->current_action || 'unmark-spammer' == $bp->current_action ) ) {
432
  /* Check the nonce */
433
  check_admin_referer( 'mark-unmark-spammer' );
434
 
435
  /* Get the functions file */
436
  require( ABSPATH . 'wp-admin/includes/mu.php' );
437
+
438
  if ( 'mark-spammer' == $bp->current_action )
439
  $is_spam = 1;
440
  else
442
 
443
  /* Get the blogs for the user */
444
  $blogs = get_blogs_of_user( $bp->displayed_user->id, true );
445
+
446
  foreach ( (array) $blogs as $key => $details ) {
447
  /* Do not mark the main or current root blog as spam */
448
+ if ( 1 == $details->userblog_id || BP_ROOT_BLOG == $details->userblog_id )
449
+ continue;
450
+
451
  /* Update the blog status */
452
  update_blog_status( $details->userblog_id, 'spam', $is_spam );
453
+
454
  /* Fire the standard WPMU hook */
455
  do_action( 'make_spam_blog', $details->userblog_id );
456
  }
457
+
458
  /* Finally, mark this user as a spammer */
459
  update_user_status( $bp->displayed_user->id, 'spam', $is_spam, 1 );
460
+
461
  if ( $is_spam )
462
  bp_core_add_message( __( 'User marked as spammer. Spam users are visible only to site admins.', 'buddypress' ) );
463
  else
464
  bp_core_add_message( __( 'User removed as spammer.', 'buddypress' ) );
465
+
466
  do_action( 'bp_core_action_set_spammer_status' );
467
+
468
  bp_core_redirect( wp_get_referer() );
469
  }
470
  }
474
  * bp_core_action_delete_user()
475
  *
476
  * Allows a site admin to delete a user from the adminbar menu.
477
+ *
478
  * @package BuddyPress Core
479
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
480
  */
481
  function bp_core_action_delete_user() {
482
  global $bp;
483
+
484
  if ( !is_site_admin() || bp_is_home() || !$bp->displayed_user->id )
485
  return false;
486
+
487
  if ( 'admin' == $bp->current_component && 'delete-user' == $bp->current_action ) {
488
  /* Check the nonce */
489
  check_admin_referer( 'delete-user' );
490
 
491
  $errors = false;
492
+
493
  if ( bp_core_delete_account( $bp->displayed_user->id ) ) {
494
  bp_core_add_message( sprintf( __( '%s has been deleted from the system.', 'buddypress' ), $bp->displayed_user->fullname ) );
495
  } else {
496
  bp_core_add_message( sprintf( __( 'There was an error deleting %s from the system. Please try again.', 'buddypress' ), $bp->displayed_user->fullname ), 'error' );
497
  $errors = true;
498
  }
499
+
500
  do_action( 'bp_core_action_set_spammer_status', $errors );
501
+
502
  if ( $errors )
503
  bp_core_redirect( $bp->displayed_user->domain );
504
  else
522
  *
523
  * Returns the domain for the passed user:
524
  * e.g. http://domain.com/members/andy/
525
+ *
526
  * @package BuddyPress Core
527
  * @global $current_user WordPress global variable containing current logged in user information
528
  * @param user_id The ID of the user.
530
  */
531
  function bp_core_get_user_domain( $user_id ) {
532
  global $bp;
533
+
534
  if ( !$user_id ) return;
535
+
536
  $ud = get_userdata($user_id);
537
+
538
  if ( defined( 'BP_ENABLE_USERNAME_COMPATIBILITY_MODE' ) )
539
  $username = $ud->user_login;
540
  else
541
  $username = $ud->user_nicename;
542
+
543
  /* If we are using a members slug, include it. */
544
  if ( !defined( 'BP_ENABLE_ROOT_PROFILES' ) )
545
  return apply_filters( 'bp_core_get_user_domain', $bp->root_domain . '/' . BP_MEMBERS_SLUG . '/' . $username . '/' );
546
  else
547
+ return apply_filters( 'bp_core_get_user_domain', $bp->root_domain . '/' . $username . '/' );
548
  }
549
 
550
  /**
552
  *
553
  * Returns the domain for the root blog.
554
  * eg: http://domain.com/ OR https://domain.com
555
+ *
556
  * @package BuddyPress Core
557
  * @uses get_blog_option() WordPress function to fetch blog meta.
558
  * @return $domain The domain URL for the blog.
559
  */
560
  function bp_core_get_root_domain() {
561
  global $current_blog;
562
+
563
  if ( defined( 'BP_ENABLE_MULTIBLOG' ) )
564
  $domain = get_blog_option( $current_blog->blog_id, 'siteurl' );
565
  else
573
  *
574
  * Returns the user id for the user that is currently being displayed.
575
  * eg: http://andy.domain.com/ or http://domain.com/andy/
576
+ *
577
  * @package BuddyPress Core
578
  * @global $current_blog WordPress global containing information and settings for the current blog being viewed.
579
  * @uses bp_core_get_userid_from_user_login() Returns the user id for the username passed
587
  * bp_core_new_nav_item()
588
  *
589
  * Adds a navigation item to the main navigation array used in BuddyPress themes.
590
+ *
591
  * @package BuddyPress Core
592
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
593
  */
611
  /* If we don't have the required info we need, don't create this subnav item */
612
  if ( empty($name) || empty($slug) )
613
  return false;
614
+
615
  /* If this is for site admins only and the user is not one, don't create the subnav item */
616
  if ( $site_admin_only && !is_site_admin() )
617
  return false;
618
+
619
  if ( empty( $item_css_id ) )
620
  $item_css_id = $slug;
621
 
634
  */
635
  if ( !$show_for_displayed_user && !bp_is_home() )
636
  return false;
637
+
638
  /***
639
  * If we are not viewing a user, and this is a root component, don't attach the
640
  * default subnav function so we can display a directory or something else.
657
  * bp_core_new_nav_default()
658
  *
659
  * Modify the default subnav item to load when a top level nav item is clicked.
660
+ *
661
  * @package BuddyPress Core
662
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
663
  */
664
  function bp_core_new_nav_default( $args = '' ) {
665
  global $bp;
666
+
667
  $defaults = array(
668
  'parent_slug' => false, // Slug of the parent
669
  'screen_function' => false, // The name of the function to run when clicked
689
  *
690
  * We can only sort nav items by their position integer at a later point in time, once all
691
  * plugins have registered their navigation items.
692
+ *
693
  * @package BuddyPress Core
694
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
695
  */
696
  function bp_core_sort_nav_items() {
697
  global $bp;
698
+
699
  if ( empty( $bp->bp_nav ) || !is_array( $bp->bp_nav ) )
700
  return false;
701
+
702
  foreach ( $bp->bp_nav as $slug => $nav_item ) {
703
  if ( empty( $temp[$nav_item['position']]) )
704
  $temp[$nav_item['position']] = $nav_item;
707
  do {
708
  $nav_item['position']++;
709
  } while ( !empty( $temp[$nav_item['position']] ) );
710
+
711
  $temp[$nav_item['position']] = $nav_item;
712
  }
713
  }
714
+
715
  ksort( $temp );
716
+ $bp->bp_nav = &$temp;
717
  }
718
  add_action( 'wp_head', 'bp_core_sort_nav_items' );
719
 
721
  * bp_core_remove_nav_item()
722
  *
723
  * Removes a navigation item from the main navigation array.
724
+ *
725
  * @package BuddyPress Core
726
  * @param $slug The slug of the sub navigation item.
727
  */
735
  * bp_core_new_subnav_item()
736
  *
737
  * Adds a navigation item to the sub navigation array used in BuddyPress themes.
738
+ *
739
  * @package BuddyPress Core
740
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
741
  */
753
  'position' => 90, // Index of where this nav item should be positioned
754
  'screen_function' => false // The name of the function to run when clicked
755
  );
756
+
757
  $r = wp_parse_args( $args, $defaults );
758
  extract( $r, EXTR_SKIP );
759
 
760
  /* If we don't have the required info we need, don't create this subnav item */
761
  if ( empty($name) || empty($slug) || empty($parent_slug) || empty($parent_url) || empty($screen_function) )
762
  return false;
763
+
764
  /* If this is for site admins only and the user is not one, don't create the subnav item */
765
  if ( $site_admin_only && !is_site_admin() )
766
  return false;
767
+
768
  if ( empty( $item_css_id ) )
769
  $item_css_id = $slug;
770
+
771
  $bp->bp_options_nav[$parent_slug][$slug] = array(
772
  'name' => $name,
773
  'link' => $parent_url . $slug . '/',
776
  'position' => $position,
777
  'user_has_access' => $user_has_access
778
  );
779
+
780
  if ( ( $bp->current_action == $slug && $bp->current_component == $parent_slug ) && $user_has_access ) {
781
  if ( !is_object( $screen_function[0] ) )
782
  add_action( 'wp', $screen_function, 3 );
790
 
791
  if ( empty( $bp->bp_options_nav ) || !is_array( $bp->bp_options_nav ) )
792
  return false;
793
+
794
  foreach ( $bp->bp_options_nav as $parent_slug => $subnav_items ) {
795
  if ( !is_array( $subnav_items ) )
796
  continue;
797
+
798
  foreach ( $subnav_items as $subnav_item ) {
799
  if ( empty( $temp[$subnav_item['position']]) )
800
  $temp[$subnav_item['position']] = $subnav_item;
803
  do {
804
  $subnav_item['position']++;
805
  } while ( !empty( $temp[$subnav_item['position']] ) );
806
+
807
  $temp[$subnav_item['position']] = $subnav_item;
808
  }
809
  }
818
  * bp_core_remove_subnav_item()
819
  *
820
  * Removes a navigation item from the sub navigation array used in BuddyPress themes.
821
+ *
822
  * @package BuddyPress Core
823
  * @param $parent_id The id of the parent navigation item.
824
  * @param $slug The slug of the sub navigation item.
825
  */
826
  function bp_core_remove_subnav_item( $parent_id, $slug ) {
827
  global $bp;
828
+
829
  unset( $bp->bp_options_nav[$parent_id][$slug] );
830
  }
831
 
833
  * bp_core_reset_subnav_items()
834
  *
835
  * Clear the subnav items for a specific nav item.
836
+ *
837
  * @package BuddyPress Core
838
  * @param $parent_id The id of the parent navigation item.
839
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
853
  * bp_core_load_template( 'profile/edit-profile' );
854
  * Loads:
855
  * wp-content/member-themes/[activated_theme]/profile/edit-profile.php
856
+ *
857
  * @package BuddyPress Core
858
  * @param $username str Username to check.
859
  * @global $wpdb WordPress DB access object.
880
  * Friends: http://domain.com/members/andy/friends
881
  * http://community.domain.com/members/andy/friends
882
  * http://domain.com/wpmu/members/andy/friends
883
+ *
884
  * @package BuddyPress Core
885
  * @param $slug str The slug of the component
886
  * @global $bp BuddyPress global settings
895
  * bp_core_get_random_member()
896
  *
897
  * Returns the user_id for a user based on their username.
898
+ *
899
  * @package BuddyPress Core
900
  * @param $username str Username to check.
901
  * @global $wpdb WordPress DB access object.
904
  */
905
  function bp_core_get_random_member() {
906
  global $bp, $wpdb;
907
+
908
  if ( isset( $_GET['random-member'] ) ) {
909
  $user = BP_Core_User::get_random_users(1);
910
+
911
  $ud = get_userdata( $user['users'][0]->user_id );
912
+
913
+ bp_core_redirect( bp_core_get_user_domain( $user['users'][0]->user_id ) );
914
  }
915
  }
916
  add_action( 'wp', 'bp_core_get_random_member' );
919
  * bp_core_get_userid()
920
  *
921
  * Returns the user_id for a user based on their username.
922
+ *
923
  * @package BuddyPress Core
924
  * @param $username str Username to check.
925
  * @global $wpdb WordPress DB access object.
928
  */
929
  function bp_core_get_userid( $username ) {
930
  global $wpdb;
931
+
932
  if ( !empty( $username ) )
933
+ return apply_filters( 'bp_core_get_userid', $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . CUSTOM_USER_TABLE . " WHERE user_login = %s", $username ) ) );
934
  }
935
 
936
  /**
937
  * bp_core_get_username()
938
  *
939
  * Returns the username for a user based on their user id.
940
+ *
941
  * @package BuddyPress Core
942
  * @param $uid int User ID to check.
943
  * @global $userdata WordPress user data for the current logged in user.
947
  */
948
  function bp_core_get_username( $uid ) {
949
  global $userdata;
950
+
951
  if ( $uid == $userdata->ID )
952
  $username = __( 'You', 'buddypress' );
953
+
954
  if ( !$ud = get_userdata($uid) )
955
  return false;
956
+
957
+ $username = $ud->user_login;
958
 
959
  return apply_filters( 'bp_core_get_username', $username );
960
  }
963
  * bp_core_get_userurl()
964
  *
965
  * Returns the URL with no HTML markup for a user based on their user id.
966
+ *
967
  * @package BuddyPress Core
968
  * @param $uid int User ID to check.
969
  * @global $userdata WordPress user data for the current logged in user.
973
  */
974
  function bp_core_get_userurl( $uid ) {
975
  global $bp;
976
+
977
  if ( !is_numeric($uid) )
978
  return false;
979
 
984
  * bp_core_get_user_email()
985
  *
986
  * Returns the email address for the user based on user ID
987
+ *
988
  * @package BuddyPress Core
989
  * @param $uid int User ID to check.
990
  * @uses get_userdata() WordPress function to fetch the userdata for a user ID
1002
  * Returns a HTML formatted link for a user with the user's full name as the link text.
1003
  * eg: <a href="http://andy.domain.com/">Andy Peatling</a>
1004
  * Optional parameters will return just the name, or just the URL, or disable "You" text when
1005
+ * user matches the logged in user.
1006
  *
1007
  * [NOTES: This function needs to be cleaned up or split into separate functions]
1008
+ *
1009
  * @package BuddyPress Core
1010
  * @param $uid int User ID to check.
1011
  * @param $no_anchor bool Disable URL and HTML and just return full name. Default false.
1020
  */
1021
  function bp_core_get_userlink( $user_id, $no_anchor = false, $just_link = false, $deprecated = false, $with_s = false ) {
1022
  global $userdata;
1023
+
1024
  $ud = get_userdata($user_id);
1025
+
1026
  if ( !$ud )
1027
  return false;
1028
 
1029
+ if ( function_exists('bp_fetch_user_fullname') ) {
1030
  $display_name = bp_core_get_user_displayname( $user_id );
1031
+
1032
  if ( $with_s )
1033
  $display_name = sprintf( __( "%s's", 'buddypress' ), $display_name );
1034
+
1035
  } else {
1036
  $display_name = $ud->display_name;
1037
  }
1038
+
1039
  if ( $no_anchor )
1040
  return $display_name;
1041
 
1042
  if ( !$url = bp_core_get_userurl($user_id) )
1043
  return false;
1044
+
1045
  if ( $just_link )
1046
  return $url;
1047
 
1048
+ return '<a href="' . $url . '">' . $display_name . '</a>';
1049
  }
1050
 
1051
 
1054
  *
1055
  * Fetch the display name for a user. This will use the "Name" field in xprofile if it is installed.
1056
  * Otherwise, it will fall back to the normal WP display_name, or user_nicename, depending on what has been set.
1057
+ *
1058
  * @package BuddyPress Core
1059
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
1060
  * @uses wp_cache_get() Will try and fetch the value from the cache, rather than querying the DB again.
1065
  */
1066
  function bp_core_get_user_displayname( $user_id ) {
1067
  global $bp;
1068
+
1069
  if ( !$user_id )
1070
  return false;
1071
+
1072
  if ( !$fullname = wp_cache_get( 'bp_user_fullname_' . $user_id, 'bp' ) ) {
1073
  if ( function_exists('xprofile_install') ) {
1074
  $fullname = xprofile_get_field_data( 1, $user_id );
1085
  }
1086
  } else {
1087
  $ud = get_userdata($user_id);
1088
+
1089
  if ( !empty( $ud->display_name ) )
1090
  $fullname = $ud->display_name;
1091
  else
1092
  $fullname = $ud->user_nicename;
1093
  }
1094
+
1095
  wp_cache_set( 'bp_user_fullname_' . $user_id, $fullname, 'bp' );
1096
  }
1097
+
1098
  return apply_filters( 'bp_core_get_user_displayname', $fullname );
1099
  }
1100
  add_filter( 'bp_core_get_user_displayname', 'strip_tags', 1 );
1106
  * bp_core_get_userlink_by_email()
1107
  *
1108
  * Returns the user link for the user based on user email address
1109
+ *
1110
  * @package BuddyPress Core
1111
  * @param $email str The email address for the user.
1112
  * @uses bp_core_get_userlink() BuddyPress function to get a userlink by user ID.
1122
  * bp_core_get_userlink_by_username()
1123
  *
1124
  * Returns the user link for the user based on user's username
1125
+ *
1126
  * @package BuddyPress Core
1127
  * @param $username str The username for the user.
1128
  * @uses bp_core_get_userlink() BuddyPress function to get a userlink by user ID.
1130
  */
1131
  function bp_core_get_userlink_by_username( $username ) {
1132
  global $wpdb;
1133
+
1134
+ $user_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . CUSTOM_USER_TABLE . " WHERE user_login = %s", $username ) );
1135
  return apply_filters( 'bp_core_get_userlink_by_username', bp_core_get_userlink( $user_id, false, false, true ) );
1136
  }
1137
 
1146
  */
1147
  function bp_core_is_user_spammer( $user_id ) {
1148
  global $wpdb;
1149
+
1150
+ return apply_filters( 'bp_core_is_user_spammer', (int) $wpdb->get_var( $wpdb->prepare( "SELECT spam FROM " . CUSTOM_USER_TABLE . " WHERE ID = %d", $user_id ) ) );
1151
  }
1152
 
1153
  /**
1161
  */
1162
  function bp_core_is_user_deleted( $user_id ) {
1163
  global $wpdb;
1164
+
1165
+ return apply_filters( 'bp_core_is_user_spammer', (int) $wpdb->get_var( $wpdb->prepare( "SELECT deleted FROM " . CUSTOM_USER_TABLE . " WHERE ID = %d", $user_id ) ) );
1166
  }
1167
 
1168
  /**
1171
  function bp_core_format_time( $time, $just_date = false ) {
1172
  if ( !$time )
1173
  return false;
1174
+
1175
  $date = date( "F j, Y ", $time );
1176
+
1177
  if ( !$just_date ) {
1178
  $date .= __('at', 'buddypress') . date( ' g:iA', $time );
1179
  }
1180
+
1181
  return $date;
1182
  }
1183
 
1186
  * bp_core_add_message()
1187
  *
1188
  * Adds a feedback (error/success) message to the WP cookie so it can be displayed after the page reloads.
1189
+ *
1190
  * @package BuddyPress Core
1191
  */
1192
  function bp_core_add_message( $message, $type = false ) {
1193
  global $bp;
1194
+
1195
  if ( !$type )
1196
  $type = 'success';
1197
+
1198
  /* Send the values to the cookie for page reload display */
1199
  @setcookie( 'bp-message', $message, time()+60*60*24, COOKIEPATH );
1200
  @setcookie( 'bp-message-type', $type, time()+60*60*24, COOKIEPATH );
1201
+
1202
  /***
1203
  * Send the values to the $bp global so we can still output messages
1204
  * without a page reload
1215
  *
1216
  * After the message is displayed, it removes the message vars from the cookie so that the message
1217
  * is not shown to the user multiple times.
1218
+ *
1219
  * @package BuddyPress Core
1220
  * @global $bp_message The message text
1221
  * @global $bp_message_type The type of message (error/success)
1226
 
1227
  if ( empty( $bp->template_message ) )
1228
  $bp->template_message = $_COOKIE['bp-message'];
1229
+
1230
  if ( empty( $bp->template_message_type ) )
1231
  $bp->template_message_type = $_COOKIE['bp-message-type'];
1232
 
1233
  add_action( 'template_notices', 'bp_core_render_message' );
1234
+
1235
  @setcookie( 'bp-message', false, time() - 1000, COOKIEPATH );
1236
  @setcookie( 'bp-message-type', false, time() - 1000, COOKIEPATH );
1237
  }
1242
  *
1243
  * Renders a feedback message (either error or success message) to the theme template.
1244
  * The hook action 'template_notices' is used to call this function, it is not called directly.
1245
+ *
1246
  * @package BuddyPress Core
1247
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
1248
  */
1249
  function bp_core_render_message() {
1250
  global $bp;
1251
+
1252
  if ( $bp->template_message ) {
1253
  $type = ( 'success' == $bp->template_message_type ) ? 'updated' : 'error';
1254
  ?>
1257
  </div>
1258
  <?php
1259
  do_action( 'bp_core_render_message' );
1260
+ }
1261
  }
1262
 
1263
  /**
1264
  * bp_core_time_since()
1265
  *
1266
  * Based on function created by Dunstan Orchard - http://1976design.com
1267
+ *
1268
  * This function will return an English representation of the time elapsed
1269
  * since a given date.
1270
  * eg: 2 hours and 50 minutes
1271
  * eg: 4 days
1272
  * eg: 4 weeks and 6 days
1273
+ *
1274
  * @package BuddyPress Core
1275
  * @param $older_date int Unix timestamp of date you want to calculate the time since for
1276
  * @param $newer_date int Unix timestamp of date to compare older date to. Default false (current time).
1288
  array( 60 , __( 'minute', 'buddypress' ), __( 'minutes', 'buddypress' ) ),
1289
  array( 1, __( 'second', 'buddypress' ), __( 'seconds', 'buddypress' ) )
1290
  );
1291
+
1292
  $older_date = strtotime( gmdate( 'Y-m-d H:i:s', $older_date ) );
1293
 
1294
  /* $newer_date will equal false if we want to know the time elapsed between a date and the current time */
1295
  /* $newer_date will have a value if we want to work out time elapsed between two known dates */
1296
  $newer_date = ( !$newer_date ) ? ( strtotime( gmdate( 'Y-m-d H:i:s' ) ) + ( 60*60*0 ) ) : $newer_date;
1297
+
1298
  /* Difference in seconds */
1299
  $since = $newer_date - $older_date;
1300
+
1301
  if ( 0 > $since )
1302
  return __( '[Use GMT Timezone]', 'buddypress' );
1303
 
1324
  if ( $i + 2 < $j ) {
1325
  $seconds2 = $chunks[$i + 1][0];
1326
  $name2 = $chunks[$i + 1][1];
1327
+
1328
  //if ( $chunks[$i + 1][1] == __( 'second', 'buddypress' ) ) return $output;
1329
+
1330
  if ( ( $count2 = floor( ( $since - ( $seconds * $count ) ) / $seconds2 ) ) != 0 ) {
1331
  /* Add to output var */
1332
  $output .= ( 1 == $count2 ) ? _c( ',|Separator in time since', 'buddypress' ) . ' 1 '. $chunks[$i + 1][1] : _c( ',|Separator in time since', 'buddypress' ) . ' ' . $count2 . ' ' . $chunks[$i + 1][2];
1346
  * Record user activity to the database. Many functions use a "last active" feature to
1347
  * show the length of time since the user was last active.
1348
  * This function will update that time as a usermeta setting for the user every 5 minutes.
1349
+ *
1350
  * @package BuddyPress Core
1351
  * @global $userdata WordPress user data for the current logged in user.
1352
  * @uses update_usermeta() WordPress function to update user metadata in the usermeta table.
1353
  */
1354
  function bp_core_record_activity() {
1355
  global $bp;
1356
+
1357
  if ( !is_user_logged_in() )
1358
  return false;
1359
+
1360
  $activity = get_usermeta( $bp->loggedin_user->id, 'last_activity' );
1361
+
1362
  if ( '' == $activity || time() >= strtotime( '+5 minutes', $activity ) )
1363
  update_usermeta( $bp->loggedin_user->id, 'last_activity', time() );
1364
  }
1369
  * bp_core_get_last_activity()
1370
  *
1371
  * Formats last activity based on time since date given.
1372
+ *
1373
  * @package BuddyPress Core
1374
  * @param last_activity_date The date of last activity.
1375
  * @param $before The text to prepend to the activity time since figure.
1381
  $last_active = __( 'not recently active', 'buddypress' );
1382
  } else {
1383
  if ( strstr( $last_activity_date, '-' ) ) {
1384
+ $last_active = bp_core_time_since( strtotime( $last_activity_date ) );
1385
  } else {
1386
+ $last_active = bp_core_time_since( $last_activity_date );
1387
  }
1388
+
1389
  $last_active = sprintf( $string, $last_active );
1390
  }
1391
+
1392
  return $last_active;
1393
  }
1394
 
1397
  * bp_core_get_all_posts_for_user()
1398
  *
1399
  * Fetch every post that is authored by the given user for the current blog.
1400
+ *
1401
  * @package BuddyPress Core
1402
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
1403
  * @global $wpdb WordPress user data for the current logged in user.
1405
  */
1406
  function bp_core_get_all_posts_for_user( $user_id = null ) {
1407
  global $bp, $wpdb;
1408
+
1409
  if ( !$user_id )
1410
  $user_id = $bp->displayed_user->id;
1411
+
1412
  return $wpdb->get_col( $wpdb->prepare( "SELECT post_id FROM $wpdb->posts WHERE post_author = %d AND post_status = 'publish' AND post_type = 'post'", $user_id ) );
1413
  }
1414
 
1417
  * bp_core_get_site_path()
1418
  *
1419
  * Get the path of of the current site.
1420
+ *
1421
  * @package BuddyPress Core
1422
  * @global $comment WordPress comment global for the current comment.
1423
  * @uses bp_core_get_userlink_by_email() Fetches a userlink via email address.
1424
  */
1425
  function bp_core_get_site_path() {
1426
  global $current_site;
1427
+
1428
  return $current_site->path;
1429
  }
1430
 
1432
  * bp_core_redirect()
1433
  *
1434
  * Performs a status safe wp_redirect() that is compatible with bp_catch_uri()
1435
+ *
1436
  * @package BuddyPress Core
1437
  * @global $bp_no_status_set Makes sure that there are no conflicts with status_header() called in bp_core_do_catch_uri()
1438
  * @uses get_themes()
1440
  */
1441
  function bp_core_redirect( $location, $status = 302 ) {
1442
  global $bp_no_status_set;
1443
+
1444
+ // Make sure we don't call status_header() in bp_core_do_catch_uri()
1445
  // as this conflicts with wp_redirect()
1446
  $bp_no_status_set = true;
1447
+
1448
  wp_redirect( $location, $status );
1449
  die;
1450
  }
1453
  * bp_core_referrer()
1454
  *
1455
  * Returns the referrer URL without the http(s)://
1456
+ *
1457
  * @package BuddyPress Core
1458
  * @return The referrer URL
1459
  */
1470
  * blog names on a subdirectory installation.
1471
  *
1472
  * For example, it would stop someone creating a blog with the slug "groups".
1473
+ *
1474
  * @package BuddyPress Core
1475
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
1476
  */
1477
  function bp_core_add_illegal_names() {
1478
  global $bp;
1479
+
1480
  $current = maybe_unserialize( get_site_option( 'illegal_names' ) );
1481
  $bp_illegal_names = $bp->root_components;
1482
+
1483
  if ( is_array( $current ) ) {
1484
  foreach( $bp_illegal_names as $bp_illegal_name ) {
1485
  if ( !in_array( $bp_illegal_name, $current ) )
1498
  * bp_core_email_from_name_filter()
1499
  *
1500
  * Sets the "From" name in emails sent to the name of the site and not "WordPress"
1501
+ *
1502
  * @package BuddyPress Core
1503
  * @uses get_blog_option() fetches the value for a meta_key in the wp_X_options table
1504
  * @return The blog name for the root blog
1513
  * bp_core_email_from_name_filter()
1514
  *
1515
  * Sets the "From" address in emails sent
1516
+ *
1517
  * @package BuddyPress Core
1518
  * @global $current_site Object containing current site metadata
1519
  * @return noreply@sitedomain email address
1529
  * bp_core_delete_account()
1530
  *
1531
  * Allows a user to completely remove their account from the system
1532
+ *
1533
  * @package BuddyPress Core
1534
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
1535
  * @uses check_admin_referer() Checks for a valid security nonce.
1543
  $user_id = $bp->loggedin_user->id;
1544
 
1545
  /* Make sure account deletion is not disabled */
1546
+ if ( (int)get_site_option( 'bp-disable-account-deletion' ) )
1547
  return false;
1548
 
1549
  /* Site admins should not be allowed to be deleted */
1561
  * bp_core_search_site()
1562
  *
1563
  * A javascript free implementation of the search functions in BuddyPress
1564
+ *
1565
  * @package BuddyPress Core
1566
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
1567
  * @param $slug The slug to redirect to for searching.
1572
  if ( $bp->current_component == BP_SEARCH_SLUG ) {
1573
  $search_terms = $_POST['search-terms'];
1574
  $search_which = $_POST['search-which'];
1575
+
1576
  if ( !$slug || empty( $slug ) ) {
1577
  switch ( $search_which ) {
1578
  case 'members': default:
1593
  break;
1594
  }
1595
  }
1596
+
1597
  $search_url = apply_filters( 'bp_core_search_site', site_url( $slug . $var . urlencode($search_terms) ), $search_terms );
1598
+
1599
  bp_core_redirect( $search_url );
1600
  }
1601
  }
1604
 
1605
  /**
1606
  * bp_core_ucfirst()
1607
+ *
1608
  * Localization safe ucfirst() support.
1609
+ *
1610
  * @package BuddyPress Core
1611
  */
1612
  function bp_core_ucfirst( $str ) {
1613
  if ( function_exists( 'mb_strtoupper' ) && function_exists( 'mb_substr' ) ) {
1614
  $fc = mb_strtoupper( mb_substr( $str, 0, 1 ) );
1615
+ return $fc.mb_substr( $str, 1 );
1616
  } else {
1617
  return ucfirst( $str );
1618
  }
1621
 
1622
  /**
1623
  * bp_core_strip_username_spaces()
1624
+ *
1625
  * Strips spaces from usernames that are created using add_user() and wp_insert_user()
1626
+ *
1627
  * @package BuddyPress Core
1628
  */
1629
  function bp_core_strip_username_spaces( $username ) {
1634
 
1635
  /**
1636
  * bp_core_clear_cache()
1637
+ * REQUIRES WP-SUPER-CACHE
1638
+ *
1639
  * When wp-super-cache is installed this function will clear cached pages
1640
  * so that success/error messages are not cached, or time sensitive content.
1641
+ *
1642
  * @package BuddyPress Core
1643
  */
1644
  function bp_core_clear_cache() {
1645
  global $cache_path, $cache_filename;
1646
+
1647
  if ( function_exists( 'prune_super_cache' ) ) {
1648
  do_action( 'bp_core_clear_cache' );
1649
+
1650
+ return prune_super_cache( $cache_path, true );
1651
  }
1652
  }
1653
 
1654
  /**
1655
  * bp_core_print_generation_time()
1656
+ *
1657
  * Prints the generation time in the footer of the site.
1658
+ *
1659
  * @package BuddyPress Core
1660
  */
1661
  function bp_core_print_generation_time() {
1668
 
1669
  /**
1670
  * bp_core_add_admin_menu_page()
1671
+ *
1672
  * A better version of add_admin_menu_page() that allows positioning of menus.
1673
+ *
1674
  * @package BuddyPress Core
1675
  */
1676
  function bp_core_add_admin_menu_page( $args = '' ) {
1688
 
1689
  $r = wp_parse_args( $args, $defaults );
1690
  extract( $r, EXTR_SKIP );
1691
+
1692
  $file = plugin_basename( $file );
1693
 
1694
  $admin_page_hooks[$file] = sanitize_title( $menu_title );
1705
  do {
1706
  $position++;
1707
  } while ( !empty( $menu[$position] ) );
1708
+
1709
  $menu[$position] = array ( $menu_title, $access_level, $file, $page_title, 'menu-top ' . $hookname, $hookname, $icon_url );
1710
 
1711
  $_registered_pages[$hookname] = true;
1718
  *
1719
  * When a user logs in, check if they have been marked as a spammer. If then simply
1720
  * redirect them to the home page and stop them from logging in.
1721
+ *
1722
  * @package BuddyPress Core
1723
  * @param $username The username of the user
1724
  * @uses delete_usermeta() deletes a row from the wp_usermeta table based on meta_key
1725
  */
1726
  function bp_core_boot_spammer( $auth_obj, $username ) {
1727
  global $bp;
1728
+
1729
  $user = get_userdatabylogin( $username );
1730
 
1731
  if ( (int)$user->spam )
1737
  * bp_core_remove_data()
1738
  *
1739
  * Deletes usermeta for the user when the user is deleted.
1740
+ *
1741
  * @package BuddyPress Core
1742
  * @param $user_id The user id for the user to delete usermeta for
1743
  * @uses delete_usermeta() deletes a row from the wp_usermeta table based on meta_key
1755
 
1756
  /**
1757
  * bp_load_buddypress_textdomain()
1758
+ *
1759
  * Load the buddypress translation file for current language
1760
+ *
1761
  * @package BuddyPress Core
1762
  */
1763
  function bp_core_load_buddypress_textdomain() {
1764
  $locale = apply_filters( 'buddypress_locale', get_locale() );
1765
  $mofile = BP_PLUGIN_DIR . "/bp-languages/buddypress-$locale.mo";
1766
+
1767
  if ( file_exists( $mofile ) )
1768
  load_textdomain( 'buddypress', $mofile );
1769
  }
1770
+ add_action ( 'plugins_loaded', 'bp_core_load_buddypress_textdomain', 5 );
1771
 
1772
  function bp_core_add_ajax_hook() {
1773
  /* Theme only, we already have the wp_ajax_ hook firing in wp-admin */
1778
 
1779
  /**
1780
  * bp_core_update_message()
1781
+ *
1782
  * Add an extra update message to the update plugin notification.
1783
+ *
1784
  * @package BuddyPress Core
1785
  */
1786
  function bp_core_update_message() {
1790
 
1791
  /**
1792
  * bp_core_clear_user_object_cache()
1793
+ *
1794
  * Clears all cached objects for a user, or a user is part of.
1795
+ *
1796
  * @package BuddyPress Core
1797
  */
1798
  function bp_core_clear_user_object_cache( $user_id ) {
bp-core/bp-core-activation.php CHANGED
@@ -2,79 +2,79 @@
2
 
3
  function bp_core_screen_activation() {
4
  global $bp, $wpdb;
5
-
6
  if ( BP_ACTIVATION_SLUG != $bp->current_component )
7
  return false;
8
-
9
  /* If we are using a BuddyPress 1.0 theme ignore this. */
10
  if ( file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
11
  return false;
12
-
13
  /* Check if an activation key has been passed */
14
  if ( isset( $_GET['key'] ) ) {
15
-
16
  require_once( ABSPATH . WPINC . '/registration.php' );
17
-
18
  /* Activate the signup */
19
  $signup = apply_filters( 'bp_core_activate_account', wpmu_activate_signup( $_GET['key'] ) );
20
-
21
  /* If there was errors, add a message and redirect */
22
  if ( $signup->errors ) {
23
  bp_core_add_message( __( 'There was an error activating your account, please try again.', 'buddypress' ), 'error' );
24
  bp_core_redirect( $bp->root_domain . '/' . BP_ACTIVATION_SLUG );
25
  }
26
-
27
  /* Set the password */
28
  if ( !empty( $signup['meta']['password'] ) )
29
  $wpdb->update( $wpdb->users, array( 'user_pass' => $signup['meta']['password'] ), array( 'ID' => $signup['user_id'] ), array( '%s' ), array( '%d' ) );
30
-
31
- /* Set any profile data */
32
  if ( function_exists( 'xprofile_set_field_data' ) ) {
33
-
34
  if ( !empty( $signup['meta']['profile_field_ids'] ) ) {
35
  $profile_field_ids = explode( ',', $signup['meta']['profile_field_ids'] );
36
-
37
  foreach( $profile_field_ids as $field_id ) {
38
  $current_field = $signup['meta']["field_{$field_id}"];
39
-
40
  if ( !empty( $current_field ) )
41
  xprofile_set_field_data( $field_id, $signup['user_id'], $current_field );
42
  }
43
  }
44
-
45
  }
46
-
47
  /* Check for an uploaded avatar and move that to the correct user folder */
48
  $hashed_key = wp_hash( $_GET['key'] );
49
-
50
  /* Check if the avatar folder exists. If it does, move rename it, move it and delete the signup avatar dir */
51
  if ( file_exists( WP_CONTENT_DIR . '/blogs.dir/' . BP_ROOT_BLOG . '/files/avatars/signups/' . $hashed_key ) ) {
52
  @rename( WP_CONTENT_DIR . '/blogs.dir/' . BP_ROOT_BLOG . '/files/avatars/signups/' . $hashed_key, WP_CONTENT_DIR . '/blogs.dir/' . BP_ROOT_BLOG . '/files/avatars/' . $signup['user_id'] );
53
  }
54
-
55
  /* Record the new user in the activity streams */
56
  if ( function_exists( 'bp_activity_add' ) ) {
57
  $userlink = bp_core_get_userlink( $signup['user_id'] );
58
-
59
  bp_activity_add( array(
60
  'user_id' => $signup['user_id'],
61
  'content' => apply_filters( 'bp_core_activity_registered_member', sprintf( __( '%s became a registered member', 'buddypress' ), $userlink ), $signup['user_id'] ),
62
  'primary_link' => apply_filters( 'bp_core_actiivty_registered_member_primary_link', $userlink ),
63
  'component_name' => 'profile',
64
- 'component_action' => 'new_member'
65
  ) );
66
  }
67
 
68
  do_action( 'bp_core_account_activated', &$signup, $_GET['key'] );
69
  bp_core_add_message( __( 'Your account is now active!', 'buddypress' ) );
70
-
71
  $bp->activation_complete = true;
72
  }
73
-
74
  if ( '' != locate_template( array( 'registration/activate' ), false ) )
75
- bp_core_load_template( apply_filters( 'bp_core_template_activate', 'activate' ) );
76
  else
77
- bp_core_load_template( apply_filters( 'bp_core_template_activate', 'registration/activate' ) );
78
  }
79
  add_action( 'wp', 'bp_core_screen_activation', 3 );
80
 
@@ -90,24 +90,66 @@ add_action( 'wp', 'bp_core_screen_activation', 3 );
90
  function bp_core_disable_welcome_email() {
91
  if ( '' == locate_template( array( 'registration/register.php' ), false ) && '' == locate_template( array( 'register.php' ), false ) )
92
  return true;
93
-
94
  return false;
95
  }
96
  add_filter( 'wpmu_welcome_user_notification', 'bp_core_disable_welcome_email' );
97
 
98
- /***
99
- * bp_core_filter_activation_email()
100
- *
101
- * Filter the activation email to remove the line stating that another email will be sent
102
- * with the generated login details. This is not the case due to bp_core_disable_welcome_email()
103
- */
104
- function bp_core_filter_activation_email( $email ) {
105
- if ( '' == locate_template( array( 'registration/register.php' ), false ) && '' == locate_template( array( 'register.php' ), false ) )
106
- return $email;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
 
108
- return str_replace( __( 'After you activate, you will receive *another email* with your login.', 'buddypress' ), '', $email );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  }
110
- add_filter( 'wpmu_signup_user_notification_email', 'bp_core_filter_activation_email' );
111
- add_filter( 'wpmu_signup_blog_notification_email', 'bp_core_filter_activation_email' );
112
 
113
  ?>
2
 
3
  function bp_core_screen_activation() {
4
  global $bp, $wpdb;
5
+
6
  if ( BP_ACTIVATION_SLUG != $bp->current_component )
7
  return false;
8
+
9
  /* If we are using a BuddyPress 1.0 theme ignore this. */
10
  if ( file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
11
  return false;
12
+
13
  /* Check if an activation key has been passed */
14
  if ( isset( $_GET['key'] ) ) {
15
+
16
  require_once( ABSPATH . WPINC . '/registration.php' );
17
+
18
  /* Activate the signup */
19
  $signup = apply_filters( 'bp_core_activate_account', wpmu_activate_signup( $_GET['key'] ) );
20
+
21
  /* If there was errors, add a message and redirect */
22
  if ( $signup->errors ) {
23
  bp_core_add_message( __( 'There was an error activating your account, please try again.', 'buddypress' ), 'error' );
24
  bp_core_redirect( $bp->root_domain . '/' . BP_ACTIVATION_SLUG );
25
  }
26
+
27
  /* Set the password */
28
  if ( !empty( $signup['meta']['password'] ) )
29
  $wpdb->update( $wpdb->users, array( 'user_pass' => $signup['meta']['password'] ), array( 'ID' => $signup['user_id'] ), array( '%s' ), array( '%d' ) );
30
+
31
+ /* Set any profile data */
32
  if ( function_exists( 'xprofile_set_field_data' ) ) {
33
+
34
  if ( !empty( $signup['meta']['profile_field_ids'] ) ) {
35
  $profile_field_ids = explode( ',', $signup['meta']['profile_field_ids'] );
36
+
37
  foreach( $profile_field_ids as $field_id ) {
38
  $current_field = $signup['meta']["field_{$field_id}"];
39
+
40
  if ( !empty( $current_field ) )
41
  xprofile_set_field_data( $field_id, $signup['user_id'], $current_field );
42
  }
43
  }
44
+
45
  }
46
+
47
  /* Check for an uploaded avatar and move that to the correct user folder */
48
  $hashed_key = wp_hash( $_GET['key'] );
49
+
50
  /* Check if the avatar folder exists. If it does, move rename it, move it and delete the signup avatar dir */
51
  if ( file_exists( WP_CONTENT_DIR . '/blogs.dir/' . BP_ROOT_BLOG . '/files/avatars/signups/' . $hashed_key ) ) {
52
  @rename( WP_CONTENT_DIR . '/blogs.dir/' . BP_ROOT_BLOG . '/files/avatars/signups/' . $hashed_key, WP_CONTENT_DIR . '/blogs.dir/' . BP_ROOT_BLOG . '/files/avatars/' . $signup['user_id'] );
53
  }
54
+
55
  /* Record the new user in the activity streams */
56
  if ( function_exists( 'bp_activity_add' ) ) {
57
  $userlink = bp_core_get_userlink( $signup['user_id'] );
58
+
59
  bp_activity_add( array(
60
  'user_id' => $signup['user_id'],
61
  'content' => apply_filters( 'bp_core_activity_registered_member', sprintf( __( '%s became a registered member', 'buddypress' ), $userlink ), $signup['user_id'] ),
62
  'primary_link' => apply_filters( 'bp_core_actiivty_registered_member_primary_link', $userlink ),
63
  'component_name' => 'profile',
64
+ 'component_action' => 'new_member'
65
  ) );
66
  }
67
 
68
  do_action( 'bp_core_account_activated', &$signup, $_GET['key'] );
69
  bp_core_add_message( __( 'Your account is now active!', 'buddypress' ) );
70
+
71
  $bp->activation_complete = true;
72
  }
73
+
74
  if ( '' != locate_template( array( 'registration/activate' ), false ) )
75
+ bp_core_load_template( apply_filters( 'bp_core_template_activate', 'activate' ) );
76
  else
77
+ bp_core_load_template( apply_filters( 'bp_core_template_activate', 'registration/activate' ) );
78
  }
79
  add_action( 'wp', 'bp_core_screen_activation', 3 );
80
 
90
  function bp_core_disable_welcome_email() {
91
  if ( '' == locate_template( array( 'registration/register.php' ), false ) && '' == locate_template( array( 'register.php' ), false ) )
92
  return true;
93
+
94
  return false;
95
  }
96
  add_filter( 'wpmu_welcome_user_notification', 'bp_core_disable_welcome_email' );
97
 
98
+ // Notify user of signup success.
99
+ function bp_core_activation_signup_blog_notification( $domain, $path, $title, $user, $user_email, $key, $meta ) {
100
+ global $current_site;
101
+
102
+ // Send email with activation link.
103
+ if ( 'no' == constant( "VHOST" ) ) {
104
+ $activate_url = bp_activation_page( false ) . "?key=$key";
105
+ } else {
106
+ $activate_url = bp_activation_page( false ) ."?key=$key";
107
+ }
108
+
109
+ $activate_url = clean_url($activate_url);
110
+ $admin_email = get_site_option( "admin_email" );
111
+
112
+ if ( empty( $admin_email ) )
113
+ $admin_email = 'support@' . $_SERVER['SERVER_NAME'];
114
+
115
+ $from_name = ( '' == get_site_option( "site_name" ) ) ? 'WordPress' : wp_specialchars( get_site_option( "site_name" ) );
116
+ $message_headers = "MIME-Version: 1.0\n" . "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
117
+ $message = sprintf(__("Thanks for registering! To complete the activation of your account and blog, please click the following link:\n\n%s\n\n\n\nAfter you activate, you can visit your blog here:\n\n%s", 'buddypress' ), $activate_url, clean_url("http://{$domain}{$path}" ) );
118
+ $subject = '[' . $from_name . '] ' . sprintf(__('Activate %s', 'buddypress' ), clean_url('http://' . $domain . $path));
119
+
120
+ wp_mail($user_email, $subject, $message, $message_headers);
121
+
122
+ // Return false to stop the original WPMU function from continuing
123
+ return false;
124
+ }
125
+ add_filter( 'wpmu_signup_blog_notification', 'bp_core_activation_signup_blog_notification', 1, 7 );
126
+
127
+ function bp_core_activation_signup_user_notification( $user, $user_email, $key, $meta ) {
128
+ global $current_site;
129
+
130
+ // Send email with activation link.
131
+ if ( 'no' == constant( "VHOST" ) ) {
132
+ $activate_url = bp_activation_page( false ) . "?key=$key";
133
+ } else {
134
+ $activate_url = bp_activation_page( false ) ."?key=$key";
135
+ }
136
 
137
+ $activate_url = clean_url($activate_url);
138
+ $admin_email = get_site_option( "admin_email" );
139
+
140
+ if ( empty( $admin_email ) )
141
+ $admin_email = 'support@' . $_SERVER['SERVER_NAME'];
142
+
143
+ $from_name = ( '' == get_site_option( "site_name" ) ) ? 'WordPress' : wp_specialchars( get_site_option( "site_name" ) );
144
+ $message_headers = "MIME-Version: 1.0\n" . "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
145
+ $message = sprintf(__("Thanks for registering! To complete the activation of your account please click the following link:\n\n%s\n\n", 'buddypress' ), $activate_url, clean_url("http://{$domain}{$path}" ) );
146
+ $subject = '[' . $from_name . '] ' . sprintf(__('Activate %s', 'buddypress' ), clean_url('http://' . $domain . $path));
147
+
148
+ wp_mail($user_email, $subject, $message, $message_headers);
149
+
150
+ // Return false to stop the original WPMU function from continuing
151
+ return false;
152
  }
153
+ add_filter( 'wpmu_signup_user_notification', 'bp_core_activation_signup_user_notification', 1, 4 );
 
154
 
155
  ?>
bp-core/bp-core-admin.php CHANGED
@@ -3,32 +3,32 @@
3
  function bp_core_admin_settings() {
4
  global $wpdb, $bp, $current_blog;
5
  ?>
6
-
7
  <?php
8
  if ( isset( $_POST['bp-admin-submit'] ) && isset( $_POST['bp-admin'] ) ) {
9
  if ( !check_admin_referer('bp-admin') )
10
  return false;
11
-
12
  // Settings form submitted, now save the settings.
13
  foreach ( $_POST['bp-admin'] as $key => $value ) {
14
-
15
  if ( function_exists( 'xprofile_install' ) ) {
16
  if ( 'bp-xprofile-base-group-name' == $key ) {
17
  $wpdb->query( $wpdb->prepare( "UPDATE {$bp->profile->table_name_groups} SET name = %s WHERE name = %s AND id = 1", $value, stripslashes( get_site_option('bp-xprofile-base-group-name') ) ) );
18
  }
19
-
20
  if ( 'bp-xprofile-fullname-field-name' == $key ) {
21
  $wpdb->query( $wpdb->prepare( "UPDATE {$bp->profile->table_name_fields} SET name = %s WHERE name = %s AND group_id = 1", $value, stripslashes( get_site_option('bp-xprofile-fullname-field-name') ) ) );
22
  }
23
  }
24
-
25
  update_site_option( $key, $value );
26
  }
27
  }
28
  ?>
29
-
30
  <div class="wrap">
31
-
32
  <h2><?php _e( 'BuddyPress Settings', 'buddypress' ) ?></h2>
33
 
34
  <?php if ( isset( $_POST['bp-admin'] ) ) : ?>
@@ -38,7 +38,7 @@ function bp_core_admin_settings() {
38
  <?php endif; ?>
39
 
40
  <form action="" method="post" id="bp-admin-form">
41
-
42
  <table class="form-table">
43
  <tbody>
44
  <?php if ( function_exists( 'xprofile_install' ) ) :?>
@@ -46,7 +46,7 @@ function bp_core_admin_settings() {
46
  <th scope="row"><?php _e( 'Base profile group name', 'buddypress' ) ?>:</th>
47
  <td>
48
  <input name="bp-admin[bp-xprofile-base-group-name]" id="bp-xprofile-base-group-name" value="<?php echo get_site_option('bp-xprofile-base-group-name') ?>" />
49
- </td>
50
  </tr>
51
  <tr>
52
  <th scope="row"><?php _e( 'Full Name field name', 'buddypress' ) ?>:</th>
@@ -59,7 +59,7 @@ function bp_core_admin_settings() {
59
  <td>
60
  <input type="radio" name="bp-admin[bp-disable-profile-sync]"<?php if ( (int)get_site_option( 'bp-disable-profile-sync' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-profile-sync" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
61
  <input type="radio" name="bp-admin[bp-disable-profile-sync]"<?php if ( !(int)get_site_option( 'bp-disable-profile-sync' ) || '' == get_site_option( 'bp-disable-profile-sync' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-profile-sync" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
62
- </td>
63
  </tr>
64
  <?php endif; ?>
65
  <tr>
@@ -67,7 +67,7 @@ function bp_core_admin_settings() {
67
  <td>
68
  <input type="radio" name="bp-admin[hide-loggedout-adminbar]"<?php if ( (int)get_site_option( 'hide-loggedout-adminbar' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-hide-loggedout-adminbar-yes" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
69
  <input type="radio" name="bp-admin[hide-loggedout-adminbar]"<?php if ( !(int)get_site_option( 'hide-loggedout-adminbar' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-hide-loggedout-adminbar-no" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
70
- </td>
71
  </tr>
72
  <tr>
73
  <th scope="row"><?php _e( 'Disable avatar uploads? (Gravatars will still work)', 'buddypress' ) ?>:</th>
@@ -82,15 +82,15 @@ function bp_core_admin_settings() {
82
  <td>
83
  <input type="radio" name="bp-admin[non-friend-wire-posting]"<?php if ( (int)get_site_option( 'non-friend-wire-posting' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-non-friend-wire-post" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
84
  <input type="radio" name="bp-admin[non-friend-wire-posting]"<?php if ( !(int)get_site_option( 'non-friend-wire-posting' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-non-friend-wire-post" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
85
- </td>
86
  </tr>
87
- <?php } ?>
88
  <tr>
89
  <th scope="row"><?php _e( 'Disable user account deletion?', 'buddypress' ) ?>:</th>
90
  <td>
91
  <input type="radio" name="bp-admin[bp-disable-account-deletion]"<?php if ( (int)get_site_option( 'bp-disable-account-deletion' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-account-deletion" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
92
  <input type="radio" name="bp-admin[bp-disable-account-deletion]"<?php if ( !(int)get_site_option( 'bp-disable-account-deletion' ) || '' == get_site_option( 'bp-disable-account-deletion' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-account-deletion" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
93
- </td>
94
  </tr>
95
  <?php if ( function_exists( 'bp_forums_setup') ) : ?>
96
  <tr>
@@ -98,18 +98,18 @@ function bp_core_admin_settings() {
98
  <td>
99
  <input type="radio" name="bp-admin[bp-disable-forum-directory]"<?php if ( (int)get_site_option( 'bp-disable-forum-directory' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-forum-directory" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
100
  <input type="radio" name="bp-admin[bp-disable-forum-directory]"<?php if ( !(int)get_site_option( 'bp-disable-forum-directory' ) || '' == get_site_option( 'bp-disable-forum-directory' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-forum-directory" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
101
- </td>
102
- </tr>
103
  <?php endif; ?>
104
-
105
  <?php $themes = bp_core_get_buddypress_themes() ?>
106
  <?php if ( $themes ) : ?>
107
  <tr>
108
  <th scope="row"><?php _e('Select theme to use for BuddyPress generated pages', 'buddypress' ) ?>:</th>
109
  <td>
110
  <select name="bp-admin[active-member-theme]" id="active-member-theme">
111
- <?php
112
- for ( $i = 0; $i < count($themes); $i++ ) {
113
  if ( $themes[$i]['template'] == get_site_option( 'active-member-theme' ) ) {
114
  $selected = ' selected="selected"';
115
  } else {
@@ -119,7 +119,7 @@ function bp_core_admin_settings() {
119
  <option<?php echo $selected ?> value="<?php echo $themes[$i]['template'] ?>"><?php echo $themes[$i]['name'] ?> (<?php echo $themes[$i]['version'] ?>)</option>
120
  <?php } ?>
121
  </select>
122
- </td>
123
  </tr>
124
  <?php else : ?>
125
  <?php if ( '' == locate_template( array( 'registration/register.php' ), false ) && $current_blog->blog_id == BP_ROOT_BLOG ) : ?>
@@ -128,7 +128,7 @@ function bp_core_admin_settings() {
128
  </div>
129
  <?php endif; ?>
130
  <?php endif; ?>
131
-
132
  <tr>
133
  <th scope="row"><?php _e( 'Default User Avatar', 'buddypress' ) ?></th>
134
  <td>
@@ -146,61 +146,61 @@ function bp_core_admin_settings() {
146
  </table>
147
 
148
  <?php do_action( 'bp_core_admin_screen' ) ?>
149
-
150
  <p class="submit">
151
  <input class="button-primary" type="submit" name="bp-admin-submit" id="bp-admin-submit" value="<?php _e( 'Save Settings', 'buddypress' ) ?>"/>
152
  </p>
153
 
154
  <?php wp_nonce_field( 'bp-admin' ) ?>
155
-
156
  </form>
157
-
158
  </div>
159
-
160
- <?php
161
  }
162
 
163
  function bp_core_admin_component_setup() {
164
  global $wpdb, $bp;
165
  ?>
166
-
167
  <?php
168
  if ( isset( $_POST['bp-admin-component-submit'] ) && isset( $_POST['bp_components'] ) ) {
169
  if ( !check_admin_referer('bp-admin-component-setup') )
170
  return false;
171
-
172
  // Settings form submitted, now save the settings.
173
  foreach ( $_POST['bp_components'] as $key => $value ) {
174
  if ( !(int) $value )
175
- $disabled[$key] = 1;
176
  }
177
  update_site_option( 'bp-deactivated-components', $disabled );
178
  }
179
  ?>
180
-
181
  <div class="wrap">
182
-
183
  <h2><?php _e( 'BuddyPress Component Setup', 'buddypress' ) ?></h2>
184
-
185
  <?php if ( isset( $_POST['bp-admin-component-submit'] ) ) : ?>
186
  <div id="message" class="updated fade">
187
  <p><?php _e( 'Settings Saved', 'buddypress' ) ?></p>
188
  </div>
189
  <?php endif; ?>
190
-
191
  <form action="" method="post" id="bp-admin-component-form">
192
-
193
  <p>
194
- <?php _e(
195
- 'By default, all BuddyPress components are enabled. You can selectively disable any of the
196
  components by using the form below. Your BuddyPress installation will continue to function, however
197
  the features of the disabled components will no longer be accessible to
198
  anyone using the site.
199
  ', 'buddypress' )?>
200
  </p>
201
-
202
  <?php $disabled_components = get_site_option( 'bp-deactivated-components' ); ?>
203
-
204
  <table class="form-table" style="width: 80%">
205
  <tbody>
206
  <?php if ( file_exists( BP_PLUGIN_DIR . '/bp-activity.php') ) : ?>
@@ -209,7 +209,7 @@ function bp_core_admin_component_setup() {
209
  <td>
210
  <input type="radio" name="bp_components[bp-activity.php]" value="1"<?php if ( !isset( $disabled_components['bp-activity.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> &nbsp;
211
  <input type="radio" name="bp_components[bp-activity.php]" value="0"<?php if ( isset( $disabled_components['bp-activity.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
212
- </td>
213
  </tr>
214
  <?php endif; ?>
215
  <?php if ( file_exists( BP_PLUGIN_DIR . '/bp-blogs.php') ) : ?>
@@ -218,7 +218,7 @@ function bp_core_admin_component_setup() {
218
  <td>
219
  <input type="radio" name="bp_components[bp-blogs.php]" value="1"<?php if ( !isset( $disabled_components['bp-blogs.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> &nbsp;
220
  <input type="radio" name="bp_components[bp-blogs.php]" value="0"<?php if ( isset( $disabled_components['bp-blogs.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
221
- </td>
222
  </tr>
223
  <?php endif; ?>
224
  <?php if ( file_exists( BP_PLUGIN_DIR . '/bp-forums.php') ) : ?>
@@ -227,7 +227,7 @@ function bp_core_admin_component_setup() {
227
  <td>
228
  <input type="radio" name="bp_components[bp-forums.php]" value="1"<?php if ( !isset( $disabled_components['bp-forums.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> &nbsp;
229
  <input type="radio" name="bp_components[bp-forums.php]" value="0"<?php if ( isset( $disabled_components['bp-forums.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
230
- </td>
231
  </tr>
232
  <?php endif; ?>
233
  <?php if ( file_exists( BP_PLUGIN_DIR . '/bp-friends.php') ) : ?>
@@ -236,7 +236,7 @@ function bp_core_admin_component_setup() {
236
  <td>
237
  <input type="radio" name="bp_components[bp-friends.php]" value="1"<?php if ( !isset( $disabled_components['bp-friends.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> &nbsp;
238
  <input type="radio" name="bp_components[bp-friends.php]" value="0"<?php if ( isset( $disabled_components['bp-friends.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
239
- </td>
240
  </tr>
241
  <?php endif; ?>
242
  <?php if ( file_exists( BP_PLUGIN_DIR . '/bp-groups.php') ) : ?>
@@ -245,7 +245,7 @@ function bp_core_admin_component_setup() {
245
  <td>
246
  <input type="radio" name="bp_components[bp-groups.php]" value="1"<?php if ( !isset( $disabled_components['bp-groups.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> &nbsp;
247
  <input type="radio" name="bp_components[bp-groups.php]" value="0"<?php if ( isset( $disabled_components['bp-groups.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
248
- </td>
249
  </tr>
250
  <?php endif; ?>
251
  <?php if ( file_exists( BP_PLUGIN_DIR . '/bp-messages.php') ) : ?>
@@ -254,7 +254,7 @@ function bp_core_admin_component_setup() {
254
  <td>
255
  <input type="radio" name="bp_components[bp-messages.php]" value="1"<?php if ( !isset( $disabled_components['bp-messages.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> &nbsp;
256
  <input type="radio" name="bp_components[bp-messages.php]" value="0"<?php if ( isset( $disabled_components['bp-messages.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
257
- </td>
258
  </tr>
259
  <?php endif; ?>
260
  <?php if ( file_exists( BP_PLUGIN_DIR . '/bp-wire.php') ) : ?>
@@ -263,7 +263,7 @@ function bp_core_admin_component_setup() {
263
  <td>
264
  <input type="radio" name="bp_components[bp-wire.php]" value="1"<?php if ( !isset( $disabled_components['bp-wire.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> &nbsp;
265
  <input type="radio" name="bp_components[bp-wire.php]" value="0"<?php if ( isset( $disabled_components['bp-wire.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
266
- </td>
267
  </tr>
268
  <?php endif; ?>
269
  <?php if ( file_exists( BP_PLUGIN_DIR . '/bp-xprofile.php') ) : ?>
@@ -286,18 +286,18 @@ function bp_core_admin_component_setup() {
286
  <?php endif; ?>
287
  </tbody>
288
  </table>
289
-
290
  <p class="submit">
291
  <input class="button-primary" type="submit" name="bp-admin-component-submit" id="bp-admin-component-submit" value="<?php _e( 'Save Settings', 'buddypress' ) ?>"/>
292
  </p>
293
-
294
  <?php wp_nonce_field( 'bp-admin-component-setup' ) ?>
295
-
296
  </form>
297
 
298
  </div>
299
-
300
- <?php
301
  }
302
 
303
  ?>
3
  function bp_core_admin_settings() {
4
  global $wpdb, $bp, $current_blog;
5
  ?>
6
+
7
  <?php
8
  if ( isset( $_POST['bp-admin-submit'] ) && isset( $_POST['bp-admin'] ) ) {
9
  if ( !check_admin_referer('bp-admin') )
10
  return false;
11
+
12
  // Settings form submitted, now save the settings.
13
  foreach ( $_POST['bp-admin'] as $key => $value ) {
14
+
15
  if ( function_exists( 'xprofile_install' ) ) {
16
  if ( 'bp-xprofile-base-group-name' == $key ) {
17
  $wpdb->query( $wpdb->prepare( "UPDATE {$bp->profile->table_name_groups} SET name = %s WHERE name = %s AND id = 1", $value, stripslashes( get_site_option('bp-xprofile-base-group-name') ) ) );
18
  }
19
+
20
  if ( 'bp-xprofile-fullname-field-name' == $key ) {
21
  $wpdb->query( $wpdb->prepare( "UPDATE {$bp->profile->table_name_fields} SET name = %s WHERE name = %s AND group_id = 1", $value, stripslashes( get_site_option('bp-xprofile-fullname-field-name') ) ) );
22
  }
23
  }
24
+
25
  update_site_option( $key, $value );
26
  }
27
  }
28
  ?>
29
+
30
  <div class="wrap">
31
+
32
  <h2><?php _e( 'BuddyPress Settings', 'buddypress' ) ?></h2>
33
 
34
  <?php if ( isset( $_POST['bp-admin'] ) ) : ?>
38
  <?php endif; ?>
39
 
40
  <form action="" method="post" id="bp-admin-form">
41
+
42
  <table class="form-table">
43
  <tbody>
44
  <?php if ( function_exists( 'xprofile_install' ) ) :?>
46
  <th scope="row"><?php _e( 'Base profile group name', 'buddypress' ) ?>:</th>
47
  <td>
48
  <input name="bp-admin[bp-xprofile-base-group-name]" id="bp-xprofile-base-group-name" value="<?php echo get_site_option('bp-xprofile-base-group-name') ?>" />
49
+ </td>
50
  </tr>
51
  <tr>
52
  <th scope="row"><?php _e( 'Full Name field name', 'buddypress' ) ?>:</th>
59
  <td>
60
  <input type="radio" name="bp-admin[bp-disable-profile-sync]"<?php if ( (int)get_site_option( 'bp-disable-profile-sync' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-profile-sync" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
61
  <input type="radio" name="bp-admin[bp-disable-profile-sync]"<?php if ( !(int)get_site_option( 'bp-disable-profile-sync' ) || '' == get_site_option( 'bp-disable-profile-sync' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-profile-sync" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
62
+ </td>
63
  </tr>
64
  <?php endif; ?>
65
  <tr>
67
  <td>
68
  <input type="radio" name="bp-admin[hide-loggedout-adminbar]"<?php if ( (int)get_site_option( 'hide-loggedout-adminbar' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-hide-loggedout-adminbar-yes" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
69
  <input type="radio" name="bp-admin[hide-loggedout-adminbar]"<?php if ( !(int)get_site_option( 'hide-loggedout-adminbar' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-hide-loggedout-adminbar-no" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
70
+ </td>
71
  </tr>
72
  <tr>
73
  <th scope="row"><?php _e( 'Disable avatar uploads? (Gravatars will still work)', 'buddypress' ) ?>:</th>
82
  <td>
83
  <input type="radio" name="bp-admin[non-friend-wire-posting]"<?php if ( (int)get_site_option( 'non-friend-wire-posting' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-non-friend-wire-post" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
84
  <input type="radio" name="bp-admin[non-friend-wire-posting]"<?php if ( !(int)get_site_option( 'non-friend-wire-posting' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-non-friend-wire-post" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
85
+ </td>
86
  </tr>
87
+ <?php } ?>
88
  <tr>
89
  <th scope="row"><?php _e( 'Disable user account deletion?', 'buddypress' ) ?>:</th>
90
  <td>
91
  <input type="radio" name="bp-admin[bp-disable-account-deletion]"<?php if ( (int)get_site_option( 'bp-disable-account-deletion' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-account-deletion" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
92
  <input type="radio" name="bp-admin[bp-disable-account-deletion]"<?php if ( !(int)get_site_option( 'bp-disable-account-deletion' ) || '' == get_site_option( 'bp-disable-account-deletion' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-account-deletion" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
93
+ </td>
94
  </tr>
95
  <?php if ( function_exists( 'bp_forums_setup') ) : ?>
96
  <tr>
98
  <td>
99
  <input type="radio" name="bp-admin[bp-disable-forum-directory]"<?php if ( (int)get_site_option( 'bp-disable-forum-directory' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-forum-directory" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
100
  <input type="radio" name="bp-admin[bp-disable-forum-directory]"<?php if ( !(int)get_site_option( 'bp-disable-forum-directory' ) || '' == get_site_option( 'bp-disable-forum-directory' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-forum-directory" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
101
+ </td>
102
+ </tr>
103
  <?php endif; ?>
104
+
105
  <?php $themes = bp_core_get_buddypress_themes() ?>
106
  <?php if ( $themes ) : ?>
107
  <tr>
108
  <th scope="row"><?php _e('Select theme to use for BuddyPress generated pages', 'buddypress' ) ?>:</th>
109
  <td>
110
  <select name="bp-admin[active-member-theme]" id="active-member-theme">
111
+ <?php
112
+ for ( $i = 0; $i < count($themes); $i++ ) {
113
  if ( $themes[$i]['template'] == get_site_option( 'active-member-theme' ) ) {
114
  $selected = ' selected="selected"';
115
  } else {
119
  <option<?php echo $selected ?> value="<?php echo $themes[$i]['template'] ?>"><?php echo $themes[$i]['name'] ?> (<?php echo $themes[$i]['version'] ?>)</option>
120
  <?php } ?>
121
  </select>
122
+ </td>
123
  </tr>
124
  <?php else : ?>
125
  <?php if ( '' == locate_template( array( 'registration/register.php' ), false ) && $current_blog->blog_id == BP_ROOT_BLOG ) : ?>
128
  </div>
129
  <?php endif; ?>
130
  <?php endif; ?>
131
+
132
  <tr>
133
  <th scope="row"><?php _e( 'Default User Avatar', 'buddypress' ) ?></th>
134
  <td>
146
  </table>
147
 
148
  <?php do_action( 'bp_core_admin_screen' ) ?>
149
+
150
  <p class="submit">
151
  <input class="button-primary" type="submit" name="bp-admin-submit" id="bp-admin-submit" value="<?php _e( 'Save Settings', 'buddypress' ) ?>"/>
152
  </p>
153
 
154
  <?php wp_nonce_field( 'bp-admin' ) ?>
155
+
156
  </form>
157
+
158
  </div>
159
+
160
+ <?php
161
  }
162
 
163
  function bp_core_admin_component_setup() {
164
  global $wpdb, $bp;
165
  ?>
166
+
167
  <?php
168
  if ( isset( $_POST['bp-admin-component-submit'] ) && isset( $_POST['bp_components'] ) ) {
169
  if ( !check_admin_referer('bp-admin-component-setup') )
170
  return false;
171
+
172
  // Settings form submitted, now save the settings.
173
  foreach ( $_POST['bp_components'] as $key => $value ) {
174
  if ( !(int) $value )
175
+ $disabled[$key] = 1;
176
  }
177
  update_site_option( 'bp-deactivated-components', $disabled );
178
  }
179
  ?>
180
+
181
  <div class="wrap">
182
+
183
  <h2><?php _e( 'BuddyPress Component Setup', 'buddypress' ) ?></h2>
184
+
185
  <?php if ( isset( $_POST['bp-admin-component-submit'] ) ) : ?>
186
  <div id="message" class="updated fade">
187
  <p><?php _e( 'Settings Saved', 'buddypress' ) ?></p>
188
  </div>
189
  <?php endif; ?>
190
+
191
  <form action="" method="post" id="bp-admin-component-form">
192
+
193
  <p>
194
+ <?php _e(
195
+ 'By default, all BuddyPress components are enabled. You can selectively disable any of the
196
  components by using the form below. Your BuddyPress installation will continue to function, however
197
  the features of the disabled components will no longer be accessible to
198
  anyone using the site.
199
  ', 'buddypress' )?>
200
  </p>
201
+
202
  <?php $disabled_components = get_site_option( 'bp-deactivated-components' ); ?>
203
+
204
  <table class="form-table" style="width: 80%">
205
  <tbody>
206
  <?php if ( file_exists( BP_PLUGIN_DIR . '/bp-activity.php') ) : ?>
209
  <td>
210
  <input type="radio" name="bp_components[bp-activity.php]" value="1"<?php if ( !isset( $disabled_components['bp-activity.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> &nbsp;
211
  <input type="radio" name="bp_components[bp-activity.php]" value="0"<?php if ( isset( $disabled_components['bp-activity.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
212
+ </td>
213
  </tr>
214
  <?php endif; ?>
215
  <?php if ( file_exists( BP_PLUGIN_DIR . '/bp-blogs.php') ) : ?>
218
  <td>
219
  <input type="radio" name="bp_components[bp-blogs.php]" value="1"<?php if ( !isset( $disabled_components['bp-blogs.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> &nbsp;
220
  <input type="radio" name="bp_components[bp-blogs.php]" value="0"<?php if ( isset( $disabled_components['bp-blogs.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
221
+ </td>
222
  </tr>
223
  <?php endif; ?>
224
  <?php if ( file_exists( BP_PLUGIN_DIR . '/bp-forums.php') ) : ?>
227
  <td>
228
  <input type="radio" name="bp_components[bp-forums.php]" value="1"<?php if ( !isset( $disabled_components['bp-forums.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> &nbsp;
229
  <input type="radio" name="bp_components[bp-forums.php]" value="0"<?php if ( isset( $disabled_components['bp-forums.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
230
+ </td>
231
  </tr>
232
  <?php endif; ?>
233
  <?php if ( file_exists( BP_PLUGIN_DIR . '/bp-friends.php') ) : ?>
236
  <td>
237
  <input type="radio" name="bp_components[bp-friends.php]" value="1"<?php if ( !isset( $disabled_components['bp-friends.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> &nbsp;
238
  <input type="radio" name="bp_components[bp-friends.php]" value="0"<?php if ( isset( $disabled_components['bp-friends.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
239
+ </td>
240
  </tr>
241
  <?php endif; ?>
242
  <?php if ( file_exists( BP_PLUGIN_DIR . '/bp-groups.php') ) : ?>
245
  <td>
246
  <input type="radio" name="bp_components[bp-groups.php]" value="1"<?php if ( !isset( $disabled_components['bp-groups.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> &nbsp;
247
  <input type="radio" name="bp_components[bp-groups.php]" value="0"<?php if ( isset( $disabled_components['bp-groups.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
248
+ </td>
249
  </tr>
250
  <?php endif; ?>
251
  <?php if ( file_exists( BP_PLUGIN_DIR . '/bp-messages.php') ) : ?>
254
  <td>
255
  <input type="radio" name="bp_components[bp-messages.php]" value="1"<?php if ( !isset( $disabled_components['bp-messages.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> &nbsp;
256
  <input type="radio" name="bp_components[bp-messages.php]" value="0"<?php if ( isset( $disabled_components['bp-messages.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
257
+ </td>
258
  </tr>
259
  <?php endif; ?>
260
  <?php if ( file_exists( BP_PLUGIN_DIR . '/bp-wire.php') ) : ?>
263
  <td>
264
  <input type="radio" name="bp_components[bp-wire.php]" value="1"<?php if ( !isset( $disabled_components['bp-wire.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> &nbsp;
265
  <input type="radio" name="bp_components[bp-wire.php]" value="0"<?php if ( isset( $disabled_components['bp-wire.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
266
+ </td>
267
  </tr>
268
  <?php endif; ?>
269
  <?php if ( file_exists( BP_PLUGIN_DIR . '/bp-xprofile.php') ) : ?>
286
  <?php endif; ?>
287
  </tbody>
288
  </table>
289
+
290
  <p class="submit">
291
  <input class="button-primary" type="submit" name="bp-admin-component-submit" id="bp-admin-component-submit" value="<?php _e( 'Save Settings', 'buddypress' ) ?>"/>
292
  </p>
293
+
294
  <?php wp_nonce_field( 'bp-admin-component-setup' ) ?>
295
+
296
  </form>
297
 
298
  </div>
299
+
300
+ <?php
301
  }
302
 
303
  ?>
bp-core/bp-core-adminbar.php CHANGED
@@ -2,12 +2,12 @@
2
 
3
  function bp_core_admin_bar() {
4
  global $bp, $wpdb, $current_blog, $doing_admin_bar;
5
-
6
  if ( defined( 'BP_DISABLE_ADMIN_BAR' ) )
7
  return false;
8
-
9
  $doing_admin_bar = true;
10
-
11
  if ( (int)get_site_option( 'hide-loggedout-adminbar' ) && !is_user_logged_in() )
12
  return false;
13
 
@@ -17,7 +17,7 @@ function bp_core_admin_bar() {
17
  do_action( 'bp_adminbar_logo' );
18
 
19
  echo '<ul class="main-nav">';
20
-
21
  // **** Do bp-adminbar-menus Actions ********
22
  do_action( 'bp_adminbar_menus' );
23
 
@@ -28,7 +28,7 @@ function bp_core_admin_bar() {
28
  // **** Default BuddyPress admin bar logo ********
29
  function bp_adminbar_logo() {
30
  global $bp;
31
-
32
  echo '<a href="' . $bp->root_domain . '" id="admin-bar-logo">' . get_blog_option( BP_ROOT_BLOG, 'blogname') . '</a>';
33
  }
34
 
@@ -36,9 +36,9 @@ function bp_adminbar_logo() {
36
  function bp_adminbar_login_menu() {
37
  global $bp;
38
 
39
- if ( !is_user_logged_in() ) {
40
  echo '<li class="bp-login no-arrow"><a href="' . $bp->root_domain . '/wp-login.php?redirect_to=' . urlencode( $bp->root_domain ) . '">' . __( 'Log In', 'buddypress' ) . '</a></li>';
41
-
42
  // Show "Sign Up" link if user registrations are allowed
43
  if ( get_site_option( 'registration' ) != 'none' && get_site_option( 'registration' ) != 'blog' ) {
44
  echo '<li class="bp-signup no-arrow"><a href="' . bp_signup_page(false) . '">' . __( 'Sign Up', 'buddypress' ) . '</a></li>';
@@ -54,45 +54,45 @@ function bp_adminbar_account_menu() {
54
  return false;
55
 
56
  if ( is_user_logged_in() ) {
57
-
58
  echo '<li id="bp-adminbar-account-menu"><a href="' . bp_loggedin_user_domain() . '">';
59
-
60
  echo __( 'My Account', 'buddypress' ) . '</a>';
61
  echo '<ul>';
62
-
63
  /* Loop through each navigation item */
64
  $counter = 0;
65
  foreach( $bp->bp_nav as $nav_item ) {
66
  $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
67
-
68
  echo '<li' . $alt . '>';
69
  echo '<a id="bp-admin-' . $nav_item['css_id'] . '" href="' . $nav_item['link'] . '">' . $nav_item['name'] . '</a>';
70
-
71
  if ( is_array( $bp->bp_options_nav[$nav_item['css_id']] ) ) {
72
  echo '<ul>';
73
  $sub_counter = 0;
74
 
75
  foreach( $bp->bp_options_nav[$nav_item['css_id']] as $subnav_item ) {
76
  $alt = ( 0 == $sub_counter % 2 ) ? ' class="alt"' : '';
77
- echo '<li' . $alt . '><a id="bp-admin-' . $subnav_item['css_id'] . '" href="' . $subnav_item['link'] . '">' . $subnav_item['name'] . '</a></li>';
78
  $sub_counter++;
79
  }
80
  echo '</ul>';
81
  }
82
-
83
  echo '</li>';
84
-
85
  $counter++;
86
  }
87
-
88
  $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
89
 
90
- if ( function_exists('wp_logout_url') ) {
91
- echo '<li' . $alt . '><a id="bp-admin-logout" href="' . wp_logout_url(site_url()) . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>';
92
- } else {
93
- echo '<li' . $alt . '><a id="bp-admin-logout" href="' . site_url() . '/wp-login.php?action=logout&amp;redirect_to=' . site_url() . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>';
94
- }
95
-
96
  echo '</ul>';
97
  echo '</li>';
98
  }
@@ -100,15 +100,15 @@ function bp_adminbar_account_menu() {
100
 
101
  // return a string indicating user's role in that blog
102
  function get_blog_role_for_user( $user, $blog ) {
103
-
104
  // If the user is a site admin, just display admin.
105
- if ( is_site_admin() )
106
  return __( 'Admin', 'buddypress');
107
-
108
  $roles = get_usermeta( $user, 'wp_' . $blog . '_capabilities' );
109
 
110
  if ( isset( $roles['subscriber'] ) )
111
- $role = __( 'Subscriber', 'buddypress' );
112
  elseif ( isset( $roles['contributor'] ) )
113
  $role = __( 'Contributor', 'buddypress' );
114
  elseif ( isset( $roles['author'] ) )
@@ -119,31 +119,31 @@ function get_blog_role_for_user( $user, $blog ) {
119
  $role = __( 'Admin', 'buddypress' );
120
  else
121
  return false;
122
-
123
  return $role;
124
  }
125
 
126
  // *** "My Blogs" Menu ********
127
  function bp_adminbar_blogs_menu() {
128
  if ( is_user_logged_in() ) {
129
- global $bp;
130
-
131
  if ( function_exists('bp_blogs_install') ) {
132
-
133
  if ( !$blogs = wp_cache_get( 'bp_blogs_of_user_' . $bp->loggedin_user->id, 'bp' ) ) {
134
  $blogs = get_blogs_of_user( $bp->loggedin_user->id );
135
  wp_cache_set( 'bp_blogs_of_user_' . $bp->loggedin_user->id, $blogs, 'bp' );
136
  }
137
 
138
  echo '<li id="bp-adminbar-blogs-menu"><a href="' . $bp->loggedin_user->domain . $bp->blogs->slug . '/my-blogs">';
139
-
140
  _e( 'My Blogs', 'buddypress' );
141
-
142
  echo '</a>';
143
-
144
- echo '<ul>';
145
  if ( is_array( $blogs )) {
146
-
147
  $counter = 0;
148
  foreach( $blogs as $blog ) {
149
  $role = get_blog_role_for_user( $bp->loggedin_user->id, $blog->userblog_id );
@@ -156,47 +156,47 @@ function bp_adminbar_blogs_menu() {
156
  echo '<li class="alt"><a href="' . $blog->siteurl . '/wp-admin/">' . __('Dashboard', 'buddypress') . '</a></li>';
157
  echo '<li><a href="' . $blog->siteurl . '/wp-admin/post-new.php">' . __('New Post', 'buddypress') . '</a></li>';
158
  echo '<li class="alt"><a href="' . $blog->siteurl . '/wp-admin/edit.php">' . __('Manage Posts', 'buddypress') . '</a></li>';
159
- echo '<li><a href="' . $blog->siteurl . '/wp-admin/edit-comments.php">' . __('Manage Comments', 'buddypress') . '</a></li>';
160
- if ( 'Admin' == $role ) {
161
- echo '<li class="alt"><a href="' . $blog->siteurl . '/wp-admin/themes.php">' . __('Switch Theme', 'buddypress') . '</a></li>';
162
- }
163
- echo '</ul>';
164
  }
165
  echo '</li>';
166
  $counter++;
167
  }
168
  }
169
-
170
  $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
171
-
172
  if ( bp_blog_signup_enabled() ) {
173
  echo '<li' . $alt . '>';
174
  echo '<a href="' . $bp->loggedin_user->domain . $bp->blogs->slug . '/create-a-blog">' . __('Create a Blog!', 'buddypress') . '</a>';
175
  echo '</li>';
176
  }
177
-
178
  echo '</ul>';
179
  echo '</li>';
180
  }
181
  }
182
- }
183
 
184
  // **** "Notifications" Menu *********
185
- function bp_adminbar_notifications_menu() {
186
  if ( is_user_logged_in() ) {
187
  global $bp;
188
-
189
  echo '<li id="bp-adminbar-notifications-menu"><a href="' . $bp->loggedin_user->domain . '">';
190
  _e( 'Notifications', 'buddypress' );
191
-
192
  if ( $notifications = bp_core_get_notifications_for_user( $bp->loggedin_user->id ) ) { ?>
193
  <span><?php echo count($notifications) ?></span>
194
  <?php
195
  }
196
-
197
  echo '</a>';
198
  echo '<ul>';
199
-
200
  if ( $notifications ) { ?>
201
  <?php $counter = 0; ?>
202
  <?php for ( $i = 0; $i < count($notifications); $i++ ) { ?>
@@ -208,7 +208,7 @@ function bp_adminbar_notifications_menu() {
208
  <li><a href="<?php echo $bp->loggedin_user->domain ?>"><?php _e( 'No new notifications.', 'buddypress' ); ?></a></li>
209
  <?php
210
  }
211
-
212
  echo '</ul>';
213
  echo '</li>';
214
  }
@@ -217,16 +217,16 @@ function bp_adminbar_notifications_menu() {
217
  // **** "Blog Authors" Menu (visible when not logged in) ********
218
  function bp_adminbar_authors_menu() {
219
  global $current_blog;
220
-
221
  if ( $current_blog->blog_id > 1 ) {
222
- $authors = get_users_of_blog();
223
-
224
  if ( is_array( $authors ) ) {
225
  /* This is a blog, render a menu with links to all authors */
226
  echo '<li id="bp-adminbar-authors-menu"><a href="/">';
227
  _e('Blog Authors', 'buddypress');
228
  echo '</a>';
229
-
230
  echo '<ul class="author-list">';
231
  foreach( $authors as $author ) {
232
  $author = new BP_Core_User( $author->user_id );
@@ -245,9 +245,9 @@ function bp_adminbar_authors_menu() {
245
  }
246
  }
247
  }
248
-
249
  // **** "Random" Menu (visible when not logged in) ********
250
- function bp_adminbar_random_menu() {
251
  global $bp; ?>
252
  <li class="align-right" id="bp-adminbar-visitrandom-menu">
253
  <a href="#"><?php _e( 'Visit', 'buddypress' ) ?></a>
@@ -260,9 +260,9 @@ function bp_adminbar_random_menu() {
260
 
261
  <?php if ( function_exists('bp_blogs_install') ) : ?>
262
  <li><a href="<?php echo $bp->root_domain . '/' . $bp->blogs->slug . '/?random-blog' ?>"><?php _e( 'Random Blog', 'buddypress' ) ?></a></li>
263
-
264
  <?php endif; ?>
265
-
266
  <?php do_action( 'bp_adminbar_random_menu' ) ?>
267
  </ul>
268
  </li>
2
 
3
  function bp_core_admin_bar() {
4
  global $bp, $wpdb, $current_blog, $doing_admin_bar;
5
+
6
  if ( defined( 'BP_DISABLE_ADMIN_BAR' ) )
7
  return false;
8
+
9
  $doing_admin_bar = true;
10
+
11
  if ( (int)get_site_option( 'hide-loggedout-adminbar' ) && !is_user_logged_in() )
12
  return false;
13
 
17
  do_action( 'bp_adminbar_logo' );
18
 
19
  echo '<ul class="main-nav">';
20
+
21
  // **** Do bp-adminbar-menus Actions ********
22
  do_action( 'bp_adminbar_menus' );
23
 
28
  // **** Default BuddyPress admin bar logo ********
29
  function bp_adminbar_logo() {
30
  global $bp;
31
+
32
  echo '<a href="' . $bp->root_domain . '" id="admin-bar-logo">' . get_blog_option( BP_ROOT_BLOG, 'blogname') . '</a>';
33
  }
34
 
36
  function bp_adminbar_login_menu() {
37
  global $bp;
38
 
39
+ if ( !is_user_logged_in() ) {
40
  echo '<li class="bp-login no-arrow"><a href="' . $bp->root_domain . '/wp-login.php?redirect_to=' . urlencode( $bp->root_domain ) . '">' . __( 'Log In', 'buddypress' ) . '</a></li>';
41
+
42
  // Show "Sign Up" link if user registrations are allowed
43
  if ( get_site_option( 'registration' ) != 'none' && get_site_option( 'registration' ) != 'blog' ) {
44
  echo '<li class="bp-signup no-arrow"><a href="' . bp_signup_page(false) . '">' . __( 'Sign Up', 'buddypress' ) . '</a></li>';
54
  return false;
55
 
56
  if ( is_user_logged_in() ) {
57
+
58
  echo '<li id="bp-adminbar-account-menu"><a href="' . bp_loggedin_user_domain() . '">';
59
+
60
  echo __( 'My Account', 'buddypress' ) . '</a>';
61
  echo '<ul>';
62
+
63
  /* Loop through each navigation item */
64
  $counter = 0;
65
  foreach( $bp->bp_nav as $nav_item ) {
66
  $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
67
+
68
  echo '<li' . $alt . '>';
69
  echo '<a id="bp-admin-' . $nav_item['css_id'] . '" href="' . $nav_item['link'] . '">' . $nav_item['name'] . '</a>';
70
+
71
  if ( is_array( $bp->bp_options_nav[$nav_item['css_id']] ) ) {
72
  echo '<ul>';
73
  $sub_counter = 0;
74
 
75
  foreach( $bp->bp_options_nav[$nav_item['css_id']] as $subnav_item ) {
76
  $alt = ( 0 == $sub_counter % 2 ) ? ' class="alt"' : '';
77
+ echo '<li' . $alt . '><a id="bp-admin-' . $subnav_item['css_id'] . '" href="' . $subnav_item['link'] . '">' . $subnav_item['name'] . '</a></li>';
78
  $sub_counter++;
79
  }
80
  echo '</ul>';
81
  }
82
+
83
  echo '</li>';
84
+
85
  $counter++;
86
  }
87
+
88
  $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
89
 
90
+ if ( function_exists('wp_logout_url') ) {
91
+ echo '<li' . $alt . '><a id="bp-admin-logout" href="' . wp_logout_url(site_url()) . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>';
92
+ } else {
93
+ echo '<li' . $alt . '><a id="bp-admin-logout" href="' . site_url() . '/wp-login.php?action=logout&amp;redirect_to=' . site_url() . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>';
94
+ }
95
+
96
  echo '</ul>';
97
  echo '</li>';
98
  }
100
 
101
  // return a string indicating user's role in that blog
102
  function get_blog_role_for_user( $user, $blog ) {
103
+
104
  // If the user is a site admin, just display admin.
105
+ if ( is_site_admin() )
106
  return __( 'Admin', 'buddypress');
107
+
108
  $roles = get_usermeta( $user, 'wp_' . $blog . '_capabilities' );
109
 
110
  if ( isset( $roles['subscriber'] ) )
111
+ $role = __( 'Subscriber', 'buddypress' );
112
  elseif ( isset( $roles['contributor'] ) )
113
  $role = __( 'Contributor', 'buddypress' );
114
  elseif ( isset( $roles['author'] ) )
119
  $role = __( 'Admin', 'buddypress' );
120
  else
121
  return false;
122
+
123
  return $role;
124
  }
125
 
126
  // *** "My Blogs" Menu ********
127
  function bp_adminbar_blogs_menu() {
128
  if ( is_user_logged_in() ) {
129
+ global $bp;
130
+
131
  if ( function_exists('bp_blogs_install') ) {
132
+
133
  if ( !$blogs = wp_cache_get( 'bp_blogs_of_user_' . $bp->loggedin_user->id, 'bp' ) ) {
134
  $blogs = get_blogs_of_user( $bp->loggedin_user->id );
135
  wp_cache_set( 'bp_blogs_of_user_' . $bp->loggedin_user->id, $blogs, 'bp' );
136
  }
137
 
138
  echo '<li id="bp-adminbar-blogs-menu"><a href="' . $bp->loggedin_user->domain . $bp->blogs->slug . '/my-blogs">';
139
+
140
  _e( 'My Blogs', 'buddypress' );
141
+
142
  echo '</a>';
143
+
144
+ echo '<ul>';
145
  if ( is_array( $blogs )) {
146
+
147
  $counter = 0;
148
  foreach( $blogs as $blog ) {
149
  $role = get_blog_role_for_user( $bp->loggedin_user->id, $blog->userblog_id );
156
  echo '<li class="alt"><a href="' . $blog->siteurl . '/wp-admin/">' . __('Dashboard', 'buddypress') . '</a></li>';
157
  echo '<li><a href="' . $blog->siteurl . '/wp-admin/post-new.php">' . __('New Post', 'buddypress') . '</a></li>';
158
  echo '<li class="alt"><a href="' . $blog->siteurl . '/wp-admin/edit.php">' . __('Manage Posts', 'buddypress') . '</a></li>';
159
+ echo '<li><a href="' . $blog->siteurl . '/wp-admin/edit-comments.php">' . __('Manage Comments', 'buddypress') . '</a></li>';
160
+ if ( 'Admin' == $role ) {
161
+ echo '<li class="alt"><a href="' . $blog->siteurl . '/wp-admin/themes.php">' . __('Switch Theme', 'buddypress') . '</a></li>';
162
+ }
163
+ echo '</ul>';
164
  }
165
  echo '</li>';
166
  $counter++;
167
  }
168
  }
169
+
170
  $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
171
+
172
  if ( bp_blog_signup_enabled() ) {
173
  echo '<li' . $alt . '>';
174
  echo '<a href="' . $bp->loggedin_user->domain . $bp->blogs->slug . '/create-a-blog">' . __('Create a Blog!', 'buddypress') . '</a>';
175
  echo '</li>';
176
  }
177
+
178
  echo '</ul>';
179
  echo '</li>';
180
  }
181
  }
182
+ }
183
 
184
  // **** "Notifications" Menu *********
185
+ function bp_adminbar_notifications_menu() {
186
  if ( is_user_logged_in() ) {
187
  global $bp;
188
+
189
  echo '<li id="bp-adminbar-notifications-menu"><a href="' . $bp->loggedin_user->domain . '">';
190
  _e( 'Notifications', 'buddypress' );
191
+
192
  if ( $notifications = bp_core_get_notifications_for_user( $bp->loggedin_user->id ) ) { ?>
193
  <span><?php echo count($notifications) ?></span>
194
  <?php
195
  }
196
+
197
  echo '</a>';
198
  echo '<ul>';
199
+
200
  if ( $notifications ) { ?>
201
  <?php $counter = 0; ?>
202
  <?php for ( $i = 0; $i < count($notifications); $i++ ) { ?>
208
  <li><a href="<?php echo $bp->loggedin_user->domain ?>"><?php _e( 'No new notifications.', 'buddypress' ); ?></a></li>
209
  <?php
210
  }
211
+
212
  echo '</ul>';
213
  echo '</li>';
214
  }
217
  // **** "Blog Authors" Menu (visible when not logged in) ********
218
  function bp_adminbar_authors_menu() {
219
  global $current_blog;
220
+
221
  if ( $current_blog->blog_id > 1 ) {
222
+ $authors = get_users_of_blog();
223
+
224
  if ( is_array( $authors ) ) {
225
  /* This is a blog, render a menu with links to all authors */
226
  echo '<li id="bp-adminbar-authors-menu"><a href="/">';
227
  _e('Blog Authors', 'buddypress');
228
  echo '</a>';
229
+
230
  echo '<ul class="author-list">';
231
  foreach( $authors as $author ) {
232
  $author = new BP_Core_User( $author->user_id );
245
  }
246
  }
247
  }
248
+
249
  // **** "Random" Menu (visible when not logged in) ********
250
+ function bp_adminbar_random_menu() {
251
  global $bp; ?>
252
  <li class="align-right" id="bp-adminbar-visitrandom-menu">
253
  <a href="#"><?php _e( 'Visit', 'buddypress' ) ?></a>
260
 
261
  <?php if ( function_exists('bp_blogs_install') ) : ?>
262
  <li><a href="<?php echo $bp->root_domain . '/' . $bp->blogs->slug . '/?random-blog' ?>"><?php _e( 'Random Blog', 'buddypress' ) ?></a></li>
263
+
264
  <?php endif; ?>
265
+
266
  <?php do_action( 'bp_adminbar_random_menu' ) ?>
267
  </ul>
268
  </li>
bp-core/bp-core-avatars.php CHANGED
@@ -31,16 +31,16 @@ if ( !defined( 'BP_AVATAR_DEFAULT' ) )
31
 
32
  if ( !defined( 'BP_AVATAR_DEFAULT_THUMB' ) )
33
  define( 'BP_AVATAR_DEFAULT_THUMB', BP_PLUGIN_URL . '/bp-xprofile/images/none-thumbnail.gif' );
34
-
35
  function bp_core_fetch_avatar( $args = '' ) {
36
  global $bp, $current_blog;
37
-
38
  $defaults = array(
39
  'item_id' => false,
40
  'object' => 'user', // user OR group OR blog OR custom type (if you use filters)
41
  'type' => 'thumb',
42
  'avatar_dir' => false,
43
- 'width' => false,
44
  'height' => false,
45
  'class' => 'avatar',
46
  'css_id' => false,
@@ -49,7 +49,7 @@ function bp_core_fetch_avatar( $args = '' ) {
49
  );
50
 
51
  $params = wp_parse_args( $args, $defaults );
52
- extract( $params, EXTR_SKIP );
53
 
54
  if ( !$item_id ) {
55
  if ( 'user' == $object )
@@ -58,12 +58,12 @@ function bp_core_fetch_avatar( $args = '' ) {
58
  $item_id = $bp->groups->current_group->id;
59
  else if ( 'blog' == $object )
60
  $item_id = $current_blog->id;
61
-
62
  $item_id = apply_filters( 'bp_core_avatar_item_id', $item_id, $object );
63
-
64
  if ( !$item_id ) return false;
65
  }
66
-
67
  if ( !$avatar_dir ) {
68
  if ( 'user' == $object )
69
  $avatar_dir = 'avatars';
@@ -71,31 +71,55 @@ function bp_core_fetch_avatar( $args = '' ) {
71
  $avatar_dir = 'group-avatars';
72
  else if ( 'blog' == $object )
73
  $avatar_dir = 'blog-avatars';
74
-
75
  $avatar_dir = apply_filters( 'bp_core_avatar_dir', $avatar_dir, $object );
76
-
77
- if ( !$avatar_dir ) return false;
78
  }
79
-
80
- if ( !$css_id )
81
- $css_id = $object . '-' . $item_id . '-avatar';
82
-
 
 
 
83
  if ( $width )
84
  $html_width = " width='{$width}'";
85
  else
86
  $html_width = ( 'thumb' == $type ) ? ' width="' . BP_AVATAR_THUMB_WIDTH . '"' : ' width="' . BP_AVATAR_FULL_WIDTH . '"';
87
-
88
  if ( $height )
89
  $html_height = " height='{$height}'";
90
  else
91
  $html_height = ( 'thumb' == $type ) ? ' height="' . BP_AVATAR_THUMB_HEIGHT . '"' : ' height="' . BP_AVATAR_FULL_HEIGHT . '"';
92
-
93
- $avatar_folder_url = apply_filters( 'bp_core_avatar_folder_url', get_blog_option( BP_ROOT_BLOG, 'siteurl' ) . '/' . basename( WP_CONTENT_DIR ) . '/blogs.dir/' . BP_ROOT_BLOG . '/files/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir );
94
- $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', WP_CONTENT_DIR . '/blogs.dir/' . BP_ROOT_BLOG . '/files/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir );
95
-
96
- /* If no avatars have been uploaded for this item, display a gravatar */
97
- if ( !file_exists( $avatar_folder_dir ) && !$no_grav ) {
98
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  if ( empty( $bp->grav_default->{$object} ) )
100
  $default_grav = 'wavatar';
101
  else if ( 'mystery' == $bp->grav_default->{$object} )
@@ -106,41 +130,27 @@ function bp_core_fetch_avatar( $args = '' ) {
106
  if ( $width ) $grav_size = $width;
107
  else if ( 'full' == $type ) $grav_size = BP_AVATAR_FULL_WIDTH;
108
  else if ( 'thumb' == $type ) $grav_size = BP_AVATAR_THUMB_WIDTH;
109
-
110
  if ( 'user' == $object ) {
111
  $ud = get_userdata( $item_id );
112
  $grav_email = $ud->user_email;
113
  } else if ( 'group' == $object || 'blog' == $object ) {
114
  $grav_email = "{$item_id}-{$object}@{$bp->root_domain}";
115
  }
116
-
117
- $grav_email = apply_filters( 'bp_core_gravatar_email', $grav_email, $item_id, $object );
118
  $gravatar = apply_filters( 'bp_gravatar_url', 'http://www.gravatar.com/avatar/' ) . md5( $grav_email ) . '?d=' . $default_grav . '&amp;s=' . $grav_size;
119
-
120
- return apply_filters( 'bp_core_fetch_avatar', "<img src='{$gravatar}' alt='{$alt}' id='{$css_id}' class='{$class}'{$html_width}{$html_height} />", $params );
121
-
122
- } else if ( !file_exists( $avatar_folder_dir ) && $no_grav )
123
  return false;
124
-
125
- /* Set the file names to search for to select the full size or thumbnail image. */
126
- $avatar_name = ( 'full' == $type ) ? '-bpfull' : '-bpthumb';
127
- $legacy_user_avatar_name = ( 'full' == $type ) ? '-avatar2' : '-avatar1';
128
- $legacy_group_avatar_name = ( 'full' == $type ) ? '-groupavatar-full' : '-groupavatar-thumb';
129
-
130
- if ( $av_dir = opendir( $avatar_folder_dir ) ) {
131
- while ( false !== ( $avatar_file = readdir($av_dir) ) ) {
132
- if ( preg_match( "/{$avatar_name}/", $avatar_file ) || preg_match( "/{$legacy_user_avatar_name}/", $avatar_file ) || preg_match( "/{$legacy_group_avatar_name}/", $avatar_file ) )
133
- $avatar_url = $avatar_folder_url . '/' . $avatar_file;
134
- }
135
  }
136
- closedir($av_dir);
137
-
138
- return apply_filters( 'bp_core_fetch_avatar', "<img src='{$avatar_url}' alt='{$alt}' id='{$css_id}' class='{$class}'{$html_width}{$html_height} />", $params );
139
  }
140
 
141
  function bp_core_delete_existing_avatar( $args = '' ) {
142
  global $bp;
143
-
144
  $defaults = array(
145
  'item_id' => false,
146
  'object' => 'user', // user OR group OR blog OR custom type (if you use filters)
@@ -148,8 +158,8 @@ function bp_core_delete_existing_avatar( $args = '' ) {
148
  );
149
 
150
  $args = wp_parse_args( $args, $defaults );
151
- extract( $args, EXTR_SKIP );
152
-
153
  if ( !$item_id ) {
154
  if ( 'user' == $object )
155
  $item_id = $bp->displayed_user->id;
@@ -157,12 +167,12 @@ function bp_core_delete_existing_avatar( $args = '' ) {
157
  $item_id = $bp->groups->current_group->id;
158
  else if ( 'blog' == $object )
159
  $item_id = $current_blog->id;
160
-
161
  $item_id = apply_filters( 'bp_core_avatar_item_id', $item_id, $object );
162
-
163
  if ( !$item_id ) return false;
164
  }
165
-
166
  if ( !$avatar_dir ) {
167
  if ( 'user' == $object )
168
  $avatar_dir = 'avatars';
@@ -170,10 +180,10 @@ function bp_core_delete_existing_avatar( $args = '' ) {
170
  $avatar_dir = 'group-avatars';
171
  else if ( 'blog' == $object )
172
  $avatar_dir = 'blog-avatars';
173
-
174
  $avatar_dir = apply_filters( 'bp_core_avatar_dir', $avatar_dir, $object );
175
-
176
- if ( !$avatar_dir ) return false;
177
  }
178
 
179
  if ( 'user' == $object ) {
@@ -184,7 +194,7 @@ function bp_core_delete_existing_avatar( $args = '' ) {
184
  delete_usermeta( $item_id, 'bp_core_avatar_v2' );
185
  }
186
 
187
- $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', WP_CONTENT_DIR . '/blogs.dir/' . BP_ROOT_BLOG . '/files/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir );
188
 
189
  if ( !file_exists( $avatar_folder_dir ) )
190
  return false;
@@ -192,7 +202,7 @@ function bp_core_delete_existing_avatar( $args = '' ) {
192
  if ( $av_dir = opendir( $avatar_folder_dir ) ) {
193
  while ( false !== ( $avatar_file = readdir($av_dir) ) ) {
194
  if ( ( preg_match( "/-bpfull/", $avatar_file ) || preg_match( "/-bpthumb/", $avatar_file ) ) && '.' != $avatar_file && '..' != $avatar_file )
195
- @unlink( $avatar_folder_dir . '/' . $avatar_file );
196
  }
197
  }
198
  closedir($av_dir);
@@ -206,37 +216,37 @@ function bp_core_delete_existing_avatar( $args = '' ) {
206
 
207
  function bp_core_avatar_handle_upload( $file, $upload_dir_filter ) {
208
  global $bp;
209
-
210
  require_once( ABSPATH . '/wp-admin/includes/image.php' );
211
  require_once( ABSPATH . '/wp-admin/includes/file.php' );
212
-
213
  $uploadErrors = array(
214
- 0 => __("There is no error, the file uploaded with success", 'buddypress'),
215
- 1 => __("Your image was bigger than the maximum allowed file size of: ", 'buddypress') . size_format(BP_AVATAR_ORIGINAL_MAX_FILESIZE),
216
- 2 => __("Your image was bigger than the maximum allowed file size of: ", 'buddypress') . size_format(BP_AVATAR_ORIGINAL_MAX_FILESIZE),
217
- 3 => __("The uploaded file was only partially uploaded", 'buddypress'),
218
- 4 => __("No file was uploaded", 'buddypress'),
219
- 6 => __("Missing a temporary folder", 'buddypress')
220
  );
221
 
222
  if ( !bp_core_check_avatar_upload( $file ) ) {
223
  bp_core_add_message( sprintf( __( 'Your upload failed, please try again. Error was: %s', 'buddypress' ), $uploadErrors[$file['file']['error']] ), 'error' );
224
  return false;
225
  }
226
-
227
  if ( !bp_core_check_avatar_size( $file ) ) {
228
  bp_core_add_message( sprintf( __( 'The file you uploaded is too big. Please upload a file under %s', 'buddypress'), size_format(BP_AVATAR_ORIGINAL_MAX_FILESIZE) ), 'error' );
229
  return false;
230
  }
231
-
232
  if ( !bp_core_check_avatar_type( $file ) ) {
233
  bp_core_add_message( __( 'Please upload only JPG, GIF or PNG photos.', 'buddypress' ), 'error' );
234
  return false;
235
  }
236
-
237
  // Filter the upload location
238
  add_filter( 'upload_dir', $upload_dir_filter, 10, 0 );
239
-
240
  $bp->avatar_admin->original = wp_handle_upload( $file['file'], array( 'action'=> 'bp_avatar_upload' ) );
241
 
242
  // Move the file to the correct upload location.
@@ -244,22 +254,28 @@ function bp_core_avatar_handle_upload( $file, $upload_dir_filter ) {
244
  bp_core_add_message( sprintf( __( 'Upload Failed! Error was: %s', 'buddypress' ), $bp->avatar_admin->original['error'] ), 'error' );
245
  return false;
246
  }
247
-
248
  // Resize the image down to something manageable and then delete the original
249
  if ( getimagesize( $bp->avatar_admin->original['file'] ) > BP_AVATAR_ORIGINAL_MAX_WIDTH ) {
250
  $bp->avatar_admin->resized = wp_create_thumbnail( $bp->avatar_admin->original['file'], BP_AVATAR_ORIGINAL_MAX_WIDTH );
251
  }
252
-
253
  $bp->avatar_admin->image = new stdClass;
254
-
255
- // We only want to handle one image after resize.
256
  if ( empty( $bp->avatar_admin->resized ) )
257
  $bp->avatar_admin->image->dir = $bp->avatar_admin->original['file'];
258
  else {
259
  $bp->avatar_admin->image->dir = $bp->avatar_admin->resized;
260
  @unlink( $bp->avatar_admin->original['file'] );
261
  }
262
-
 
 
 
 
 
 
263
  /* Set the url value for the image */
264
  $bp->avatar_admin->image->url = str_replace( WP_CONTENT_DIR, WP_CONTENT_URL, $bp->avatar_admin->image->dir );
265
 
@@ -268,7 +284,7 @@ function bp_core_avatar_handle_upload( $file, $upload_dir_filter ) {
268
 
269
  function bp_core_avatar_handle_crop( $args = '' ) {
270
  global $bp;
271
-
272
  $defaults = array(
273
  'object' => 'user',
274
  'avatar_dir' => 'avatars',
@@ -288,32 +304,32 @@ function bp_core_avatar_handle_crop( $args = '' ) {
288
 
289
  if ( !file_exists( WP_CONTENT_DIR . '/' . $original_file ) )
290
  return false;
291
-
292
  if ( !$item_id )
293
- $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', WP_CONTENT_DIR . dirname( $original_file ), $item_id, $object, $avatar_dir );
294
  else
295
  $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', WP_CONTENT_DIR . '/blogs.dir/' . BP_ROOT_BLOG . '/files/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir );
296
 
297
  if ( !file_exists( $avatar_folder_dir ) )
298
  return false;
299
-
300
  require_once( ABSPATH . '/wp-admin/includes/image.php' );
301
  require_once( ABSPATH . '/wp-admin/includes/file.php' );
302
 
303
  /* Delete the existing avatar files for the object */
304
  bp_core_delete_existing_avatar( array( 'object' => $object, 'avatar_path' => $avatar_folder_dir ) );
305
-
306
  /* Make sure we at least have a width and height for cropping */
307
  if ( !(int)$crop_w )
308
  $crop_w = BP_AVATAR_FULL_WIDTH;
309
-
310
  if ( !(int)$crop_h )
311
  $crop_h = BP_AVATAR_FULL_HEIGHT;
312
 
313
  /* Set the full and thumb filenames */
314
  $full_filename = wp_hash( $original_file . time() ) . '-bpfull.jpg';
315
  $thumb_filename = wp_hash( $original_file . time() ) . '-bpthumb.jpg';
316
-
317
  /* Crop the image */
318
  $full_cropped = wp_crop_image( WP_CONTENT_DIR . $original_file, (int)$crop_x, (int)$crop_y, (int)$crop_w, (int)$crop_h, BP_AVATAR_FULL_WIDTH, BP_AVATAR_FULL_HEIGHT, false, $avatar_folder_dir . '/' . $full_filename );
319
  $thumb_cropped = wp_crop_image( WP_CONTENT_DIR . $original_file, (int)$crop_x, (int)$crop_y, (int)$crop_w, (int)$crop_h, BP_AVATAR_THUMB_WIDTH, BP_AVATAR_THUMB_HEIGHT, false, $avatar_folder_dir . '/' . $thumb_filename );
@@ -328,7 +344,7 @@ function bp_core_avatar_handle_crop( $args = '' ) {
328
  function bp_core_fetch_avatar_filter( $avatar, $id_or_email, $size, $default, $alt ) {
329
  if ( is_object ( $id_or_email ) )
330
  $id_or_email = $id_or_email->user_id;
331
-
332
  $bp_avatar = bp_core_fetch_avatar( array( 'no_grav' => true, 'item_id' => $id_or_email, 'width' => $size, 'height' => $size, 'alt' => $alt ) );
333
 
334
  return ( !$bp_avatar ) ? $avatar : $bp_avatar;
@@ -338,21 +354,21 @@ add_filter( 'get_avatar', 'bp_core_fetch_avatar_filter', 10, 5 );
338
  function bp_core_check_avatar_upload($file) {
339
  if ( $file['error'] )
340
  return false;
341
-
342
  return true;
343
  }
344
 
345
  function bp_core_check_avatar_size($file) {
346
  if ( $file['file']['size'] > BP_AVATAR_ORIGINAL_MAX_FILESIZE )
347
  return false;
348
-
349
  return true;
350
  }
351
 
352
  function bp_core_check_avatar_type($file) {
353
  if ( ( strlen($file['file']['type']) && !preg_match('/(jpe?g|gif|png)$/', $file['file']['type'] ) ) && !preg_match( '/(jpe?g|gif|png)$/', $file['file']['name'] ) )
354
  return false;
355
-
356
  return true;
357
  }
358
 
31
 
32
  if ( !defined( 'BP_AVATAR_DEFAULT_THUMB' ) )
33
  define( 'BP_AVATAR_DEFAULT_THUMB', BP_PLUGIN_URL . '/bp-xprofile/images/none-thumbnail.gif' );
34
+
35
  function bp_core_fetch_avatar( $args = '' ) {
36
  global $bp, $current_blog;
37
+
38
  $defaults = array(
39
  'item_id' => false,
40
  'object' => 'user', // user OR group OR blog OR custom type (if you use filters)
41
  'type' => 'thumb',
42
  'avatar_dir' => false,
43
+ 'width' => false,
44
  'height' => false,
45
  'class' => 'avatar',
46
  'css_id' => false,
49
  );
50
 
51
  $params = wp_parse_args( $args, $defaults );
52
+ extract( $params, EXTR_SKIP );
53
 
54
  if ( !$item_id ) {
55
  if ( 'user' == $object )
58
  $item_id = $bp->groups->current_group->id;
59
  else if ( 'blog' == $object )
60
  $item_id = $current_blog->id;
61
+
62
  $item_id = apply_filters( 'bp_core_avatar_item_id', $item_id, $object );
63
+
64
  if ( !$item_id ) return false;
65
  }
66
+
67
  if ( !$avatar_dir ) {
68
  if ( 'user' == $object )
69
  $avatar_dir = 'avatars';
71
  $avatar_dir = 'group-avatars';
72
  else if ( 'blog' == $object )
73
  $avatar_dir = 'blog-avatars';
74
+
75
  $avatar_dir = apply_filters( 'bp_core_avatar_dir', $avatar_dir, $object );
76
+
77
+ if ( !$avatar_dir ) return false;
78
  }
79
+
80
+ /* Add an identifying class to each item */
81
+ $class .= ' ' . $object . '-' . $item_id . '-avatar';
82
+
83
+ if ( !empty($css_id) )
84
+ $css_id = " id='{$css_id}'";
85
+
86
  if ( $width )
87
  $html_width = " width='{$width}'";
88
  else
89
  $html_width = ( 'thumb' == $type ) ? ' width="' . BP_AVATAR_THUMB_WIDTH . '"' : ' width="' . BP_AVATAR_FULL_WIDTH . '"';
90
+
91
  if ( $height )
92
  $html_height = " height='{$height}'";
93
  else
94
  $html_height = ( 'thumb' == $type ) ? ' height="' . BP_AVATAR_THUMB_HEIGHT . '"' : ' height="' . BP_AVATAR_FULL_HEIGHT . '"';
95
+
96
+ $avatar_folder_url = apply_filters( 'bp_core_avatar_folder_url', get_blog_option( BP_ROOT_BLOG, 'siteurl' ) . '/' . basename( WP_CONTENT_DIR ) . '/blogs.dir/' . BP_ROOT_BLOG . '/files/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir );
97
+ $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', WP_CONTENT_DIR . '/blogs.dir/' . BP_ROOT_BLOG . '/files/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir );
98
+
99
+ /****
100
+ * Look for uploaded avatar first. Use it if it exists.
101
+ * Set the file names to search for, to select the full size
102
+ * or thumbnail image.
103
+ */
104
+ $avatar_name = ( 'full' == $type ) ? '-bpfull' : '-bpthumb';
105
+ $legacy_user_avatar_name = ( 'full' == $type ) ? '-avatar2' : '-avatar1';
106
+ $legacy_group_avatar_name = ( 'full' == $type ) ? '-groupavatar-full' : '-groupavatar-thumb';
107
+
108
+ if ( file_exists( $avatar_folder_dir ) ) {
109
+ if ( $av_dir = opendir( $avatar_folder_dir ) ) {
110
+ while ( false !== ( $avatar_file = readdir($av_dir) ) ) {
111
+ if ( preg_match( "/{$avatar_name}/", $avatar_file ) || preg_match( "/{$legacy_user_avatar_name}/", $avatar_file ) || preg_match( "/{$legacy_group_avatar_name}/", $avatar_file ) )
112
+ $avatar_url = $avatar_folder_url . '/' . $avatar_file;
113
+ }
114
+ }
115
+ closedir($av_dir);
116
+
117
+ if ( $avatar_url )
118
+ return apply_filters( 'bp_core_fetch_avatar', "<img src='{$avatar_url}' alt='{$alt}' class='{$class}'{$css_id}{$html_width}{$html_height} />", $params );
119
+ }
120
+
121
+ /* If no avatars have been uploaded for this item, display a gravatar */
122
+ if ( !$no_grav ) {
123
  if ( empty( $bp->grav_default->{$object} ) )
124
  $default_grav = 'wavatar';
125
  else if ( 'mystery' == $bp->grav_default->{$object} )
130
  if ( $width ) $grav_size = $width;
131
  else if ( 'full' == $type ) $grav_size = BP_AVATAR_FULL_WIDTH;
132
  else if ( 'thumb' == $type ) $grav_size = BP_AVATAR_THUMB_WIDTH;
133
+
134
  if ( 'user' == $object ) {
135
  $ud = get_userdata( $item_id );
136
  $grav_email = $ud->user_email;
137
  } else if ( 'group' == $object || 'blog' == $object ) {
138
  $grav_email = "{$item_id}-{$object}@{$bp->root_domain}";
139
  }
140
+
141
+ $grav_email = apply_filters( 'bp_core_gravatar_email', $grav_email, $item_id, $object );
142
  $gravatar = apply_filters( 'bp_gravatar_url', 'http://www.gravatar.com/avatar/' ) . md5( $grav_email ) . '?d=' . $default_grav . '&amp;s=' . $grav_size;
143
+
144
+ return apply_filters( 'bp_core_fetch_avatar', "<img src='{$gravatar}' alt='{$alt}' class='{$class}'{$css_id}{$html_width}{$html_height} />", $params );
145
+
146
+ } else {
147
  return false;
 
 
 
 
 
 
 
 
 
 
 
148
  }
 
 
 
149
  }
150
 
151
  function bp_core_delete_existing_avatar( $args = '' ) {
152
  global $bp;
153
+
154
  $defaults = array(
155
  'item_id' => false,
156
  'object' => 'user', // user OR group OR blog OR custom type (if you use filters)
158
  );
159
 
160
  $args = wp_parse_args( $args, $defaults );
161
+ extract( $args, EXTR_SKIP );
162
+
163
  if ( !$item_id ) {
164
  if ( 'user' == $object )
165
  $item_id = $bp->displayed_user->id;
167
  $item_id = $bp->groups->current_group->id;
168
  else if ( 'blog' == $object )
169
  $item_id = $current_blog->id;
170
+
171
  $item_id = apply_filters( 'bp_core_avatar_item_id', $item_id, $object );
172
+
173
  if ( !$item_id ) return false;
174
  }
175
+
176
  if ( !$avatar_dir ) {
177
  if ( 'user' == $object )
178
  $avatar_dir = 'avatars';
180
  $avatar_dir = 'group-avatars';
181
  else if ( 'blog' == $object )
182
  $avatar_dir = 'blog-avatars';
183
+
184
  $avatar_dir = apply_filters( 'bp_core_avatar_dir', $avatar_dir, $object );
185
+
186
+ if ( !$avatar_dir ) return false;
187
  }
188
 
189
  if ( 'user' == $object ) {
194
  delete_usermeta( $item_id, 'bp_core_avatar_v2' );
195
  }
196
 
197
+ $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', WP_CONTENT_DIR . '/blogs.dir/' . BP_ROOT_BLOG . '/files/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir );
198
 
199
  if ( !file_exists( $avatar_folder_dir ) )
200
  return false;
202
  if ( $av_dir = opendir( $avatar_folder_dir ) ) {
203
  while ( false !== ( $avatar_file = readdir($av_dir) ) ) {
204
  if ( ( preg_match( "/-bpfull/", $avatar_file ) || preg_match( "/-bpthumb/", $avatar_file ) ) && '.' != $avatar_file && '..' != $avatar_file )
205
+ @unlink( $avatar_folder_dir . '/' . $avatar_file );
206
  }
207
  }
208
  closedir($av_dir);
216
 
217
  function bp_core_avatar_handle_upload( $file, $upload_dir_filter ) {
218
  global $bp;
219
+
220
  require_once( ABSPATH . '/wp-admin/includes/image.php' );
221
  require_once( ABSPATH . '/wp-admin/includes/file.php' );
222
+
223
  $uploadErrors = array(
224
+ 0 => __("There is no error, the file uploaded with success", 'buddypress'),
225
+ 1 => __("Your image was bigger than the maximum allowed file size of: ", 'buddypress') . size_format(BP_AVATAR_ORIGINAL_MAX_FILESIZE),
226
+ 2 => __("Your image was bigger than the maximum allowed file size of: ", 'buddypress') . size_format(BP_AVATAR_ORIGINAL_MAX_FILESIZE),
227
+ 3 => __("The uploaded file was only partially uploaded", 'buddypress'),
228
+ 4 => __("No file was uploaded", 'buddypress'),
229
+ 6 => __("Missing a temporary folder", 'buddypress')
230
  );
231
 
232
  if ( !bp_core_check_avatar_upload( $file ) ) {
233
  bp_core_add_message( sprintf( __( 'Your upload failed, please try again. Error was: %s', 'buddypress' ), $uploadErrors[$file['file']['error']] ), 'error' );
234
  return false;
235
  }
236
+
237
  if ( !bp_core_check_avatar_size( $file ) ) {
238
  bp_core_add_message( sprintf( __( 'The file you uploaded is too big. Please upload a file under %s', 'buddypress'), size_format(BP_AVATAR_ORIGINAL_MAX_FILESIZE) ), 'error' );
239
  return false;
240
  }
241
+
242
  if ( !bp_core_check_avatar_type( $file ) ) {
243
  bp_core_add_message( __( 'Please upload only JPG, GIF or PNG photos.', 'buddypress' ), 'error' );
244
  return false;
245
  }
246
+
247
  // Filter the upload location
248
  add_filter( 'upload_dir', $upload_dir_filter, 10, 0 );
249
+
250
  $bp->avatar_admin->original = wp_handle_upload( $file['file'], array( 'action'=> 'bp_avatar_upload' ) );
251
 
252
  // Move the file to the correct upload location.
254
  bp_core_add_message( sprintf( __( 'Upload Failed! Error was: %s', 'buddypress' ), $bp->avatar_admin->original['error'] ), 'error' );
255
  return false;
256
  }
257
+
258
  // Resize the image down to something manageable and then delete the original
259
  if ( getimagesize( $bp->avatar_admin->original['file'] ) > BP_AVATAR_ORIGINAL_MAX_WIDTH ) {
260
  $bp->avatar_admin->resized = wp_create_thumbnail( $bp->avatar_admin->original['file'], BP_AVATAR_ORIGINAL_MAX_WIDTH );
261
  }
262
+
263
  $bp->avatar_admin->image = new stdClass;
264
+
265
+ // We only want to handle one image after resize.
266
  if ( empty( $bp->avatar_admin->resized ) )
267
  $bp->avatar_admin->image->dir = $bp->avatar_admin->original['file'];
268
  else {
269
  $bp->avatar_admin->image->dir = $bp->avatar_admin->resized;
270
  @unlink( $bp->avatar_admin->original['file'] );
271
  }
272
+
273
+ /* Check for WP_Error on what should be an image */
274
+ if ( is_wp_error( $bp->avatar_admin->image->dir ) ) {
275
+ bp_core_add_message( sprintf( __( 'Upload failed! Error was: %s', 'buddypress' ), $bp->avatar_admin->image->dir->get_error_message() ), 'error' );
276
+ return false;
277
+ }
278
+
279
  /* Set the url value for the image */
280
  $bp->avatar_admin->image->url = str_replace( WP_CONTENT_DIR, WP_CONTENT_URL, $bp->avatar_admin->image->dir );
281
 
284
 
285
  function bp_core_avatar_handle_crop( $args = '' ) {
286
  global $bp;
287
+
288
  $defaults = array(
289
  'object' => 'user',
290
  'avatar_dir' => 'avatars',
304
 
305
  if ( !file_exists( WP_CONTENT_DIR . '/' . $original_file ) )
306
  return false;
307
+
308
  if ( !$item_id )
309
+ $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', WP_CONTENT_DIR . dirname( $original_file ), $item_id, $object, $avatar_dir );
310
  else
311
  $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', WP_CONTENT_DIR . '/blogs.dir/' . BP_ROOT_BLOG . '/files/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir );
312
 
313
  if ( !file_exists( $avatar_folder_dir ) )
314
  return false;
315
+
316
  require_once( ABSPATH . '/wp-admin/includes/image.php' );
317
  require_once( ABSPATH . '/wp-admin/includes/file.php' );
318
 
319
  /* Delete the existing avatar files for the object */
320
  bp_core_delete_existing_avatar( array( 'object' => $object, 'avatar_path' => $avatar_folder_dir ) );
321
+
322
  /* Make sure we at least have a width and height for cropping */
323
  if ( !(int)$crop_w )
324
  $crop_w = BP_AVATAR_FULL_WIDTH;
325
+
326
  if ( !(int)$crop_h )
327
  $crop_h = BP_AVATAR_FULL_HEIGHT;
328
 
329
  /* Set the full and thumb filenames */
330
  $full_filename = wp_hash( $original_file . time() ) . '-bpfull.jpg';
331
  $thumb_filename = wp_hash( $original_file . time() ) . '-bpthumb.jpg';
332
+
333
  /* Crop the image */
334
  $full_cropped = wp_crop_image( WP_CONTENT_DIR . $original_file, (int)$crop_x, (int)$crop_y, (int)$crop_w, (int)$crop_h, BP_AVATAR_FULL_WIDTH, BP_AVATAR_FULL_HEIGHT, false, $avatar_folder_dir . '/' . $full_filename );
335
  $thumb_cropped = wp_crop_image( WP_CONTENT_DIR . $original_file, (int)$crop_x, (int)$crop_y, (int)$crop_w, (int)$crop_h, BP_AVATAR_THUMB_WIDTH, BP_AVATAR_THUMB_HEIGHT, false, $avatar_folder_dir . '/' . $thumb_filename );
344
  function bp_core_fetch_avatar_filter( $avatar, $id_or_email, $size, $default, $alt ) {
345
  if ( is_object ( $id_or_email ) )
346
  $id_or_email = $id_or_email->user_id;
347
+
348
  $bp_avatar = bp_core_fetch_avatar( array( 'no_grav' => true, 'item_id' => $id_or_email, 'width' => $size, 'height' => $size, 'alt' => $alt ) );
349
 
350
  return ( !$bp_avatar ) ? $avatar : $bp_avatar;
354
  function bp_core_check_avatar_upload($file) {
355
  if ( $file['error'] )
356
  return false;
357
+
358
  return true;
359
  }
360
 
361
  function bp_core_check_avatar_size($file) {
362
  if ( $file['file']['size'] > BP_AVATAR_ORIGINAL_MAX_FILESIZE )
363
  return false;
364
+
365
  return true;
366
  }
367
 
368
  function bp_core_check_avatar_type($file) {
369
  if ( ( strlen($file['file']['type']) && !preg_match('/(jpe?g|gif|png)$/', $file['file']['type'] ) ) && !preg_match( '/(jpe?g|gif|png)$/', $file['file']['name'] ) )
370
  return false;
371
+
372
  return true;
373
  }
374
 
bp-core/bp-core-catchuri.php CHANGED
@@ -16,13 +16,13 @@ Modified for BuddyPress by: Andy Peatling - http://apeatling.wordpress.com/
16
  * The URI's are broken down as follows:
17
  * - http:// domain.com / members / andy / [current_component] / [current_action] / [action_variables] / [action_variables] / ...
18
  * - OUTSIDE ROOT: http:// domain.com / sites / buddypress / members / andy / [current_component] / [current_action] / [action_variables] / [action_variables] / ...
19
- *
20
  * Example:
21
  * - http://domain.com/members/andy/profile/edit/group/5/
22
  * - $bp->current_component: string 'profile'
23
  * - $bp->current_action: string 'edit'
24
  * - $bp->action_variables: array ['group', 5]
25
- *
26
  * @package BuddyPress Core
27
  */
28
  function bp_core_set_uri_globals() {
@@ -31,7 +31,7 @@ function bp_core_set_uri_globals() {
31
  global $is_member_page;
32
  global $bp_unfiltered_uri;
33
  global $bp, $current_blog;
34
-
35
  if ( !defined( 'BP_ENABLE_MULTIBLOG' ) ) {
36
  /* Only catch URI's on the root blog if we are not running BP on multiple blogs */
37
  if ( BP_ROOT_BLOG != (int) $current_blog->blog_id )
@@ -63,15 +63,15 @@ function bp_core_set_uri_globals() {
63
  if ( $current_blog->path != '/' )
64
  array_shift( $bp_uri );
65
  }
66
-
67
  /* Set the indexes, these are incresed by one if we are not on a VHOST install */
68
  $component_index = 0;
69
  $action_index = $component_index + 1;
70
-
71
  // If this is a WordPress page, return from the function.
72
  if ( is_page( $bp_uri[$component_index] ) )
73
  return false;
74
-
75
  /* Get site path items */
76
  $paths = explode( '/', bp_core_get_site_path() );
77
 
@@ -92,22 +92,22 @@ function bp_core_set_uri_globals() {
92
  /* Reset the keys by merging with an empty array */
93
  $bp_uri = array_merge( array(), $bp_uri );
94
  $bp_unfiltered_uri = $bp_uri;
95
-
96
  /* If we are under anything with a members slug, set the correct globals */
97
  if ( $bp_uri[0] == BP_MEMBERS_SLUG ) {
98
  $is_member_page = true;
99
- $is_root_component = true;
100
  }
101
 
102
  /* Catch a member page and set the current member ID */
103
- if ( !defined( 'BP_ENABLE_ROOT_PROFILES' ) ) {
104
- if ( ( $bp_uri[0] == BP_MEMBERS_SLUG && !empty( $bp_uri[1] ) ) || in_array( 'wp-load.php', $bp_uri ) ) {
105
  // We are within a member page, set up user id globals
106
  $displayed_user_id = bp_core_get_displayed_userid( $bp_uri[1] );
107
 
108
  unset($bp_uri[0]);
109
  unset($bp_uri[1]);
110
-
111
  /* Reset the keys by merging with an empty array */
112
  $bp_uri = array_merge( array(), $bp_uri );
113
  }
@@ -115,17 +115,17 @@ function bp_core_set_uri_globals() {
115
  if ( get_userdatabylogin( $bp_uri[0] ) || in_array( 'wp-load.php', $bp_uri ) ) {
116
  $is_member_page = true;
117
  $is_root_component = true;
118
-
119
  // We are within a member page, set up user id globals
120
  $displayed_user_id = bp_core_get_displayed_userid( $bp_uri[0] );
121
-
122
  unset($bp_uri[0]);
123
 
124
  /* Reset the keys by merging with an empty array */
125
  $bp_uri = array_merge( array(), $bp_uri );
126
  }
127
  }
128
-
129
  if ( !isset($is_root_component) )
130
  $is_root_component = in_array( $bp_uri[0], $bp->root_components );
131
 
@@ -136,10 +136,10 @@ function bp_core_set_uri_globals() {
136
 
137
  /* Set the current component */
138
  $current_component = $bp_uri[$component_index];
139
-
140
  /* Set the current action */
141
  $current_action = $bp_uri[$action_index];
142
-
143
  /* Set the entire URI as the action variables, we will unset the current_component and action in a second */
144
  $action_variables = $bp_uri;
145
 
@@ -150,7 +150,7 @@ function bp_core_set_uri_globals() {
150
  /* Remove the username from action variables if this is not a VHOST install */
151
  if ( 'no' == VHOST && !$is_root_component )
152
  array_shift($action_variables);
153
-
154
  /* Reset the keys by merging with an empty array */
155
  $action_variables = array_merge( array(), $action_variables );
156
 
@@ -161,11 +161,11 @@ add_action( 'plugins_loaded', 'bp_core_set_uri_globals', 3 );
161
  /**
162
  * bp_catch_uri()
163
  *
164
- * Takes either a single page name or array of page names and
165
  * loads the first template file that can be found.
166
  *
167
  * Please don't call this function directly anymore, use: bp_core_load_template()
168
- *
169
  * @package BuddyPress Core
170
  * @global $bp_path BuddyPress global containing the template file names to use.
171
  * @param $pages Template file names to use.
@@ -173,7 +173,7 @@ add_action( 'plugins_loaded', 'bp_core_set_uri_globals', 3 );
173
  */
174
  function bp_catch_uri( $pages, $skip_blog_check = false ) {
175
  global $bp_path, $bp_skip_blog_check;
176
-
177
  $bp_skip_blog_check = $skip_blog_check;
178
 
179
  $bp_path = $pages;
@@ -188,7 +188,7 @@ function bp_catch_uri( $pages, $skip_blog_check = false ) {
188
  * bp_core_do_catch_uri()
189
  *
190
  * Loads the first template file found based on the $bp_path global.
191
- *
192
  * @package BuddyPress Core
193
  * @global $bp_path BuddyPress global containing the template file names to use.
194
  */
@@ -197,10 +197,10 @@ function bp_core_do_catch_uri() {
197
  global $current_blog, $bp_skip_blog_check;
198
  global $bp_no_status_set;
199
  global $wp_query;
200
-
201
- /* Can be a single template or an array of templates */
202
  $templates = $bp_path;
203
-
204
  /* Don't hijack any URLs on blog pages */
205
  if ( bp_is_blog_page() ) {
206
  if ( !$bp_skip_blog_check )
@@ -213,14 +213,14 @@ function bp_core_do_catch_uri() {
213
  if ( !$bp_no_status_set ) {
214
  status_header( 200 );
215
  $wp_query->is_404 = false;
216
-
217
  if ( $bp->current_component != BP_HOME_BLOG_SLUG )
218
  $wp_query->is_page = true;
219
  }
220
-
221
  foreach ( (array)$templates as $template )
222
  $filtered_templates[] = $template . '.php';
223
-
224
  if ( $located_template = apply_filters( 'bp_located_template', locate_template( (array) $filtered_templates, false ), $filtered_templates ) ) {
225
  load_template( apply_filters( 'bp_load_template', $located_template ) );
226
  } else {
@@ -268,11 +268,11 @@ add_action( 'wp', 'bp_core_catch_no_access' );
268
  *
269
  * If the extended profiles component is not installed we still need
270
  * to catch the /profile URI's and display whatever we have installed.
271
- *
272
  */
273
  function bp_core_catch_profile_uri() {
274
  global $bp;
275
-
276
  if ( !function_exists('xprofile_install') )
277
  bp_core_load_template( apply_filters( 'bp_core_template_display_profile', 'profile/index' ) );
278
  }
16
  * The URI's are broken down as follows:
17
  * - http:// domain.com / members / andy / [current_component] / [current_action] / [action_variables] / [action_variables] / ...
18
  * - OUTSIDE ROOT: http:// domain.com / sites / buddypress / members / andy / [current_component] / [current_action] / [action_variables] / [action_variables] / ...
19
+ *
20
  * Example:
21
  * - http://domain.com/members/andy/profile/edit/group/5/
22
  * - $bp->current_component: string 'profile'
23
  * - $bp->current_action: string 'edit'
24
  * - $bp->action_variables: array ['group', 5]
25
+ *
26
  * @package BuddyPress Core
27
  */
28
  function bp_core_set_uri_globals() {
31
  global $is_member_page;
32
  global $bp_unfiltered_uri;
33
  global $bp, $current_blog;
34
+
35
  if ( !defined( 'BP_ENABLE_MULTIBLOG' ) ) {
36
  /* Only catch URI's on the root blog if we are not running BP on multiple blogs */
37
  if ( BP_ROOT_BLOG != (int) $current_blog->blog_id )
63
  if ( $current_blog->path != '/' )
64
  array_shift( $bp_uri );
65
  }
66
+
67
  /* Set the indexes, these are incresed by one if we are not on a VHOST install */
68
  $component_index = 0;
69
  $action_index = $component_index + 1;
70
+
71
  // If this is a WordPress page, return from the function.
72
  if ( is_page( $bp_uri[$component_index] ) )
73
  return false;
74
+
75
  /* Get site path items */
76
  $paths = explode( '/', bp_core_get_site_path() );
77
 
92
  /* Reset the keys by merging with an empty array */
93
  $bp_uri = array_merge( array(), $bp_uri );
94
  $bp_unfiltered_uri = $bp_uri;
95
+
96
  /* If we are under anything with a members slug, set the correct globals */
97
  if ( $bp_uri[0] == BP_MEMBERS_SLUG ) {
98
  $is_member_page = true;
99
+ $is_root_component = true;
100
  }
101
 
102
  /* Catch a member page and set the current member ID */
103
+ if ( !defined( 'BP_ENABLE_ROOT_PROFILES' ) ) {
104
+ if ( ( $bp_uri[0] == BP_MEMBERS_SLUG && !empty( $bp_uri[1] ) ) || in_array( 'wp-load.php', $bp_uri ) ) {
105
  // We are within a member page, set up user id globals
106
  $displayed_user_id = bp_core_get_displayed_userid( $bp_uri[1] );
107
 
108
  unset($bp_uri[0]);
109
  unset($bp_uri[1]);
110
+
111
  /* Reset the keys by merging with an empty array */
112
  $bp_uri = array_merge( array(), $bp_uri );
113
  }
115
  if ( get_userdatabylogin( $bp_uri[0] ) || in_array( 'wp-load.php', $bp_uri ) ) {
116
  $is_member_page = true;
117
  $is_root_component = true;
118
+
119
  // We are within a member page, set up user id globals
120
  $displayed_user_id = bp_core_get_displayed_userid( $bp_uri[0] );
121
+
122
  unset($bp_uri[0]);
123
 
124
  /* Reset the keys by merging with an empty array */
125
  $bp_uri = array_merge( array(), $bp_uri );
126
  }
127
  }
128
+
129
  if ( !isset($is_root_component) )
130
  $is_root_component = in_array( $bp_uri[0], $bp->root_components );
131
 
136
 
137
  /* Set the current component */
138
  $current_component = $bp_uri[$component_index];
139
+
140
  /* Set the current action */
141
  $current_action = $bp_uri[$action_index];
142
+
143
  /* Set the entire URI as the action variables, we will unset the current_component and action in a second */
144
  $action_variables = $bp_uri;
145
 
150
  /* Remove the username from action variables if this is not a VHOST install */
151
  if ( 'no' == VHOST && !$is_root_component )
152
  array_shift($action_variables);
153
+
154
  /* Reset the keys by merging with an empty array */
155
  $action_variables = array_merge( array(), $action_variables );
156
 
161
  /**
162
  * bp_catch_uri()
163
  *
164
+ * Takes either a single page name or array of page names and
165
  * loads the first template file that can be found.
166
  *
167
  * Please don't call this function directly anymore, use: bp_core_load_template()
168
+ *
169
  * @package BuddyPress Core
170
  * @global $bp_path BuddyPress global containing the template file names to use.
171
  * @param $pages Template file names to use.
173
  */
174
  function bp_catch_uri( $pages, $skip_blog_check = false ) {
175
  global $bp_path, $bp_skip_blog_check;
176
+
177
  $bp_skip_blog_check = $skip_blog_check;
178
 
179
  $bp_path = $pages;
188
  * bp_core_do_catch_uri()
189
  *
190
  * Loads the first template file found based on the $bp_path global.
191
+ *
192
  * @package BuddyPress Core
193
  * @global $bp_path BuddyPress global containing the template file names to use.
194
  */
197
  global $current_blog, $bp_skip_blog_check;
198
  global $bp_no_status_set;
199
  global $wp_query;
200
+
201
+ /* Can be a single template or an array of templates */
202
  $templates = $bp_path;
203
+
204
  /* Don't hijack any URLs on blog pages */
205
  if ( bp_is_blog_page() ) {
206
  if ( !$bp_skip_blog_check )
213
  if ( !$bp_no_status_set ) {
214
  status_header( 200 );
215
  $wp_query->is_404 = false;
216
+
217
  if ( $bp->current_component != BP_HOME_BLOG_SLUG )
218
  $wp_query->is_page = true;
219
  }
220
+
221
  foreach ( (array)$templates as $template )
222
  $filtered_templates[] = $template . '.php';
223
+
224
  if ( $located_template = apply_filters( 'bp_located_template', locate_template( (array) $filtered_templates, false ), $filtered_templates ) ) {
225
  load_template( apply_filters( 'bp_load_template', $located_template ) );
226
  } else {
268
  *
269
  * If the extended profiles component is not installed we still need
270
  * to catch the /profile URI's and display whatever we have installed.
271
+ *
272
  */
273
  function bp_core_catch_profile_uri() {
274
  global $bp;
275
+
276
  if ( !function_exists('xprofile_install') )
277
  bp_core_load_template( apply_filters( 'bp_core_template_display_profile', 'profile/index' ) );
278
  }
bp-core/bp-core-classes.php CHANGED
@@ -2,14 +2,14 @@
2
  /**
3
  * BP_Core_User class can be used by any component. It will fetch useful
4
  * details for any user when provided with a user_id.
5
- *
6
  * Example:
7
  * $user = new BP_Core_User( $user_id );
8
  * $user_avatar = $user->avatar;
9
  * $user_email = $user->email;
10
  * $user_status = $user->status;
11
  * etc.
12
- *
13
  * @package BuddyPress Core
14
  */
15
  class BP_Core_User {
@@ -19,10 +19,10 @@ class BP_Core_User {
19
  var $avatar_mini;
20
  var $fullname;
21
  var $email;
22
-
23
  var $user_url;
24
  var $user_link;
25
-
26
  var $last_active;
27
  var $profile_last_updated;
28
 
@@ -30,22 +30,22 @@ class BP_Core_User {
30
  var $total_friends;
31
  var $total_blogs;
32
  var $total_groups;
33
-
34
  function bp_core_user( $user_id, $populate_extras = false ) {
35
  if ( $user_id ) {
36
  $this->id = $user_id;
37
  $this->populate();
38
-
39
  if ( $populate_extras )
40
  $this->populate_extras();
41
  }
42
- }
43
-
44
  /**
45
  * populate()
46
  *
47
  * Populate the instantiated class with data based on the User ID provided.
48
- *
49
  * @package BuddyPress Core
50
  * @global $userdata WordPress user data for the current logged in user.
51
  * @uses bp_core_get_userurl() Returns the URL with no HTML markup for a user based on their user id
@@ -58,7 +58,7 @@ class BP_Core_User {
58
  function populate() {
59
  $this->user_url = bp_core_get_userurl( $this->id );
60
  $this->user_link = bp_core_get_userlink( $this->id );
61
-
62
  $this->fullname = attribute_escape( bp_core_get_user_displayname( $this->id ) );
63
  $this->email = attribute_escape( bp_core_get_user_email( $this->id ) );
64
  $this->last_active = attribute_escape( bp_core_get_last_activity( get_usermeta( $this->id, 'last_activity' ), __( 'active %s ago', 'buddypress' ) ) );
@@ -67,37 +67,37 @@ class BP_Core_User {
67
  $this->avatar_thumb = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'thumb' ) );
68
  $this->avatar_mini = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'thumb', 'width' => 30, 'height' => 30 ) );
69
  }
70
-
71
  function populate_extras() {
72
  global $bp;
73
-
74
- if ( function_exists('friends_install') ) {
75
- $this->total_friends = BP_Friends_Friendship::total_friend_count( $this->id );
76
 
77
  if ( $this->total_friends ) {
78
  if ( 1 == $this->total_friends )
79
  $this->total_friends .= ' ' . __( 'friend', 'buddypress' );
80
  else
81
  $this->total_friends .= ' ' . __( 'friends', 'buddypress' );
82
-
83
  $this->total_friends = '<a href="' . $this->user_url . $bp->friends->slug . '" title="' . sprintf( __( "%s's friend list", 'buddypress' ), $this->fullname ) . '">' . $this->total_friends . '</a>';
84
  }
85
  }
86
 
87
- if ( function_exists('bp_blogs_install') ) {
88
  if ( $this->total_blogs ) {
89
  if ( 1 == $this->total_blogs )
90
  $this->total_blogs .= ' ' . __( 'blog', 'buddypress' );
91
  else
92
- $this->total_blogs .= ' ' . __( 'blogs', 'buddypress' );
93
-
94
  $this->total_blogs = '<a href="' . $this->user_url . $bp->blogs->slug . '" title="' . sprintf( __( "%s's blog list", 'buddypress' ), $this->fullname ) . '">' . $this->total_blogs . '</a>';
95
  }
96
  }
97
-
98
  if ( function_exists('groups_install') ) {
99
- $this->total_groups = BP_Groups_Member::total_group_count( $this->id );
100
-
101
  if ( $this->total_groups ) {
102
  if ( 1 == $this->total_groups )
103
  $this->total_groups .= ' ' . __( 'group', 'buddypress' );
@@ -108,79 +108,79 @@ class BP_Core_User {
108
  }
109
  }
110
  }
111
-
112
  /* Static Functions */
113
-
114
  function get_newest_users( $limit = null, $page = 1 ) {
115
  global $wpdb;
116
-
117
  if ( $limit && $page )
118
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
119
-
120
- $total_users_sql = apply_filters( 'bp_core_newest_users_count_sql', "SELECT DISTINCT count(ID) FROM " . CUSTOM_USER_TABLE . " WHERE spam = 0 AND deleted = 0 AND user_status = 0 ORDER BY user_registered DESC" );
121
  $paged_users_sql = apply_filters( 'bp_core_newest_users_sql', "SELECT DISTINCT ID as user_id, DATE_ADD( user_registered, INTERVAL " . get_option('gmt_offset') . " HOUR ) as user_registered FROM " . CUSTOM_USER_TABLE . " WHERE spam = 0 AND deleted = 0 AND user_status = 0 ORDER BY user_registered DESC{$pag_sql}", $pag_sql );
122
-
123
  $total_users = $wpdb->get_var( $total_users_sql );
124
  $paged_users = $wpdb->get_results( $paged_users_sql );
125
-
126
  return array( 'users' => $paged_users, 'total' => $total_users );
127
  }
128
-
129
  function get_active_users( $limit = null, $page = 1 ) {
130
  global $wpdb;
131
 
132
  if ( $limit && $page )
133
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
134
 
135
- $total_users_sql = apply_filters( 'bp_core_active_users_count_sql', "SELECT DISTINCT count(um.user_id) FROM " . CUSTOM_USER_META_TABLE . " um LEFT JOIN " . CUSTOM_USER_TABLE . " u ON u.ID = um.user_id WHERE um.meta_key = 'last_activity' AND u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 ORDER BY FROM_UNIXTIME(um.meta_value) DESC" );
136
  $paged_users_sql = apply_filters( 'bp_core_active_users_sql', "SELECT DISTINCT user_id FROM " . CUSTOM_USER_META_TABLE . " um LEFT JOIN " . CUSTOM_USER_TABLE . " u ON u.ID = um.user_id WHERE um.meta_key = 'last_activity' AND u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 ORDER BY FROM_UNIXTIME(um.meta_value) DESC{$pag_sql}", $pag_sql );
137
-
138
  $total_users = $wpdb->get_var( $total_users_sql );
139
  $paged_users = $wpdb->get_results( $paged_users_sql );
140
-
141
  return array( 'users' => $paged_users, 'total' => $total_users );
142
  }
143
 
144
  function get_popular_users( $limit = null, $page = 1 ) {
145
  global $wpdb;
146
-
147
  if ( !function_exists('friends_install') )
148
  return false;
149
-
150
  if ( $limit && $page )
151
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
152
 
153
- $total_users_sql = apply_filters( 'bp_core_popular_users_count_sql', "SELECT DISTINCT count(um.user_id) FROM " . CUSTOM_USER_META_TABLE . " um LEFT JOIN " . CUSTOM_USER_TABLE . " u ON u.ID = um.user_id WHERE um.meta_key = 'total_friend_count' AND u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 ORDER BY CONVERT(um.meta_value, SIGNED) DESC" );
154
  $paged_users_sql = apply_filters( 'bp_core_popular_users_sql', "SELECT DISTINCT um.user_id FROM " . CUSTOM_USER_META_TABLE . " um LEFT JOIN " . CUSTOM_USER_TABLE . " u ON u.ID = um.user_id WHERE um.meta_key = 'total_friend_count' AND u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 ORDER BY CONVERT(um.meta_value, SIGNED) DESC{$pag_sql}", $pag_sql );
155
 
156
  $total_users = $wpdb->get_var( $total_users_sql );
157
  $paged_users = $wpdb->get_results( $paged_users_sql );
158
-
159
  return array( 'users' => $paged_users, 'total' => $total_users );
160
  }
161
-
162
  function get_random_users( $limit = null, $page = 1 ) {
163
  global $wpdb, $bp;
164
-
165
  if ( $limit && $page )
166
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
167
 
168
- $total_users_sql = apply_filters( 'bp_core_random_users_count_sql', $wpdb->prepare( "SELECT DISTINCT count(um.user_id) FROM " . CUSTOM_USER_META_TABLE . " um LEFT JOIN " . CUSTOM_USER_TABLE . " u ON u.ID = um.user_id WHERE u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 AND u.ID != %d ORDER BY RAND() DESC", $bp->loggedin_user->id ) );
169
  $paged_users_sql = apply_filters( 'bp_core_random_users_sql', $wpdb->prepare( "SELECT DISTINCT um.user_id FROM " . CUSTOM_USER_META_TABLE . " um LEFT JOIN " . CUSTOM_USER_TABLE . " u ON u.ID = um.user_id WHERE u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 AND u.ID != %d ORDER BY RAND(){$pag_sql}", $bp->loggedin_user->id ), $pag_sql );
170
 
171
  $total_users = $wpdb->get_var( $total_users_sql );
172
  $paged_users = $wpdb->get_results( $paged_users_sql );
173
-
174
  return array( 'users' => $paged_users, 'total' => $total_users );
175
  }
176
-
177
  function get_online_users( $limit = null, $page = 1 ) {
178
  global $wpdb;
179
-
180
  if ( $limit && $page )
181
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
182
 
183
- $total_users_sql = apply_filters( 'bp_core_online_users_count_sql', "SELECT DISTINCT count(um.user_id) FROM " . CUSTOM_USER_META_TABLE . " um LEFT JOIN " . CUSTOM_USER_TABLE . " u ON u.ID = um.user_id WHERE um.meta_key = 'last_activity' AND u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 AND DATE_ADD( FROM_UNIXTIME(um.meta_value), INTERVAL 5 MINUTE ) >= NOW() ORDER BY FROM_UNIXTIME(um.meta_value) DESC" );
184
  $paged_users_sql = apply_filters( 'bp_core_online_users_sql', "SELECT DISTINCT um.user_id FROM " . CUSTOM_USER_META_TABLE . " um LEFT JOIN " . CUSTOM_USER_TABLE . " u ON u.ID = um.user_id WHERE um.meta_key = 'last_activity' AND u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 AND DATE_ADD( FROM_UNIXTIME(um.meta_value), INTERVAL 5 MINUTE ) >= NOW() ORDER BY FROM_UNIXTIME(um.meta_value) DESC{$pag_sql}", $pag_sql );
185
 
186
  $total_users = $wpdb->get_var( $total_users_sql );
@@ -188,65 +188,65 @@ class BP_Core_User {
188
 
189
  return array( 'users' => $paged_users, 'total' => $total_users );
190
  }
191
-
192
  function get_alphabetical_users( $limit = null, $page = 1 ) {
193
  global $wpdb, $bp;
194
 
195
  if ( !function_exists( 'xprofile_install' ) )
196
  return BP_Core_User::get_active_users( $limit, $page );
197
-
198
  if ( $limit && $page )
199
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
200
 
201
- $total_users_sql = apply_filters( 'bp_core_alphabetical_users_count_sql', $wpdb->prepare( "SELECT DISTINCT count(u.ID) FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id LEFT JOIN {$bp->profile->table_name_fields} pf ON pd.field_id = pf.id WHERE u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 AND pf.name = %s ORDER BY pd.value ASC", BP_XPROFILE_FULLNAME_FIELD_NAME ) );
202
- $paged_users_sql = apply_filters( 'bp_core_alphabetical_users_sql', $wpdb->prepare( "SELECT DISTINCT u.ID as user_id FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id LEFT JOIN {$bp->profile->table_name_fields} pf ON pd.field_id = pf.id WHERE u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 AND pf.name = %s ORDER BY pd.value ASC{$pag_sql}", BP_XPROFILE_FULLNAME_FIELD_NAME ), $pag_sql );
203
 
204
  $total_users = $wpdb->get_var( $total_users_sql );
205
  $paged_users = $wpdb->get_results( $paged_users_sql );
206
 
207
  return array( 'users' => $paged_users, 'total' => $total_users );
208
  }
209
-
210
  function get_users_by_letter( $letter, $limit = null, $page = 1 ) {
211
  global $wpdb, $bp;
212
-
213
  if ( !function_exists('xprofile_install') )
214
  return BP_Core_User::get_active_users( $limit, $page );
215
-
216
  if ( $limit && $page )
217
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
218
-
219
  if ( strlen($letter) > 1 || is_numeric($letter) || !$letter )
220
  return false;
221
-
222
  $letter = like_escape( $wpdb->escape( $letter ) );
223
 
224
- $total_users_sql = apply_filters( 'bp_core_users_by_letter_count_sql', $wpdb->prepare( "SELECT DISTINCT count(u.ID) FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id LEFT JOIN {$bp->profile->table_name_fields} pf ON pd.field_id = pf.id WHERE u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 AND pf.name = %s AND pd.value LIKE '$letter%%' ORDER BY pd.value ASC", BP_XPROFILE_FULLNAME_FIELD_NAME ), $letter );
225
  $paged_users_sql = apply_filters( 'bp_core_users_by_letter_sql', $wpdb->prepare( "SELECT DISTINCT u.ID as user_id FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id LEFT JOIN {$bp->profile->table_name_fields} pf ON pd.field_id = pf.id WHERE u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 AND pf.name = %s AND pd.value LIKE '$letter%%' ORDER BY pd.value ASC{$pag_sql}", BP_XPROFILE_FULLNAME_FIELD_NAME ), $letter, $pag_sql );
226
 
227
  $total_users = $wpdb->get_var( $total_users_sql );
228
  $paged_users = $wpdb->get_results( $paged_users_sql );
229
-
230
  return array( 'users' => $paged_users, 'total' => $total_users );
231
  }
232
-
233
  function search_users( $search_terms, $limit = null, $page = 1 ) {
234
  global $wpdb, $bp;
235
-
236
  if ( !function_exists('xprofile_install') )
237
  return BP_Core_User::get_active_users( $limit, $page );
238
-
239
  if ( $limit && $page )
240
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
241
-
242
- $search_terms = like_escape( $wpdb->escape( $search_terms ) );
243
 
244
- $total_users_sql = apply_filters( 'bp_core_search_users_count_sql', "SELECT DISTINCT count(u.ID) as user_id FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id WHERE u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 AND pd.value LIKE '%%$search_terms%%' ORDER BY pd.value ASC", $search_terms );
 
 
245
  $paged_users_sql = apply_filters( 'bp_core_search_users_sql', "SELECT DISTINCT u.ID as user_id FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id WHERE u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 AND pd.value LIKE '%%$search_terms%%' ORDER BY pd.value ASC{$pag_sql}", $search_terms, $pag_sql );
246
 
247
  $total_users = $wpdb->get_var( $total_users_sql );
248
  $paged_users = $wpdb->get_results( $paged_users_sql );
249
-
250
  return array( 'users' => $paged_users, 'total' => $total_users );
251
  }
252
  }
@@ -255,7 +255,7 @@ class BP_Core_User {
255
  /**
256
  * BP_Core_Notification class can be used by any component.
257
  * It will handle the fetching, saving and deleting of a user notification.
258
- *
259
  * @package BuddyPress Core
260
  */
261
 
@@ -268,17 +268,17 @@ class BP_Core_Notification {
268
  var $component_action;
269
  var $date_notified;
270
  var $is_new;
271
-
272
  function bp_core_notification( $id = false ) {
273
  if ( $id ) {
274
  $this->id = $id;
275
  $this->populate();
276
  }
277
  }
278
-
279
  function populate() {
280
  global $wpdb, $bp;
281
-
282
  if ( $notification = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->core->table_name_notifications} WHERE id = %d", $this->id ) ) ) {
283
  $this->item_id = $notification->item_id;
284
  $this->secondary_item_id = $notification->secondary_item_id;
@@ -288,11 +288,11 @@ class BP_Core_Notification {
288
  $this->date_notified = $notification->date_notified;
289
  $this->is_new = $notification->is_new;
290
  }
291
- }
292
-
293
  function save() {
294
  global $wpdb, $bp;
295
-
296
  if ( $this->id ) {
297
  // Update
298
  $sql = $wpdb->prepare( "UPDATE {$bp->core->table_name_notifications} SET item_id = %d, secondary_item_id = %d, user_id = %d, component_name = %s, component_action = %d, date_notified = FROM_UNIXTIME(%d), is_new = %d ) WHERE id = %d", $this->item_id, $this->secondary_item_id, $this->user_id, $this->component_name, $this->component_action, $this->date_notified, $this->is_new, $this->id );
@@ -309,52 +309,52 @@ class BP_Core_Notification {
309
  }
310
 
311
  /* Static functions */
312
-
313
  function check_access( $user_id, $notification_id ) {
314
  global $wpdb, $bp;
315
-
316
- return $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->core->table_name_notifications} WHERE id = %d AND user_id = %d", $notification_id, $user_id ) );
317
  }
318
-
319
  function get_all_for_user( $user_id ) {
320
  global $wpdb, $bp;
321
 
322
  return $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->core->table_name_notifications} WHERE user_id = %d AND is_new = 1", $user_id ) );
323
  }
324
-
325
  function delete_for_user_by_type( $user_id, $component_name, $component_action ) {
326
  global $wpdb, $bp;
327
-
328
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE user_id = %d AND component_name = %s AND component_action = %s", $user_id, $component_name, $component_action ) );
329
  }
330
-
331
  function delete_for_user_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id ) {
332
  global $wpdb, $bp;
333
-
334
  if ( $secondary_item_id )
335
  $secondary_item_sql = $wpdb->prepare( " AND secondary_item_id = %d", $secondary_item_id );
336
-
337
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE user_id = %d AND item_id = %d AND component_name = %s AND component_action = %s{$secondary_item_sql}", $user_id, $item_id, $component_name, $component_action ) );
338
  }
339
-
340
  function delete_from_user_by_type( $user_id, $component_name, $component_action ) {
341
  global $wpdb, $bp;
342
-
343
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE item_id = %d AND component_name = %s AND component_action = %s", $user_id, $component_name, $component_action ) );
344
  }
345
-
346
  function delete_all_by_type( $item_id, $component_name, $component_action, $secondary_item_id ) {
347
  global $wpdb, $bp;
348
-
349
  if ( $component_action )
350
  $component_action_sql = $wpdb->prepare( "AND component_action = %s", $component_action );
351
-
352
  if ( $secondary_item_id )
353
  $secondary_item_sql = $wpdb->prepare( "AND secondary_item_id = %d", $secondary_item_id );
354
-
355
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE item_id = %d AND component_name = %s {$component_action_sql} {$secondary_item_sql}", $item_id, $component_name ) );
356
  }
357
- }
358
 
359
 
360
  ?>
2
  /**
3
  * BP_Core_User class can be used by any component. It will fetch useful
4
  * details for any user when provided with a user_id.
5
+ *
6
  * Example:
7
  * $user = new BP_Core_User( $user_id );
8
  * $user_avatar = $user->avatar;
9
  * $user_email = $user->email;
10
  * $user_status = $user->status;
11
  * etc.
12
+ *
13
  * @package BuddyPress Core
14
  */
15
  class BP_Core_User {
19
  var $avatar_mini;
20
  var $fullname;
21
  var $email;
22
+
23
  var $user_url;
24
  var $user_link;
25
+
26
  var $last_active;
27
  var $profile_last_updated;
28
 
30
  var $total_friends;
31
  var $total_blogs;
32
  var $total_groups;
33
+
34
  function bp_core_user( $user_id, $populate_extras = false ) {
35
  if ( $user_id ) {
36
  $this->id = $user_id;
37
  $this->populate();
38
+
39
  if ( $populate_extras )
40
  $this->populate_extras();
41
  }
42
+ }
43
+
44
  /**
45
  * populate()
46
  *
47
  * Populate the instantiated class with data based on the User ID provided.
48
+ *
49
  * @package BuddyPress Core
50
  * @global $userdata WordPress user data for the current logged in user.
51
  * @uses bp_core_get_userurl() Returns the URL with no HTML markup for a user based on their user id
58
  function populate() {
59
  $this->user_url = bp_core_get_userurl( $this->id );
60
  $this->user_link = bp_core_get_userlink( $this->id );
61
+
62
  $this->fullname = attribute_escape( bp_core_get_user_displayname( $this->id ) );
63
  $this->email = attribute_escape( bp_core_get_user_email( $this->id ) );
64
  $this->last_active = attribute_escape( bp_core_get_last_activity( get_usermeta( $this->id, 'last_activity' ), __( 'active %s ago', 'buddypress' ) ) );
67
  $this->avatar_thumb = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'thumb' ) );
68
  $this->avatar_mini = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'thumb', 'width' => 30, 'height' => 30 ) );
69
  }
70
+
71
  function populate_extras() {
72
  global $bp;
73
+
74
+ if ( function_exists('friends_install') ) {
75
+ $this->total_friends = BP_Friends_Friendship::total_friend_COUNT( $this->id );
76
 
77
  if ( $this->total_friends ) {
78
  if ( 1 == $this->total_friends )
79
  $this->total_friends .= ' ' . __( 'friend', 'buddypress' );
80
  else
81
  $this->total_friends .= ' ' . __( 'friends', 'buddypress' );
82
+
83
  $this->total_friends = '<a href="' . $this->user_url . $bp->friends->slug . '" title="' . sprintf( __( "%s's friend list", 'buddypress' ), $this->fullname ) . '">' . $this->total_friends . '</a>';
84
  }
85
  }
86
 
87
+ if ( function_exists('bp_blogs_install') ) {
88
  if ( $this->total_blogs ) {
89
  if ( 1 == $this->total_blogs )
90
  $this->total_blogs .= ' ' . __( 'blog', 'buddypress' );
91
  else
92
+ $this->total_blogs .= ' ' . __( 'blogs', 'buddypress' );
93
+
94
  $this->total_blogs = '<a href="' . $this->user_url . $bp->blogs->slug . '" title="' . sprintf( __( "%s's blog list", 'buddypress' ), $this->fullname ) . '">' . $this->total_blogs . '</a>';
95
  }
96
  }
97
+
98
  if ( function_exists('groups_install') ) {
99
+ $this->total_groups = BP_Groups_Member::total_group_COUNT( $this->id );
100
+
101
  if ( $this->total_groups ) {
102
  if ( 1 == $this->total_groups )
103
  $this->total_groups .= ' ' . __( 'group', 'buddypress' );
108
  }
109
  }
110
  }
111
+
112
  /* Static Functions */
113
+
114
  function get_newest_users( $limit = null, $page = 1 ) {
115
  global $wpdb;
116
+
117
  if ( $limit && $page )
118
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
119
+
120
+ $total_users_sql = apply_filters( 'bp_core_newest_users_count_sql', "SELECT COUNT(DISTINCT ID) FROM " . CUSTOM_USER_TABLE . " WHERE spam = 0 AND deleted = 0 AND user_status = 0 ORDER BY user_registered DESC" );
121
  $paged_users_sql = apply_filters( 'bp_core_newest_users_sql', "SELECT DISTINCT ID as user_id, DATE_ADD( user_registered, INTERVAL " . get_option('gmt_offset') . " HOUR ) as user_registered FROM " . CUSTOM_USER_TABLE . " WHERE spam = 0 AND deleted = 0 AND user_status = 0 ORDER BY user_registered DESC{$pag_sql}", $pag_sql );
122
+
123
  $total_users = $wpdb->get_var( $total_users_sql );
124
  $paged_users = $wpdb->get_results( $paged_users_sql );
125
+
126
  return array( 'users' => $paged_users, 'total' => $total_users );
127
  }
128
+
129
  function get_active_users( $limit = null, $page = 1 ) {
130
  global $wpdb;
131
 
132
  if ( $limit && $page )
133
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
134
 
135
+ $total_users_sql = apply_filters( 'bp_core_active_users_count_sql', "SELECT COUNT(DISTINCT um.user_id) FROM " . CUSTOM_USER_META_TABLE . " um LEFT JOIN " . CUSTOM_USER_TABLE . " u ON u.ID = um.user_id WHERE um.meta_key = 'last_activity' AND u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 ORDER BY FROM_UNIXTIME(um.meta_value) DESC" );
136
  $paged_users_sql = apply_filters( 'bp_core_active_users_sql', "SELECT DISTINCT user_id FROM " . CUSTOM_USER_META_TABLE . " um LEFT JOIN " . CUSTOM_USER_TABLE . " u ON u.ID = um.user_id WHERE um.meta_key = 'last_activity' AND u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 ORDER BY FROM_UNIXTIME(um.meta_value) DESC{$pag_sql}", $pag_sql );
137
+
138
  $total_users = $wpdb->get_var( $total_users_sql );
139
  $paged_users = $wpdb->get_results( $paged_users_sql );
140
+
141
  return array( 'users' => $paged_users, 'total' => $total_users );
142
  }
143
 
144
  function get_popular_users( $limit = null, $page = 1 ) {
145
  global $wpdb;
146
+
147
  if ( !function_exists('friends_install') )
148
  return false;
149
+
150
  if ( $limit && $page )
151
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
152
 
153
+ $total_users_sql = apply_filters( 'bp_core_popular_users_count_sql', "SELECT COUNT(DISTINCT um.user_id) FROM " . CUSTOM_USER_META_TABLE . " um LEFT JOIN " . CUSTOM_USER_TABLE . " u ON u.ID = um.user_id WHERE um.meta_key = 'total_friend_count' AND u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 ORDER BY CONVERT(um.meta_value, SIGNED) DESC" );
154
  $paged_users_sql = apply_filters( 'bp_core_popular_users_sql', "SELECT DISTINCT um.user_id FROM " . CUSTOM_USER_META_TABLE . " um LEFT JOIN " . CUSTOM_USER_TABLE . " u ON u.ID = um.user_id WHERE um.meta_key = 'total_friend_count' AND u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 ORDER BY CONVERT(um.meta_value, SIGNED) DESC{$pag_sql}", $pag_sql );
155
 
156
  $total_users = $wpdb->get_var( $total_users_sql );
157
  $paged_users = $wpdb->get_results( $paged_users_sql );
158
+
159
  return array( 'users' => $paged_users, 'total' => $total_users );
160
  }
161
+
162
  function get_random_users( $limit = null, $page = 1 ) {
163
  global $wpdb, $bp;
164
+
165
  if ( $limit && $page )
166
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
167
 
168
+ $total_users_sql = apply_filters( 'bp_core_random_users_count_sql', $wpdb->prepare( "SELECT COUNT(DISTINCT um.user_id) FROM " . CUSTOM_USER_META_TABLE . " um LEFT JOIN " . CUSTOM_USER_TABLE . " u ON u.ID = um.user_id WHERE u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 AND u.ID != %d ORDER BY RAND() DESC", $bp->loggedin_user->id ) );
169
  $paged_users_sql = apply_filters( 'bp_core_random_users_sql', $wpdb->prepare( "SELECT DISTINCT um.user_id FROM " . CUSTOM_USER_META_TABLE . " um LEFT JOIN " . CUSTOM_USER_TABLE . " u ON u.ID = um.user_id WHERE u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 AND u.ID != %d ORDER BY RAND(){$pag_sql}", $bp->loggedin_user->id ), $pag_sql );
170
 
171
  $total_users = $wpdb->get_var( $total_users_sql );
172
  $paged_users = $wpdb->get_results( $paged_users_sql );
173
+
174
  return array( 'users' => $paged_users, 'total' => $total_users );
175
  }
176
+
177
  function get_online_users( $limit = null, $page = 1 ) {
178
  global $wpdb;
179
+
180
  if ( $limit && $page )
181
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
182
 
183
+ $total_users_sql = apply_filters( 'bp_core_online_users_count_sql', "SELECT COUNT(DISTINCT um.user_id) FROM " . CUSTOM_USER_META_TABLE . " um LEFT JOIN " . CUSTOM_USER_TABLE . " u ON u.ID = um.user_id WHERE um.meta_key = 'last_activity' AND u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 AND DATE_ADD( FROM_UNIXTIME(um.meta_value), INTERVAL 5 MINUTE ) >= NOW() ORDER BY FROM_UNIXTIME(um.meta_value) DESC" );
184
  $paged_users_sql = apply_filters( 'bp_core_online_users_sql', "SELECT DISTINCT um.user_id FROM " . CUSTOM_USER_META_TABLE . " um LEFT JOIN " . CUSTOM_USER_TABLE . " u ON u.ID = um.user_id WHERE um.meta_key = 'last_activity' AND u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 AND DATE_ADD( FROM_UNIXTIME(um.meta_value), INTERVAL 5 MINUTE ) >= NOW() ORDER BY FROM_UNIXTIME(um.meta_value) DESC{$pag_sql}", $pag_sql );
185
 
186
  $total_users = $wpdb->get_var( $total_users_sql );
188
 
189
  return array( 'users' => $paged_users, 'total' => $total_users );
190
  }
191
+
192
  function get_alphabetical_users( $limit = null, $page = 1 ) {
193
  global $wpdb, $bp;
194
 
195
  if ( !function_exists( 'xprofile_install' ) )
196
  return BP_Core_User::get_active_users( $limit, $page );
197
+
198
  if ( $limit && $page )
199
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
200
 
201
+ $total_users_sql = apply_filters( 'bp_core_search_users_count_sql', "SELECT DISTINCT u.ID as user_id FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id WHERE u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 AND pd.value LIKE '%%$search_terms%%' ORDER BY pd.value ASC", $search_terms );
202
+ $paged_users_sql = apply_filters( 'bp_core_search_users_sql', "SELECT DISTINCT u.ID as user_id FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id WHERE u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 AND pd.value LIKE '%%$search_terms%%' ORDER BY pd.value ASC{$pag_sql}", $search_terms, $pag_sql );
203
 
204
  $total_users = $wpdb->get_var( $total_users_sql );
205
  $paged_users = $wpdb->get_results( $paged_users_sql );
206
 
207
  return array( 'users' => $paged_users, 'total' => $total_users );
208
  }
209
+
210
  function get_users_by_letter( $letter, $limit = null, $page = 1 ) {
211
  global $wpdb, $bp;
212
+
213
  if ( !function_exists('xprofile_install') )
214
  return BP_Core_User::get_active_users( $limit, $page );
215
+
216
  if ( $limit && $page )
217
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
218
+
219
  if ( strlen($letter) > 1 || is_numeric($letter) || !$letter )
220
  return false;
221
+
222
  $letter = like_escape( $wpdb->escape( $letter ) );
223
 
224
+ $total_users_sql = apply_filters( 'bp_core_users_by_letter_count_sql', $wpdb->prepare( "SELECT COUNT(DISTINCT u.ID) FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id LEFT JOIN {$bp->profile->table_name_fields} pf ON pd.field_id = pf.id WHERE u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 AND pf.name = %s AND pd.value LIKE '$letter%%' ORDER BY pd.value ASC", BP_XPROFILE_FULLNAME_FIELD_NAME ), $letter );
225
  $paged_users_sql = apply_filters( 'bp_core_users_by_letter_sql', $wpdb->prepare( "SELECT DISTINCT u.ID as user_id FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id LEFT JOIN {$bp->profile->table_name_fields} pf ON pd.field_id = pf.id WHERE u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 AND pf.name = %s AND pd.value LIKE '$letter%%' ORDER BY pd.value ASC{$pag_sql}", BP_XPROFILE_FULLNAME_FIELD_NAME ), $letter, $pag_sql );
226
 
227
  $total_users = $wpdb->get_var( $total_users_sql );
228
  $paged_users = $wpdb->get_results( $paged_users_sql );
229
+
230
  return array( 'users' => $paged_users, 'total' => $total_users );
231
  }
232
+
233
  function search_users( $search_terms, $limit = null, $page = 1 ) {
234
  global $wpdb, $bp;
235
+
236
  if ( !function_exists('xprofile_install') )
237
  return BP_Core_User::get_active_users( $limit, $page );
238
+
239
  if ( $limit && $page )
240
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
 
 
241
 
242
+ $search_terms = like_escape( $wpdb->escape( $search_terms ) );
243
+
244
+ $total_users_sql = apply_filters( 'bp_core_search_users_count_sql', "SELECT COUNT(DISTINCT u.ID) as user_id FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id WHERE u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 AND pd.value LIKE '%%$search_terms%%' ORDER BY pd.value ASC", $search_terms );
245
  $paged_users_sql = apply_filters( 'bp_core_search_users_sql', "SELECT DISTINCT u.ID as user_id FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id WHERE u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 AND pd.value LIKE '%%$search_terms%%' ORDER BY pd.value ASC{$pag_sql}", $search_terms, $pag_sql );
246
 
247
  $total_users = $wpdb->get_var( $total_users_sql );
248
  $paged_users = $wpdb->get_results( $paged_users_sql );
249
+
250
  return array( 'users' => $paged_users, 'total' => $total_users );
251
  }
252
  }
255
  /**
256
  * BP_Core_Notification class can be used by any component.
257
  * It will handle the fetching, saving and deleting of a user notification.
258
+ *
259
  * @package BuddyPress Core
260
  */
261
 
268
  var $component_action;
269
  var $date_notified;
270
  var $is_new;
271
+
272
  function bp_core_notification( $id = false ) {
273
  if ( $id ) {
274
  $this->id = $id;
275
  $this->populate();
276
  }
277
  }
278
+
279
  function populate() {
280
  global $wpdb, $bp;
281
+
282
  if ( $notification = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->core->table_name_notifications} WHERE id = %d", $this->id ) ) ) {
283
  $this->item_id = $notification->item_id;
284
  $this->secondary_item_id = $notification->secondary_item_id;
288
  $this->date_notified = $notification->date_notified;
289
  $this->is_new = $notification->is_new;
290
  }
291
+ }
292
+
293
  function save() {
294
  global $wpdb, $bp;
295
+
296
  if ( $this->id ) {
297
  // Update
298
  $sql = $wpdb->prepare( "UPDATE {$bp->core->table_name_notifications} SET item_id = %d, secondary_item_id = %d, user_id = %d, component_name = %s, component_action = %d, date_notified = FROM_UNIXTIME(%d), is_new = %d ) WHERE id = %d", $this->item_id, $this->secondary_item_id, $this->user_id, $this->component_name, $this->component_action, $this->date_notified, $this->is_new, $this->id );
309
  }
310
 
311
  /* Static functions */
312
+
313
  function check_access( $user_id, $notification_id ) {
314
  global $wpdb, $bp;
315
+
316
+ return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->core->table_name_notifications} WHERE id = %d AND user_id = %d", $notification_id, $user_id ) );
317
  }
318
+
319
  function get_all_for_user( $user_id ) {
320
  global $wpdb, $bp;
321
 
322
  return $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->core->table_name_notifications} WHERE user_id = %d AND is_new = 1", $user_id ) );
323
  }
324
+
325
  function delete_for_user_by_type( $user_id, $component_name, $component_action ) {
326
  global $wpdb, $bp;
327
+
328
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE user_id = %d AND component_name = %s AND component_action = %s", $user_id, $component_name, $component_action ) );
329
  }
330
+
331
  function delete_for_user_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id ) {
332
  global $wpdb, $bp;
333
+
334
  if ( $secondary_item_id )
335
  $secondary_item_sql = $wpdb->prepare( " AND secondary_item_id = %d", $secondary_item_id );
336
+
337
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE user_id = %d AND item_id = %d AND component_name = %s AND component_action = %s{$secondary_item_sql}", $user_id, $item_id, $component_name, $component_action ) );
338
  }
339
+
340
  function delete_from_user_by_type( $user_id, $component_name, $component_action ) {
341
  global $wpdb, $bp;
342
+
343
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE item_id = %d AND component_name = %s AND component_action = %s", $user_id, $component_name, $component_action ) );
344
  }
345
+
346
  function delete_all_by_type( $item_id, $component_name, $component_action, $secondary_item_id ) {
347
  global $wpdb, $bp;
348
+
349
  if ( $component_action )
350
  $component_action_sql = $wpdb->prepare( "AND component_action = %s", $component_action );
351
+
352
  if ( $secondary_item_id )
353
  $secondary_item_sql = $wpdb->prepare( "AND secondary_item_id = %d", $secondary_item_id );
354
+
355
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE item_id = %d AND component_name = %s {$component_action_sql} {$secondary_item_sql}", $item_id, $component_name ) );
356
  }
357
+ }
358
 
359
 
360
  ?>
bp-core/bp-core-cssjs.php CHANGED
@@ -4,13 +4,13 @@
4
  * bp_core_add_admin_bar_css()
5
  *
6
  * Add the CSS needed for the admin bar on blogs (other than the root) and in the admin area.
7
- *
8
  * @package BuddyPress Core
9
  * @uses get_option() Selects a site setting from the DB.
10
  */
11
  function bp_core_add_admin_bar_css() {
12
  global $current_blog;
13
-
14
  if ( defined( 'BP_DISABLE_ADMIN_BAR' ) )
15
  return false;
16
 
@@ -31,7 +31,7 @@ add_action( 'template_redirect', 'bp_core_add_admin_bar_css' );
31
  * bp_core_add_admin_bar_js()
32
  *
33
  * Add the minor JS needed for the admin bar.
34
- *
35
  * @package BuddyPress Core
36
  * @uses get_option() Selects a site setting from the DB.
37
  */
@@ -45,7 +45,7 @@ add_action( 'wp', 'bp_core_add_admin_bar_js' );
45
  * bp_core_admin_menu_icon_css()
46
  *
47
  * Add a hover-able icon to the "BuddyPress" wp-admin area menu.
48
- *
49
  * @package BuddyPress Core
50
  */
51
  function bp_core_admin_menu_icon_css() {
@@ -59,7 +59,7 @@ function bp_core_admin_menu_icon_css() {
59
  <?php
60
  }
61
  add_action( 'admin_head', 'bp_core_admin_menu_icon_css' );
62
-
63
  function bp_core_confirmation_js() {
64
  ?>
65
  <script type="text/javascript"> jQuery(document).ready( function() { jQuery("a.confirm").click( function() { if ( confirm( '<?php _e( 'Are you sure?', 'buddypress' ) ?>' ) ) return true; else return false; }); });</script>
@@ -71,31 +71,31 @@ add_action( 'wp_head', 'bp_core_confirmation_js', 100 );
71
  * bp_core_add_jquery_cropper()
72
  *
73
  * Makes sure the jQuery jCrop library is loaded.
74
- *
75
  * @package BuddyPress Core
76
  */
77
  function bp_core_add_jquery_cropper() {
78
  wp_enqueue_script( 'jcrop', array( 'jquery' ) );
79
- add_action( 'wp_head', 'bp_core_add_cropper_inline_js' );
80
- add_action( 'wp_head', 'bp_core_add_cropper_inline_css' );
81
  }
82
 
83
  /**
84
  * bp_core_add_cropper_inline_js()
85
  *
86
  * Adds the inline JS needed for the cropper to work on a per-page basis.
87
- *
88
  * @package BuddyPress Core
89
  */
90
  function bp_core_add_cropper_inline_js() {
91
  global $bp;
92
-
93
  $image = apply_filters( 'bp_inline_cropper_image', getimagesize( $bp->avatar_admin->image->dir ) );
94
 
95
- $aspect_ratio = 1;
96
-
97
  /* Calculate Aspect Ratio */
98
- if ( (int) constant( 'BP_AVATAR_FULL_HEIGHT' ) && ( (int) constant( 'BP_AVATAR_FULL_WIDTH' ) != (int) constant( 'BP_AVATAR_FULL_HEIGHT' ) ) )
99
  $aspect_ratio = (int) constant( 'BP_AVATAR_FULL_WIDTH' ) / (int) constant( 'BP_AVATAR_FULL_HEIGHT' );
100
  ?>
101
  <script type="text/javascript">
@@ -130,7 +130,7 @@ function bp_core_add_cropper_inline_js() {
130
  marginTop: '-' + Math.round(ry * coords.y) + 'px'
131
  });
132
  }
133
- }
134
  </script>
135
  <?php
136
  }
@@ -139,14 +139,14 @@ function bp_core_add_cropper_inline_js() {
139
  * bp_core_add_cropper_inline_css()
140
  *
141
  * Adds the inline CSS needed for the cropper to work on a per-page basis.
142
- *
143
  * @package BuddyPress Core
144
  */
145
  function bp_core_add_cropper_inline_css() {
146
  global $bp;
147
  ?>
148
  <style type="text/css">
149
- .jcrop-holder { text-align: left; }
150
  .jcrop-vline, .jcrop-hline { font-size: 0; position: absolute; background: white top left repeat url( <?php echo BP_PLUGIN_URL ?>/bp-core/images/Jcrop.gif ); }
151
  .jcrop-vline { height: 100%; width: 1px !important; }
152
  .jcrop-hline { width: 100%; height: 1px !important; }
@@ -156,7 +156,7 @@ function bp_core_add_cropper_inline_css() {
156
  .custom .jcrop-handle { border-color: black; background-color: #C7BB00; -moz-border-radius: 3px; -webkit-border-radius: 3px; }
157
  #avatar-crop-pane { width: <?php echo BP_AVATAR_FULL_WIDTH ?>px; height: <?php echo BP_AVATAR_FULL_HEIGHT ?>px; overflow: hidden; }
158
  #avatar-crop-submit { margin: 20px 0; }
159
- #avatar-upload-form img { border: none !important; }
160
  </style>
161
  <?php
162
  }
@@ -165,13 +165,13 @@ function bp_core_add_cropper_inline_css() {
165
  * bp_core_add_ajax_url_js()
166
  *
167
  * Adds AJAX target URL so themes can access the WordPress AJAX functionality.
168
- *
169
  * @package BuddyPress Core
170
  */
171
  function bp_core_add_ajax_url_js() {
172
  global $bp;
173
-
174
- echo
175
  '<script type="text/javascript">var ajaxurl = "' . $bp->root_domain . str_replace( 'index.php', 'wp-load.php', $_SERVER['SCRIPT_NAME'] ) . '";</script>
176
  ';
177
  }
@@ -181,10 +181,10 @@ add_action( 'wp_head', 'bp_core_add_ajax_url_js' );
181
  * bp_core_override_adminbar_css()
182
  *
183
  * Overrides the theme's admin bar CSS to hide the adminbar if disabled.
184
- *
185
  * @package BuddyPress Core
186
  */
187
- function bp_core_override_adminbar_css() {
188
  if ( defined( 'BP_DISABLE_ADMIN_BAR' ) || ( get_site_option( 'hide-loggedout-adminbar' ) && !is_user_logged_in() ) ) {
189
  ?>
190
  <style type="text/css">body { padding-top: 0 !important; } #wp-admin-bar { display: none; }</style>
4
  * bp_core_add_admin_bar_css()
5
  *
6
  * Add the CSS needed for the admin bar on blogs (other than the root) and in the admin area.
7
+ *
8
  * @package BuddyPress Core
9
  * @uses get_option() Selects a site setting from the DB.
10
  */
11
  function bp_core_add_admin_bar_css() {
12
  global $current_blog;
13
+
14
  if ( defined( 'BP_DISABLE_ADMIN_BAR' ) )
15
  return false;
16
 
31
  * bp_core_add_admin_bar_js()
32
  *
33
  * Add the minor JS needed for the admin bar.
34
+ *
35
  * @package BuddyPress Core
36
  * @uses get_option() Selects a site setting from the DB.
37
  */
45
  * bp_core_admin_menu_icon_css()
46
  *
47
  * Add a hover-able icon to the "BuddyPress" wp-admin area menu.
48
+ *
49
  * @package BuddyPress Core
50
  */
51
  function bp_core_admin_menu_icon_css() {
59
  <?php
60
  }
61
  add_action( 'admin_head', 'bp_core_admin_menu_icon_css' );
62
+
63
  function bp_core_confirmation_js() {
64
  ?>
65
  <script type="text/javascript"> jQuery(document).ready( function() { jQuery("a.confirm").click( function() { if ( confirm( '<?php _e( 'Are you sure?', 'buddypress' ) ?>' ) ) return true; else return false; }); });</script>
71
  * bp_core_add_jquery_cropper()
72
  *
73
  * Makes sure the jQuery jCrop library is loaded.
74
+ *
75
  * @package BuddyPress Core
76
  */
77
  function bp_core_add_jquery_cropper() {
78
  wp_enqueue_script( 'jcrop', array( 'jquery' ) );
79
+ add_action( 'wp_head', 'bp_core_add_cropper_inline_js' );
80
+ add_action( 'wp_head', 'bp_core_add_cropper_inline_css' );
81
  }
82
 
83
  /**
84
  * bp_core_add_cropper_inline_js()
85
  *
86
  * Adds the inline JS needed for the cropper to work on a per-page basis.
87
+ *
88
  * @package BuddyPress Core
89
  */
90
  function bp_core_add_cropper_inline_js() {
91
  global $bp;
92
+
93
  $image = apply_filters( 'bp_inline_cropper_image', getimagesize( $bp->avatar_admin->image->dir ) );
94
 
95
+ $aspect_ratio = 1;
96
+
97
  /* Calculate Aspect Ratio */
98
+ if ( (int) constant( 'BP_AVATAR_FULL_HEIGHT' ) && ( (int) constant( 'BP_AVATAR_FULL_WIDTH' ) != (int) constant( 'BP_AVATAR_FULL_HEIGHT' ) ) )
99
  $aspect_ratio = (int) constant( 'BP_AVATAR_FULL_WIDTH' ) / (int) constant( 'BP_AVATAR_FULL_HEIGHT' );
100
  ?>
101
  <script type="text/javascript">
130
  marginTop: '-' + Math.round(ry * coords.y) + 'px'
131
  });
132
  }
133
+ }
134
  </script>
135
  <?php
136
  }
139
  * bp_core_add_cropper_inline_css()
140
  *
141
  * Adds the inline CSS needed for the cropper to work on a per-page basis.
142
+ *
143
  * @package BuddyPress Core
144
  */
145
  function bp_core_add_cropper_inline_css() {
146
  global $bp;
147
  ?>
148
  <style type="text/css">
149
+ .jcrop-holder { float: left; margin: 0 20px 20px 0; text-align: left; }
150
  .jcrop-vline, .jcrop-hline { font-size: 0; position: absolute; background: white top left repeat url( <?php echo BP_PLUGIN_URL ?>/bp-core/images/Jcrop.gif ); }
151
  .jcrop-vline { height: 100%; width: 1px !important; }
152
  .jcrop-hline { width: 100%; height: 1px !important; }
156
  .custom .jcrop-handle { border-color: black; background-color: #C7BB00; -moz-border-radius: 3px; -webkit-border-radius: 3px; }
157
  #avatar-crop-pane { width: <?php echo BP_AVATAR_FULL_WIDTH ?>px; height: <?php echo BP_AVATAR_FULL_HEIGHT ?>px; overflow: hidden; }
158
  #avatar-crop-submit { margin: 20px 0; }
159
+ #avatar-upload-form img, #create-group-form img, #group-settings-form img { border: none !important; }
160
  </style>
161
  <?php
162
  }
165
  * bp_core_add_ajax_url_js()
166
  *
167
  * Adds AJAX target URL so themes can access the WordPress AJAX functionality.
168
+ *
169
  * @package BuddyPress Core
170
  */
171
  function bp_core_add_ajax_url_js() {
172
  global $bp;
173
+
174
+ echo
175
  '<script type="text/javascript">var ajaxurl = "' . $bp->root_domain . str_replace( 'index.php', 'wp-load.php', $_SERVER['SCRIPT_NAME'] ) . '";</script>
176
  ';
177
  }
181
  * bp_core_override_adminbar_css()
182
  *
183
  * Overrides the theme's admin bar CSS to hide the adminbar if disabled.
184
+ *
185
  * @package BuddyPress Core
186
  */
187
+ function bp_core_override_adminbar_css() {
188
  if ( defined( 'BP_DISABLE_ADMIN_BAR' ) || ( get_site_option( 'hide-loggedout-adminbar' ) && !is_user_logged_in() ) ) {
189
  ?>
190
  <style type="text/css">body { padding-top: 0 !important; } #wp-admin-bar { display: none; }</style>
bp-core/bp-core-notifications.php CHANGED
@@ -2,10 +2,10 @@
2
 
3
  function bp_core_add_notification( $item_id, $user_id, $component_name, $component_action, $secondary_item_id = false, $date_notified = false ) {
4
  global $bp;
5
-
6
  if ( !$date_notified )
7
  $date_notified = time();
8
-
9
  $notification = new BP_Core_Notification;
10
  $notification->item_id = $item_id;
11
  $notification->user_id = $user_id;
@@ -16,47 +16,47 @@ function bp_core_add_notification( $item_id, $user_id, $component_name, $compone
16
 
17
  if ( $secondary_item_id )
18
  $notification->secondary_item_id = $secondary_item_id;
19
-
20
  if ( !$notification->save() )
21
  return false;
22
-
23
  return true;
24
  }
25
 
26
  function bp_core_delete_notification( $id ) {
27
  if ( !bp_core_check_notification_access( $bp->loggedin_user->id, $id ) )
28
  return false;
29
-
30
  return BP_Core_Notification::delete( $id );
31
  }
32
 
33
  function bp_core_get_notification( $id ) {
34
- return new BP_Core_Notification( $id );
35
  }
36
 
37
  function bp_core_get_notifications_for_user( $user_id ) {
38
  global $bp;
39
-
40
  $notifications = BP_Core_Notification::get_all_for_user( $user_id );
41
-
42
  /* Group notifications by component and component_action and provide totals */
43
  for ( $i = 0; $i < count($notifications); $i++ ) {
44
  $notification = $notifications[$i];
45
-
46
  $grouped_notifications[$notification->component_name][$notification->component_action][] = $notification;
47
  }
48
-
49
  if ( !$grouped_notifications )
50
  return false;
51
-
52
  /* Calculated a renderable outcome for each notification type */
53
  foreach ( $grouped_notifications as $component_name => $action_arrays ) {
54
  if ( !$action_arrays )
55
  continue;
56
-
57
  foreach ( $action_arrays as $component_action_name => $component_action_items ) {
58
  $action_item_count = count($component_action_items);
59
-
60
  if ( $action_item_count < 1 )
61
  continue;
62
 
@@ -64,8 +64,8 @@ function bp_core_get_notifications_for_user( $user_id ) {
64
  $renderable[] = call_user_func( $bp->{$component_name}->format_notification_function, $component_action_name, $component_action_items[0]->item_id, $component_action_items[0]->secondary_item_id, $action_item_count );
65
  }
66
  }
67
- }
68
-
69
  return $renderable;
70
  }
71
 
@@ -88,7 +88,7 @@ function bp_core_delete_notifications_from_user( $user_id, $component_name, $com
88
  function bp_core_check_notification_access( $user_id, $notification_id ) {
89
  if ( !BP_Core_Notification::check_access( $user_id, $notification_id ) )
90
  return false;
91
-
92
  return true;
93
  }
94
 
2
 
3
  function bp_core_add_notification( $item_id, $user_id, $component_name, $component_action, $secondary_item_id = false, $date_notified = false ) {
4
  global $bp;
5
+
6
  if ( !$date_notified )
7
  $date_notified = time();
8
+
9
  $notification = new BP_Core_Notification;
10
  $notification->item_id = $item_id;
11
  $notification->user_id = $user_id;
16
 
17
  if ( $secondary_item_id )
18
  $notification->secondary_item_id = $secondary_item_id;
19
+
20
  if ( !$notification->save() )
21
  return false;
22
+
23
  return true;
24
  }
25
 
26
  function bp_core_delete_notification( $id ) {
27
  if ( !bp_core_check_notification_access( $bp->loggedin_user->id, $id ) )
28
  return false;
29
+
30
  return BP_Core_Notification::delete( $id );
31
  }
32
 
33
  function bp_core_get_notification( $id ) {
34
+ return new BP_Core_Notification( $id );
35
  }
36
 
37
  function bp_core_get_notifications_for_user( $user_id ) {
38
  global $bp;
39
+
40
  $notifications = BP_Core_Notification::get_all_for_user( $user_id );
41
+
42
  /* Group notifications by component and component_action and provide totals */
43
  for ( $i = 0; $i < count($notifications); $i++ ) {
44
  $notification = $notifications[$i];
45
+
46
  $grouped_notifications[$notification->component_name][$notification->component_action][] = $notification;
47
  }
48
+
49
  if ( !$grouped_notifications )
50
  return false;
51
+
52
  /* Calculated a renderable outcome for each notification type */
53
  foreach ( $grouped_notifications as $component_name => $action_arrays ) {
54
  if ( !$action_arrays )
55
  continue;
56
+
57
  foreach ( $action_arrays as $component_action_name => $component_action_items ) {
58
  $action_item_count = count($component_action_items);
59
+
60
  if ( $action_item_count < 1 )
61
  continue;
62
 
64
  $renderable[] = call_user_func( $bp->{$component_name}->format_notification_function, $component_action_name, $component_action_items[0]->item_id, $component_action_items[0]->secondary_item_id, $action_item_count );
65
  }
66
  }
67
+ }
68
+
69
  return $renderable;
70
  }
71
 
88
  function bp_core_check_notification_access( $user_id, $notification_id ) {
89
  if ( !BP_Core_Notification::check_access( $user_id, $notification_id ) )
90
  return false;
91
+
92
  return true;
93
  }
94
 
bp-core/bp-core-settings.php CHANGED
@@ -2,25 +2,25 @@
2
 
3
  if ( !defined( 'BP_SETTINGS_SLUG' ) )
4
  define( 'BP_SETTINGS_SLUG', 'settings' );
5
-
6
  function bp_core_add_settings_nav() {
7
  global $bp;
8
-
9
  /* Set up settings as a sudo-component for identification and nav selection */
10
  $bp->settings->id = 'settings';
11
  $bp->settings->slug = BP_SETTINGS_SLUG;
12
-
13
  /* Register this in the active components array */
14
  $bp->active_components[$bp->settings->slug] = $bp->settings->id;
15
 
16
  /* Add the settings navigation item */
17
  bp_core_new_nav_item( array( 'name' => __('Settings', 'buddypress'), 'slug' => $bp->settings->slug, 'position' => 100, 'show_for_displayed_user' => false, 'screen_function' => 'bp_core_screen_general_settings', 'default_subnav_slug' => 'general' ) );
18
 
19
- $settings_link = $bp->loggedin_user->domain . 'settings/';
20
-
21
  bp_core_new_subnav_item( array( 'name' => __( 'General', 'buddypress' ), 'slug' => 'general', 'parent_url' => $settings_link, 'parent_slug' => $bp->settings->slug, 'screen_function' => 'bp_core_screen_general_settings', 'position' => 10, 'user_has_access' => bp_is_home() ) );
22
  bp_core_new_subnav_item( array( 'name' => __( 'Notifications', 'buddypress' ), 'slug' => 'notifications', 'parent_url' => $settings_link, 'parent_slug' => $bp->settings->slug, 'screen_function' => 'bp_core_screen_notification_settings', 'position' => 20, 'user_has_access' => bp_is_home() ) );
23
-
24
  if ( !is_site_admin() && !(int) get_site_option( 'bp-disable-account-deletion' ) )
25
  bp_core_new_subnav_item( array( 'name' => __( 'Delete Account', 'buddypress' ), 'slug' => 'delete-account', 'parent_url' => $settings_link, 'parent_slug' => $bp->settings->slug, 'screen_function' => 'bp_core_screen_delete_account', 'position' => 90, 'user_has_access' => bp_is_home() ) );
26
  }
@@ -31,17 +31,17 @@ add_action( 'admin_menu', 'bp_core_add_settings_nav', 2 );
31
 
32
  function bp_core_screen_general_settings() {
33
  global $current_user, $bp_settings_updated, $pass_error;
34
-
35
  $bp_settings_updated = false;
36
  $pass_error = false;
37
-
38
  if ( isset($_POST['submit']) ) {
39
  check_admin_referer('bp_settings_general');
40
-
41
  require_once( WPINC . '/registration.php' );
42
-
43
  // Form has been submitted and nonce checks out, lets do it.
44
-
45
  if ( $_POST['email'] != '' )
46
  $current_user->user_email = wp_specialchars( trim( $_POST['email'] ) );
47
 
@@ -55,14 +55,14 @@ function bp_core_screen_general_settings() {
55
  } else {
56
  unset( $current_user->user_pass );
57
  }
58
-
59
  if ( !$pass_error && wp_update_user( get_object_vars( $current_user ) ) )
60
  $bp_settings_updated = true;
61
  }
62
-
63
  add_action( 'bp_template_title', 'bp_core_screen_general_settings_title' );
64
  add_action( 'bp_template_content', 'bp_core_screen_general_settings_content' );
65
-
66
  bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'plugin-template' ) );
67
  }
68
 
@@ -78,21 +78,21 @@ function bp_core_screen_general_settings_content() {
78
  <p><?php _e( 'Changes Saved.', 'buddypress' ) ?></p>
79
  </div>
80
  <?php } ?>
81
-
82
  <?php if ( $pass_error && !$bp_settings_updated ) { ?>
83
  <div id="message" class="error fade">
84
  <p><?php _e( 'Your passwords did not match', 'buddypress' ) ?></p>
85
- </div>
86
  <?php } ?>
87
 
88
- <form action="<?php echo $bp->loggedin_user->domain . 'settings/general' ?>" method="post" class="standard-form" id="settings-form">
89
  <label for="email"><?php _e( 'Account Email', 'buddypress' ) ?></label>
90
  <input type="text" name="email" id="email" value="<?php echo attribute_escape( $current_user->user_email ); ?>" class="settings-input" />
91
-
92
  <label for="pass1"><?php _e( 'Change Password <span>(leave blank for no change)</span>', 'buddypress' ) ?></label>
93
  <input type="password" name="pass1" id="pass1" size="16" value="" class="settings-input small" /> &nbsp;<?php _e( 'New Password', 'buddypress' ) ?><br />
94
  <input type="password" name="pass2" id="pass2" size="16" value="" class="settings-input small" /> &nbsp;<?php _e( 'Repeat New Password', 'buddypress' ) ?>
95
-
96
  <p class="submit"><input type="submit" name="submit" value="<?php _e( 'Save Changes', 'buddypress' ) ?>" id="submit" class="auto"/></p>
97
  <?php wp_nonce_field('bp_settings_general') ?>
98
  </form>
@@ -103,24 +103,24 @@ function bp_core_screen_general_settings_content() {
103
 
104
  function bp_core_screen_notification_settings() {
105
  global $current_user, $bp_settings_updated;
106
-
107
  $bp_settings_updated = false;
108
-
109
  if ( $_POST['submit'] ) {
110
  check_admin_referer('bp_settings_notifications');
111
-
112
  if ( $_POST['notifications'] ) {
113
  foreach ( $_POST['notifications'] as $key => $value ) {
114
  update_usermeta( (int)$current_user->id, $key, $value );
115
  }
116
  }
117
-
118
  $bp_settings_updated = true;
119
  }
120
-
121
  add_action( 'bp_template_title', 'bp_core_screen_notification_settings_title' );
122
  add_action( 'bp_template_content', 'bp_core_screen_notification_settings_content' );
123
-
124
  bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'plugin-template' ) );
125
  }
126
 
@@ -136,24 +136,24 @@ function bp_core_screen_notification_settings_content() {
136
  <p><?php _e( 'Changes Saved.', 'buddypress' ) ?></p>
137
  </div>
138
  <?php } ?>
139
-
140
- <form action="<?php echo $bp->loggedin_user->domain . 'settings/notifications' ?>" method="post" id="settings-form">
141
  <h3><?php _e( 'Email Notifications', 'buddypress' ) ?></h3>
142
  <p><?php _e( 'Send a notification by email when:', 'buddypress' ) ?></p>
143
-
144
  <?php do_action( 'bp_notification_settings' ) ?>
145
-
146
- <p class="submit"><input type="submit" name="submit" value="<?php _e( 'Save Changes', 'buddypress' ) ?>" id="submit" class="auto"/></p>
147
-
148
  <?php wp_nonce_field('bp_settings_notifications') ?>
149
-
150
  </form>
151
  <?php
152
  }
153
 
154
  /**** DELETE ACCOUNT ****/
155
 
156
- function bp_core_screen_delete_account() {
157
  if ( isset( $_POST['delete-account-understand'] ) ) {
158
  check_admin_referer( 'delete-account' );
159
 
@@ -161,10 +161,10 @@ function bp_core_screen_delete_account() {
161
  if ( bp_core_delete_account() )
162
  bp_core_redirect( site_url() );
163
  }
164
-
165
  add_action( 'bp_template_title', 'bp_core_screen_delete_account_title' );
166
  add_action( 'bp_template_content', 'bp_core_screen_delete_account_content' );
167
-
168
  bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'plugin-template' ) );
169
  }
170
 
@@ -175,12 +175,12 @@ function bp_core_screen_delete_account_title() {
175
  function bp_core_screen_delete_account_content() {
176
  global $bp, $current_user, $bp_settings_updated, $pass_error; ?>
177
 
178
- <form action="<?php echo $bp->loggedin_user->domain . 'settings/delete-account'; ?>" name="account-delete-form" id="account-delete-form" class="standard-form" method="post">
179
-
180
  <div id="message" class="info">
181
  <p><?php _e( 'WARNING: Deleting your account will completely remove ALL content associated with it. There is no way back, please be careful with this option.', 'buddypress' ); ?></p>
182
  </div>
183
-
184
  <input type="checkbox" name="delete-account-understand" id="delete-account-understand" value="1" onclick="if(this.checked) { document.getElementById('delete-account-button').disabled = ''; } else { document.getElementById('delete-account-button').disabled = 'disabled'; }" /> <?php _e( 'I understand the consequences of deleting my account.', 'buddypress' ); ?>
185
  <p><input type="submit" disabled="disabled" value="<?php _e( 'Delete My Account', 'buddypress' ) ?> &raquo;" id="delete-account-button" name="delete-account-button" /></p>
186
  <?php wp_nonce_field('delete-account') ?>
2
 
3
  if ( !defined( 'BP_SETTINGS_SLUG' ) )
4
  define( 'BP_SETTINGS_SLUG', 'settings' );
5
+
6
  function bp_core_add_settings_nav() {
7
  global $bp;
8
+
9
  /* Set up settings as a sudo-component for identification and nav selection */
10
  $bp->settings->id = 'settings';
11
  $bp->settings->slug = BP_SETTINGS_SLUG;
12
+
13
  /* Register this in the active components array */
14
  $bp->active_components[$bp->settings->slug] = $bp->settings->id;
15
 
16
  /* Add the settings navigation item */
17
  bp_core_new_nav_item( array( 'name' => __('Settings', 'buddypress'), 'slug' => $bp->settings->slug, 'position' => 100, 'show_for_displayed_user' => false, 'screen_function' => 'bp_core_screen_general_settings', 'default_subnav_slug' => 'general' ) );
18
 
19
+ $settings_link = $bp->loggedin_user->domain . BP_SETTINGS_SLUG . '/';
20
+
21
  bp_core_new_subnav_item( array( 'name' => __( 'General', 'buddypress' ), 'slug' => 'general', 'parent_url' => $settings_link, 'parent_slug' => $bp->settings->slug, 'screen_function' => 'bp_core_screen_general_settings', 'position' => 10, 'user_has_access' => bp_is_home() ) );
22
  bp_core_new_subnav_item( array( 'name' => __( 'Notifications', 'buddypress' ), 'slug' => 'notifications', 'parent_url' => $settings_link, 'parent_slug' => $bp->settings->slug, 'screen_function' => 'bp_core_screen_notification_settings', 'position' => 20, 'user_has_access' => bp_is_home() ) );
23
+
24
  if ( !is_site_admin() && !(int) get_site_option( 'bp-disable-account-deletion' ) )
25
  bp_core_new_subnav_item( array( 'name' => __( 'Delete Account', 'buddypress' ), 'slug' => 'delete-account', 'parent_url' => $settings_link, 'parent_slug' => $bp->settings->slug, 'screen_function' => 'bp_core_screen_delete_account', 'position' => 90, 'user_has_access' => bp_is_home() ) );
26
  }
31
 
32
  function bp_core_screen_general_settings() {
33
  global $current_user, $bp_settings_updated, $pass_error;
34
+
35
  $bp_settings_updated = false;
36
  $pass_error = false;
37
+
38
  if ( isset($_POST['submit']) ) {
39
  check_admin_referer('bp_settings_general');
40
+
41
  require_once( WPINC . '/registration.php' );
42
+
43
  // Form has been submitted and nonce checks out, lets do it.
44
+
45
  if ( $_POST['email'] != '' )
46
  $current_user->user_email = wp_specialchars( trim( $_POST['email'] ) );
47
 
55
  } else {
56
  unset( $current_user->user_pass );
57
  }
58
+
59
  if ( !$pass_error && wp_update_user( get_object_vars( $current_user ) ) )
60
  $bp_settings_updated = true;
61
  }
62
+
63
  add_action( 'bp_template_title', 'bp_core_screen_general_settings_title' );
64
  add_action( 'bp_template_content', 'bp_core_screen_general_settings_content' );
65
+
66
  bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'plugin-template' ) );
67
  }
68
 
78
  <p><?php _e( 'Changes Saved.', 'buddypress' ) ?></p>
79
  </div>
80
  <?php } ?>
81
+
82
  <?php if ( $pass_error && !$bp_settings_updated ) { ?>
83
  <div id="message" class="error fade">
84
  <p><?php _e( 'Your passwords did not match', 'buddypress' ) ?></p>
85
+ </div>
86
  <?php } ?>
87
 
88
+ <form action="<?php echo $bp->loggedin_user->domain . $bp->settings->slug . '/general' ?>" method="post" class="standard-form" id="settings-form">
89
  <label for="email"><?php _e( 'Account Email', 'buddypress' ) ?></label>
90
  <input type="text" name="email" id="email" value="<?php echo attribute_escape( $current_user->user_email ); ?>" class="settings-input" />
91
+
92
  <label for="pass1"><?php _e( 'Change Password <span>(leave blank for no change)</span>', 'buddypress' ) ?></label>
93
  <input type="password" name="pass1" id="pass1" size="16" value="" class="settings-input small" /> &nbsp;<?php _e( 'New Password', 'buddypress' ) ?><br />
94
  <input type="password" name="pass2" id="pass2" size="16" value="" class="settings-input small" /> &nbsp;<?php _e( 'Repeat New Password', 'buddypress' ) ?>
95
+
96
  <p class="submit"><input type="submit" name="submit" value="<?php _e( 'Save Changes', 'buddypress' ) ?>" id="submit" class="auto"/></p>
97
  <?php wp_nonce_field('bp_settings_general') ?>
98
  </form>
103
 
104
  function bp_core_screen_notification_settings() {
105
  global $current_user, $bp_settings_updated;
106
+
107
  $bp_settings_updated = false;
108
+
109
  if ( $_POST['submit'] ) {
110
  check_admin_referer('bp_settings_notifications');
111
+
112
  if ( $_POST['notifications'] ) {
113
  foreach ( $_POST['notifications'] as $key => $value ) {
114
  update_usermeta( (int)$current_user->id, $key, $value );
115
  }
116
  }
117
+
118
  $bp_settings_updated = true;
119
  }
120
+
121
  add_action( 'bp_template_title', 'bp_core_screen_notification_settings_title' );
122
  add_action( 'bp_template_content', 'bp_core_screen_notification_settings_content' );
123
+
124
  bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'plugin-template' ) );
125
  }
126
 
136
  <p><?php _e( 'Changes Saved.', 'buddypress' ) ?></p>
137
  </div>
138
  <?php } ?>
139
+
140
+ <form action="<?php echo $bp->loggedin_user->domain . $bp->settings->slug . '/notifications' ?>" method="post" id="settings-form">
141
  <h3><?php _e( 'Email Notifications', 'buddypress' ) ?></h3>
142
  <p><?php _e( 'Send a notification by email when:', 'buddypress' ) ?></p>
143
+
144
  <?php do_action( 'bp_notification_settings' ) ?>
145
+
146
+ <p class="submit"><input type="submit" name="submit" value="<?php _e( 'Save Changes', 'buddypress' ) ?>" id="submit" class="auto"/></p>
147
+
148
  <?php wp_nonce_field('bp_settings_notifications') ?>
149
+
150
  </form>
151
  <?php
152
  }
153
 
154
  /**** DELETE ACCOUNT ****/
155
 
156
+ function bp_core_screen_delete_account() {
157
  if ( isset( $_POST['delete-account-understand'] ) ) {
158
  check_admin_referer( 'delete-account' );
159
 
161
  if ( bp_core_delete_account() )
162
  bp_core_redirect( site_url() );
163
  }
164
+
165
  add_action( 'bp_template_title', 'bp_core_screen_delete_account_title' );
166
  add_action( 'bp_template_content', 'bp_core_screen_delete_account_content' );
167
+
168
  bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'plugin-template' ) );
169
  }
170
 
175
  function bp_core_screen_delete_account_content() {
176
  global $bp, $current_user, $bp_settings_updated, $pass_error; ?>
177
 
178
+ <form action="<?php echo $bp->loggedin_user->domain . $bp->settings->slug . '/delete-account'; ?>" name="account-delete-form" id="account-delete-form" class="standard-form" method="post">
179
+
180
  <div id="message" class="info">
181
  <p><?php _e( 'WARNING: Deleting your account will completely remove ALL content associated with it. There is no way back, please be careful with this option.', 'buddypress' ); ?></p>
182
  </div>
183
+
184
  <input type="checkbox" name="delete-account-understand" id="delete-account-understand" value="1" onclick="if(this.checked) { document.getElementById('delete-account-button').disabled = ''; } else { document.getElementById('delete-account-button').disabled = 'disabled'; }" /> <?php _e( 'I understand the consequences of deleting my account.', 'buddypress' ); ?>
185
  <p><input type="submit" disabled="disabled" value="<?php _e( 'Delete My Account', 'buddypress' ) ?> &raquo;" id="delete-account-button" name="delete-account-button" /></p>
186
  <?php wp_nonce_field('delete-account') ?>
bp-core/bp-core-signup.php CHANGED
@@ -2,14 +2,14 @@
2
 
3
  function bp_core_screen_signup() {
4
  global $bp, $wpdb;
5
-
6
  if ( $bp->current_component != BP_REGISTER_SLUG )
7
  return false;
8
-
9
  /* If the user is logged in, redirect away from here */
10
  if ( is_user_logged_in() )
11
  bp_core_redirect( $bp->root_domain );
12
-
13
  /***
14
  * For backwards compatibility with the old pre 1.1 two theme system, skip this screen function
15
  * if the user is using the old two theme method.
@@ -20,27 +20,27 @@ function bp_core_screen_signup() {
20
  /* If signups are disabled, just re-direct */
21
  if ( 'none' == bp_get_signup_allowed() || 'blog' == bp_get_signup_allowed() )
22
  bp_core_redirect( $bp->root_domain );
23
-
24
  $bp->signup->step = 'request-details';
25
-
26
  /* If the signup page is submitted, validate and save */
27
  if ( isset( $_POST['signup_submit'] ) ) {
28
-
29
  /* Check the nonce */
30
  check_admin_referer( 'bp_new_signup' );
31
-
32
  require_once( ABSPATH . WPINC . '/registration.php' );
33
-
34
  /* Check the base account details for problems */
35
  $account_details = wpmu_validate_user_signup( $_POST['signup_username'] , $_POST['signup_email'] );
36
-
37
  /* If there are errors with account details, set them for display */
38
  if ( !empty( $account_details['errors']->errors['user_name'] ) )
39
  $bp->signup->errors['signup_username'] = $account_details['errors']->errors['user_name'][0];
40
-
41
  if ( !empty( $account_details['errors']->errors['user_email'] ) )
42
  $bp->signup->errors['signup_email'] = $account_details['errors']->errors['user_email'][0];
43
-
44
  /* Check that both password fields are filled in */
45
  if ( empty( $_POST['signup_password'] ) || empty( $_POST['signup_password_confirm'] ) )
46
  $bp->signup->errors['signup_password'] = __( 'Please make sure you enter your password twice', 'buddypress' );
@@ -53,12 +53,12 @@ function bp_core_screen_signup() {
53
  $profile_field_ids = explode( ',', $_POST['signup_profile_field_ids'] );
54
 
55
  /* Loop through the posted fields formatting any datebox values then validate the field */
56
- foreach ( (array) $profile_field_ids as $field_id ) {
57
  if ( !isset( $_POST['field_' . $field_id] ) ) {
58
  if ( isset( $_POST['field_' . $field_id . '_day'] ) )
59
  $_POST['field_' . $field_id] = strtotime( $_POST['field_' . $field_id . '_day'] . $_POST['field_' . $field_id . '_month'] . $_POST['field_' . $field_id . '_year'] );
60
  }
61
-
62
  if ( xprofile_check_is_required_field( $field_id ) && empty( $_POST['field_' . $field_id] ) )
63
  $bp->signup->errors['field_' . $field_id] = __( 'This is a required field', 'buddypress' );
64
  }
@@ -66,10 +66,10 @@ function bp_core_screen_signup() {
66
  /* Finally, let's check the blog details, if the user wants a blog and blog creation is enabled */
67
  if ( isset( $_POST['signup_with_blog'] ) ) {
68
  $active_signup = get_site_option( 'registration' );
69
-
70
  if ( 'blog' == $active_signup || 'all' == $active_signup ) {
71
  $blog_details = wpmu_validate_blog_signup( $_POST['signup_blog_url'], $_POST['signup_blog_title'] );
72
-
73
  /* If there are errors with blog details, set them for display */
74
  if ( !empty( $blog_details['errors']->errors['blogname'] ) )
75
  $bp->signup->errors['signup_blog_url'] = $blog_details['errors']->errors['blogname'][0];
@@ -87,97 +87,97 @@ function bp_core_screen_signup() {
87
  add_action( 'bp_' . $fieldname . '_errors', create_function( '', 'echo "<div class=\"error\">' . $error_message . '</div>";' ) );
88
  } else {
89
  $bp->signup->step = 'save-details';
90
-
91
  /* No errors! Let's register those deets. */
92
  $active_signup = get_site_option( 'registration' );
93
-
94
  if ( 'none' != $active_signup ) {
95
-
96
  /* Let's compact any profile field info into usermeta */
97
  $profile_field_ids = explode( ',', $_POST['signup_profile_field_ids'] );
98
 
99
  /* Loop through the posted fields formatting any datebox values then add to usermeta */
100
- foreach ( (array) $profile_field_ids as $field_id ) {
101
  if ( !isset( $_POST['field_' . $field_id] ) ) {
102
  if ( isset( $_POST['field_' . $field_id . '_day'] ) )
103
  $_POST['field_' . $field_id] = strtotime( $_POST['field_' . $field_id . '_day'] . $_POST['field_' . $field_id . '_month'] . $_POST['field_' . $field_id . '_year'] );
104
  }
105
-
106
  if ( !empty( $_POST['field_' . $field_id] ) )
107
  $usermeta['field_' . $field_id] = $_POST['field_' . $field_id];
108
  }
109
-
110
  /* Store the profile field ID's in usermeta */
111
  $usermeta['profile_field_ids'] = $_POST['signup_profile_field_ids'];
112
-
113
  /* Hash and store the password */
114
  $usermeta['password'] = wp_hash_password( $_POST['signup_password'] );
115
-
116
  /* If the user decided to create a blog, save those details to usermeta */
117
  if ( 'blog' == $active_signup || 'all' == $active_signup ) {
118
  $usermeta['public'] = ( 'public' == $_POST['signup_blog_privacy'] ) ? true : false;
119
  }
120
-
121
  $usermeta = apply_filters( 'bp_signup_usermeta', $usermeta );
122
-
123
  /* Finally, sign up the user and/or blog*/
124
  if ( isset( $_POST['signup_with_blog'] ) )
125
  wpmu_signup_blog( $blog_details['domain'], $blog_details['path'], $blog_details['blog_title'], $_POST['signup_username'], $_POST['signup_email'], $usermeta );
126
  else
127
  wpmu_signup_user( $_POST['signup_username'], $_POST['signup_email'], $usermeta );
128
-
129
  $bp->signup->step = 'completed-confirmation';
130
  }
131
 
132
  do_action( 'bp_complete_signup' );
133
  }
134
-
135
  }
136
 
137
  $bp->avatar_admin->step = 'upload-image';
138
 
139
  /* If user has uploaded a new avatar */
140
  if ( !empty( $_FILES ) ) {
141
-
142
  /* Check the nonce */
143
  check_admin_referer( 'bp_avatar_upload' );
144
 
145
  $bp->signup->step = 'completed-confirmation';
146
-
147
  /* Get the activation key */
148
  if ( !$bp->signup->key = $wpdb->get_var( $wpdb->prepare( "SELECT activation_key FROM {$wpdb->signups} WHERE user_login = %s AND user_email = %s", $_POST[ 'signup_username' ], $_POST[ 'signup_email' ] ) ) ) {
149
  bp_core_add_message( __( 'There was a problem uploading your avatar, please try uploading it again', 'buddypress' ) );
150
  } else {
151
  /* Hash the key to create the upload folder (added security so people don't sniff the activation key) */
152
  $bp->signup->avatar_dir = wp_hash( $bp->signup->key );
153
-
154
- /* Pass the file to the avatar upload handler */
155
- if ( bp_core_avatar_handle_upload( $_FILES, 'bp_core_signup_avatar_upload_dir' ) ) {
156
  $bp->avatar_admin->step = 'crop-image';
157
 
158
  /* Make sure we include the jQuery jCrop file for image cropping */
159
  add_action( 'wp', 'bp_core_add_jquery_cropper' );
160
- }
161
  }
162
  }
163
-
164
  /* If the image cropping is done, crop the image and save a full/thumb version */
165
  if ( isset( $_POST['avatar-crop-submit'] ) ) {
166
-
167
  /* Check the nonce */
168
  check_admin_referer( 'bp_avatar_cropstore' );
169
-
170
  /* Reset the avatar step so we can show the upload form again if needed */
171
  $bp->signup->step = 'completed-confirmation';
172
  $bp->avatar_admin->step = 'upload-image';
173
 
174
  if ( !bp_core_avatar_handle_crop( array( 'original_file' => $_POST['image_src'], 'crop_x' => $_POST['x'], 'crop_y' => $_POST['y'], 'crop_w' => $_POST['w'], 'crop_h' => $_POST['h'] ) ) )
175
- bp_core_add_message( __( 'There was a problem cropping your avatar, please try uploading it again', 'buddypress' ) );
176
  else
177
  bp_core_add_message( __( 'Your new avatar was uploaded successfully', 'buddypress' ) );
178
 
179
  }
180
- bp_core_load_template( 'registration/register' );
181
  }
182
  add_action( 'wp', 'bp_core_screen_signup', 3 );
183
 
@@ -186,13 +186,13 @@ function bp_core_signup_avatar_upload_dir() {
186
 
187
  if ( !$bp->signup->avatar_dir )
188
  return false;
189
-
190
  $path = get_blog_option( BP_ROOT_BLOG, 'upload_path' );
191
  $newdir = WP_CONTENT_DIR . str_replace( 'wp-content', '', $path );
192
  $newdir .= '/avatars/signups/' . $bp->signup->avatar_dir;
193
 
194
  $newbdir = $newdir;
195
-
196
  if ( !file_exists( $newdir ) )
197
  @wp_mkdir_p( $newdir );
198
 
@@ -200,7 +200,7 @@ function bp_core_signup_avatar_upload_dir() {
200
  $newburl = $newurl;
201
  $newsubdir = '/avatars/signups/' . $bp->signup->avatar_dir;
202
 
203
- return apply_filters( 'bp_core_signup_avatar_upload_dir', array( 'path' => $newdir, 'url' => $newurl, 'subdir' => $newsubdir, 'basedir' => $newbdir, 'baseurl' => $newburl, 'error' => false ) );
204
  }
205
 
206
  /* Kill the wp-signup.php if custom registration signup templates are present */
@@ -208,12 +208,8 @@ function bp_core_wpsignup_redirect() {
208
  if ( false === strpos( $_SERVER['SCRIPT_NAME'], 'wp-signup.php') )
209
  return false;
210
 
211
- if ( '' != locate_template( array( 'registration/register.php' ), false ) || '' != locate_template( array( 'register.php' ), false ) )
212
- die;
213
  }
214
  add_action( 'signup_header', 'bp_core_wpsignup_redirect' );
215
-
216
-
217
-
218
-
219
  ?>
2
 
3
  function bp_core_screen_signup() {
4
  global $bp, $wpdb;
5
+
6
  if ( $bp->current_component != BP_REGISTER_SLUG )
7
  return false;
8
+
9
  /* If the user is logged in, redirect away from here */
10
  if ( is_user_logged_in() )
11
  bp_core_redirect( $bp->root_domain );
12
+
13
  /***
14
  * For backwards compatibility with the old pre 1.1 two theme system, skip this screen function
15
  * if the user is using the old two theme method.
20
  /* If signups are disabled, just re-direct */
21
  if ( 'none' == bp_get_signup_allowed() || 'blog' == bp_get_signup_allowed() )
22
  bp_core_redirect( $bp->root_domain );
23
+
24
  $bp->signup->step = 'request-details';
25
+
26
  /* If the signup page is submitted, validate and save */
27
  if ( isset( $_POST['signup_submit'] ) ) {
28
+
29
  /* Check the nonce */
30
  check_admin_referer( 'bp_new_signup' );
31
+
32
  require_once( ABSPATH . WPINC . '/registration.php' );
33
+
34
  /* Check the base account details for problems */
35
  $account_details = wpmu_validate_user_signup( $_POST['signup_username'] , $_POST['signup_email'] );
36
+
37
  /* If there are errors with account details, set them for display */
38
  if ( !empty( $account_details['errors']->errors['user_name'] ) )
39
  $bp->signup->errors['signup_username'] = $account_details['errors']->errors['user_name'][0];
40
+
41
  if ( !empty( $account_details['errors']->errors['user_email'] ) )
42
  $bp->signup->errors['signup_email'] = $account_details['errors']->errors['user_email'][0];
43
+
44
  /* Check that both password fields are filled in */
45
  if ( empty( $_POST['signup_password'] ) || empty( $_POST['signup_password_confirm'] ) )
46
  $bp->signup->errors['signup_password'] = __( 'Please make sure you enter your password twice', 'buddypress' );
53
  $profile_field_ids = explode( ',', $_POST['signup_profile_field_ids'] );
54
 
55
  /* Loop through the posted fields formatting any datebox values then validate the field */
56
+ foreach ( (array) $profile_field_ids as $field_id ) {
57
  if ( !isset( $_POST['field_' . $field_id] ) ) {
58
  if ( isset( $_POST['field_' . $field_id . '_day'] ) )
59
  $_POST['field_' . $field_id] = strtotime( $_POST['field_' . $field_id . '_day'] . $_POST['field_' . $field_id . '_month'] . $_POST['field_' . $field_id . '_year'] );
60
  }
61
+
62
  if ( xprofile_check_is_required_field( $field_id ) && empty( $_POST['field_' . $field_id] ) )
63
  $bp->signup->errors['field_' . $field_id] = __( 'This is a required field', 'buddypress' );
64
  }
66
  /* Finally, let's check the blog details, if the user wants a blog and blog creation is enabled */
67
  if ( isset( $_POST['signup_with_blog'] ) ) {
68
  $active_signup = get_site_option( 'registration' );
69
+
70
  if ( 'blog' == $active_signup || 'all' == $active_signup ) {
71
  $blog_details = wpmu_validate_blog_signup( $_POST['signup_blog_url'], $_POST['signup_blog_title'] );
72
+
73
  /* If there are errors with blog details, set them for display */
74
  if ( !empty( $blog_details['errors']->errors['blogname'] ) )
75
  $bp->signup->errors['signup_blog_url'] = $blog_details['errors']->errors['blogname'][0];
87
  add_action( 'bp_' . $fieldname . '_errors', create_function( '', 'echo "<div class=\"error\">' . $error_message . '</div>";' ) );
88
  } else {
89
  $bp->signup->step = 'save-details';
90
+
91
  /* No errors! Let's register those deets. */
92
  $active_signup = get_site_option( 'registration' );
93
+
94
  if ( 'none' != $active_signup ) {
95
+
96
  /* Let's compact any profile field info into usermeta */
97
  $profile_field_ids = explode( ',', $_POST['signup_profile_field_ids'] );
98
 
99
  /* Loop through the posted fields formatting any datebox values then add to usermeta */
100
+ foreach ( (array) $profile_field_ids as $field_id ) {
101
  if ( !isset( $_POST['field_' . $field_id] ) ) {
102
  if ( isset( $_POST['field_' . $field_id . '_day'] ) )
103
  $_POST['field_' . $field_id] = strtotime( $_POST['field_' . $field_id . '_day'] . $_POST['field_' . $field_id . '_month'] . $_POST['field_' . $field_id . '_year'] );
104
  }
105
+
106
  if ( !empty( $_POST['field_' . $field_id] ) )
107
  $usermeta['field_' . $field_id] = $_POST['field_' . $field_id];
108
  }
109
+
110
  /* Store the profile field ID's in usermeta */
111
  $usermeta['profile_field_ids'] = $_POST['signup_profile_field_ids'];
112
+
113
  /* Hash and store the password */
114
  $usermeta['password'] = wp_hash_password( $_POST['signup_password'] );
115
+
116
  /* If the user decided to create a blog, save those details to usermeta */
117
  if ( 'blog' == $active_signup || 'all' == $active_signup ) {
118
  $usermeta['public'] = ( 'public' == $_POST['signup_blog_privacy'] ) ? true : false;
119
  }
120
+
121
  $usermeta = apply_filters( 'bp_signup_usermeta', $usermeta );
122
+
123
  /* Finally, sign up the user and/or blog*/
124
  if ( isset( $_POST['signup_with_blog'] ) )
125
  wpmu_signup_blog( $blog_details['domain'], $blog_details['path'], $blog_details['blog_title'], $_POST['signup_username'], $_POST['signup_email'], $usermeta );
126
  else
127
  wpmu_signup_user( $_POST['signup_username'], $_POST['signup_email'], $usermeta );
128
+
129
  $bp->signup->step = 'completed-confirmation';
130
  }
131
 
132
  do_action( 'bp_complete_signup' );
133
  }
134
+
135
  }
136
 
137
  $bp->avatar_admin->step = 'upload-image';
138
 
139
  /* If user has uploaded a new avatar */
140
  if ( !empty( $_FILES ) ) {
141
+
142
  /* Check the nonce */
143
  check_admin_referer( 'bp_avatar_upload' );
144
 
145
  $bp->signup->step = 'completed-confirmation';
146
+
147
  /* Get the activation key */
148
  if ( !$bp->signup->key = $wpdb->get_var( $wpdb->prepare( "SELECT activation_key FROM {$wpdb->signups} WHERE user_login = %s AND user_email = %s", $_POST[ 'signup_username' ], $_POST[ 'signup_email' ] ) ) ) {
149
  bp_core_add_message( __( 'There was a problem uploading your avatar, please try uploading it again', 'buddypress' ) );
150
  } else {
151
  /* Hash the key to create the upload folder (added security so people don't sniff the activation key) */
152
  $bp->signup->avatar_dir = wp_hash( $bp->signup->key );
153
+
154
+ /* Pass the file to the avatar upload handler */
155
+ if ( bp_core_avatar_handle_upload( $_FILES, 'bp_core_signup_avatar_upload_dir' ) ) {
156
  $bp->avatar_admin->step = 'crop-image';
157
 
158
  /* Make sure we include the jQuery jCrop file for image cropping */
159
  add_action( 'wp', 'bp_core_add_jquery_cropper' );
160
+ }
161
  }
162
  }
163
+
164
  /* If the image cropping is done, crop the image and save a full/thumb version */
165
  if ( isset( $_POST['avatar-crop-submit'] ) ) {
166
+
167
  /* Check the nonce */
168
  check_admin_referer( 'bp_avatar_cropstore' );
169
+
170
  /* Reset the avatar step so we can show the upload form again if needed */
171
  $bp->signup->step = 'completed-confirmation';
172
  $bp->avatar_admin->step = 'upload-image';
173
 
174
  if ( !bp_core_avatar_handle_crop( array( 'original_file' => $_POST['image_src'], 'crop_x' => $_POST['x'], 'crop_y' => $_POST['y'], 'crop_w' => $_POST['w'], 'crop_h' => $_POST['h'] ) ) )
175
+ bp_core_add_message( __( 'There was a problem cropping your avatar, please try uploading it again', 'buddypress' ), 'error' );
176
  else
177
  bp_core_add_message( __( 'Your new avatar was uploaded successfully', 'buddypress' ) );
178
 
179
  }
180
+ bp_core_load_template( 'registration/register' );
181
  }
182
  add_action( 'wp', 'bp_core_screen_signup', 3 );
183
 
186
 
187
  if ( !$bp->signup->avatar_dir )
188
  return false;
189
+
190
  $path = get_blog_option( BP_ROOT_BLOG, 'upload_path' );
191
  $newdir = WP_CONTENT_DIR . str_replace( 'wp-content', '', $path );
192
  $newdir .= '/avatars/signups/' . $bp->signup->avatar_dir;
193
 
194
  $newbdir = $newdir;
195
+
196
  if ( !file_exists( $newdir ) )
197
  @wp_mkdir_p( $newdir );
198
 
200
  $newburl = $newurl;
201
  $newsubdir = '/avatars/signups/' . $bp->signup->avatar_dir;
202
 
203
+ return apply_filters( 'bp_core_signup_avatar_upload_dir', array( 'path' => $newdir, 'url' => $newurl, 'subdir' => $newsubdir, 'basedir' => $newbdir, 'baseurl' => $newburl, 'error' => false ) );
204
  }
205
 
206
  /* Kill the wp-signup.php if custom registration signup templates are present */
208
  if ( false === strpos( $_SERVER['SCRIPT_NAME'], 'wp-signup.php') )
209
  return false;
210
 
211
+ if ( locate_template( array( 'registration/register.php' ), false ) || locate_template( array( 'register.php' ), false ) )
212
+ wp_redirect( bp_root_domain() . BP_REGISTER_SLUG );
213
  }
214
  add_action( 'signup_header', 'bp_core_wpsignup_redirect' );
 
 
 
 
215
  ?>
bp-core/bp-core-templatetags.php CHANGED
@@ -5,7 +5,7 @@
5
  *
6
  * Uses the $bp->bp_nav global to render out the navigation within a BuddyPress install.
7
  * Each component adds to this navigation array within its own [component_name]_setup_nav() function.
8
- *
9
  * This navigation array is the top level navigation, so it contains items such as:
10
  * [Blog, Profile, Messages, Groups, Friends] ...
11
  *
@@ -17,7 +17,7 @@
17
  */
18
  function bp_get_loggedin_user_nav() {
19
  global $bp, $current_blog;
20
-
21
  /* Loop through each navigation item */
22
  foreach( (array) $bp->bp_nav as $nav_item ) {
23
  /* If the current component matches the nav item id, then add a highlight CSS class. */
@@ -26,13 +26,13 @@ function bp_get_loggedin_user_nav() {
26
  } else {
27
  $selected = '';
28
  }
29
-
30
  /* If we are viewing another person (current_userid does not equal loggedin_user->id)
31
  then check to see if the two users are friends. if they are, add a highlight CSS class
32
  to the friends nav item if it exists. */
33
  if ( !bp_is_home() && $bp->displayed_user->id ) {
34
  $selected = '';
35
-
36
  if ( function_exists('friends_install') ) {
37
  if ( $nav_item['css_id'] == $bp->friends->id ) {
38
  if ( friends_check_friendship( $bp->loggedin_user->id, $bp->displayed_user->id ) )
@@ -40,18 +40,18 @@ function bp_get_loggedin_user_nav() {
40
  }
41
  }
42
  }
43
-
44
  /* echo out the final list item */
45
  echo apply_filters( 'bp_get_loggedin_user_nav_' . $nav_item['css_id'], '<li id="li-nav-' . $nav_item['css_id'] . '" ' . $selected . '><a id="my-' . $nav_item['css_id'] . '" href="' . $nav_item['link'] . '">' . $nav_item['name'] . '</a></li>', &$nav_item );
46
  }
47
-
48
  /* Always add a log out list item to the end of the navigation */
49
  if ( function_exists( 'wp_logout_url' ) ) {
50
- $logout_link = '<li><a id="wp-logout" href="' . wp_logout_url( $bp->root_domain ) . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>';
51
  } else {
52
  $logout_link = '<li><a id="wp-logout" href="' . site_url() . '/wp-login.php?action=logout&amp;redirect_to=' . $bp->root_domain . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>';
53
  }
54
-
55
  echo apply_filters( 'bp_logout_nav_link', $logout_link );
56
  }
57
  /* DEPRECATED - use bp_get_loggedin_user_nav() */
@@ -71,38 +71,38 @@ function bp_get_displayed_user_nav() {
71
  global $bp;
72
 
73
  foreach ( $bp->bp_nav as $user_nav_item ) {
74
- if ( !$user_nav_item['show_for_displayed_user'] )
75
  continue;
76
-
77
  if ( $bp->current_component == $user_nav_item['css_id'] )
78
  $selected = ' class="current"';
79
  else
80
  $selected = '';
81
-
82
  if ( $bp->loggedin_user->domain )
83
  $link = str_replace( $bp->loggedin_user->domain, $bp->displayed_user->domain, $user_nav_item['link'] );
84
  else
85
  $link = $bp->displayed_user->domain . $user_nav_item['link'];
86
-
87
  echo apply_filters( 'bp_get_displayed_user_nav_' . $user_nav_item['css_id'], '<li id="li-subnav-' . $user_nav_item['css_id'] . '" ' . $selected . '><a id="user-' . $user_nav_item['css_id'] . '" href="' . $link . '">' . $user_nav_item['name'] . '</a></li>', &$user_nav_item );
88
- }
89
  }
90
  /* DEPRECATED - use bp_get_displayed_user_nav() */
91
  function bp_get_user_nav() { bp_get_displayed_user_nav(); }
92
-
93
  /**
94
  * bp_get_options_nav()
95
  * TEMPLATE TAG
96
  *
97
  * Uses the $bp->bp_options_nav global to render out the sub navigation for the current component.
98
  * Each component adds to its sub navigation array within its own [component_name]_setup_nav() function.
99
- *
100
  * This sub navigation array is the secondary level navigation, so for profile it contains:
101
  * [Public, Edit Profile, Change Avatar]
102
  *
103
  * The function will also analyze the current action for the current component to determine whether
104
  * or not to highlight a particular sub nav item.
105
- *
106
  * @package BuddyPress Core
107
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
108
  * @uses bp_get_user_nav() Renders the navigation for a profile of a currently viewed user.
@@ -117,21 +117,21 @@ function bp_get_options_nav() {
117
  if ( bp_is_home() || $bp->is_single_item ) {
118
  if ( count( $bp->bp_options_nav[$bp->current_component] ) < 1 )
119
  return false;
120
-
121
  /* Loop through each navigation item */
122
  foreach ( $bp->bp_options_nav[$bp->current_component] as $subnav_item ) {
123
  if ( !$subnav_item['user_has_access'] )
124
  continue;
125
-
126
  /* If the current action or an action variable matches the nav item id, then add a highlight CSS class. */
127
  if ( $subnav_item['slug'] == $bp->current_action ) {
128
  $selected = ' class="current"';
129
  } else {
130
  $selected = '';
131
  }
132
-
133
  /* echo out the final list item */
134
- echo apply_filters( 'bp_get_options_nav_' . $subnav_item['css_id'], '<li id="li-subnav-' . $subnav_item['css_id'] . '" ' . $selected . '><a id="' . $subnav_item['css_id'] . '" href="' . $subnav_item['link'] . '">' . $subnav_item['name'] . '</a></li>', $subnav_item );
135
  }
136
  } else {
137
  /* If we get here we are viewing another user, so show the displayed user's nav items */
@@ -141,13 +141,13 @@ function bp_get_options_nav() {
141
 
142
  function bp_get_options_title() {
143
  global $bp;
144
-
145
  if ( empty( $bp->bp_options_title ) )
146
  $bp->bp_options_title = __( 'Options', 'buddypress' );
147
-
148
  echo apply_filters( 'bp_get_options_title', attribute_escape( $bp->bp_options_title ) );
149
  }
150
-
151
 
152
  /** AVATAR TEMPLATE TAGS *******************************************************/
153
 
@@ -163,10 +163,10 @@ function bp_get_options_title() {
163
  */
164
  function bp_has_options_avatar() {
165
  global $bp;
166
-
167
  if ( empty( $bp->bp_options_avatar ) )
168
  return false;
169
-
170
  return true;
171
  }
172
 
@@ -178,9 +178,9 @@ function bp_get_options_avatar() {
178
 
179
  function bp_comment_author_avatar() {
180
  global $comment;
181
-
182
  if ( function_exists('bp_core_fetch_avatar') ) {
183
- echo apply_filters( 'bp_comment_author_avatar', bp_core_fetch_avatar( array( 'item_id' => $comment->user_id, 'type' => 'thumb' ) ) );
184
  } else if ( function_exists('get_avatar') ) {
185
  get_avatar();
186
  }
@@ -188,9 +188,9 @@ function bp_comment_author_avatar() {
188
 
189
  function bp_post_author_avatar() {
190
  global $post;
191
-
192
  if ( function_exists('bp_core_fetch_avatar') ) {
193
- echo apply_filters( 'bp_post_author_avatar', bp_core_fetch_avatar( array( 'item_id' => $post->post_author, 'type' => 'thumb' ) ) );
194
  } else if ( function_exists('get_avatar') ) {
195
  get_avatar();
196
  }
@@ -210,9 +210,9 @@ function bp_loggedin_user_avatar( $args = '' ) {
210
 
211
  $r = wp_parse_args( $args, $defaults );
212
  extract( $r, EXTR_SKIP );
213
-
214
  return apply_filters( 'bp_get_loggedin_user_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->loggedin_user->id, 'type' => $type, 'width' => $width, 'height' => $height ) ) );
215
- }
216
 
217
  function bp_displayed_user_avatar( $args = '' ) {
218
  echo bp_get_displayed_user_avatar( $args );
@@ -228,9 +228,9 @@ function bp_displayed_user_avatar( $args = '' ) {
228
 
229
  $r = wp_parse_args( $args, $defaults );
230
  extract( $r, EXTR_SKIP );
231
-
232
  return apply_filters( 'bp_get_displayed_user_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => $type, 'width' => $width, 'height' => $height ) ) );
233
- }
234
 
235
  function bp_avatar_admin_step() {
236
  echo bp_get_avatar_admin_step();
@@ -255,13 +255,13 @@ function bp_avatar_to_crop_src() {
255
  }
256
  function bp_get_avatar_to_crop_src() {
257
  global $bp;
258
-
259
  return apply_filters( 'bp_get_avatar_to_crop_src', str_replace( WP_CONTENT_DIR, '', $bp->avatar_admin->image->dir ) );
260
  }
261
-
262
  function bp_avatar_cropper() {
263
  global $bp;
264
-
265
  echo '<img id="avatar-to-crop" class="avatar" src="' . $bp->avatar_admin->image . '" />';
266
  }
267
 
@@ -271,19 +271,19 @@ function bp_site_name() {
271
 
272
  function bp_is_home() {
273
  global $bp;
274
-
275
  if ( is_user_logged_in() && $bp->loggedin_user->id == $bp->displayed_user->id )
276
  return true;
277
-
278
  return false;
279
  }
280
 
281
  function bp_last_activity( $user_id = false, $echo = true ) {
282
  global $bp;
283
-
284
  if ( !$user_id )
285
  $user_id = $bp->displayed_user->id;
286
-
287
  $last_activity = bp_core_get_last_activity( get_usermeta( $user_id, 'last_activity' ), __('active %s ago', 'buddypress') );
288
 
289
  if ( $echo )
@@ -294,25 +294,25 @@ function bp_last_activity( $user_id = false, $echo = true ) {
294
 
295
  function bp_user_link() {
296
  global $bp;
297
-
298
  echo apply_filters( 'bp_the_avatar_thumbnail', $bp->displayed_user->domain );
299
  }
300
 
301
  function bp_get_loggedin_user_link() {
302
  global $bp;
303
-
304
  return $bp->loggedin_user->domain;
305
  }
306
 
307
  function bp_get_displayed_user_link() {
308
  global $bp;
309
-
310
  return $bp->displayed_user->domain;
311
  }
312
 
313
  function bp_core_get_wp_profile() {
314
  global $bp;
315
-
316
  $ud = get_userdata( $bp->displayed_user->id );
317
  ?>
318
 
@@ -392,26 +392,26 @@ function bp_get_profile_header() {
392
  function bp_exists( $component_name ) {
393
  if ( function_exists($component_name . '_install') )
394
  return true;
395
-
396
  return false;
397
  }
398
 
399
  function bp_format_time( $time, $just_date = false ) {
400
  $date = date( get_option('date_format'), $time );
401
-
402
  if ( !$just_date ) {
403
  $date .= ' ' . __( 'at', 'buddypress' ) . date( ' ' . get_option('time_format'), $time );
404
  }
405
-
406
  return apply_filters( 'bp_format_time', $date );
407
  }
408
 
409
  function bp_word_or_name( $youtext, $nametext, $capitalize = true, $echo = true ) {
410
  global $bp;
411
-
412
  if ( $capitalize )
413
  $youtext = bp_core_ucfirst($youtext);
414
-
415
  if ( $bp->displayed_user->id == $bp->loggedin_user->id ) {
416
  if ( $echo )
417
  echo apply_filters( 'bp_word_or_name', $youtext );
@@ -428,10 +428,10 @@ function bp_word_or_name( $youtext, $nametext, $capitalize = true, $echo = true
428
 
429
  function bp_your_or_their( $capitalize = true, $echo = true ) {
430
  global $bp;
431
-
432
  if ( $capitalize )
433
  $yourtext = bp_core_ucfirst($yourtext);
434
-
435
  if ( $bp->displayed_user->id == $bp->loggedin_user->id ) {
436
  if ( $echo )
437
  echo apply_filters( 'bp_your_or_their', $yourtext );
@@ -447,7 +447,7 @@ function bp_your_or_their( $capitalize = true, $echo = true ) {
447
 
448
  function bp_loggedinuser_link() {
449
  global $bp;
450
-
451
  if ( $link = bp_core_get_userlink( $bp->loggedin_user->id ) ) {
452
  echo apply_filters( 'bp_loggedinuser_link', $link );
453
  }
@@ -482,9 +482,9 @@ function bp_get_page_title() {
482
  if ( is_single() ) {
483
  $title = __( 'Blog &#8212; ' . $post->post_title, 'buddypress' );
484
  } else if ( is_category() ) {
485
- $title = __( 'Blog &#8212; Categories &#8212; ' . ucwords( $wp_query->query_vars['category_name'] ), 'buddypress' );
486
  } else if ( is_tag() ) {
487
- $title = __( 'Blog &#8212; Tags &#8212; ' . ucwords( $wp_query->query_vars['tag'] ), 'buddypress' );
488
  } else
489
  $title = __( 'Blog', 'buddypress' );
490
 
@@ -501,13 +501,13 @@ function bp_get_page_title() {
501
  global $post;
502
  $title = get_the_title($post->ID);
503
  }
504
-
505
  if ( defined( 'BP_ENABLE_MULTIBLOG' ) ) {
506
  $blog_title = get_blog_option( $current_blog->blog_id, 'blogname' );
507
  } else {
508
- $blog_title = get_blog_option( BP_ROOT_BLOG, 'blogname' );
509
  }
510
-
511
  return apply_filters( 'bp_page_title', $blog_title . ' &#8212; ' . attribute_escape( $title ), attribute_escape( $title ) );
512
  }
513
 
@@ -518,13 +518,13 @@ function bp_styles() {
518
 
519
  function bp_is_page($page) {
520
  global $bp;
521
-
522
  if ( $bp->displayed_user->id || $bp->is_single_item )
523
  return false;
524
-
525
  if ( $page == $bp->current_component || ( is_home() && $page == 'home' && $bp->current_component == $bp->default_component ) || ( $page == BP_MEMBERS_SLUG && !$bp->current_component ) )
526
  return true;
527
-
528
  return false;
529
  }
530
 
@@ -534,7 +534,7 @@ function bp_has_custom_signup_page() {
534
 
535
  if ( file_exists( WP_CONTENT_DIR . '/themes/' . get_blog_option( BP_ROOT_BLOG, 'template') . '/registration/register.php') )
536
  return true;
537
-
538
  return false;
539
  }
540
 
@@ -546,7 +546,7 @@ function bp_signup_page( $deprecated = true ) {
546
  }
547
  function bp_get_signup_page() {
548
  global $bp;
549
-
550
  if ( bp_has_custom_signup_page() ) {
551
  return apply_filters( 'bp_get_signup_page', $bp->root_domain . '/' . BP_REGISTER_SLUG );
552
  } else {
@@ -560,13 +560,13 @@ function bp_has_custom_activation_page() {
560
 
561
  if ( file_exists( WP_CONTENT_DIR . '/themes/' . get_blog_option( BP_ROOT_BLOG, 'template') . '/registration/activate.php') )
562
  return true;
563
-
564
  return false;
565
  }
566
 
567
  function bp_activation_page( $echo = true ) {
568
  global $bp;
569
-
570
  if ( bp_has_custom_activation_page() ) {
571
  if ( $echo )
572
  echo $bp->root_domain . '/' . BP_ACTIVATION_SLUG;
@@ -582,18 +582,18 @@ function bp_activation_page( $echo = true ) {
582
 
583
  function bp_search_form_action() {
584
  global $bp;
585
-
586
  return apply_filters( 'bp_search_form_action', $bp->root_domain . '/search' );
587
  }
588
 
589
  function bp_search_form_type_select() {
590
  // Eventually this won't be needed and a page will be built to integrate all search results.
591
  $selection_box = '<select name="search-which" id="search-which" style="width: auto">';
592
-
593
  if ( function_exists( 'xprofile_install' ) ) {
594
  $selection_box .= '<option value="members">' . __( 'Members', 'buddypress' ) . '</option>';
595
  }
596
-
597
  if ( function_exists( 'groups_install' ) ) {
598
  $selection_box .= '<option value="groups">' . __( 'Groups', 'buddypress' ) . '</option>';
599
  }
@@ -601,27 +601,27 @@ function bp_search_form_type_select() {
601
  if ( function_exists( 'bp_forums_setup' ) && !(int) get_site_option( 'bp-disable-forum-directory' ) ) {
602
  $selection_box .= '<option value="forums">' . __( 'Forums', 'buddypress' ) . '</option>';
603
  }
604
-
605
  if ( function_exists( 'bp_blogs_install' ) ) {
606
  $selection_box .= '<option value="blogs">' . __( 'Blogs', 'buddypress' ) . '</option>';
607
  }
608
-
609
  $selection_box .= '</select>';
610
-
611
  return apply_filters( 'bp_search_form_type_select', $selection_box );
612
  }
613
 
614
  function bp_search_form() {
615
  $form = '
616
  <form action="' . bp_search_form_action() . '" method="post" id="search-form">
617
- <input type="text" id="search-terms" name="search-terms" value="" />
618
  ' . bp_search_form_type_select() . '
619
-
620
  <input type="submit" name="search-submit" id="search-submit" value="' . __( 'Search', 'buddypress' ) . '" />
621
  ' . wp_nonce_field( 'bp_search_form' ) . '
622
  </form>
623
  ';
624
-
625
  echo apply_filters( 'bp_search_form', $form );
626
  }
627
 
@@ -630,24 +630,24 @@ function bp_log_out_link() {
630
  if ( function_exists('wp_logout_url') )
631
  $logout_link = '<a href="' . wp_logout_url( $bp->root_domain ) . '">' . __( 'Log Out', 'buddypress' ) . '</a>';
632
  else
633
- $logout_link = '<a href="' . $bp->root_domain . '/wp-login.php?action=logout&amp;redirect_to=' . $bp->root_domain . '">' . __( 'Log Out', 'buddypress' ) . '</a>';
634
 
635
  echo apply_filters( 'bp_logout_link', $logout_link );
636
  }
637
 
638
  function bp_profile_wire_can_post() {
639
  global $bp;
640
-
641
  if ( bp_is_home() )
642
  return true;
643
-
644
  if ( function_exists('friends_install') ) {
645
  if ( friends_check_friendship( $bp->loggedin_user->id, $bp->displayed_user->id ) )
646
  return true;
647
  else
648
  return false;
649
- }
650
-
651
  return true;
652
  }
653
 
@@ -658,11 +658,11 @@ function bp_nav_items() {
658
  <li<?php if ( bp_is_page( 'home' ) ) {?> class="selected"<?php } ?>><a href="<?php echo get_option('home') ?>" title="<?php _e( 'Home', 'buddypress' ) ?>"><?php _e( 'Home', 'buddypress' ) ?></a></li>
659
  <li<?php if ( bp_is_page( BP_HOME_BLOG_SLUG ) ) {?> class="selected"<?php } ?>><a href="<?php echo get_option('home') ?>/<?php echo BP_HOME_BLOG_SLUG ?>" title="<?php _e( 'Blog', 'buddypress' ) ?>"><?php _e( 'Blog', 'buddypress' ) ?></a></li>
660
  <li<?php if ( bp_is_page( BP_MEMBERS_SLUG ) ) {?> class="selected"<?php } ?>><a href="<?php echo get_option('home') ?>/<?php echo BP_MEMBERS_SLUG ?>" title="<?php _e( 'Members', 'buddypress' ) ?>"><?php _e( 'Members', 'buddypress' ) ?></a></li>
661
-
662
  <?php if ( function_exists( 'groups_install' ) ) { ?>
663
  <li<?php if ( bp_is_page( $bp->groups->slug ) ) {?> class="selected"<?php } ?>><a href="<?php echo get_option('home') ?>/<?php echo $bp->groups->slug ?>" title="<?php _e( 'Groups', 'buddypress' ) ?>"><?php _e( 'Groups', 'buddypress' ) ?></a></li>
664
  <?php } ?>
665
-
666
  <?php if ( function_exists( 'bp_blogs_install' ) ) { ?>
667
  <li<?php if ( bp_is_page( $bp->blogs->slug ) ) {?> class="selected"<?php } ?>><a href="<?php echo get_option('home') ?>/<?php echo $bp->blogs->slug ?>" title="<?php _e( 'Blogs', 'buddypress' ) ?>"><?php _e( 'Blogs', 'buddypress' ) ?></a></li>
668
  <?php } ?>
@@ -680,7 +680,7 @@ function bp_custom_profile_sidebar_boxes() {
680
 
681
  function bp_is_directory() {
682
  global $bp;
683
-
684
  return $bp->is_directory;
685
  }
686
 
@@ -688,7 +688,7 @@ function bp_is_directory() {
688
  * bp_create_excerpt()
689
  *
690
  * Fakes an excerpt on any content. Will not truncate words.
691
- *
692
  * @package BuddyPress Core
693
  * @param $text str The text to create the excerpt from
694
  * @uses $excerpt_length The maximum length in characters of the excerpt.
@@ -706,7 +706,7 @@ function bp_create_excerpt( $text, $excerpt_length = 55, $filter_shortcodes = tr
706
  array_push($words, '[...]');
707
  $text = implode(' ', $words);
708
  }
709
-
710
  return apply_filters( 'bp_create_excerpt', $text );
711
  }
712
  add_filter( 'bp_create_excerpt', 'wptexturize' );
@@ -721,7 +721,7 @@ add_filter( 'bp_create_excerpt', 'force_balance_tags' );
721
  * bp_is_serialized()
722
  *
723
  * Checks to see if the data passed has been serialized.
724
- *
725
  * @package BuddyPress Core
726
  * @param $data str The data that will be checked
727
  * @return bool false if the data is not serialized
@@ -761,7 +761,7 @@ function bp_signup_with_blog_value() {
761
  function bp_get_signup_with_blog_value() {
762
  return apply_filters( 'bp_get_signup_with_blog_value', $_POST['signup_with_blog'] );
763
  }
764
-
765
  function bp_signup_blog_url_value() {
766
  echo bp_get_signup_blog_url_value();
767
  }
@@ -788,7 +788,7 @@ function bp_signup_avatar_dir_value() {
788
  }
789
  function bp_get_signup_avatar_dir_value() {
790
  global $bp;
791
-
792
  return apply_filters( 'bp_get_signup_avatar_dir_value', $bp->signup->avatar_dir );
793
  }
794
 
@@ -797,7 +797,7 @@ function bp_current_signup_step() {
797
  }
798
  function bp_get_current_signup_step() {
799
  global $bp;
800
-
801
  return $bp->signup->step;
802
  }
803
 
@@ -806,16 +806,16 @@ function bp_signup_avatar( $args = '' ) {
806
  }
807
  function bp_get_signup_avatar( $args = '' ) {
808
  global $bp;
809
-
810
  $defaults = array(
811
  'size' => BP_AVATAR_FULL_WIDTH,
812
  'class' => 'avatar',
813
- 'alt' => __( 'Your Avatar', 'buddypress' )
814
  );
815
 
816
  $r = wp_parse_args( $args, $defaults );
817
  extract( $r, EXTR_SKIP );
818
-
819
  $signup_avatar_dir = ( !empty( $_POST['signup_avatar_dir'] ) ) ? $_POST['signup_avatar_dir'] : $bp->signup->avatar_dir;
820
 
821
  if ( empty( $signup_avatar_dir ) ) {
@@ -826,7 +826,7 @@ function bp_signup_avatar( $args = '' ) {
826
  } else {
827
  $default_grav = $bp->grav_default->user;
828
  }
829
-
830
  $gravatar_url = apply_filters( 'bp_gravatar_url', 'http://www.gravatar.com/avatar/' );
831
  return apply_filters( 'bp_get_signup_avatar', '<img src="' . $gravatar_url . md5( $_POST['signup_email'] ) . '?d=' . $default_grav . '&amp;s=' . $size ) . '" width="' . $size . '" height="' . $size . '" alt="' . $alt . '" class="' . $class . '" />';
832
  } else {
@@ -843,7 +843,7 @@ function bp_signup_allowed() {
843
 
844
  function bp_account_was_activated() {
845
  global $bp;
846
-
847
  return $bp->activation_complete;
848
  }
849
 
@@ -862,13 +862,13 @@ class BP_Core_Members_Template {
862
  var $pag_num;
863
  var $pag_links;
864
  var $total_member_count;
865
-
866
  function bp_core_members_template( $type, $per_page, $max ) {
867
  global $bp, $bp_the_member_query;
868
 
869
  $this->pag_page = isset( $_REQUEST['upage'] ) ? intval( $_REQUEST['upage'] ) : 1;
870
  $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
871
-
872
  if ( isset( $_REQUEST['s'] ) && '' != $_REQUEST['s'] && $type != 'random' ) {
873
  $this->members = BP_Core_User::search_users( $_REQUEST['s'], $this->pag_num, $this->pag_page );
874
  } else if ( isset( $_REQUEST['letter'] ) && '' != $_REQUEST['letter'] ) {
@@ -878,29 +878,29 @@ class BP_Core_Members_Template {
878
  case 'random':
879
  $this->members = BP_Core_User::get_random_users( $this->pag_num, $this->pag_page );
880
  break;
881
-
882
  case 'newest':
883
  $this->members = BP_Core_User::get_newest_users( $this->pag_num, $this->pag_page );
884
  break;
885
 
886
  case 'popular':
887
  $this->members = BP_Core_User::get_popular_users( $this->pag_num, $this->pag_page );
888
- break;
889
 
890
  case 'online':
891
  $this->members = BP_Core_User::get_online_users( $this->pag_num, $this->pag_page );
892
  break;
893
-
894
  case 'alphabetical':
895
  $this->members = BP_Core_User::get_alphabetical_users( $this->pag_num, $this->pag_page );
896
  break;
897
-
898
  case 'active': default:
899
  $this->members = BP_Core_User::get_active_users( $this->pag_num, $this->pag_page );
900
- break;
901
  }
902
  }
903
-
904
  if ( !$max || $max >= (int)$this->members['total'] )
905
  $this->total_member_count = (int)$this->members['total'];
906
  else
@@ -916,8 +916,8 @@ class BP_Core_Members_Template {
916
  } else {
917
  $this->member_count = count($this->members);
918
  }
919
-
920
- if ( (int) $this->total_member_count && (int) $this->pag_num ) {
921
  $this->pag_links = paginate_links( array(
922
  'base' => add_query_arg( 'upage', '%#%' ),
923
  'format' => '',
@@ -926,32 +926,32 @@ class BP_Core_Members_Template {
926
  'prev_text' => '&laquo;',
927
  'next_text' => '&raquo;',
928
  'mid_size' => 1
929
- ));
930
  }
931
  }
932
-
933
  function has_members() {
934
  if ( $this->member_count )
935
  return true;
936
-
937
  return false;
938
  }
939
-
940
  function next_member() {
941
  $this->current_member++;
942
  $this->member = $this->members[$this->current_member];
943
-
944
  return $this->member;
945
  }
946
-
947
  function rewind_members() {
948
  $this->current_member = -1;
949
  if ( $this->member_count > 0 ) {
950
  $this->member = $this->members[0];
951
  }
952
  }
953
-
954
- function site_members() {
955
  if ( $this->current_member + 1 < $this->member_count ) {
956
  return true;
957
  } elseif ( $this->current_member + 1 == $this->member_count ) {
@@ -963,7 +963,7 @@ class BP_Core_Members_Template {
963
  $this->in_the_loop = false;
964
  return false;
965
  }
966
-
967
  function the_member() {
968
  global $member, $bp;
969
 
@@ -976,10 +976,10 @@ class BP_Core_Members_Template {
976
  $this->member = new BP_Core_User( $user_id );
977
  wp_cache_set( 'bp_user_' . $user_id, $this->member, 'bp' );
978
  }
979
-
980
  if ( $user_registered )
981
  $this->member->user_registered = $user_registered;
982
-
983
  if ( 0 == $this->current_member ) // loop has just started
984
  do_action('loop_start');
985
  }
@@ -987,7 +987,7 @@ class BP_Core_Members_Template {
987
 
988
  function bp_rewind_site_members() {
989
  global $site_members_template;
990
-
991
  return $site_members_template->rewind_members();
992
  }
993
 
@@ -1004,14 +1004,14 @@ function bp_has_site_members( $args = '' ) {
1004
  extract( $r, EXTR_SKIP );
1005
 
1006
  // type: active ( default ) | random | newest | popular | online | alphabetical
1007
-
1008
  if ( $max ) {
1009
  if ( $per_page > $max )
1010
  $per_page = $max;
1011
  }
1012
 
1013
  $site_members_template = new BP_Core_Members_Template( $type, $per_page, $max );
1014
-
1015
  return $site_members_template->has_members();
1016
  }
1017
 
@@ -1027,7 +1027,7 @@ function bp_site_members() {
1027
 
1028
  function bp_site_members_pagination_count() {
1029
  global $bp, $site_members_template;
1030
-
1031
  $from_num = intval( ( $site_members_template->pag_page - 1 ) * $site_members_template->pag_num ) + 1;
1032
  $to_num = ( $from_num + ( $site_members_template->pag_num - 1 ) > $site_members_template->total_member_count ) ? $site_members_template->total_member_count : $from_num + ( $site_members_template->pag_num - 1) ;
1033
 
@@ -1040,24 +1040,24 @@ function bp_site_members_pagination_links() {
1040
  }
1041
  function bp_get_site_members_pagination_links() {
1042
  global $site_members_template;
1043
-
1044
  return apply_filters( 'bp_get_site_members_pagination_links', $site_members_template->pag_links );
1045
  }
1046
 
1047
- function bp_the_site_member_user_id() {
1048
- echo bp_get_the_site_member_user_id();
1049
  }
1050
- function bp_get_the_site_member_user_id() {
1051
- global $site_members_template;
1052
 
1053
- return apply_filters( 'bp_get_the_site_member_user_id', $site_members_template->member->id );
1054
  }
1055
 
1056
  function bp_the_site_member_avatar() {
1057
  echo apply_filters( 'bp_the_site_member_avatar', bp_get_the_site_member_avatar() );
1058
  }
1059
- function bp_get_the_site_member_avatar() {
1060
- global $site_members_template;
1061
 
1062
  return apply_filters( 'bp_get_the_site_member_avatar', $site_members_template->member->avatar_thumb );
1063
  }
@@ -1099,10 +1099,10 @@ function bp_the_site_member_registered() {
1099
 
1100
  return apply_filters( 'bp_the_site_member_last_active', strtotime( $site_members_template->member->user_registered ) );
1101
  }
1102
-
1103
  function bp_the_site_member_add_friend_button() {
1104
  global $site_members_template;
1105
-
1106
  if ( function_exists( 'bp_add_friend_button' ) ) {
1107
  echo bp_add_friend_button( $site_members_template->member->id );
1108
  }
@@ -1110,10 +1110,10 @@ function bp_the_site_member_add_friend_button() {
1110
 
1111
  function bp_the_site_member_total_friend_count() {
1112
  global $site_members_template;
1113
-
1114
  if ( !(int) $site_members_template->member->total_friends )
1115
  return false;
1116
-
1117
  echo bp_get_the_site_member_total_friend_count();
1118
  }
1119
  function bp_get_the_site_member_total_friend_count() {
@@ -1125,9 +1125,9 @@ function bp_the_site_member_total_friend_count() {
1125
  if ( 1 == (int) $site_members_template->member->total_friends )
1126
  return apply_filters( 'bp_get_the_site_member_total_friend_count', sprintf( __( '%d friend', 'buddypress' ), (int) $site_members_template->member->total_friends ) );
1127
  else
1128
- return apply_filters( 'bp_get_the_site_member_total_friend_count', sprintf( __( '%d friends', 'buddypress' ), (int) $site_members_template->member->total_friends ) );
1129
  }
1130
-
1131
  function bp_the_site_member_random_profile_data() {
1132
  global $site_members_template;
1133
 
@@ -1164,7 +1164,7 @@ function bp_directory_members_search_form() {
1164
 
1165
  function bp_home_blog_url() {
1166
  global $bp, $current_blog;
1167
-
1168
  if ( defined( 'BP_ENABLE_MULTIBLOG' ) ) {
1169
  $blog_id = $current_blog->blog_id;
1170
  } else {
@@ -1215,27 +1215,27 @@ function bp_loggedin_user_fullname() {
1215
  }
1216
  function bp_get_loggedin_user_fullname() {
1217
  global $bp;
1218
- return apply_filters( 'bp_get_loggedin_user_fullname', $bp->loggedin_user->fullname );
1219
  }
1220
 
1221
  function bp_current_component() {
1222
  global $bp;
1223
- return apply_filters( 'bp_current_component', $bp->current_component );
1224
  }
1225
 
1226
  function bp_current_action() {
1227
  global $bp;
1228
- return apply_filters( 'bp_current_action', $bp->current_action );
1229
  }
1230
 
1231
  function bp_current_item() {
1232
  global $bp;
1233
- return apply_filters( 'bp_current_item', $bp->current_item );
1234
  }
1235
 
1236
  function bp_action_variables() {
1237
  global $bp;
1238
- return apply_filters( 'bp_action_variables', $bp->action_variables );
1239
  }
1240
 
1241
  function bp_root_domain() {
@@ -1243,7 +1243,7 @@ function bp_root_domain() {
1243
  }
1244
  function bp_get_root_domain() {
1245
  global $bp;
1246
-
1247
  return $bp->root_domain;
1248
  }
1249
 
@@ -1251,338 +1251,347 @@ function bp_root_domain() {
1251
 
1252
  function bp_is_profile_component() {
1253
  global $bp;
1254
-
1255
  if ( BP_XPROFILE_SLUG == $bp->current_component )
1256
  return true;
1257
-
1258
  return false;
1259
  }
1260
 
1261
  function bp_is_activity_component() {
1262
  global $bp;
1263
-
1264
  if ( BP_ACTIVITY_SLUG == $bp->current_component )
1265
  return true;
1266
-
1267
- return false;
1268
  }
1269
 
1270
  function bp_is_blogs_component() {
1271
  global $bp;
1272
-
1273
  if ( BP_BLOGS_SLUG == $bp->current_component )
1274
  return true;
1275
-
1276
- return false;
1277
  }
1278
 
1279
  function bp_is_wire_component() {
1280
  global $bp;
1281
-
1282
  if ( BP_WIRE_SLUG == $bp->current_action || in_array( BP_WIRE_SLUG, (array)$bp->action_variables ) )
1283
  return true;
1284
-
1285
- return false;
1286
  }
1287
 
1288
  function bp_is_messages_component() {
1289
  global $bp;
1290
-
1291
  if ( BP_MESSAGES_SLUG == $bp->current_component )
1292
  return true;
1293
-
1294
- return false;
1295
  }
1296
 
1297
  function bp_is_friends_component() {
1298
  global $bp;
1299
-
1300
  if ( BP_FRIENDS_SLUG == $bp->current_component )
1301
  return true;
1302
-
1303
- return false;
1304
  }
1305
 
1306
  function bp_is_groups_component() {
1307
  global $bp;
1308
-
1309
  if ( BP_GROUPS_SLUG == $bp->current_component )
1310
  return true;
1311
-
1312
- return false;
1313
  }
1314
 
1315
  function bp_is_settings_component() {
1316
  global $bp;
1317
-
1318
  if ( BP_SETTINGS_SLUG == $bp->current_component )
1319
  return true;
1320
-
1321
- return false;
1322
  }
1323
 
1324
  function bp_is_user_activity() {
1325
  global $bp;
1326
-
1327
  if ( BP_ACTIVITY_SLUG == $bp->current_component && ( !$bp->current_action || 'my-activity' == $bp->current_action ) )
1328
  return true;
1329
-
1330
  return false;
1331
- }
1332
 
1333
  function bp_is_user_friends_activity() {
1334
  global $bp;
1335
-
1336
  if ( BP_ACTIVITY_SLUG == $bp->current_component && 'my-friends' == $bp->current_action )
1337
  return true;
1338
-
1339
- return false;
1340
  }
1341
 
1342
  function bp_is_user_profile() {
1343
  global $bp;
1344
-
1345
  if ( BP_XPROFILE_SLUG == $bp->current_component )
1346
  return true;
1347
-
1348
- return false;
1349
  }
1350
 
1351
  function bp_is_profile_edit() {
1352
  global $bp;
1353
-
1354
  if ( BP_XPROFILE_SLUG == $bp->current_component && 'edit' == $bp->current_action )
1355
  return true;
1356
-
1357
  return false;
1358
  }
1359
 
1360
  function bp_is_change_avatar() {
1361
  global $bp;
1362
-
1363
  if ( BP_XPROFILE_SLUG == $bp->current_component && 'change-avatar' == $bp->current_action )
1364
  return true;
1365
-
1366
- return false;
1367
  }
1368
 
1369
  function bp_is_profile_wire() {
1370
  global $bp;
1371
-
1372
  if ( BP_XPROFILE_SLUG == $bp->current_component && 'wire' == $bp->current_action )
1373
  return true;
1374
-
1375
- return false;
1376
  }
1377
 
1378
  function bp_is_user_groups() {
1379
  global $bp;
1380
-
1381
  if ( BP_GROUPS_SLUG == $bp->current_component && ( !$bp->current_action || 'my-groups' == $bp->current_action ) )
1382
  return true;
1383
-
1384
- return false;
1385
  }
1386
 
1387
  function bp_is_group_home() {
1388
  global $bp;
1389
-
1390
  if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && ( !$bp->current_action || 'home' == $bp->current_action ) )
1391
  return true;
1392
-
1393
- return false;
1394
  }
1395
 
1396
  function bp_is_group_create() {
1397
  global $bp;
1398
-
1399
  if ( BP_GROUPS_SLUG == $bp->current_component && 'create' == $bp->current_action )
1400
  return true;
1401
-
1402
  return false;
1403
  }
1404
 
1405
 
1406
  function bp_is_group_admin_page() {
1407
  global $bp;
1408
-
1409
  if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'admin' == $bp->current_action )
1410
  return true;
1411
-
1412
- return false;
1413
  }
1414
 
1415
  function bp_is_group_wire() {
1416
  global $bp;
1417
-
1418
  if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'wire' == $bp->current_action )
1419
  return true;
1420
-
1421
- return false;
1422
  }
1423
 
1424
  function bp_is_group_forum() {
1425
  global $bp;
1426
-
1427
  if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'forum' == $bp->current_action )
1428
  return true;
1429
-
1430
- return false;
1431
  }
1432
 
1433
  function bp_is_group_forum_topic() {
1434
  global $bp;
1435
-
1436
  if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'forum' == $bp->current_action && 'topic' == $bp->action_variables[0] )
1437
  return true;
1438
-
1439
- return false;
1440
  }
1441
 
1442
  function bp_is_group_members() {
1443
  global $bp;
1444
-
1445
  if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'members' == $bp->current_action )
1446
  return true;
1447
-
1448
- return false;
1449
  }
1450
 
1451
  function bp_is_group_invites() {
1452
  global $bp;
1453
-
1454
  if ( BP_GROUPS_SLUG == $bp->current_component && 'invites' == $bp->current_action )
1455
  return true;
1456
-
1457
- return false;
1458
  }
1459
 
1460
  function bp_is_group_leave() {
1461
  global $bp;
1462
-
1463
  if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'leave-group' == $bp->current_action )
1464
  return true;
1465
-
1466
- return false;
 
 
 
 
 
 
 
 
 
1467
  }
1468
 
1469
  function bp_is_user_blogs() {
1470
  global $bp;
1471
-
1472
  if ( BP_BLOGS_SLUG == $bp->current_component && ( !$bp->current_action || 'my-blogs' == $bp->current_action ) )
1473
  return true;
1474
-
1475
- return false;
1476
  }
1477
 
1478
  function bp_is_user_recent_posts() {
1479
  global $bp;
1480
-
1481
  if ( BP_BLOGS_SLUG == $bp->current_component && 'recent-posts' == $bp->current_action )
1482
  return true;
1483
-
1484
- return false;
1485
  }
1486
 
1487
  function bp_is_user_recent_commments() {
1488
  global $bp;
1489
-
1490
  if ( BP_BLOGS_SLUG == $bp->current_component && 'recent-comments' == $bp->current_action )
1491
  return true;
1492
-
1493
- return false;
1494
  }
1495
 
1496
  function bp_is_create_blog() {
1497
  global $bp;
1498
-
1499
  if ( BP_BLOGS_SLUG == $bp->current_component && 'create-a-blog' == $bp->current_action )
1500
  return true;
1501
-
1502
- return false;
1503
  }
1504
 
1505
  function bp_is_user_friends() {
1506
  global $bp;
1507
-
1508
  if ( BP_FRIENDS_SLUG == $bp->current_component && ( !$bp->current_action || 'my-friends' == $bp->current_action ) )
1509
  return true;
1510
-
1511
- return false;
1512
  }
1513
 
1514
  function bp_is_friend_requests() {
1515
  global $bp;
1516
-
1517
  if ( BP_FRIENDS_SLUG == $bp->current_component && 'requests' == $bp->current_action )
1518
  return true;
1519
-
1520
- return false;
1521
  }
1522
 
1523
  function bp_is_messages_inbox() {
1524
  global $bp;
1525
-
1526
  if ( BP_MESSAGES_SLUG == $bp->current_component && ( !$bp->current_action || 'inbox' == $bp->current_action ) )
1527
  return true;
1528
-
1529
- return false;
1530
  }
1531
 
1532
  function bp_is_messages_sentbox() {
1533
  global $bp;
1534
-
1535
  if ( BP_MESSAGES_SLUG == $bp->current_component && 'sentbox' == $bp->current_action )
1536
  return true;
1537
-
1538
- return false;
1539
  }
1540
 
1541
 
1542
  function bp_is_notices() {
1543
  global $bp;
1544
-
1545
  if ( BP_MESSAGES_SLUG == $bp->current_component && 'notices' == $bp->current_action )
1546
  return true;
1547
-
1548
- return false;
1549
  }
1550
 
1551
 
1552
  function bp_is_messages_compose_screen() {
1553
  global $bp;
1554
-
1555
  if ( BP_MESSAGES_SLUG == $bp->current_component && 'compose' == $bp->current_action )
1556
  return true;
1557
-
1558
- return false;
1559
  }
1560
 
1561
  function bp_is_single_item() {
1562
  global $bp;
1563
-
1564
  if ( $bp->is_single_item )
1565
  return true;
1566
-
1567
  return false;
1568
  }
1569
 
1570
  function bp_is_activation_page() {
1571
  global $bp;
1572
-
1573
  if ( BP_ACTIVATION_SLUG == $bp->current_component )
1574
  return true;
1575
-
1576
- return false;
1577
  }
1578
 
1579
  function bp_is_register_page() {
1580
  global $bp;
1581
-
1582
  if ( BP_REGISTER_SLUG == $bp->current_component )
1583
  return true;
1584
-
1585
- return false;
1586
  }
1587
 
1588
  /* Use the above is_() functions to output a body class for each page */
@@ -1590,26 +1599,26 @@ function bp_is_register_page() {
1590
  function bp_the_body_class() {
1591
  echo bp_get_the_body_class();
1592
  }
1593
- function bp_get_the_body_class( $wp_classes, $custom_classes ) {
1594
  global $bp;
1595
 
1596
- if ( bp_is_blog_page() && is_front_page() && $bp->current_component != BP_HOME_BLOG_SLUG )
1597
- $bp_classes[] = 'home-page';
1598
-
1599
  if ( bp_is_blog_page() || bp_is_register_page() || bp_is_activation_page() )
1600
  $bp_classes[] = 'blog-page';
1601
-
1602
  if ( !bp_is_blog_page() && !bp_is_register_page() && !bp_is_activation_page() )
1603
  $bp_classes[] = 'internal-page';
1604
-
1605
  if ( bp_is_directory() )
1606
  $bp_classes[] = 'directory';
1607
-
1608
  if ( bp_is_user_profile() && !bp_is_blog_page() )
1609
  $bp_classes[] = 'profile';
1610
-
1611
  if ( bp_is_activity_component() && !bp_is_blog_page() )
1612
- $bp_classes[] = 'activity';
1613
 
1614
  if ( bp_is_blogs_component() && !bp_is_blog_page() )
1615
  $bp_classes[] = 'blogs';
@@ -1618,20 +1627,20 @@ function bp_the_body_class() {
1618
  $bp_classes[] = 'wire';
1619
 
1620
  if ( bp_is_messages_component() && !bp_is_blog_page() )
1621
- $bp_classes[] = 'messages';
1622
-
1623
  if ( bp_is_friends_component() && !bp_is_blog_page() )
1624
  $bp_classes[] = 'friends';
1625
-
1626
  if ( bp_is_groups_component() && !bp_is_blog_page() )
1627
  $bp_classes[] = 'groups';
1628
 
1629
  if ( bp_is_settings_component() && !bp_is_blog_page() )
1630
  $bp_classes[] = 'settings';
1631
-
1632
  if ( bp_is_single_item() )
1633
  $bp_classes[] = 'single-item';
1634
-
1635
  if ( bp_is_messages_inbox() )
1636
  $bp_classes[] = 'inbox';
1637
 
@@ -1643,76 +1652,76 @@ function bp_the_body_class() {
1643
 
1644
  if ( bp_is_notices() )
1645
  $bp_classes[] = 'notices';
1646
-
1647
  if ( bp_is_friend_requests() )
1648
  $bp_classes[] = 'friend-requests';
1649
 
1650
  if ( bp_is_user_friends() )
1651
  $bp_classes[] = 'my-friends';
1652
-
1653
  if ( bp_is_create_blog() )
1654
  $bp_classes[] = 'create-blog';
1655
-
1656
  if ( bp_is_user_recent_commments() )
1657
  $bp_classes[] = 'recent-comments';
1658
-
1659
  if ( bp_is_user_recent_posts() )
1660
  $bp_classes[] = 'recent-posts';
1661
-
1662
  if ( bp_is_user_blogs() && !bp_is_directory() )
1663
  $bp_classes[] = 'my-blogs';
1664
-
1665
  if ( bp_is_user_groups() && !bp_is_directory() )
1666
  $bp_classes[] = 'my-groups';
1667
-
1668
  if ( bp_is_group_leave() )
1669
  $bp_classes[] = 'leave-group';
1670
-
1671
  if ( bp_is_group_invites() )
1672
  $bp_classes[] = 'group-invites';
1673
-
1674
  if ( bp_is_group_members() )
1675
  $bp_classes[] = 'group-members';
1676
-
1677
  if ( bp_is_group_forum_topic() )
1678
  $bp_classes[] = 'group-forum-topic';
1679
-
1680
  if ( bp_is_group_forum() )
1681
  $bp_classes[] = 'group-forum';
1682
-
1683
  if ( bp_is_group_wire() )
1684
  $bp_classes[] = 'group-wire';
1685
-
1686
  if ( bp_is_group_admin_page() )
1687
  $bp_classes[] = 'group-admin';
1688
-
1689
  if ( bp_is_group_create() )
1690
  $bp_classes[] = 'group-create';
1691
-
1692
  if ( bp_is_group_home() )
1693
  $bp_classes[] = 'group-home';
1694
-
1695
  if ( bp_is_profile_wire() )
1696
  $bp_classes[] = 'profile-wire';
1697
-
1698
  if ( bp_is_change_avatar() )
1699
  $bp_classes[] = 'change-avatar';
1700
-
1701
  if ( bp_is_profile_edit() )
1702
  $bp_classes[] = 'profile-edit';
1703
-
1704
  if ( bp_is_user_friends_activity() )
1705
  $bp_classes[] = 'friends-activity';
1706
-
1707
  if ( bp_is_user_activity() )
1708
  $bp_classes[] = 'my-activity';
1709
-
1710
  if ( bp_is_register_page() )
1711
  $bp_classes[] = 'registration';
1712
-
1713
  if ( bp_is_activation_page() )
1714
  $bp_classes[] = 'activation';
1715
-
1716
  if ( is_user_logged_in() )
1717
  $bp_classes[] = 'logged-in';
1718
 
@@ -1720,11 +1729,11 @@ function bp_the_body_class() {
1720
  if ( !bp_is_blog_page() ) {
1721
  if ( !empty( $bp->current_component ) )
1722
  $bp_classes[] = $bp->current_component;
1723
-
1724
  if ( !empty( $bp->current_action ) )
1725
  $bp_classes[] = $bp->current_action;
1726
  }
1727
-
1728
  /* We don't want WordPress blog classes to appear on non-blog pages. */
1729
  if ( !bp_is_blog_page() || is_home() ) {
1730
  /* Preserve any custom classes already set */
@@ -1733,13 +1742,13 @@ function bp_the_body_class() {
1733
  else
1734
  $wp_classes = array();
1735
  }
1736
-
1737
  /* Merge WP classes with BP classes */
1738
  $classes = array_merge( (array) $bp_classes, (array) $wp_classes );
1739
-
1740
  /* Remove any duplicates */
1741
  $classes = array_unique( $classes );
1742
-
1743
  return apply_filters( 'bp_get_the_body_class', $classes, $bp_classes, $wp_classes, $custom_classes );
1744
  }
1745
  add_filter( 'body_class', 'bp_get_the_body_class', 10, 2 )
5
  *
6
  * Uses the $bp->bp_nav global to render out the navigation within a BuddyPress install.
7
  * Each component adds to this navigation array within its own [component_name]_setup_nav() function.
8
+ *
9
  * This navigation array is the top level navigation, so it contains items such as:
10
  * [Blog, Profile, Messages, Groups, Friends] ...
11
  *
17
  */
18
  function bp_get_loggedin_user_nav() {
19
  global $bp, $current_blog;
20
+
21
  /* Loop through each navigation item */
22
  foreach( (array) $bp->bp_nav as $nav_item ) {
23
  /* If the current component matches the nav item id, then add a highlight CSS class. */
26
  } else {
27
  $selected = '';
28
  }
29
+
30
  /* If we are viewing another person (current_userid does not equal loggedin_user->id)
31
  then check to see if the two users are friends. if they are, add a highlight CSS class
32
  to the friends nav item if it exists. */
33
  if ( !bp_is_home() && $bp->displayed_user->id ) {
34
  $selected = '';
35
+
36
  if ( function_exists('friends_install') ) {
37
  if ( $nav_item['css_id'] == $bp->friends->id ) {
38
  if ( friends_check_friendship( $bp->loggedin_user->id, $bp->displayed_user->id ) )
40
  }
41
  }
42
  }
43
+
44
  /* echo out the final list item */
45
  echo apply_filters( 'bp_get_loggedin_user_nav_' . $nav_item['css_id'], '<li id="li-nav-' . $nav_item['css_id'] . '" ' . $selected . '><a id="my-' . $nav_item['css_id'] . '" href="' . $nav_item['link'] . '">' . $nav_item['name'] . '</a></li>', &$nav_item );
46
  }
47
+
48
  /* Always add a log out list item to the end of the navigation */
49
  if ( function_exists( 'wp_logout_url' ) ) {
50
+ $logout_link = '<li><a id="wp-logout" href="' . wp_logout_url( $bp->root_domain ) . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>';
51
  } else {
52
  $logout_link = '<li><a id="wp-logout" href="' . site_url() . '/wp-login.php?action=logout&amp;redirect_to=' . $bp->root_domain . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>';
53
  }
54
+
55
  echo apply_filters( 'bp_logout_nav_link', $logout_link );
56
  }
57
  /* DEPRECATED - use bp_get_loggedin_user_nav() */
71
  global $bp;
72
 
73
  foreach ( $bp->bp_nav as $user_nav_item ) {
74
+ if ( !$user_nav_item['show_for_displayed_user'] )
75
  continue;
76
+
77
  if ( $bp->current_component == $user_nav_item['css_id'] )
78
  $selected = ' class="current"';
79
  else
80
  $selected = '';
81
+
82
  if ( $bp->loggedin_user->domain )
83
  $link = str_replace( $bp->loggedin_user->domain, $bp->displayed_user->domain, $user_nav_item['link'] );
84
  else
85
  $link = $bp->displayed_user->domain . $user_nav_item['link'];
86
+
87
  echo apply_filters( 'bp_get_displayed_user_nav_' . $user_nav_item['css_id'], '<li id="li-subnav-' . $user_nav_item['css_id'] . '" ' . $selected . '><a id="user-' . $user_nav_item['css_id'] . '" href="' . $link . '">' . $user_nav_item['name'] . '</a></li>', &$user_nav_item );
88
+ }
89
  }
90
  /* DEPRECATED - use bp_get_displayed_user_nav() */
91
  function bp_get_user_nav() { bp_get_displayed_user_nav(); }
92
+
93
  /**
94
  * bp_get_options_nav()
95
  * TEMPLATE TAG
96
  *
97
  * Uses the $bp->bp_options_nav global to render out the sub navigation for the current component.
98
  * Each component adds to its sub navigation array within its own [component_name]_setup_nav() function.
99
+ *
100
  * This sub navigation array is the secondary level navigation, so for profile it contains:
101
  * [Public, Edit Profile, Change Avatar]
102
  *
103
  * The function will also analyze the current action for the current component to determine whether
104
  * or not to highlight a particular sub nav item.
105
+ *
106
  * @package BuddyPress Core
107
  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
108
  * @uses bp_get_user_nav() Renders the navigation for a profile of a currently viewed user.
117
  if ( bp_is_home() || $bp->is_single_item ) {
118
  if ( count( $bp->bp_options_nav[$bp->current_component] ) < 1 )
119
  return false;
120
+
121
  /* Loop through each navigation item */
122
  foreach ( $bp->bp_options_nav[$bp->current_component] as $subnav_item ) {
123
  if ( !$subnav_item['user_has_access'] )
124
  continue;
125
+
126
  /* If the current action or an action variable matches the nav item id, then add a highlight CSS class. */
127
  if ( $subnav_item['slug'] == $bp->current_action ) {
128
  $selected = ' class="current"';
129
  } else {
130
  $selected = '';
131
  }
132
+
133
  /* echo out the final list item */
134
+ echo apply_filters( 'bp_get_options_nav_' . $subnav_item['css_id'], '<li id="li-subnav-' . $subnav_item['css_id'] . '" ' . $selected . '><a id="' . $subnav_item['css_id'] . '" href="' . $subnav_item['link'] . '">' . $subnav_item['name'] . '</a></li>', $subnav_item );
135
  }
136
  } else {
137
  /* If we get here we are viewing another user, so show the displayed user's nav items */
141
 
142
  function bp_get_options_title() {
143
  global $bp;
144
+
145
  if ( empty( $bp->bp_options_title ) )
146
  $bp->bp_options_title = __( 'Options', 'buddypress' );
147
+
148
  echo apply_filters( 'bp_get_options_title', attribute_escape( $bp->bp_options_title ) );
149
  }
150
+
151
 
152
  /** AVATAR TEMPLATE TAGS *******************************************************/
153
 
163
  */
164
  function bp_has_options_avatar() {
165
  global $bp;
166
+
167
  if ( empty( $bp->bp_options_avatar ) )
168
  return false;
169
+
170
  return true;
171
  }
172
 
178
 
179
  function bp_comment_author_avatar() {
180
  global $comment;
181
+
182
  if ( function_exists('bp_core_fetch_avatar') ) {
183
+ echo apply_filters( 'bp_comment_author_avatar', bp_core_fetch_avatar( array( 'item_id' => $comment->user_id, 'type' => 'thumb' ) ) );
184
  } else if ( function_exists('get_avatar') ) {
185
  get_avatar();
186
  }
188
 
189
  function bp_post_author_avatar() {
190
  global $post;
191
+
192
  if ( function_exists('bp_core_fetch_avatar') ) {
193
+ echo apply_filters( 'bp_post_author_avatar', bp_core_fetch_avatar( array( 'item_id' => $post->post_author, 'type' => 'thumb' ) ) );
194
  } else if ( function_exists('get_avatar') ) {
195
  get_avatar();
196
  }
210
 
211
  $r = wp_parse_args( $args, $defaults );
212
  extract( $r, EXTR_SKIP );
213
+
214
  return apply_filters( 'bp_get_loggedin_user_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->loggedin_user->id, 'type' => $type, 'width' => $width, 'height' => $height ) ) );
215
+ }
216
 
217
  function bp_displayed_user_avatar( $args = '' ) {
218
  echo bp_get_displayed_user_avatar( $args );
228
 
229
  $r = wp_parse_args( $args, $defaults );
230
  extract( $r, EXTR_SKIP );
231
+
232
  return apply_filters( 'bp_get_displayed_user_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => $type, 'width' => $width, 'height' => $height ) ) );
233
+ }
234
 
235
  function bp_avatar_admin_step() {
236
  echo bp_get_avatar_admin_step();
255
  }
256
  function bp_get_avatar_to_crop_src() {
257
  global $bp;
258
+
259
  return apply_filters( 'bp_get_avatar_to_crop_src', str_replace( WP_CONTENT_DIR, '', $bp->avatar_admin->image->dir ) );
260
  }
261
+
262
  function bp_avatar_cropper() {
263
  global $bp;
264
+
265
  echo '<img id="avatar-to-crop" class="avatar" src="' . $bp->avatar_admin->image . '" />';
266
  }
267
 
271
 
272
  function bp_is_home() {
273
  global $bp;
274
+
275
  if ( is_user_logged_in() && $bp->loggedin_user->id == $bp->displayed_user->id )
276
  return true;
277
+
278
  return false;
279
  }
280
 
281
  function bp_last_activity( $user_id = false, $echo = true ) {
282
  global $bp;
283
+
284
  if ( !$user_id )
285
  $user_id = $bp->displayed_user->id;
286
+
287
  $last_activity = bp_core_get_last_activity( get_usermeta( $user_id, 'last_activity' ), __('active %s ago', 'buddypress') );
288
 
289
  if ( $echo )
294
 
295
  function bp_user_link() {
296
  global $bp;
297
+
298
  echo apply_filters( 'bp_the_avatar_thumbnail', $bp->displayed_user->domain );
299
  }
300
 
301
  function bp_get_loggedin_user_link() {
302
  global $bp;
303
+
304
  return $bp->loggedin_user->domain;
305
  }
306
 
307
  function bp_get_displayed_user_link() {
308
  global $bp;
309
+
310
  return $bp->displayed_user->domain;
311
  }
312
 
313
  function bp_core_get_wp_profile() {
314
  global $bp;
315
+
316
  $ud = get_userdata( $bp->displayed_user->id );
317
  ?>
318
 
392
  function bp_exists( $component_name ) {
393
  if ( function_exists($component_name . '_install') )
394
  return true;
395
+
396
  return false;
397
  }
398
 
399
  function bp_format_time( $time, $just_date = false ) {
400
  $date = date( get_option('date_format'), $time );
401
+
402
  if ( !$just_date ) {
403
  $date .= ' ' . __( 'at', 'buddypress' ) . date( ' ' . get_option('time_format'), $time );
404
  }
405
+
406
  return apply_filters( 'bp_format_time', $date );
407
  }
408
 
409
  function bp_word_or_name( $youtext, $nametext, $capitalize = true, $echo = true ) {
410
  global $bp;
411
+
412
  if ( $capitalize )
413
  $youtext = bp_core_ucfirst($youtext);
414
+
415
  if ( $bp->displayed_user->id == $bp->loggedin_user->id ) {
416
  if ( $echo )
417
  echo apply_filters( 'bp_word_or_name', $youtext );
428
 
429
  function bp_your_or_their( $capitalize = true, $echo = true ) {
430
  global $bp;
431
+
432
  if ( $capitalize )
433
  $yourtext = bp_core_ucfirst($yourtext);
434
+
435
  if ( $bp->displayed_user->id == $bp->loggedin_user->id ) {
436
  if ( $echo )
437
  echo apply_filters( 'bp_your_or_their', $yourtext );
447
 
448
  function bp_loggedinuser_link() {
449
  global $bp;
450
+
451
  if ( $link = bp_core_get_userlink( $bp->loggedin_user->id ) ) {
452
  echo apply_filters( 'bp_loggedinuser_link', $link );
453
  }
482
  if ( is_single() ) {
483
  $title = __( 'Blog &#8212; ' . $post->post_title, 'buddypress' );
484
  } else if ( is_category() ) {
485
+ $title = __( 'Blog &#8212; Categories &#8212; ' . ucwords( $wp_query->query_vars['category_name'] ), 'buddypress' );
486
  } else if ( is_tag() ) {
487
+ $title = __( 'Blog &#8212; Tags &#8212; ' . ucwords( $wp_query->query_vars['tag'] ), 'buddypress' );
488
  } else
489
  $title = __( 'Blog', 'buddypress' );
490
 
501
  global $post;
502
  $title = get_the_title($post->ID);
503
  }
504
+
505
  if ( defined( 'BP_ENABLE_MULTIBLOG' ) ) {
506
  $blog_title = get_blog_option( $current_blog->blog_id, 'blogname' );
507
  } else {
508
+ $blog_title = get_blog_option( BP_ROOT_BLOG, 'blogname' );
509
  }
510
+
511
  return apply_filters( 'bp_page_title', $blog_title . ' &#8212; ' . attribute_escape( $title ), attribute_escape( $title ) );
512
  }
513
 
518
 
519
  function bp_is_page($page) {
520
  global $bp;
521
+
522
  if ( $bp->displayed_user->id || $bp->is_single_item )
523
  return false;
524
+
525
  if ( $page == $bp->current_component || ( is_home() && $page == 'home' && $bp->current_component == $bp->default_component ) || ( $page == BP_MEMBERS_SLUG && !$bp->current_component ) )
526
  return true;
527
+
528
  return false;
529
  }
530
 
534
 
535
  if ( file_exists( WP_CONTENT_DIR . '/themes/' . get_blog_option( BP_ROOT_BLOG, 'template') . '/registration/register.php') )
536
  return true;
537
+
538
  return false;
539
  }
540
 
546
  }
547
  function bp_get_signup_page() {
548
  global $bp;
549
+
550
  if ( bp_has_custom_signup_page() ) {
551
  return apply_filters( 'bp_get_signup_page', $bp->root_domain . '/' . BP_REGISTER_SLUG );
552
  } else {
560
 
561
  if ( file_exists( WP_CONTENT_DIR . '/themes/' . get_blog_option( BP_ROOT_BLOG, 'template') . '/registration/activate.php') )
562
  return true;
563
+
564
  return false;
565
  }
566
 
567
  function bp_activation_page( $echo = true ) {
568
  global $bp;
569
+
570
  if ( bp_has_custom_activation_page() ) {
571
  if ( $echo )
572
  echo $bp->root_domain . '/' . BP_ACTIVATION_SLUG;
582
 
583
  function bp_search_form_action() {
584
  global $bp;
585
+
586
  return apply_filters( 'bp_search_form_action', $bp->root_domain . '/search' );
587
  }
588
 
589
  function bp_search_form_type_select() {
590
  // Eventually this won't be needed and a page will be built to integrate all search results.
591
  $selection_box = '<select name="search-which" id="search-which" style="width: auto">';
592
+
593
  if ( function_exists( 'xprofile_install' ) ) {
594
  $selection_box .= '<option value="members">' . __( 'Members', 'buddypress' ) . '</option>';
595
  }
596
+
597
  if ( function_exists( 'groups_install' ) ) {
598
  $selection_box .= '<option value="groups">' . __( 'Groups', 'buddypress' ) . '</option>';
599
  }
601
  if ( function_exists( 'bp_forums_setup' ) && !(int) get_site_option( 'bp-disable-forum-directory' ) ) {
602
  $selection_box .= '<option value="forums">' . __( 'Forums', 'buddypress' ) . '</option>';
603
  }
604
+
605
  if ( function_exists( 'bp_blogs_install' ) ) {
606
  $selection_box .= '<option value="blogs">' . __( 'Blogs', 'buddypress' ) . '</option>';
607
  }
608
+
609
  $selection_box .= '</select>';
610
+
611
  return apply_filters( 'bp_search_form_type_select', $selection_box );
612
  }
613
 
614
  function bp_search_form() {
615
  $form = '
616
  <form action="' . bp_search_form_action() . '" method="post" id="search-form">
617
+ <input type="text" id="search-terms" name="search-terms" value="" />
618
  ' . bp_search_form_type_select() . '
619
+
620
  <input type="submit" name="search-submit" id="search-submit" value="' . __( 'Search', 'buddypress' ) . '" />
621
  ' . wp_nonce_field( 'bp_search_form' ) . '
622
  </form>
623
  ';
624
+
625
  echo apply_filters( 'bp_search_form', $form );
626
  }
627
 
630
  if ( function_exists('wp_logout_url') )
631
  $logout_link = '<a href="' . wp_logout_url( $bp->root_domain ) . '">' . __( 'Log Out', 'buddypress' ) . '</a>';
632
  else
633
+ $logout_link = '<a href="' . $bp->root_domain . '/wp-login.php?action=logout&amp;redirect_to=' . $bp->root_domain . '">' . __( 'Log Out', 'buddypress' ) . '</a>';
634
 
635
  echo apply_filters( 'bp_logout_link', $logout_link );
636
  }
637
 
638
  function bp_profile_wire_can_post() {
639
  global $bp;
640
+
641
  if ( bp_is_home() )
642
  return true;
643
+
644
  if ( function_exists('friends_install') ) {
645
  if ( friends_check_friendship( $bp->loggedin_user->id, $bp->displayed_user->id ) )
646
  return true;
647
  else
648
  return false;
649
+ }
650
+
651
  return true;
652
  }
653
 
658
  <li<?php if ( bp_is_page( 'home' ) ) {?> class="selected"<?php } ?>><a href="<?php echo get_option('home') ?>" title="<?php _e( 'Home', 'buddypress' ) ?>"><?php _e( 'Home', 'buddypress' ) ?></a></li>
659
  <li<?php if ( bp_is_page( BP_HOME_BLOG_SLUG ) ) {?> class="selected"<?php } ?>><a href="<?php echo get_option('home') ?>/<?php echo BP_HOME_BLOG_SLUG ?>" title="<?php _e( 'Blog', 'buddypress' ) ?>"><?php _e( 'Blog', 'buddypress' ) ?></a></li>
660
  <li<?php if ( bp_is_page( BP_MEMBERS_SLUG ) ) {?> class="selected"<?php } ?>><a href="<?php echo get_option('home') ?>/<?php echo BP_MEMBERS_SLUG ?>" title="<?php _e( 'Members', 'buddypress' ) ?>"><?php _e( 'Members', 'buddypress' ) ?></a></li>
661
+
662
  <?php if ( function_exists( 'groups_install' ) ) { ?>
663
  <li<?php if ( bp_is_page( $bp->groups->slug ) ) {?> class="selected"<?php } ?>><a href="<?php echo get_option('home') ?>/<?php echo $bp->groups->slug ?>" title="<?php _e( 'Groups', 'buddypress' ) ?>"><?php _e( 'Groups', 'buddypress' ) ?></a></li>
664
  <?php } ?>
665
+
666
  <?php if ( function_exists( 'bp_blogs_install' ) ) { ?>
667
  <li<?php if ( bp_is_page( $bp->blogs->slug ) ) {?> class="selected"<?php } ?>><a href="<?php echo get_option('home') ?>/<?php echo $bp->blogs->slug ?>" title="<?php _e( 'Blogs', 'buddypress' ) ?>"><?php _e( 'Blogs', 'buddypress' ) ?></a></li>
668
  <?php } ?>
680
 
681
  function bp_is_directory() {
682
  global $bp;
683
+
684
  return $bp->is_directory;
685
  }
686
 
688
  * bp_create_excerpt()
689
  *
690
  * Fakes an excerpt on any content. Will not truncate words.
691
+ *
692
  * @package BuddyPress Core
693
  * @param $text str The text to create the excerpt from
694
  * @uses $excerpt_length The maximum length in characters of the excerpt.
706
  array_push($words, '[...]');
707
  $text = implode(' ', $words);
708
  }
709
+
710
  return apply_filters( 'bp_create_excerpt', $text );
711
  }
712
  add_filter( 'bp_create_excerpt', 'wptexturize' );
721
  * bp_is_serialized()
722
  *
723
  * Checks to see if the data passed has been serialized.
724
+ *
725
  * @package BuddyPress Core
726
  * @param $data str The data that will be checked
727
  * @return bool false if the data is not serialized
761
  function bp_get_signup_with_blog_value() {
762
  return apply_filters( 'bp_get_signup_with_blog_value', $_POST['signup_with_blog'] );
763
  }
764
+
765
  function bp_signup_blog_url_value() {
766
  echo bp_get_signup_blog_url_value();
767
  }
788
  }
789
  function bp_get_signup_avatar_dir_value() {
790
  global $bp;
791
+
792
  return apply_filters( 'bp_get_signup_avatar_dir_value', $bp->signup->avatar_dir );
793
  }
794
 
797
  }
798
  function bp_get_current_signup_step() {
799
  global $bp;
800
+
801
  return $bp->signup->step;
802
  }
803
 
806
  }
807
  function bp_get_signup_avatar( $args = '' ) {
808
  global $bp;
809
+
810
  $defaults = array(
811
  'size' => BP_AVATAR_FULL_WIDTH,
812
  'class' => 'avatar',
813
+ 'alt' => __( 'Your Avatar', 'buddypress' )
814
  );
815
 
816
  $r = wp_parse_args( $args, $defaults );
817
  extract( $r, EXTR_SKIP );
818
+
819
  $signup_avatar_dir = ( !empty( $_POST['signup_avatar_dir'] ) ) ? $_POST['signup_avatar_dir'] : $bp->signup->avatar_dir;
820
 
821
  if ( empty( $signup_avatar_dir ) ) {
826
  } else {
827
  $default_grav = $bp->grav_default->user;
828
  }
829
+
830
  $gravatar_url = apply_filters( 'bp_gravatar_url', 'http://www.gravatar.com/avatar/' );
831
  return apply_filters( 'bp_get_signup_avatar', '<img src="' . $gravatar_url . md5( $_POST['signup_email'] ) . '?d=' . $default_grav . '&amp;s=' . $size ) . '" width="' . $size . '" height="' . $size . '" alt="' . $alt . '" class="' . $class . '" />';
832
  } else {
843
 
844
  function bp_account_was_activated() {
845
  global $bp;
846
+
847
  return $bp->activation_complete;
848
  }
849
 
862
  var $pag_num;
863
  var $pag_links;
864
  var $total_member_count;
865
+
866
  function bp_core_members_template( $type, $per_page, $max ) {
867
  global $bp, $bp_the_member_query;
868
 
869
  $this->pag_page = isset( $_REQUEST['upage'] ) ? intval( $_REQUEST['upage'] ) : 1;
870
  $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
871
+
872
  if ( isset( $_REQUEST['s'] ) && '' != $_REQUEST['s'] && $type != 'random' ) {
873
  $this->members = BP_Core_User::search_users( $_REQUEST['s'], $this->pag_num, $this->pag_page );
874
  } else if ( isset( $_REQUEST['letter'] ) && '' != $_REQUEST['letter'] ) {
878
  case 'random':
879
  $this->members = BP_Core_User::get_random_users( $this->pag_num, $this->pag_page );
880
  break;
881
+
882
  case 'newest':
883
  $this->members = BP_Core_User::get_newest_users( $this->pag_num, $this->pag_page );
884
  break;
885
 
886
  case 'popular':
887
  $this->members = BP_Core_User::get_popular_users( $this->pag_num, $this->pag_page );
888
+ break;
889
 
890
  case 'online':
891
  $this->members = BP_Core_User::get_online_users( $this->pag_num, $this->pag_page );
892
  break;
893
+
894
  case 'alphabetical':
895
  $this->members = BP_Core_User::get_alphabetical_users( $this->pag_num, $this->pag_page );
896
  break;
897
+
898
  case 'active': default:
899
  $this->members = BP_Core_User::get_active_users( $this->pag_num, $this->pag_page );
900
+ break;
901
  }
902
  }
903
+
904
  if ( !$max || $max >= (int)$this->members['total'] )
905
  $this->total_member_count = (int)$this->members['total'];
906
  else
916
  } else {
917
  $this->member_count = count($this->members);
918
  }
919
+
920
+ if ( (int) $this->total_member_count && (int) $this->pag_num ) {
921
  $this->pag_links = paginate_links( array(
922
  'base' => add_query_arg( 'upage', '%#%' ),
923
  'format' => '',
926
  'prev_text' => '&laquo;',
927
  'next_text' => '&raquo;',
928
  'mid_size' => 1
929
+ ));
930
  }
931
  }
932
+
933
  function has_members() {
934
  if ( $this->member_count )
935
  return true;
936
+
937
  return false;
938
  }
939
+
940
  function next_member() {
941
  $this->current_member++;
942
  $this->member = $this->members[$this->current_member];
943
+
944
  return $this->member;
945
  }
946
+
947
  function rewind_members() {
948
  $this->current_member = -1;
949
  if ( $this->member_count > 0 ) {
950
  $this->member = $this->members[0];
951
  }
952
  }
953
+
954
+ function site_members() {
955
  if ( $this->current_member + 1 < $this->member_count ) {
956
  return true;
957
  } elseif ( $this->current_member + 1 == $this->member_count ) {
963
  $this->in_the_loop = false;
964
  return false;
965
  }
966
+
967
  function the_member() {
968
  global $member, $bp;
969
 
976
  $this->member = new BP_Core_User( $user_id );
977
  wp_cache_set( 'bp_user_' . $user_id, $this->member, 'bp' );
978
  }
979
+
980
  if ( $user_registered )
981
  $this->member->user_registered = $user_registered;
982
+
983
  if ( 0 == $this->current_member ) // loop has just started
984
  do_action('loop_start');
985
  }
987
 
988
  function bp_rewind_site_members() {
989
  global $site_members_template;
990
+
991
  return $site_members_template->rewind_members();
992
  }
993
 
1004
  extract( $r, EXTR_SKIP );
1005
 
1006
  // type: active ( default ) | random | newest | popular | online | alphabetical
1007
+
1008
  if ( $max ) {
1009
  if ( $per_page > $max )
1010
  $per_page = $max;
1011
  }
1012
 
1013
  $site_members_template = new BP_Core_Members_Template( $type, $per_page, $max );
1014
+
1015
  return $site_members_template->has_members();
1016
  }
1017
 
1027
 
1028
  function bp_site_members_pagination_count() {
1029
  global $bp, $site_members_template;
1030
+
1031
  $from_num = intval( ( $site_members_template->pag_page - 1 ) * $site_members_template->pag_num ) + 1;
1032
  $to_num = ( $from_num + ( $site_members_template->pag_num - 1 ) > $site_members_template->total_member_count ) ? $site_members_template->total_member_count : $from_num + ( $site_members_template->pag_num - 1) ;
1033
 
1040
  }
1041
  function bp_get_site_members_pagination_links() {
1042
  global $site_members_template;
1043
+
1044
  return apply_filters( 'bp_get_site_members_pagination_links', $site_members_template->pag_links );
1045
  }
1046
 
1047
+ function bp_the_site_member_user_id() {
1048
+ echo bp_get_the_site_member_user_id();
1049
  }
1050
+ function bp_get_the_site_member_user_id() {
1051
+ global $site_members_template;
1052
 
1053
+ return apply_filters( 'bp_get_the_site_member_user_id', $site_members_template->member->id );
1054
  }
1055
 
1056
  function bp_the_site_member_avatar() {
1057
  echo apply_filters( 'bp_the_site_member_avatar', bp_get_the_site_member_avatar() );
1058
  }
1059
+ function bp_get_the_site_member_avatar() {
1060
+ global $site_members_template;
1061
 
1062
  return apply_filters( 'bp_get_the_site_member_avatar', $site_members_template->member->avatar_thumb );
1063
  }
1099
 
1100
  return apply_filters( 'bp_the_site_member_last_active', strtotime( $site_members_template->member->user_registered ) );
1101
  }
1102
+
1103
  function bp_the_site_member_add_friend_button() {
1104
  global $site_members_template;
1105
+
1106
  if ( function_exists( 'bp_add_friend_button' ) ) {
1107
  echo bp_add_friend_button( $site_members_template->member->id );
1108
  }
1110
 
1111
  function bp_the_site_member_total_friend_count() {
1112
  global $site_members_template;
1113
+
1114
  if ( !(int) $site_members_template->member->total_friends )
1115
  return false;
1116
+
1117
  echo bp_get_the_site_member_total_friend_count();
1118
  }
1119
  function bp_get_the_site_member_total_friend_count() {
1125
  if ( 1 == (int) $site_members_template->member->total_friends )
1126
  return apply_filters( 'bp_get_the_site_member_total_friend_count', sprintf( __( '%d friend', 'buddypress' ), (int) $site_members_template->member->total_friends ) );
1127
  else
1128
+ return apply_filters( 'bp_get_the_site_member_total_friend_count', sprintf( __( '%d friends', 'buddypress' ), (int) $site_members_template->member->total_friends ) );
1129
  }
1130
+
1131
  function bp_the_site_member_random_profile_data() {
1132
  global $site_members_template;
1133
 
1164
 
1165
  function bp_home_blog_url() {
1166
  global $bp, $current_blog;
1167
+
1168
  if ( defined( 'BP_ENABLE_MULTIBLOG' ) ) {
1169
  $blog_id = $current_blog->blog_id;
1170
  } else {
1215
  }
1216
  function bp_get_loggedin_user_fullname() {
1217
  global $bp;
1218
+ return apply_filters( 'bp_get_loggedin_user_fullname', $bp->loggedin_user->fullname );
1219
  }
1220
 
1221
  function bp_current_component() {
1222
  global $bp;
1223
+ return apply_filters( 'bp_current_component', $bp->current_component );
1224
  }
1225
 
1226
  function bp_current_action() {
1227
  global $bp;
1228
+ return apply_filters( 'bp_current_action', $bp->current_action );
1229
  }
1230
 
1231
  function bp_current_item() {
1232
  global $bp;
1233
+ return apply_filters( 'bp_current_item', $bp->current_item );
1234
  }
1235
 
1236
  function bp_action_variables() {
1237
  global $bp;
1238
+ return apply_filters( 'bp_action_variables', $bp->action_variables );
1239
  }
1240
 
1241
  function bp_root_domain() {
1243
  }
1244
  function bp_get_root_domain() {
1245
  global $bp;
1246
+
1247
  return $bp->root_domain;
1248
  }
1249
 
1251
 
1252
  function bp_is_profile_component() {
1253
  global $bp;
1254
+
1255
  if ( BP_XPROFILE_SLUG == $bp->current_component )
1256
  return true;
1257
+
1258
  return false;
1259
  }
1260
 
1261
  function bp_is_activity_component() {
1262
  global $bp;
1263
+
1264
  if ( BP_ACTIVITY_SLUG == $bp->current_component )
1265
  return true;
1266
+
1267
+ return false;
1268
  }
1269
 
1270
  function bp_is_blogs_component() {
1271
  global $bp;
1272
+
1273
  if ( BP_BLOGS_SLUG == $bp->current_component )
1274
  return true;
1275
+
1276
+ return false;
1277
  }
1278
 
1279
  function bp_is_wire_component() {
1280
  global $bp;
1281
+
1282
  if ( BP_WIRE_SLUG == $bp->current_action || in_array( BP_WIRE_SLUG, (array)$bp->action_variables ) )
1283
  return true;
1284
+
1285
+ return false;
1286
  }
1287
 
1288
  function bp_is_messages_component() {
1289
  global $bp;
1290
+
1291
  if ( BP_MESSAGES_SLUG == $bp->current_component )
1292
  return true;
1293
+
1294
+ return false;
1295
  }
1296
 
1297
  function bp_is_friends_component() {
1298
  global $bp;
1299
+
1300
  if ( BP_FRIENDS_SLUG == $bp->current_component )
1301
  return true;
1302
+
1303
+ return false;
1304
  }
1305
 
1306
  function bp_is_groups_component() {
1307
  global $bp;
1308
+
1309
  if ( BP_GROUPS_SLUG == $bp->current_component )
1310
  return true;
1311
+
1312
+ return false;
1313
  }
1314
 
1315
  function bp_is_settings_component() {
1316
  global $bp;
1317
+
1318
  if ( BP_SETTINGS_SLUG == $bp->current_component )
1319
  return true;
1320
+
1321
+ return false;
1322
  }
1323
 
1324
  function bp_is_user_activity() {
1325
  global $bp;
1326
+
1327
  if ( BP_ACTIVITY_SLUG == $bp->current_component && ( !$bp->current_action || 'my-activity' == $bp->current_action ) )
1328
  return true;
1329
+
1330
  return false;
1331
+ }
1332
 
1333
  function bp_is_user_friends_activity() {
1334
  global $bp;
1335
+
1336
  if ( BP_ACTIVITY_SLUG == $bp->current_component && 'my-friends' == $bp->current_action )
1337
  return true;
1338
+
1339
+ return false;
1340
  }
1341
 
1342
  function bp_is_user_profile() {
1343
  global $bp;
1344
+
1345
  if ( BP_XPROFILE_SLUG == $bp->current_component )
1346
  return true;
1347
+
1348
+ return false;
1349
  }
1350
 
1351
  function bp_is_profile_edit() {
1352
  global $bp;
1353
+
1354
  if ( BP_XPROFILE_SLUG == $bp->current_component && 'edit' == $bp->current_action )
1355
  return true;
1356
+
1357
  return false;
1358
  }
1359
 
1360
  function bp_is_change_avatar() {
1361
  global $bp;
1362
+
1363
  if ( BP_XPROFILE_SLUG == $bp->current_component && 'change-avatar' == $bp->current_action )
1364
  return true;
1365
+
1366
+ return false;
1367
  }
1368
 
1369
  function bp_is_profile_wire() {
1370
  global $bp;
1371
+
1372
  if ( BP_XPROFILE_SLUG == $bp->current_component && 'wire' == $bp->current_action )
1373
  return true;
1374
+
1375
+ return false;
1376
  }
1377
 
1378
  function bp_is_user_groups() {
1379
  global $bp;
1380
+
1381
  if ( BP_GROUPS_SLUG == $bp->current_component && ( !$bp->current_action || 'my-groups' == $bp->current_action ) )
1382
  return true;
1383
+
1384
+ return false;
1385
  }
1386
 
1387
  function bp_is_group_home() {
1388
  global $bp;
1389
+
1390
  if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && ( !$bp->current_action || 'home' == $bp->current_action ) )
1391
  return true;
1392
+
1393
+ return false;
1394
  }
1395
 
1396
  function bp_is_group_create() {
1397
  global $bp;
1398
+
1399
  if ( BP_GROUPS_SLUG == $bp->current_component && 'create' == $bp->current_action )
1400
  return true;
1401
+
1402
  return false;
1403
  }
1404
 
1405
 
1406
  function bp_is_group_admin_page() {
1407
  global $bp;
1408
+
1409
  if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'admin' == $bp->current_action )
1410
  return true;
1411
+
1412
+ return false;
1413
  }
1414
 
1415
  function bp_is_group_wire() {
1416
  global $bp;
1417
+
1418
  if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'wire' == $bp->current_action )
1419
  return true;
1420
+
1421
+ return false;
1422
  }
1423
 
1424
  function bp_is_group_forum() {
1425
  global $bp;
1426
+
1427
  if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'forum' == $bp->current_action )
1428
  return true;
1429
+
1430
+ return false;
1431
  }
1432
 
1433
  function bp_is_group_forum_topic() {
1434
  global $bp;
1435
+
1436
  if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'forum' == $bp->current_action && 'topic' == $bp->action_variables[0] )
1437
  return true;
1438
+
1439
+ return false;
1440
  }
1441
 
1442
  function bp_is_group_members() {
1443
  global $bp;
1444
+
1445
  if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'members' == $bp->current_action )
1446
  return true;
1447
+
1448
+ return false;
1449
  }
1450
 
1451
  function bp_is_group_invites() {
1452
  global $bp;
1453
+
1454
  if ( BP_GROUPS_SLUG == $bp->current_component && 'invites' == $bp->current_action )
1455
  return true;
1456
+
1457
+ return false;
1458
  }
1459
 
1460
  function bp_is_group_leave() {
1461
  global $bp;
1462
+
1463
  if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'leave-group' == $bp->current_action )
1464
  return true;
1465
+
1466
+ return false;
1467
+ }
1468
+
1469
+ function bp_is_group_single() {
1470
+ global $bp;
1471
+
1472
+ if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item )
1473
+ return true;
1474
+
1475
+ return false;
1476
  }
1477
 
1478
  function bp_is_user_blogs() {
1479
  global $bp;
1480
+
1481
  if ( BP_BLOGS_SLUG == $bp->current_component && ( !$bp->current_action || 'my-blogs' == $bp->current_action ) )
1482
  return true;
1483
+
1484
+ return false;
1485
  }
1486
 
1487
  function bp_is_user_recent_posts() {
1488
  global $bp;
1489
+
1490
  if ( BP_BLOGS_SLUG == $bp->current_component && 'recent-posts' == $bp->current_action )
1491
  return true;
1492
+
1493
+ return false;
1494
  }
1495
 
1496
  function bp_is_user_recent_commments() {
1497
  global $bp;
1498
+
1499
  if ( BP_BLOGS_SLUG == $bp->current_component && 'recent-comments' == $bp->current_action )
1500
  return true;
1501
+
1502
+ return false;
1503
  }
1504
 
1505
  function bp_is_create_blog() {
1506
  global $bp;
1507
+
1508
  if ( BP_BLOGS_SLUG == $bp->current_component && 'create-a-blog' == $bp->current_action )
1509
  return true;
1510
+
1511
+ return false;
1512
  }
1513
 
1514
  function bp_is_user_friends() {
1515
  global $bp;
1516
+
1517
  if ( BP_FRIENDS_SLUG == $bp->current_component && ( !$bp->current_action || 'my-friends' == $bp->current_action ) )
1518
  return true;
1519
+
1520
+ return false;
1521
  }
1522
 
1523
  function bp_is_friend_requests() {
1524
  global $bp;
1525
+
1526
  if ( BP_FRIENDS_SLUG == $bp->current_component && 'requests' == $bp->current_action )
1527
  return true;
1528
+
1529
+ return false;
1530
  }
1531
 
1532
  function bp_is_messages_inbox() {
1533
  global $bp;
1534
+
1535
  if ( BP_MESSAGES_SLUG == $bp->current_component && ( !$bp->current_action || 'inbox' == $bp->current_action ) )
1536
  return true;
1537
+
1538
+ return false;
1539
  }
1540
 
1541
  function bp_is_messages_sentbox() {
1542
  global $bp;
1543
+
1544
  if ( BP_MESSAGES_SLUG == $bp->current_component && 'sentbox' == $bp->current_action )
1545
  return true;
1546
+
1547
+ return false;
1548
  }
1549
 
1550
 
1551
  function bp_is_notices() {
1552
  global $bp;
1553
+
1554
  if ( BP_MESSAGES_SLUG == $bp->current_component && 'notices' == $bp->current_action )
1555
  return true;
1556
+
1557
+ return false;
1558
  }
1559
 
1560
 
1561
  function bp_is_messages_compose_screen() {
1562
  global $bp;
1563
+
1564
  if ( BP_MESSAGES_SLUG == $bp->current_component && 'compose' == $bp->current_action )
1565
  return true;
1566
+
1567
+ return false;
1568
  }
1569
 
1570
  function bp_is_single_item() {
1571
  global $bp;
1572
+
1573
  if ( $bp->is_single_item )
1574
  return true;
1575
+
1576
  return false;
1577
  }
1578
 
1579
  function bp_is_activation_page() {
1580
  global $bp;
1581
+
1582
  if ( BP_ACTIVATION_SLUG == $bp->current_component )
1583
  return true;
1584
+
1585
+ return false;
1586
  }
1587
 
1588
  function bp_is_register_page() {
1589
  global $bp;
1590
+
1591
  if ( BP_REGISTER_SLUG == $bp->current_component )
1592
  return true;
1593
+
1594
+ return false;
1595
  }
1596
 
1597
  /* Use the above is_() functions to output a body class for each page */
1599
  function bp_the_body_class() {
1600
  echo bp_get_the_body_class();
1601
  }
1602
+ function bp_get_the_body_class( $wp_classes, $custom_classes = false ) {
1603
  global $bp;
1604
 
1605
+ if ( bp_is_blog_page() && is_front_page() && $bp->current_component != BP_HOME_BLOG_SLUG )
1606
+ $bp_classes[] = 'home-page';
1607
+
1608
  if ( bp_is_blog_page() || bp_is_register_page() || bp_is_activation_page() )
1609
  $bp_classes[] = 'blog-page';
1610
+
1611
  if ( !bp_is_blog_page() && !bp_is_register_page() && !bp_is_activation_page() )
1612
  $bp_classes[] = 'internal-page';
1613
+
1614
  if ( bp_is_directory() )
1615
  $bp_classes[] = 'directory';
1616
+
1617
  if ( bp_is_user_profile() && !bp_is_blog_page() )
1618
  $bp_classes[] = 'profile';
1619
+
1620
  if ( bp_is_activity_component() && !bp_is_blog_page() )
1621
+ $bp_classes[] = 'activity';
1622
 
1623
  if ( bp_is_blogs_component() && !bp_is_blog_page() )
1624
  $bp_classes[] = 'blogs';
1627
  $bp_classes[] = 'wire';
1628
 
1629
  if ( bp_is_messages_component() && !bp_is_blog_page() )
1630
+ $bp_classes[] = 'messages';
1631
+
1632
  if ( bp_is_friends_component() && !bp_is_blog_page() )
1633
  $bp_classes[] = 'friends';
1634
+
1635
  if ( bp_is_groups_component() && !bp_is_blog_page() )
1636
  $bp_classes[] = 'groups';
1637
 
1638
  if ( bp_is_settings_component() && !bp_is_blog_page() )
1639
  $bp_classes[] = 'settings';
1640
+
1641
  if ( bp_is_single_item() )
1642
  $bp_classes[] = 'single-item';
1643
+
1644
  if ( bp_is_messages_inbox() )
1645
  $bp_classes[] = 'inbox';
1646
 
1652
 
1653
  if ( bp_is_notices() )
1654
  $bp_classes[] = 'notices';
1655
+
1656
  if ( bp_is_friend_requests() )
1657
  $bp_classes[] = 'friend-requests';
1658
 
1659
  if ( bp_is_user_friends() )
1660
  $bp_classes[] = 'my-friends';
1661
+
1662
  if ( bp_is_create_blog() )
1663
  $bp_classes[] = 'create-blog';
1664
+
1665
  if ( bp_is_user_recent_commments() )
1666
  $bp_classes[] = 'recent-comments';
1667
+
1668
  if ( bp_is_user_recent_posts() )
1669
  $bp_classes[] = 'recent-posts';
1670
+
1671
  if ( bp_is_user_blogs() && !bp_is_directory() )
1672
  $bp_classes[] = 'my-blogs';
1673
+
1674
  if ( bp_is_user_groups() && !bp_is_directory() )
1675
  $bp_classes[] = 'my-groups';
1676
+
1677
  if ( bp_is_group_leave() )
1678
  $bp_classes[] = 'leave-group';
1679
+
1680
  if ( bp_is_group_invites() )
1681
  $bp_classes[] = 'group-invites';
1682
+
1683
  if ( bp_is_group_members() )
1684
  $bp_classes[] = 'group-members';
1685
+
1686
  if ( bp_is_group_forum_topic() )
1687
  $bp_classes[] = 'group-forum-topic';
1688
+
1689
  if ( bp_is_group_forum() )
1690
  $bp_classes[] = 'group-forum';
1691
+
1692
  if ( bp_is_group_wire() )
1693
  $bp_classes[] = 'group-wire';
1694
+
1695
  if ( bp_is_group_admin_page() )
1696
  $bp_classes[] = 'group-admin';
1697
+
1698
  if ( bp_is_group_create() )
1699
  $bp_classes[] = 'group-create';
1700
+
1701
  if ( bp_is_group_home() )
1702
  $bp_classes[] = 'group-home';
1703
+
1704
  if ( bp_is_profile_wire() )
1705
  $bp_classes[] = 'profile-wire';
1706
+
1707
  if ( bp_is_change_avatar() )
1708
  $bp_classes[] = 'change-avatar';
1709
+
1710
  if ( bp_is_profile_edit() )
1711
  $bp_classes[] = 'profile-edit';
1712
+
1713
  if ( bp_is_user_friends_activity() )
1714
  $bp_classes[] = 'friends-activity';
1715
+
1716
  if ( bp_is_user_activity() )
1717
  $bp_classes[] = 'my-activity';
1718
+
1719
  if ( bp_is_register_page() )
1720
  $bp_classes[] = 'registration';
1721
+
1722
  if ( bp_is_activation_page() )
1723
  $bp_classes[] = 'activation';
1724
+
1725
  if ( is_user_logged_in() )
1726
  $bp_classes[] = 'logged-in';
1727
 
1729
  if ( !bp_is_blog_page() ) {
1730
  if ( !empty( $bp->current_component ) )
1731
  $bp_classes[] = $bp->current_component;
1732
+
1733
  if ( !empty( $bp->current_action ) )
1734
  $bp_classes[] = $bp->current_action;
1735
  }
1736
+
1737
  /* We don't want WordPress blog classes to appear on non-blog pages. */
1738
  if ( !bp_is_blog_page() || is_home() ) {
1739
  /* Preserve any custom classes already set */
1742
  else
1743
  $wp_classes = array();
1744
  }
1745
+
1746
  /* Merge WP classes with BP classes */
1747
  $classes = array_merge( (array) $bp_classes, (array) $wp_classes );
1748
+
1749
  /* Remove any duplicates */
1750
  $classes = array_unique( $classes );
1751
+
1752
  return apply_filters( 'bp_get_the_body_class', $classes, $bp_classes, $wp_classes, $custom_classes );
1753
  }
1754
  add_filter( 'body_class', 'bp_get_the_body_class', 10, 2 )
bp-core/bp-core-widgets.php CHANGED
@@ -30,7 +30,7 @@ class BP_Core_Welcome_Widget extends WP_Widget {
30
  <?php if ( !is_user_logged_in() ) { ?>
31
  <div class="create-account"><div class="visit generic-button"><a href="<?php bp_signup_page() ?>" title="<?php _e('Create Account', 'buddypress') ?>"><?php _e('Create Account', 'buddypress') ?></a></div></div>
32
  <?php } ?>
33
-
34
  <?php echo $after_widget; ?>
35
  <?php
36
  }
@@ -73,27 +73,27 @@ class BP_Core_Members_Widget extends WP_Widget {
73
  parent::WP_Widget( false, $name = __( 'Members', 'buddypress' ) );
74
 
75
  if ( is_active_widget( false, false, $this->id_base ) )
76
- wp_enqueue_script( 'bp_core_widget_members-js', BP_PLUGIN_URL . '/bp-core/js/widget-members.js', array('jquery', 'jquery-livequery-pack') );
77
  }
78
 
79
  function widget($args, $instance) {
80
  global $bp;
81
-
82
  extract( $args );
83
-
84
  echo $before_widget;
85
  echo $before_title
86
- . $widget_name
87
  . $after_title; ?>
88
 
89
  <?php if ( bp_has_site_members( 'type=newest&max=' . $instance['max_members'] ) ) : ?>
90
  <div class="item-options" id="members-list-options">
91
  <span class="ajax-loader" id="ajax-loader-members"></span>
92
- <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="newest-members" class="selected"><?php _e( 'Newest', 'buddypress' ) ?></a> |
93
- <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="recently-active-members"><?php _e( 'Active', 'buddypress' ) ?></a> |
94
  <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="popular-members"><?php _e( 'Popular', 'buddypress' ) ?></a>
95
  </div>
96
-
97
  <ul id="members-list" class="item-list">
98
  <?php while ( bp_site_members() ) : bp_the_site_member(); ?>
99
  <li class="vcard">
@@ -108,10 +108,10 @@ class BP_Core_Members_Widget extends WP_Widget {
108
  </li>
109
 
110
  <?php endwhile; ?>
111
- </ul>
112
  <?php wp_nonce_field( 'bp_core_widget_members', '_wpnonce-members' ); ?>
113
  <input type="hidden" name="members_widget_max" id="members_widget_max" value="<?php echo attribute_escape( $instance['max_members'] ); ?>" />
114
-
115
  <?php else: ?>
116
 
117
  <div class="widget-error">
@@ -119,7 +119,7 @@ class BP_Core_Members_Widget extends WP_Widget {
119
  </div>
120
 
121
  <?php endif; ?>
122
-
123
  <?php echo $after_widget; ?>
124
  <?php
125
  }
@@ -150,22 +150,22 @@ class BP_Core_Whos_Online_Widget extends WP_Widget {
150
 
151
  function widget($args, $instance) {
152
  global $bp;
153
-
154
  extract( $args );
155
-
156
  echo $before_widget;
157
  echo $before_title
158
- . $widget_name
159
  . $after_title; ?>
160
-
161
- <?php if ( bp_has_site_members( 'type=online&per_page=' . $instance['max_members'] . '&max=' . $instance['max_members'] ) ) : ?>
162
  <div class="avatar-block">
163
  <?php while ( bp_site_members() ) : bp_the_site_member(); ?>
164
  <div class="item-avatar">
165
  <a href="<?php bp_the_site_member_link() ?>" title="<?php bp_the_site_member_name() ?>"><?php bp_the_site_member_avatar() ?></a>
166
  </div>
167
  <?php endwhile; ?>
168
- </div>
169
  <?php else: ?>
170
 
171
  <div class="widget-error">
@@ -173,7 +173,7 @@ class BP_Core_Whos_Online_Widget extends WP_Widget {
173
  </div>
174
 
175
  <?php endif; ?>
176
-
177
  <?php echo $after_widget; ?>
178
  <?php
179
  }
@@ -204,22 +204,22 @@ class BP_Core_Recently_Active_Widget extends WP_Widget {
204
 
205
  function widget($args, $instance) {
206
  global $bp;
207
-
208
  extract( $args );
209
-
210
  echo $before_widget;
211
  echo $before_title
212
- . $widget_name
213
  . $after_title; ?>
214
-
215
- <?php if ( bp_has_site_members( 'type=active&per_page=' . $instance['max_members'] . '&max=' . $instance['max_members'] ) ) : ?>
216
  <div class="avatar-block">
217
  <?php while ( bp_site_members() ) : bp_the_site_member(); ?>
218
  <div class="item-avatar">
219
  <a href="<?php bp_the_site_member_link() ?>" title="<?php bp_the_site_member_name() ?>"><?php bp_the_site_member_avatar() ?></a>
220
  </div>
221
  <?php endwhile; ?>
222
- </div>
223
  <?php else: ?>
224
 
225
  <div class="widget-error">
@@ -227,7 +227,7 @@ class BP_Core_Recently_Active_Widget extends WP_Widget {
227
  </div>
228
 
229
  <?php endif; ?>
230
-
231
  <?php echo $after_widget; ?>
232
  <?php
233
  }
@@ -255,7 +255,7 @@ function bp_core_ajax_widget_members() {
255
  global $bp;
256
 
257
  check_ajax_referer('bp_core_widget_members');
258
-
259
  switch ( $_POST['filter'] ) {
260
  case 'newest-members':
261
  if ( !$users = wp_cache_get( 'newest_users', 'bp' ) ) {
@@ -276,10 +276,10 @@ function bp_core_ajax_widget_members() {
276
  }
277
  break;
278
  }
279
-
280
  if ( $users['users'] ) {
281
  echo '0[[SPLIT]]'; // return valid result.
282
-
283
  foreach ( (array) $users['users'] as $user ) {
284
  ?>
285
  <li class="vcard">
@@ -291,7 +291,7 @@ function bp_core_ajax_widget_members() {
291
  <div class="item-title"><?php echo bp_core_get_userlink( $user->user_id ) ?></div>
292
  <div class="item-meta">
293
  <span class="activity">
294
- <?php
295
  if ( 'newest-members' == $_POST['filter'] ) {
296
  echo bp_core_get_last_activity( $user->user_registered, __( 'registered %s ago', 'buddypress' ) );
297
  } else if ( 'recently-active-members' == $_POST['filter'] ) {
@@ -307,7 +307,7 @@ function bp_core_ajax_widget_members() {
307
  </div>
308
  </div>
309
  </li>
310
- <?php
311
  }
312
  } else {
313
  echo "-1[[SPLIT]]<li>" . __("No members matched the current filter.", 'buddypress');
30
  <?php if ( !is_user_logged_in() ) { ?>
31
  <div class="create-account"><div class="visit generic-button"><a href="<?php bp_signup_page() ?>" title="<?php _e('Create Account', 'buddypress') ?>"><?php _e('Create Account', 'buddypress') ?></a></div></div>
32
  <?php } ?>
33
+
34
  <?php echo $after_widget; ?>
35
  <?php
36
  }
73
  parent::WP_Widget( false, $name = __( 'Members', 'buddypress' ) );
74
 
75
  if ( is_active_widget( false, false, $this->id_base ) )
76
+ wp_enqueue_script( 'bp_core_widget_members-js', BP_PLUGIN_URL . '/bp-core/js/widget-members.js', array('jquery', 'jquery-livequery-pack') );
77
  }
78
 
79
  function widget($args, $instance) {
80
  global $bp;
81
+
82
  extract( $args );
83
+
84
  echo $before_widget;
85
  echo $before_title
86
+ . $widget_name
87
  . $after_title; ?>
88
 
89
  <?php if ( bp_has_site_members( 'type=newest&max=' . $instance['max_members'] ) ) : ?>
90
  <div class="item-options" id="members-list-options">
91
  <span class="ajax-loader" id="ajax-loader-members"></span>
92
+ <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="newest-members" class="selected"><?php _e( 'Newest', 'buddypress' ) ?></a> |
93
+ <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="recently-active-members"><?php _e( 'Active', 'buddypress' ) ?></a> |
94
  <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="popular-members"><?php _e( 'Popular', 'buddypress' ) ?></a>
95
  </div>
96
+
97
  <ul id="members-list" class="item-list">
98
  <?php while ( bp_site_members() ) : bp_the_site_member(); ?>
99
  <li class="vcard">
108
  </li>
109
 
110
  <?php endwhile; ?>
111
+ </ul>
112
  <?php wp_nonce_field( 'bp_core_widget_members', '_wpnonce-members' ); ?>
113
  <input type="hidden" name="members_widget_max" id="members_widget_max" value="<?php echo attribute_escape( $instance['max_members'] ); ?>" />
114
+
115
  <?php else: ?>
116
 
117
  <div class="widget-error">
119
  </div>
120
 
121
  <?php endif; ?>
122
+
123
  <?php echo $after_widget; ?>
124
  <?php
125
  }
150
 
151
  function widget($args, $instance) {
152
  global $bp;
153
+
154
  extract( $args );
155
+
156
  echo $before_widget;
157
  echo $before_title
158
+ . $widget_name
159
  . $after_title; ?>
160
+
161
+ <?php if ( bp_has_site_members( 'type=online&per_page=' . $instance['max_members'] . '&max=' . $instance['max_members'] ) ) : ?>
162
  <div class="avatar-block">
163
  <?php while ( bp_site_members() ) : bp_the_site_member(); ?>
164
  <div class="item-avatar">
165
  <a href="<?php bp_the_site_member_link() ?>" title="<?php bp_the_site_member_name() ?>"><?php bp_the_site_member_avatar() ?></a>
166
  </div>
167
  <?php endwhile; ?>
168
+ </div>
169
  <?php else: ?>
170
 
171
  <div class="widget-error">
173
  </div>
174
 
175
  <?php endif; ?>
176
+
177
  <?php echo $after_widget; ?>
178
  <?php
179
  }
204
 
205
  function widget($args, $instance) {
206
  global $bp;
207
+
208
  extract( $args );
209
+
210
  echo $before_widget;
211
  echo $before_title
212
+ . $widget_name
213
  . $after_title; ?>
214
+
215
+ <?php if ( bp_has_site_members( 'type=active&per_page=' . $instance['max_members'] . '&max=' . $instance['max_members'] ) ) : ?>
216
  <div class="avatar-block">
217
  <?php while ( bp_site_members() ) : bp_the_site_member(); ?>
218
  <div class="item-avatar">
219
  <a href="<?php bp_the_site_member_link() ?>" title="<?php bp_the_site_member_name() ?>"><?php bp_the_site_member_avatar() ?></a>
220
  </div>
221
  <?php endwhile; ?>
222
+ </div>
223
  <?php else: ?>
224
 
225
  <div class="widget-error">
227
  </div>
228
 
229
  <?php endif; ?>
230
+
231
  <?php echo $after_widget; ?>
232
  <?php
233
  }
255
  global $bp;
256
 
257
  check_ajax_referer('bp_core_widget_members');
258
+
259
  switch ( $_POST['filter'] ) {
260
  case 'newest-members':
261
  if ( !$users = wp_cache_get( 'newest_users', 'bp' ) ) {
276
  }
277
  break;
278
  }
279
+
280
  if ( $users['users'] ) {
281
  echo '0[[SPLIT]]'; // return valid result.
282
+
283
  foreach ( (array) $users['users'] as $user ) {
284
  ?>
285
  <li class="vcard">
291
  <div class="item-title"><?php echo bp_core_get_userlink( $user->user_id ) ?></div>
292
  <div class="item-meta">
293
  <span class="activity">
294
+ <?php
295
  if ( 'newest-members' == $_POST['filter'] ) {
296
  echo bp_core_get_last_activity( $user->user_registered, __( 'registered %s ago', 'buddypress' ) );
297
  } else if ( 'recently-active-members' == $_POST['filter'] ) {
307
  </div>
308
  </div>
309
  </li>
310
+ <?php
311
  }
312
  } else {
313
  echo "-1[[SPLIT]]<li>" . __("No members matched the current filter.", 'buddypress');
bp-core/css/widget-members.css CHANGED
File without changes
bp-core/deprecated/bp-core-deprecated.php CHANGED
@@ -3,7 +3,7 @@
3
  * Deprecated Core Functionality
4
  *
5
  * This file contains functions that are deprecated.
6
- * You should not under any circumstance use these functions as they are
7
  * either no longer valid, or have been replaced with something much more awesome.
8
  *
9
  * If you are using functions in this file you should slap the back of your head
@@ -12,9 +12,9 @@
12
  *
13
  * Of course, things will still work if you use these functions but you will
14
  * be the laughing stock of the BuddyPress community. We will all point and laugh at
15
- * you. You'll also be making things harder for yourself in the long run,
16
  * and you will miss out on lovely performance and functionality improvements.
17
- *
18
  * If you've checked you are not using any deprecated functions and finished your little
19
  * dance, you can add the following line to your wp-config.php file to prevent any of
20
  * these old functions from being loaded:
@@ -24,7 +24,7 @@
24
 
25
  function bp_core_deprecated_globals() {
26
  global $bp;
27
-
28
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
29
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
30
  return false;
@@ -64,16 +64,16 @@ function bp_core_signup_register_headers() {
64
 
65
  function bp_core_signup_show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) {
66
  global $current_site;
67
-
68
  ?>
69
  <h3><?php _e( 'Blog Details', 'buddypress' ) ?></h3>
70
  <p id="blog-details-help">
71
  <?php _e( "To register your first blog, just fill in the details below and your registration is complete.", 'buddypress' ) ?>
72
  </p>
73
-
74
  <div id="blog-details-fields">
75
  <?php
76
-
77
  // Blog name
78
  if ( 'no' == constant( "VHOST" ) )
79
  echo '<label for="blogname">' . __('Blog Name:', 'buddypress') . '</label>';
@@ -89,7 +89,7 @@ function bp_core_signup_show_blog_form( $blogname = '', $blog_title = '', $error
89
  } else {
90
  echo '<input name="blogname" type="text" id="blogname" value="'.$blogname.'" maxlength="50" /><span class="suffix_address">.' . $current_site->domain . $current_site->path . '</span><br />';
91
  }
92
-
93
  if ( !is_user_logged_in() ) {
94
  echo '<p class="help-text">';
95
  print '(<strong>' . __( 'Your address will be ', 'buddypress' );
@@ -104,7 +104,7 @@ function bp_core_signup_show_blog_form( $blogname = '', $blog_title = '', $error
104
 
105
  // Blog Title
106
  ?>
107
- <label for="blog_title"><?php _e( 'Blog Title:', 'buddypress' ) ?></label>
108
  <?php if ( $errmsg = $errors->get_error_message('blog_title') ) { ?>
109
  <p class="error"><?php echo $errmsg ?></p>
110
  <?php }
@@ -113,7 +113,7 @@ function bp_core_signup_show_blog_form( $blogname = '', $blog_title = '', $error
113
 
114
  <p>
115
  <label for="blog_public_on"><?php _e( 'Privacy:', 'buddypress' ) ?></label>
116
- <?php _e( 'I would like my blog to appear in search engines like Google and Technorati, and in public listings around this site.', 'buddypress' ); ?>
117
  <label class="checkbox" for="blog_public_on">
118
  <input type="radio" id="blog_public_on" name="blog_public" value="1" <?php if( !isset( $_POST['blog_public'] ) || '1' == $_POST['blog_public'] ) { ?>checked="checked"<?php } ?> />
119
  &nbsp;<?php _e( 'Yes', 'buddypress' ); ?>
@@ -152,14 +152,14 @@ function bp_core_signup_show_user_form($user_name = '', $user_email = '', $error
152
  <label for="user_email"><?php _e( 'Email&nbsp;Address:', 'buddypress' ) ?></label>
153
  <?php if ( $errmsg = $errors->get_error_message('user_email') ) { ?>
154
  <p class="error"><?php echo $errmsg ?></p>
155
- <?php } ?>
156
  <input name="user_email" type="text" id="user_email" value="<?php echo wp_specialchars($user_email, 1) ?>" maxlength="200" /><p class="help-text"><?php _e( '(We&#8217;ll send your password to this address, so <strong>triple-check it</strong>.)', 'buddypress' ) ?></p>
157
  <?php
158
  if ( $errmsg = $errors->get_error_message('generic') ) {
159
  echo '<p class="error">'.$errmsg.'</p>';
160
  }
161
  echo '</div>';
162
-
163
  echo '<div id="extra-fields">';
164
  do_action( 'signup_extra_fields', $errors );
165
  echo '</div>';
@@ -171,7 +171,7 @@ function bp_core_signup_validate_user_form() {
171
 
172
  function bp_core_signup_signup_another_blog($blogname = '', $blog_title = '', $errors = '') {
173
  global $current_user, $current_site;
174
-
175
  if ( ! is_wp_error($errors) ) {
176
  $errors = new WP_Error();
177
  }
@@ -185,10 +185,10 @@ function bp_core_signup_signup_another_blog($blogname = '', $blog_title = '', $e
185
  ?>
186
  <h3><?php _e( "You're already registered!", 'buddypress' )?></h3>
187
  <p><?php _e( 'You can still create another blog however. Fill in the form below to add another blog to your account.', 'buddypress' ) ?>
188
-
189
 
190
  <p><?php _e( "There is no limit to the number of blogs you can have, so create to your heart's content, but blog responsibly. If you&#8217;re not going to use a great blog domain, leave it for a new user. Now have at it!", 'buddypress' ) ?></p>
191
-
192
  <form id="setupform" method="post" action="<?php echo site_url(BP_REGISTER_SLUG) ?>">
193
  <input type="hidden" name="stage" value="gimmeanotherblog" />
194
  <?php do_action( "signup_hidden_fields" ); ?>
@@ -253,14 +253,14 @@ function bp_core_signup_signup_user($user_name = '', $user_email = '', $errors =
253
  $errors = $filtered_results['errors'];
254
 
255
  ?>
256
-
257
  <form id="setupform" method="post" action="<?php echo site_url(BP_REGISTER_SLUG) ?>">
258
  <p id="intro-text"><?php _e( 'Registering for a new account is easy, just fill in the form below and you\'ll be a new member in no time at all.', 'buddypress' ) ?></p>
259
  <input type="hidden" name="stage" value="validate-user-signup" />
260
  <?php do_action( "signup_hidden_fields" ); ?>
261
-
262
  <?php bp_core_signup_show_user_form($user_name, $user_email, $errors); ?>
263
-
264
  <?php if( 'blog' == $active_signup ) { ?>
265
  <input id="signupblog" type="hidden" name="signup_for" value="blog" />
266
  <?php } elseif( 'user' == $active_signup ) { ?>
@@ -269,15 +269,15 @@ function bp_core_signup_signup_user($user_name = '', $user_email = '', $errors =
269
  <div id="blog-or-username">
270
  <h3><?php _e( 'Create a Blog?', 'buddypress' ) ?></h3>
271
  <p id="blog-help-text"><?php _e( 'If you want to create your first blog, select the option below and you\'ll be asked for a few more details.', 'buddypress' ) ?></p>
272
-
273
  <div id="blog-or-username-fields">
274
  <p>
275
  <input id="signupblog" type="radio" name="signup_for" value="blog" <?php echo $signup['blog'] ?> />
276
- <label class="checkbox" for="signupblog"><?php _e( 'Gimme a blog!', 'buddypress' ) ?></label>
277
  </p>
278
-
279
  <p>
280
- <input id="signupuser" type="radio" name="signup_for" value="user" <?php echo $signup['user'] ?> />
281
  <label class="checkbox" for="signupuser"><?php _e( 'Just a username, please.', 'buddypress' ) ?></label>
282
  </p>
283
  </div>
@@ -377,10 +377,10 @@ function bp_core_signup_validate_blog_signup() {
377
  function bp_core_signup_confirm_blog_signup($domain, $path, $blog_title, $user_name = '', $user_email = '', $meta) {
378
  ?>
379
  <h3><?php _e('Congratulations, You are now registered!', 'buddypress' ) ?></h3>
380
-
381
  <p><?php printf( __('But, before you can start using your blog, <strong>you must activate it</strong>. Check your inbox at <strong>%s</strong> and click the link given. It should arrive within 30 minutes.', 'buddypress' ), $user_email) ?></p>
382
  <p>&nbsp;</p>
383
-
384
  <h3><?php _e( 'Still waiting for your email?', 'buddypress' ); ?></h3>
385
  <p>
386
  <?php _e( "If you haven't received your email yet, there are a number of things you can do:", 'buddypress' ) ?>
@@ -464,26 +464,26 @@ function bp_core_signup_do_signup() {
464
 
465
  function bp_core_activation_set_headers() {
466
  global $wp_object_cache;
467
-
468
  define( "WP_INSTALLING", true );
469
-
470
  require_once( ABSPATH . WPINC . '/registration.php');
471
-
472
  if( is_object( $wp_object_cache ) )
473
  $wp_object_cache->cache_enabled = false;
474
-
475
  do_action("activate_header");
476
  }
477
 
478
  function bp_core_activation_do_activation() {
479
  global $current_site, $blog_id, $user_id; ?>
480
-
481
  <?php if ( empty( $_GET['key'] ) && empty( $_POST['key'] ) ) { ?>
482
 
483
  <h3><?php _e( 'Activation Key Required', 'buddypress' ) ?></h3>
484
-
485
  <p id="intro-text"><?php _e( 'This is the key contained in the email you were sent after registering for this site.', 'buddypress' ) ?></p>
486
-
487
  <div class="field-box">
488
  <form name="activateform" id="activateform" method="post" action="<?php echo 'http://' . $current_site->domain . $current_site->path ?>wp-activate.php">
489
  <p>
@@ -495,22 +495,22 @@ function bp_core_activation_do_activation() {
495
  </p>
496
  </form>
497
  </div>
498
-
499
  <?php } else {
500
 
501
  $key = !empty($_GET['key']) ? $_GET['key'] : $_POST['key'];
502
  $result = wpmu_activate_signup($key);
503
-
504
  if ( is_wp_error($result) ) {
505
  if ( 'already_active' == $result->get_error_code() || 'blog_taken' == $result->get_error_code() ) {
506
  $signup = $result->get_error_data();
507
  ?>
508
-
509
  <h3><?php _e('Your account is now active!', 'buddypress' ); ?></h3>
510
-
511
  <?php
512
  _e( 'Your account has already been activated. You can now log in with the account details that were emailed to you.' );
513
-
514
  } else {
515
  ?>
516
  <h2><?php _e('An error occurred during the activation', 'buddypress' ); ?></h2>
@@ -521,74 +521,24 @@ function bp_core_activation_do_activation() {
521
  extract($result);
522
 
523
  $user = new WP_User( (int) $user_id);
524
-
525
  ?>
526
-
527
  <h3><?php _e('Your account is now active!', 'buddypress' ); ?></h3>
528
-
529
  <p class="view"><?php printf( __( 'Your account is now activated. <a href="%1$s">Login</a> or go back to the <a href="%2$s">homepage</a>.', 'buddypress' ), site_url( 'wp-login.php?redirect_to=' . site_url() ), site_url() ); ?></p>
530
-
531
  <div class="field-box" id="signup-welcome">
532
  <p><span class="label"><?php _e( 'Username:', 'buddypress' ); ?></span> <?php echo $user->user_login ?></p>
533
  <p><span class="label"><?php _e( 'Password:', 'buddypress' ); ?></span> <?php echo $password; ?></p>
534
  </div>
535
-
536
- <?php
537
  do_action( 'bp_activation_extras', $user_id, $meta );
538
  }
539
  }
540
  }
541
 
542
- // Notify user of signup success.
543
- function bp_core_activation_signup_blog_notification( $domain, $path, $title, $user, $user_email, $key, $meta ) {
544
- global $current_site;
545
-
546
- // Send email with activation link.
547
- if ( 'no' == constant( "VHOST" ) ) {
548
- $activate_url = bp_activation_page( false ) . "?key=$key";
549
- } else {
550
- $activate_url = bp_activation_page( false ) ."?key=$key";
551
- }
552
-
553
- $activate_url = clean_url($activate_url);
554
- $admin_email = get_site_option( "admin_email" );
555
-
556
- if ( empty( $admin_email ) )
557
- $admin_email = 'support@' . $_SERVER['SERVER_NAME'];
558
-
559
- $from_name = ( '' == get_site_option( "site_name" ) ) ? 'WordPress' : wp_specialchars( get_site_option( "site_name" ) );
560
- $message_headers = "MIME-Version: 1.0\n" . "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
561
- $message = sprintf(__("To activate your blog, please click the following link:\n\n%s\n\nAfter you activate, you will receive *another email* with your login.\n\nAfter you activate, you can visit your blog here:\n\n%s", 'buddypress' ), $activate_url, clean_url("http://{$domain}{$path}" ) );
562
- $subject = '[' . $from_name . '] ' . sprintf(__('Activate %s', 'buddypress' ), clean_url('http://' . $domain . $path));
563
-
564
- wp_mail($user_email, $subject, $message, $message_headers);
565
-
566
- // Return false to stop the original WPMU function from continuing
567
- return false;
568
- }
569
- add_filter( 'wpmu_signup_blog_notification', 'bp_core_activation_signup_blog_notification', 1, 7 );
570
-
571
- function bp_core_activation_signup_user_notification( $user, $user_email, $key, $meta ) {
572
- global $current_site;
573
-
574
- // Send email with activation link.
575
- $admin_email = get_site_option( "admin_email" );
576
-
577
- if ( empty( $admin_email ) )
578
- $admin_email = 'support@' . $_SERVER['SERVER_NAME'];
579
-
580
- $from_name = ( '' == get_site_option( "site_name" ) ) ? 'WordPress' : wp_specialchars( get_site_option( "site_name" ) );
581
- $message_headers = "MIME-Version: 1.0\n" . "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
582
- $message = apply_filters( 'wpmu_signup_user_notification_email', sprintf( __( "To activate your user, please click the following link:\n\n%s\n\nAfter you activate, you will receive *another email* with your login.\n\n", 'buddypress' ), clean_url( bp_activation_page( false ) . "?key=$key" ) ) );
583
- $subject = apply_filters( 'wpmu_signup_user_notification_subject', sprintf( __( 'Activate %s', 'buddypress' ), $user ) );
584
-
585
- wp_mail( $user_email, $subject, $message, $message_headers );
586
-
587
- // Return false to stop the original WPMU function from continuing
588
- return false;
589
- }
590
- add_filter( 'wpmu_signup_user_notification', 'bp_core_activation_signup_user_notification', 1, 4 );
591
-
592
  /*** END DEPRECATED SIGNUP FUNCTIONS **********/
593
 
594
 
@@ -631,14 +581,14 @@ function bp_the_avatar_thumbnail() {
631
  /* DEPRECATED - use bp_loggedin_user_avatar( 'type=full' ); */
632
  function bp_loggedinuser_avatar( $width = false, $height = false ) {
633
  global $bp;
634
-
635
  echo apply_filters( 'bp_loggedinuser_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb', 'width' => $width, 'height' => $height ) ) );
636
  }
637
 
638
  /* DEPRECATED - use bp_loggedin_user_avatar( 'type=thumb' ); */
639
  function bp_loggedinuser_avatar_thumbnail( $width = false, $height = false ) {
640
  global $bp;
641
-
642
  echo apply_filters( 'bp_get_options_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->loggedin_user->id, 'type' => 'thumb', 'width' => $width, 'height' => $height ) ) );
643
  }
644
 
@@ -666,38 +616,38 @@ define( 'CORE_DEFAULT_AVATAR_THUMB', apply_filters( 'bp_core_avatar_default_thum
666
  function bp_core_avatar_admin( $message = null, $action, $delete_action) { ?>
667
  <p><?php _e('Your avatar will be used on your profile and throughout the site.', 'buddypress') ?></p>
668
  <p><?php _e( 'Click below to select a JPG, GIF or PNG format photo from your computer and then click \'Upload Photo\' to proceed.', 'buddypress' ) ?></p>
669
-
670
- <form action="" method="post" id="avatar-upload-form" enctype="multipart/form-data">
671
 
672
  <?php if ( 'upload-image' == bp_get_avatar_admin_step() ) : ?>
673
-
674
  <h3><?php _e( 'Your Current Avatar', 'buddypress' ) ?></h3>
675
 
676
  <?php bp_displayed_user_avatar( 'type=full') ?>
677
  <?php bp_displayed_user_avatar( 'type=thumb' ) ?>
678
-
679
  <p>
680
- <input type="file" name="file" id="file" />
681
  <input type="submit" name="upload" id="upload" value="<?php _e( 'Upload Image', 'buddypress' ) ?>" />
682
  <input type="hidden" name="action" id="action" value="bp_avatar_upload" />
683
  </p>
684
 
685
  <?php wp_nonce_field( 'bp_avatar_upload' ) ?>
686
-
687
  <?php endif; ?>
688
-
689
  <?php if ( 'crop-image' == bp_get_avatar_admin_step() ) : ?>
690
-
691
  <h3><?php _e( 'Crop Your New Avatar', 'buddypress' ) ?></h3>
692
-
693
  <img src="<?php bp_avatar_to_crop() ?>" id="avatar-to-crop" class="avatar" alt="<?php _e( 'Avatar to crop', 'buddypress' ) ?>" />
694
-
695
  <div id="avatar-crop-pane" style="width:100px;height:100px;overflow:hidden;">
696
  <img src="<?php bp_avatar_to_crop() ?>" id="avatar-crop-preview" class="avatar" alt="<?php _e( 'Avatar preview', 'buddypress' ) ?>" />
697
  </div>
698
 
699
  <input type="submit" name="avatar-crop-submit" id="avatar-crop-submit" value="<?php _e( 'Crop Image', 'buddypress' ) ?>" />
700
-
701
  <input type="hidden" name="image_src" id="image_src" value="<?php bp_avatar_to_crop_src() ?>" />
702
  <input type="hidden" id="x" name="x" />
703
  <input type="hidden" id="y" name="y" />
@@ -705,17 +655,17 @@ function bp_core_avatar_admin( $message = null, $action, $delete_action) { ?>
705
  <input type="hidden" id="h" name="h" />
706
 
707
  <?php wp_nonce_field( 'bp_avatar_cropstore' ) ?>
708
-
709
  <?php endif; ?>
710
-
711
  </form> <?php
712
  }
713
 
714
  function bp_core_handle_avatar_upload($file) {
715
  global $wp_upload_error;
716
-
717
  require_once( ABSPATH . '/wp-admin/includes/file.php' );
718
-
719
  // Change the upload file location to /avatars/user_id
720
  add_filter( 'upload_dir', 'xprofile_avatar_upload_dir' );
721
 
@@ -749,30 +699,30 @@ function bp_core_resize_avatar( $file, $size = false ) {
749
  /*** BEGIN DEPRECATED OLD BUDDYPRESS THEME SUPPORT ************/
750
 
751
  /***
752
- * In older versions of BuddyPress, BuddyPress templates were in a seperate theme.
753
  * The child theme setup makes upgrades and extending themes much easier, so the
754
  * old method was deprecated.
755
  */
756
 
757
  function bp_core_get_buddypress_themes() {
758
  global $wp_themes;
759
-
760
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
761
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
762
  return false;
763
-
764
  /* Remove the cached WP themes first */
765
  $wp_existing_themes = &$wp_themes;
766
  $wp_themes = null;
767
-
768
  add_filter( 'theme_root', 'bp_core_filter_buddypress_theme_root' );
769
  $themes = get_themes();
770
-
771
  if ( $themes ) {
772
  foreach ( $themes as $name => $values ) {
773
  if ( $name == 'BuddyPress Default Home Theme' )
774
  continue;
775
-
776
  $member_themes[] = array(
777
  'name' => $name,
778
  'template' => $values['Template'],
@@ -780,10 +730,10 @@ function bp_core_get_buddypress_themes() {
780
  );
781
  }
782
  }
783
-
784
  /* Restore the cached WP themes */
785
  $wp_themes = $wp_existing_themes;
786
-
787
  return $member_themes;
788
  }
789
  function bp_core_get_member_themes() { return bp_core_get_buddypress_themes(); } // DEPRECATED
@@ -806,14 +756,14 @@ function bp_core_filter_buddypress_theme_root_uri() {
806
 
807
  function bp_core_force_buddypress_theme( $template ) {
808
  global $is_member_page, $bp;
809
-
810
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
811
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
812
  return $template;
813
-
814
  if ( $is_member_page ) {
815
  $member_theme = get_site_option( 'active-member-theme' );
816
-
817
  if ( empty( $member_theme ) )
818
  $member_theme = 'bpmember';
819
 
@@ -829,13 +779,13 @@ add_filter( 'template', 'bp_core_force_buddypress_theme' );
829
 
830
  function bp_core_force_buddypress_stylesheet( $stylesheet ) {
831
  global $is_member_page;
832
-
833
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
834
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
835
  return $stylesheet;
836
 
837
  $member_theme = get_site_option( 'active-member-theme' );
838
-
839
  if ( empty( $member_theme ) )
840
  $member_theme = 'bpmember';
841
 
@@ -858,7 +808,7 @@ function bp_core_add_structure_css() {
858
  return false;
859
 
860
  /* Enqueue the structure CSS file to give basic positional formatting for components */
861
- wp_enqueue_style( 'bp-core-structure', BP_PLUGIN_URL . '/bp-core/deprecated/css/structure.css' );
862
  }
863
  add_action( 'bp_styles', 'bp_core_add_structure_css' );
864
 
@@ -867,12 +817,12 @@ function bp_core_add_css() {
867
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
868
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
869
  return false;
870
-
871
  // Enable a sitewide CSS file that will apply styles to both the home blog theme
872
  // and the member theme.
873
  if ( file_exists( WP_CONTENT_DIR . '/themes/' . get_blog_option( BP_ROOT_BLOG, 'stylesheet' ) . '/css/site-wide.css' ) )
874
  wp_enqueue_style( 'site-wide-styles', WP_CONTENT_URL . '/themes/' . get_blog_option( BP_ROOT_BLOG, 'stylesheet' ) . '/css/site-wide.css' );
875
-
876
  wp_print_styles();
877
  }
878
  add_action( 'wp_head', 'bp_core_add_css', 2 );
@@ -885,12 +835,12 @@ function bp_core_admin_bar_css() {
885
 
886
  if ( defined( 'BP_DISABLE_ADMIN_BAR') )
887
  return false;
888
-
889
  if ( is_user_logged_in() || ( !(int)get_site_option( 'hide-loggedout-adminbar' ) && !is_user_logged_in() ) ) {
890
  wp_enqueue_style( 'bp-admin-bar', apply_filters( 'bp_core_admin_bar_css', BP_PLUGIN_URL . '/bp-core/deprecated/css/admin-bar.css' ) );
891
-
892
  if ( 'rtl' == get_bloginfo('text_direction') && file_exists( BP_PLUGIN_DIR . '/bp-core/deprecated/css/admin-bar-rtl.css' ) )
893
- wp_enqueue_style( 'bp-admin-bar-rtl', BP_PLUGIN_URL . '/bp-core/deprecated/css/admin-bar-rtl.css' );
894
  }
895
  }
896
  add_action( 'wp_head', 'bp_core_admin_bar_css' );
@@ -901,7 +851,7 @@ function bp_core_add_js() {
901
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
902
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
903
  return $template;
904
-
905
  wp_enqueue_script( 'jquery' );
906
  wp_enqueue_script( 'jquery-livequery-pack', BP_PLUGIN_URL . '/bp-core/deprecated/js/jquery/jquery.livequery.pack.js', 'jquery' );
907
  wp_enqueue_script( 'bp-general-js', BP_PLUGIN_URL . '/bp-core/deprecated/js/general.js' );
@@ -913,10 +863,10 @@ function bp_core_directory_members_js() {
913
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
914
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
915
  return $template;
916
-
917
  wp_enqueue_script( 'bp-core-directory-members', BP_PLUGIN_URL . '/bp-core/deprecated/js/directory-members.js', array( 'jquery', 'jquery-livequery-pack' ) );
918
  }
919
- add_action( 'bp_core_action_directory_members', 'bp_core_directory_members_js' );
920
 
921
  /*** END DEPRECATED OLD BUDDYPRESS THEME SUPPORT ************/
922
 
@@ -924,9 +874,9 @@ function bp_core_ajax_directory_members() {
924
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
925
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
926
  return false;
927
-
928
  check_ajax_referer('directory_members');
929
-
930
  locate_template( array( 'directories/members/members-loop.php' ), true );
931
  }
932
  add_action( 'wp_ajax_directory_members', 'bp_core_ajax_directory_members' );
@@ -934,52 +884,52 @@ add_action( 'wp_ajax_directory_members', 'bp_core_ajax_directory_members' );
934
  /* DEPRECATED -- This should now be directly in the template */
935
  function bp_login_bar() {
936
  global $bp;
937
-
938
  if ( !is_user_logged_in() ) : ?>
939
-
940
  <form name="login-form" id="login-form" action="<?php echo $bp->root_domain . '/wp-login.php' ?>" method="post">
941
  <input type="text" name="log" id="user_login" value="<?php _e( 'Username', 'buddypress' ) ?>" onfocus="if (this.value == '<?php _e( 'Username', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Username', 'buddypress' ) ?>';}" />
942
  <input type="password" name="pwd" id="user_pass" class="input" value="" />
943
-
944
  <input type="checkbox" name="rememberme" id="rememberme" value="forever" title="<?php _e( 'Remember Me', 'buddypress' ) ?>" />
945
-
946
- <input type="submit" name="wp-submit" id="wp-submit" value="<?php _e( 'Log In', 'buddypress' ) ?>"/>
947
  <input type="button" name="signup-submit" id="signup-submit" value="<?php _e( 'Sign Up', 'buddypress' ) ?>" onclick="location.href='<?php echo bp_signup_page() ?>'" />
948
 
949
  <input type="hidden" name="redirect_to" value="http://<?php echo $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] ?>" />
950
  <input type="hidden" name="testcookie" value="1" />
951
-
952
  <?php do_action( 'bp_login_bar_logged_out' ) ?>
953
  </form>
954
-
955
  <?php else : ?>
956
-
957
  <div id="logout-link">
958
  <?php bp_loggedinuser_avatar_thumbnail( 20, 20 ) ?> &nbsp;
959
  <?php bp_loggedinuser_link() ?>
960
- <?php
961
  if ( function_exists('wp_logout_url') ) {
962
  $logout_link = '/ <a href="' . wp_logout_url( $bp->root_domain ) . '">' . __( 'Log Out', 'buddypress' ) . '</a>';
963
  } else {
964
- $logout_link = '/ <a href="' . $bp->root_domain . '/wp-login.php?action=logout&amp;redirect_to=' . $bp->root_domain . '">' . __( 'Log Out', 'buddypress' ) . '</a>';
965
- }
966
-
967
  echo apply_filters( 'bp_logout_link', $logout_link );
968
  ?>
969
-
970
  <?php do_action( 'bp_login_bar_logged_in' ) ?>
971
  </div>
972
-
973
  <?php endif;
974
  }
975
 
976
  /* DEPRECATED - use the param 'default_subnav_slug' in bp_core_new_nav_item() OR bp_core_new_nav_default() */
977
  function bp_core_add_nav_default( $parent_id, $function, $slug = false, $user_has_access = true, $admin_only = false ) {
978
  global $bp;
979
-
980
  if ( !$user_has_access && !bp_is_home() )
981
  return false;
982
-
983
  if ( $admin_only && !is_site_admin() )
984
  return false;
985
 
@@ -987,7 +937,7 @@ function bp_core_add_nav_default( $parent_id, $function, $slug = false, $user_ha
987
  if ( function_exists($function) ) {
988
  add_action( 'wp', $function, 3 );
989
  }
990
-
991
  if ( $slug )
992
  $bp->current_action = $slug;
993
  }
@@ -996,20 +946,20 @@ function bp_core_add_nav_default( $parent_id, $function, $slug = false, $user_ha
996
  /* DEPRECATED - use <?php locate_template( array( 'userbar.php' ), true ) ?> */
997
  function bp_get_userbar( $hide_on_directory = true ) {
998
  global $bp;
999
-
1000
  if ( $hide_on_directory && $bp->is_directory )
1001
  return false;
1002
-
1003
  load_template( TEMPLATEPATH . '/userbar.php' );
1004
  }
1005
 
1006
  /* DEPRECATED - use <?php locate_template( array( 'optionsbar.php' ), true ) ?> */
1007
  function bp_get_optionsbar( $hide_on_directory = true ) {
1008
  global $bp;
1009
-
1010
  if ( $hide_on_directory && $bp->is_directory )
1011
  return false;
1012
-
1013
  load_template( TEMPLATEPATH . '/optionsbar.php' );
1014
  }
1015
 
3
  * Deprecated Core Functionality
4
  *
5
  * This file contains functions that are deprecated.
6
+ * You should not under any circumstance use these functions as they are
7
  * either no longer valid, or have been replaced with something much more awesome.
8
  *
9
  * If you are using functions in this file you should slap the back of your head
12
  *
13
  * Of course, things will still work if you use these functions but you will
14
  * be the laughing stock of the BuddyPress community. We will all point and laugh at
15
+ * you. You'll also be making things harder for yourself in the long run,
16
  * and you will miss out on lovely performance and functionality improvements.
17
+ *
18
  * If you've checked you are not using any deprecated functions and finished your little
19
  * dance, you can add the following line to your wp-config.php file to prevent any of
20
  * these old functions from being loaded:
24
 
25
  function bp_core_deprecated_globals() {
26
  global $bp;
27
+
28
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
29
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
30
  return false;
64
 
65
  function bp_core_signup_show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) {
66
  global $current_site;
67
+
68
  ?>
69
  <h3><?php _e( 'Blog Details', 'buddypress' ) ?></h3>
70
  <p id="blog-details-help">
71
  <?php _e( "To register your first blog, just fill in the details below and your registration is complete.", 'buddypress' ) ?>
72
  </p>
73
+
74
  <div id="blog-details-fields">
75
  <?php
76
+
77
  // Blog name
78
  if ( 'no' == constant( "VHOST" ) )
79
  echo '<label for="blogname">' . __('Blog Name:', 'buddypress') . '</label>';
89
  } else {
90
  echo '<input name="blogname" type="text" id="blogname" value="'.$blogname.'" maxlength="50" /><span class="suffix_address">.' . $current_site->domain . $current_site->path . '</span><br />';
91
  }
92
+
93
  if ( !is_user_logged_in() ) {
94
  echo '<p class="help-text">';
95
  print '(<strong>' . __( 'Your address will be ', 'buddypress' );
104
 
105
  // Blog Title
106
  ?>
107
+ <label for="blog_title"><?php _e( 'Blog Title:', 'buddypress' ) ?></label>
108
  <?php if ( $errmsg = $errors->get_error_message('blog_title') ) { ?>
109
  <p class="error"><?php echo $errmsg ?></p>
110
  <?php }
113
 
114
  <p>
115
  <label for="blog_public_on"><?php _e( 'Privacy:', 'buddypress' ) ?></label>
116
+ <?php _e( 'I would like my blog to appear in search engines like Google and Technorati, and in public listings around this site.', 'buddypress' ); ?>
117
  <label class="checkbox" for="blog_public_on">
118
  <input type="radio" id="blog_public_on" name="blog_public" value="1" <?php if( !isset( $_POST['blog_public'] ) || '1' == $_POST['blog_public'] ) { ?>checked="checked"<?php } ?> />
119
  &nbsp;<?php _e( 'Yes', 'buddypress' ); ?>
152
  <label for="user_email"><?php _e( 'Email&nbsp;Address:', 'buddypress' ) ?></label>
153
  <?php if ( $errmsg = $errors->get_error_message('user_email') ) { ?>
154
  <p class="error"><?php echo $errmsg ?></p>
155
+ <?php } ?>
156
  <input name="user_email" type="text" id="user_email" value="<?php echo wp_specialchars($user_email, 1) ?>" maxlength="200" /><p class="help-text"><?php _e( '(We&#8217;ll send your password to this address, so <strong>triple-check it</strong>.)', 'buddypress' ) ?></p>
157
  <?php
158
  if ( $errmsg = $errors->get_error_message('generic') ) {
159
  echo '<p class="error">'.$errmsg.'</p>';
160
  }
161
  echo '</div>';
162
+
163
  echo '<div id="extra-fields">';
164
  do_action( 'signup_extra_fields', $errors );
165
  echo '</div>';
171
 
172
  function bp_core_signup_signup_another_blog($blogname = '', $blog_title = '', $errors = '') {
173
  global $current_user, $current_site;
174
+
175
  if ( ! is_wp_error($errors) ) {
176
  $errors = new WP_Error();
177
  }
185
  ?>
186
  <h3><?php _e( "You're already registered!", 'buddypress' )?></h3>
187
  <p><?php _e( 'You can still create another blog however. Fill in the form below to add another blog to your account.', 'buddypress' ) ?>
188
+
189
 
190
  <p><?php _e( "There is no limit to the number of blogs you can have, so create to your heart's content, but blog responsibly. If you&#8217;re not going to use a great blog domain, leave it for a new user. Now have at it!", 'buddypress' ) ?></p>
191
+
192
  <form id="setupform" method="post" action="<?php echo site_url(BP_REGISTER_SLUG) ?>">
193
  <input type="hidden" name="stage" value="gimmeanotherblog" />
194
  <?php do_action( "signup_hidden_fields" ); ?>
253
  $errors = $filtered_results['errors'];
254
 
255
  ?>
256
+
257
  <form id="setupform" method="post" action="<?php echo site_url(BP_REGISTER_SLUG) ?>">
258
  <p id="intro-text"><?php _e( 'Registering for a new account is easy, just fill in the form below and you\'ll be a new member in no time at all.', 'buddypress' ) ?></p>
259
  <input type="hidden" name="stage" value="validate-user-signup" />
260
  <?php do_action( "signup_hidden_fields" ); ?>
261
+
262
  <?php bp_core_signup_show_user_form($user_name, $user_email, $errors); ?>
263
+
264
  <?php if( 'blog' == $active_signup ) { ?>
265
  <input id="signupblog" type="hidden" name="signup_for" value="blog" />
266
  <?php } elseif( 'user' == $active_signup ) { ?>
269
  <div id="blog-or-username">
270
  <h3><?php _e( 'Create a Blog?', 'buddypress' ) ?></h3>
271
  <p id="blog-help-text"><?php _e( 'If you want to create your first blog, select the option below and you\'ll be asked for a few more details.', 'buddypress' ) ?></p>
272
+
273
  <div id="blog-or-username-fields">
274
  <p>
275
  <input id="signupblog" type="radio" name="signup_for" value="blog" <?php echo $signup['blog'] ?> />
276
+ <label class="checkbox" for="signupblog"><?php _e( 'Gimme a blog!', 'buddypress' ) ?></label>
277
  </p>
278
+
279
  <p>
280
+ <input id="signupuser" type="radio" name="signup_for" value="user" <?php echo $signup['user'] ?> />
281
  <label class="checkbox" for="signupuser"><?php _e( 'Just a username, please.', 'buddypress' ) ?></label>
282
  </p>
283
  </div>
377
  function bp_core_signup_confirm_blog_signup($domain, $path, $blog_title, $user_name = '', $user_email = '', $meta) {
378
  ?>
379
  <h3><?php _e('Congratulations, You are now registered!', 'buddypress' ) ?></h3>
380
+
381
  <p><?php printf( __('But, before you can start using your blog, <strong>you must activate it</strong>. Check your inbox at <strong>%s</strong> and click the link given. It should arrive within 30 minutes.', 'buddypress' ), $user_email) ?></p>
382
  <p>&nbsp;</p>
383
+
384
  <h3><?php _e( 'Still waiting for your email?', 'buddypress' ); ?></h3>
385
  <p>
386
  <?php _e( "If you haven't received your email yet, there are a number of things you can do:", 'buddypress' ) ?>
464
 
465
  function bp_core_activation_set_headers() {
466
  global $wp_object_cache;
467
+
468
  define( "WP_INSTALLING", true );
469
+
470
  require_once( ABSPATH . WPINC . '/registration.php');
471
+
472
  if( is_object( $wp_object_cache ) )
473
  $wp_object_cache->cache_enabled = false;
474
+
475
  do_action("activate_header");
476
  }
477
 
478
  function bp_core_activation_do_activation() {
479
  global $current_site, $blog_id, $user_id; ?>
480
+
481
  <?php if ( empty( $_GET['key'] ) && empty( $_POST['key'] ) ) { ?>
482
 
483
  <h3><?php _e( 'Activation Key Required', 'buddypress' ) ?></h3>
484
+
485
  <p id="intro-text"><?php _e( 'This is the key contained in the email you were sent after registering for this site.', 'buddypress' ) ?></p>
486
+
487
  <div class="field-box">
488
  <form name="activateform" id="activateform" method="post" action="<?php echo 'http://' . $current_site->domain . $current_site->path ?>wp-activate.php">
489
  <p>
495
  </p>
496
  </form>
497
  </div>
498
+
499
  <?php } else {
500
 
501
  $key = !empty($_GET['key']) ? $_GET['key'] : $_POST['key'];
502
  $result = wpmu_activate_signup($key);
503
+
504
  if ( is_wp_error($result) ) {
505
  if ( 'already_active' == $result->get_error_code() || 'blog_taken' == $result->get_error_code() ) {
506
  $signup = $result->get_error_data();
507
  ?>
508
+
509
  <h3><?php _e('Your account is now active!', 'buddypress' ); ?></h3>
510
+
511
  <?php
512
  _e( 'Your account has already been activated. You can now log in with the account details that were emailed to you.' );
513
+
514
  } else {
515
  ?>
516
  <h2><?php _e('An error occurred during the activation', 'buddypress' ); ?></h2>
521
  extract($result);
522
 
523
  $user = new WP_User( (int) $user_id);
524
+
525
  ?>
526
+
527
  <h3><?php _e('Your account is now active!', 'buddypress' ); ?></h3>
528
+
529
  <p class="view"><?php printf( __( 'Your account is now activated. <a href="%1$s">Login</a> or go back to the <a href="%2$s">homepage</a>.', 'buddypress' ), site_url( 'wp-login.php?redirect_to=' . site_url() ), site_url() ); ?></p>
530
+
531
  <div class="field-box" id="signup-welcome">
532
  <p><span class="label"><?php _e( 'Username:', 'buddypress' ); ?></span> <?php echo $user->user_login ?></p>
533
  <p><span class="label"><?php _e( 'Password:', 'buddypress' ); ?></span> <?php echo $password; ?></p>
534
  </div>
535
+
536
+ <?php
537
  do_action( 'bp_activation_extras', $user_id, $meta );
538
  }
539
  }
540
  }
541
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
542
  /*** END DEPRECATED SIGNUP FUNCTIONS **********/
543
 
544
 
581
  /* DEPRECATED - use bp_loggedin_user_avatar( 'type=full' ); */
582
  function bp_loggedinuser_avatar( $width = false, $height = false ) {
583
  global $bp;
584
+
585
  echo apply_filters( 'bp_loggedinuser_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb', 'width' => $width, 'height' => $height ) ) );
586
  }
587
 
588
  /* DEPRECATED - use bp_loggedin_user_avatar( 'type=thumb' ); */
589
  function bp_loggedinuser_avatar_thumbnail( $width = false, $height = false ) {
590
  global $bp;
591
+
592
  echo apply_filters( 'bp_get_options_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->loggedin_user->id, 'type' => 'thumb', 'width' => $width, 'height' => $height ) ) );
593
  }
594
 
616
  function bp_core_avatar_admin( $message = null, $action, $delete_action) { ?>
617
  <p><?php _e('Your avatar will be used on your profile and throughout the site.', 'buddypress') ?></p>
618
  <p><?php _e( 'Click below to select a JPG, GIF or PNG format photo from your computer and then click \'Upload Photo\' to proceed.', 'buddypress' ) ?></p>
619
+
620
+ <form action="" method="post" id="avatar-upload-form" enctype="multipart/form-data">
621
 
622
  <?php if ( 'upload-image' == bp_get_avatar_admin_step() ) : ?>
623
+
624
  <h3><?php _e( 'Your Current Avatar', 'buddypress' ) ?></h3>
625
 
626
  <?php bp_displayed_user_avatar( 'type=full') ?>
627
  <?php bp_displayed_user_avatar( 'type=thumb' ) ?>
628
+
629
  <p>
630
+ <input type="file" name="file" id="file" />
631
  <input type="submit" name="upload" id="upload" value="<?php _e( 'Upload Image', 'buddypress' ) ?>" />
632
  <input type="hidden" name="action" id="action" value="bp_avatar_upload" />
633
  </p>
634
 
635
  <?php wp_nonce_field( 'bp_avatar_upload' ) ?>
636
+
637
  <?php endif; ?>
638
+
639
  <?php if ( 'crop-image' == bp_get_avatar_admin_step() ) : ?>
640
+
641
  <h3><?php _e( 'Crop Your New Avatar', 'buddypress' ) ?></h3>
642
+
643
  <img src="<?php bp_avatar_to_crop() ?>" id="avatar-to-crop" class="avatar" alt="<?php _e( 'Avatar to crop', 'buddypress' ) ?>" />
644
+
645
  <div id="avatar-crop-pane" style="width:100px;height:100px;overflow:hidden;">
646
  <img src="<?php bp_avatar_to_crop() ?>" id="avatar-crop-preview" class="avatar" alt="<?php _e( 'Avatar preview', 'buddypress' ) ?>" />
647
  </div>
648
 
649
  <input type="submit" name="avatar-crop-submit" id="avatar-crop-submit" value="<?php _e( 'Crop Image', 'buddypress' ) ?>" />
650
+
651
  <input type="hidden" name="image_src" id="image_src" value="<?php bp_avatar_to_crop_src() ?>" />
652
  <input type="hidden" id="x" name="x" />
653
  <input type="hidden" id="y" name="y" />
655
  <input type="hidden" id="h" name="h" />
656
 
657
  <?php wp_nonce_field( 'bp_avatar_cropstore' ) ?>
658
+
659
  <?php endif; ?>
660
+
661
  </form> <?php
662
  }
663
 
664
  function bp_core_handle_avatar_upload($file) {
665
  global $wp_upload_error;
666
+
667
  require_once( ABSPATH . '/wp-admin/includes/file.php' );
668
+
669
  // Change the upload file location to /avatars/user_id
670
  add_filter( 'upload_dir', 'xprofile_avatar_upload_dir' );
671
 
699
  /*** BEGIN DEPRECATED OLD BUDDYPRESS THEME SUPPORT ************/
700
 
701
  /***
702
+ * In older versions of BuddyPress, BuddyPress templates were in a separate theme.
703
  * The child theme setup makes upgrades and extending themes much easier, so the
704
  * old method was deprecated.
705
  */
706
 
707
  function bp_core_get_buddypress_themes() {
708
  global $wp_themes;
709
+
710
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
711
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
712
  return false;
713
+
714
  /* Remove the cached WP themes first */
715
  $wp_existing_themes = &$wp_themes;
716
  $wp_themes = null;
717
+
718
  add_filter( 'theme_root', 'bp_core_filter_buddypress_theme_root' );
719
  $themes = get_themes();
720
+
721
  if ( $themes ) {
722
  foreach ( $themes as $name => $values ) {
723
  if ( $name == 'BuddyPress Default Home Theme' )
724
  continue;
725
+
726
  $member_themes[] = array(
727
  'name' => $name,
728
  'template' => $values['Template'],
730
  );
731
  }
732
  }
733
+
734
  /* Restore the cached WP themes */
735
  $wp_themes = $wp_existing_themes;
736
+
737
  return $member_themes;
738
  }
739
  function bp_core_get_member_themes() { return bp_core_get_buddypress_themes(); } // DEPRECATED
756
 
757
  function bp_core_force_buddypress_theme( $template ) {
758
  global $is_member_page, $bp;
759
+
760
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
761
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
762
  return $template;
763
+
764
  if ( $is_member_page ) {
765
  $member_theme = get_site_option( 'active-member-theme' );
766
+
767
  if ( empty( $member_theme ) )
768
  $member_theme = 'bpmember';
769
 
779
 
780
  function bp_core_force_buddypress_stylesheet( $stylesheet ) {
781
  global $is_member_page;
782
+
783
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
784
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
785
  return $stylesheet;
786
 
787
  $member_theme = get_site_option( 'active-member-theme' );
788
+
789
  if ( empty( $member_theme ) )
790
  $member_theme = 'bpmember';
791
 
808
  return false;
809
 
810
  /* Enqueue the structure CSS file to give basic positional formatting for components */
811
+ wp_enqueue_style( 'bp-core-structure', BP_PLUGIN_URL . '/bp-core/deprecated/css/structure.css' );
812
  }
813
  add_action( 'bp_styles', 'bp_core_add_structure_css' );
814
 
817
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
818
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
819
  return false;
820
+
821
  // Enable a sitewide CSS file that will apply styles to both the home blog theme
822
  // and the member theme.
823
  if ( file_exists( WP_CONTENT_DIR . '/themes/' . get_blog_option( BP_ROOT_BLOG, 'stylesheet' ) . '/css/site-wide.css' ) )
824
  wp_enqueue_style( 'site-wide-styles', WP_CONTENT_URL . '/themes/' . get_blog_option( BP_ROOT_BLOG, 'stylesheet' ) . '/css/site-wide.css' );
825
+
826
  wp_print_styles();
827
  }
828
  add_action( 'wp_head', 'bp_core_add_css', 2 );
835
 
836
  if ( defined( 'BP_DISABLE_ADMIN_BAR') )
837
  return false;
838
+
839
  if ( is_user_logged_in() || ( !(int)get_site_option( 'hide-loggedout-adminbar' ) && !is_user_logged_in() ) ) {
840
  wp_enqueue_style( 'bp-admin-bar', apply_filters( 'bp_core_admin_bar_css', BP_PLUGIN_URL . '/bp-core/deprecated/css/admin-bar.css' ) );
841
+
842
  if ( 'rtl' == get_bloginfo('text_direction') && file_exists( BP_PLUGIN_DIR . '/bp-core/deprecated/css/admin-bar-rtl.css' ) )
843
+ wp_enqueue_style( 'bp-admin-bar-rtl', BP_PLUGIN_URL . '/bp-core/deprecated/css/admin-bar-rtl.css' );
844
  }
845
  }
846
  add_action( 'wp_head', 'bp_core_admin_bar_css' );
851
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
852
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
853
  return $template;
854
+
855
  wp_enqueue_script( 'jquery' );
856
  wp_enqueue_script( 'jquery-livequery-pack', BP_PLUGIN_URL . '/bp-core/deprecated/js/jquery/jquery.livequery.pack.js', 'jquery' );
857
  wp_enqueue_script( 'bp-general-js', BP_PLUGIN_URL . '/bp-core/deprecated/js/general.js' );
863
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
864
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
865
  return $template;
866
+
867
  wp_enqueue_script( 'bp-core-directory-members', BP_PLUGIN_URL . '/bp-core/deprecated/js/directory-members.js', array( 'jquery', 'jquery-livequery-pack' ) );
868
  }
869
+ add_action( 'bp_core_action_directory_members', 'bp_core_directory_members_js' );
870
 
871
  /*** END DEPRECATED OLD BUDDYPRESS THEME SUPPORT ************/
872
 
874
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
875
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
876
  return false;
877
+
878
  check_ajax_referer('directory_members');
879
+
880
  locate_template( array( 'directories/members/members-loop.php' ), true );
881
  }
882
  add_action( 'wp_ajax_directory_members', 'bp_core_ajax_directory_members' );
884
  /* DEPRECATED -- This should now be directly in the template */
885
  function bp_login_bar() {
886
  global $bp;
887
+
888
  if ( !is_user_logged_in() ) : ?>
889
+
890
  <form name="login-form" id="login-form" action="<?php echo $bp->root_domain . '/wp-login.php' ?>" method="post">
891
  <input type="text" name="log" id="user_login" value="<?php _e( 'Username', 'buddypress' ) ?>" onfocus="if (this.value == '<?php _e( 'Username', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Username', 'buddypress' ) ?>';}" />
892
  <input type="password" name="pwd" id="user_pass" class="input" value="" />
893
+
894
  <input type="checkbox" name="rememberme" id="rememberme" value="forever" title="<?php _e( 'Remember Me', 'buddypress' ) ?>" />
895
+
896
+ <input type="submit" name="wp-submit" id="wp-submit" value="<?php _e( 'Log In', 'buddypress' ) ?>"/>
897
  <input type="button" name="signup-submit" id="signup-submit" value="<?php _e( 'Sign Up', 'buddypress' ) ?>" onclick="location.href='<?php echo bp_signup_page() ?>'" />
898
 
899
  <input type="hidden" name="redirect_to" value="http://<?php echo $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] ?>" />
900
  <input type="hidden" name="testcookie" value="1" />
901
+
902
  <?php do_action( 'bp_login_bar_logged_out' ) ?>
903
  </form>
904
+
905
  <?php else : ?>
906
+
907
  <div id="logout-link">
908
  <?php bp_loggedinuser_avatar_thumbnail( 20, 20 ) ?> &nbsp;
909
  <?php bp_loggedinuser_link() ?>
910
+ <?php
911
  if ( function_exists('wp_logout_url') ) {
912
  $logout_link = '/ <a href="' . wp_logout_url( $bp->root_domain ) . '">' . __( 'Log Out', 'buddypress' ) . '</a>';
913
  } else {
914
+ $logout_link = '/ <a href="' . $bp->root_domain . '/wp-login.php?action=logout&amp;redirect_to=' . $bp->root_domain . '">' . __( 'Log Out', 'buddypress' ) . '</a>';
915
+ }
916
+
917
  echo apply_filters( 'bp_logout_link', $logout_link );
918
  ?>
919
+
920
  <?php do_action( 'bp_login_bar_logged_in' ) ?>
921
  </div>
922
+
923
  <?php endif;
924
  }
925
 
926
  /* DEPRECATED - use the param 'default_subnav_slug' in bp_core_new_nav_item() OR bp_core_new_nav_default() */
927
  function bp_core_add_nav_default( $parent_id, $function, $slug = false, $user_has_access = true, $admin_only = false ) {
928
  global $bp;
929
+
930
  if ( !$user_has_access && !bp_is_home() )
931
  return false;
932
+
933
  if ( $admin_only && !is_site_admin() )
934
  return false;
935
 
937
  if ( function_exists($function) ) {
938
  add_action( 'wp', $function, 3 );
939
  }
940
+
941
  if ( $slug )
942
  $bp->current_action = $slug;
943
  }
946
  /* DEPRECATED - use <?php locate_template( array( 'userbar.php' ), true ) ?> */
947
  function bp_get_userbar( $hide_on_directory = true ) {
948
  global $bp;
949
+
950
  if ( $hide_on_directory && $bp->is_directory )
951
  return false;
952
+
953
  load_template( TEMPLATEPATH . '/userbar.php' );
954
  }
955
 
956
  /* DEPRECATED - use <?php locate_template( array( 'optionsbar.php' ), true ) ?> */
957
  function bp_get_optionsbar( $hide_on_directory = true ) {
958
  global $bp;
959
+
960
  if ( $hide_on_directory && $bp->is_directory )
961
  return false;
962
+
963
  load_template( TEMPLATEPATH . '/optionsbar.php' );
964
  }
965
 
bp-core/deprecated/css/admin-bar.css CHANGED
File without changes
bp-core/deprecated/css/structure.css CHANGED
File without changes
bp-core/deprecated/images/accept_button_side.gif CHANGED
File without changes
bp-core/deprecated/images/add_button_side.gif CHANGED
File without changes
bp-core/deprecated/images/add_friend_button.gif CHANGED
File without changes
bp-core/deprecated/images/admin-menu-arrow.gif CHANGED
File without changes
bp-core/deprecated/images/admin_bar_back.gif CHANGED
File without changes
bp-core/deprecated/images/admin_bar_logo.gif CHANGED
File without changes
bp-core/deprecated/images/ajax-loader.gif CHANGED
File without changes
bp-core/deprecated/images/blog.png CHANGED
File without changes
bp-core/deprecated/images/button_back.gif CHANGED
File without changes
bp-core/deprecated/images/check_button_side.gif CHANGED
File without changes
bp-core/deprecated/images/loading_button_side.gif CHANGED
File without changes
bp-core/deprecated/images/logout_bullet.gif CHANGED
File without changes
bp-core/deprecated/images/member.png CHANGED
File without changes
bp-core/deprecated/images/nav_bullet.gif CHANGED
File without changes
bp-core/deprecated/images/reject_button_side.gif CHANGED
File without changes
bp-core/deprecated/images/remove_button_side.gif CHANGED
File without changes
bp-core/deprecated/images/remove_friend_button.gif CHANGED
File without changes
bp-core/deprecated/images/requested_friend_button.gif CHANGED
File without changes
bp-core/deprecated/images/view_button_side.gif CHANGED
File without changes
bp-core/deprecated/js/directory-members.js CHANGED
File without changes
bp-core/deprecated/js/general.js CHANGED
File without changes
bp-core/deprecated/js/jquery/jquery.livequery.pack.js CHANGED
File without changes
bp-core/deprecated/js/jquery/jquery.tablednd.js CHANGED
File without changes
bp-core/images/Jcrop.gif CHANGED
File without changes
bp-core/images/admin_menu_icon.png CHANGED
File without changes
bp-core/images/mystery-man.jpg CHANGED
File without changes
bp-core/js/admin-bar.js CHANGED
File without changes
bp-core/js/widget-members.js CHANGED
File without changes
bp-forums.php CHANGED
@@ -3,7 +3,7 @@
3
  /* Define the parent forum ID */
4
  if ( !defined( 'BP_FORUMS_PARENT_FORUM_ID' ) )
5
  define( 'BP_FORUMS_PARENT_FORUM_ID', 1 );
6
-
7
  if ( !defined( 'BP_FORUMS_SLUG' ) )
8
  define( 'BP_FORUMS_SLUG', 'forums' );
9
 
@@ -18,11 +18,11 @@ function bp_forums_setup() {
18
 
19
  /* For internal identification */
20
  $bp->forums->id = 'forums';
21
-
22
  $bp->forums->image_base = BP_PLUGIN_URL . '/bp-forums/images';
23
  $bp->forums->bbconfig = get_site_option( 'bb-config-location' );
24
  $bp->forums->slug = BP_FORUMS_SLUG;
25
-
26
  /* Register this in the active components array */
27
  $bp->active_components[$bp->forums->slug] = $bp->forums->id;
28
 
@@ -33,10 +33,10 @@ add_action( 'admin_head', 'bp_forums_setup', 2 );
33
 
34
  function bp_forums_is_installed_correctly() {
35
  global $bp;
36
-
37
  if ( file_exists( $bp->forums->bbconfig ) )
38
  return true;
39
-
40
  return false;
41
  }
42
 
@@ -52,15 +52,15 @@ function bp_forums_directory_forums_setup() {
52
  if ( $bp->current_component == $bp->forums->slug ) {
53
  if ( (int) get_site_option( 'bp-disable-forum-directory' ) || !function_exists( 'groups_install' ) )
54
  return false;
55
-
56
  if ( !bp_forums_is_installed_correctly() ) {
57
  bp_core_add_message( __( 'The forums component has not been set up yet.', 'buddypress' ), 'error' );
58
  bp_core_redirect( $bp->root_domain );
59
  }
60
-
61
  $bp->is_directory = true;
62
-
63
- do_action( 'bbpress_init' );
64
  do_action( 'bp_forums_directory_forums_setup' );
65
  bp_core_load_template( apply_filters( 'bp_forums_template_directory_forums_setup', 'directories/forums/index' ) );
66
  }
@@ -69,12 +69,12 @@ add_action( 'wp', 'bp_forums_directory_forums_setup', 2 );
69
 
70
  function bp_forums_add_admin_menu() {
71
  global $bp;
72
-
73
  if ( !is_site_admin() )
74
  return false;
75
 
76
  require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-admin.php' );
77
-
78
  /* Add the administration tab under the "Site Admin" tab for site administrators */
79
  add_submenu_page( 'bp-general-settings', __( 'Forums Setup', 'buddypress' ), __( 'Forums Setup', 'buddypress' ), 'manage_options', 'bb-forums-setup', "bp_forums_bbpress_admin" );
80
  }
@@ -89,24 +89,24 @@ function bp_forums_get_forum( $forum_id ) {
89
 
90
  function bp_forums_new_forum( $args = '' ) {
91
  do_action( 'bbpress_init' );
92
-
93
- $defaults = array(
94
- 'forum_name' => '',
95
- 'forum_desc' => '',
96
- 'forum_parent_id' => BP_FORUMS_PARENT_FORUM_ID,
97
- 'forum_order' => false,
98
  'forum_is_category' => 0
99
  );
100
 
101
  $r = wp_parse_args( $args, $defaults );
102
  extract( $r, EXTR_SKIP );
103
-
104
  return bb_new_forum( array( 'forum_name' => stripslashes( $forum_name ), 'forum_desc' => stripslashes( $forum_desc ), 'forum_parent' => $forum_parent_id, 'forum_order' => $forum_order, 'forum_is_category' => $forum_is_category ) );
105
  }
106
 
107
  function bp_forums_get_forum_topicpost_count( $forum_id ) {
108
  global $wpdb, $bbdb;
109
-
110
  do_action( 'bbpress_init' );
111
 
112
  /* Need to find a bbPress function that does this */
@@ -117,19 +117,19 @@ function bp_forums_get_forum_topicpost_count( $forum_id ) {
117
 
118
  function bp_forums_get_forum_topics( $args = '' ) {
119
  global $bp;
120
-
121
  do_action( 'bbpress_init' );
122
-
123
  $defaults = array(
124
  'type' => 'newest',
125
- 'forum_id' => false,
126
- 'page' => 1,
127
- 'per_page' => 15,
128
  'exclude' => false,
129
  'show_stickies' => 'all',
130
  'filter' => false // if $type = tag then filter is the tag name, otherwise it's terms to search on.
131
  );
132
-
133
  $r = wp_parse_args( $args, $defaults );
134
  extract( $r, EXTR_SKIP );
135
 
@@ -138,22 +138,22 @@ function bp_forums_get_forum_topics( $args = '' ) {
138
  $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'per_page' => $per_page, 'page' => $page, 'number' => $per_page, 'exclude' => $exclude, 'topic_title' => $filter, 'sticky' => $show_stickies ), 'get_latest_topics' );
139
  $topics = $query->results;
140
  break;
141
-
142
  case 'popular':
143
  $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'per_page' => $per_page, 'page' => $page, 'order_by' => 't.topic_posts', 'topic_title' => $filter, 'sticky' => $show_stickies ) );
144
  $topics =& $query->results;
145
  break;
146
-
147
  case 'unreplied':
148
  $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'post_count' => 1, 'per_page' => $per_page, 'page' => $page, 'order_by' => 't.topic_time', 'topic_title' => $filter, 'sticky' => $show_stickies ) );
149
  $topics =& $query->results;
150
- break;
151
-
152
  case 'personal':
153
  $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'per_page' => $per_page, 'page' => $page, 'topic_author_id' => $bp->loggedin_user->id, 'order_by' => 't.topic_time', 'topic_title' => $filter, 'sticky' => $show_stickies ), 'get_recent_user_threads' );
154
  $topics =& $query->results;
155
  break;
156
-
157
  case 'tag':
158
  $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'tag' => $filter, 'per_page' => $per_page, 'page' => $page, 'order_by' => 't.topic_time', 'sticky' => $show_stickies ) );
159
  $topics =& $query->results;
@@ -166,7 +166,7 @@ function bp_forums_get_forum_topics( $args = '' ) {
166
  function bp_forums_get_topic_details( $topic_id ) {
167
  do_action( 'bbpress_init' );
168
 
169
- $query = new BB_Query( 'topic', 'topic_id=' . $topic_id . '&page=1' /* Page override so bbPress doesn't use the URI */ );
170
 
171
  return $query->results[0];
172
  }
@@ -178,9 +178,9 @@ function bp_forums_get_topic_id_from_slug( $topic_slug ) {
178
 
179
  function bp_forums_new_topic( $args = '' ) {
180
  global $bp;
181
-
182
  do_action( 'bbpress_init' );
183
-
184
  $defaults = array(
185
  'topic_title' => '',
186
  'topic_slug' => '',
@@ -197,25 +197,25 @@ function bp_forums_new_topic( $args = '' ) {
197
 
198
  $r = wp_parse_args( $args, $defaults );
199
  extract( $r, EXTR_SKIP );
200
-
201
  if ( empty( $topic_slug ) )
202
  $topic_slug = sanitize_title( $topic_title );
203
-
204
  if ( !$topic_id = bb_insert_topic( array( 'topic_title' => stripslashes( $topic_title ), 'topic_slug' => $topic_slug, 'topic_poster' => $topic_poster, 'topic_poster_name' => $topic_poster_name, 'topic_last_poster' => $topic_last_poster, 'topic_last_poster_name' => $topic_last_poster_name, 'topic_start_time' => $topic_start_time, 'topic_time' => $topic_time, 'topic_open' => $topic_open, 'forum_id' => (int)$forum_id, 'tags' => $topic_tags ) ) )
205
  return false;
206
 
207
  /* Now insert the first post. */
208
  if ( !bp_forums_insert_post( array( 'topic_id' => $topic_id, 'post_text' => $topic_text, 'post_time' => $topic_time, 'poster_id' => $topic_poster ) ) )
209
  return false;
210
-
211
  return $topic_id;
212
  }
213
 
214
  function bp_forums_update_topic( $args = '' ) {
215
  global $bp;
216
-
217
  do_action( 'bbpress_init' );
218
-
219
  $defaults = array(
220
  'topic_id' => false,
221
  'topic_title' => '',
@@ -224,25 +224,25 @@ function bp_forums_update_topic( $args = '' ) {
224
 
225
  $r = wp_parse_args( $args, $defaults );
226
  extract( $r, EXTR_SKIP );
227
-
228
  if ( !$topic_id = bb_insert_topic( array( 'topic_id' => $topic_id, 'topic_title' => stripslashes( $topic_title ) ) ) )
229
  return false;
230
-
231
  if ( !$post = bb_get_first_post( $topic_id ) )
232
  return false;
233
 
234
  /* Update the first post */
235
  if ( !$post = bb_insert_post( array( 'post_id' => $post->post_id, 'topic_id' => $topic_id, 'post_text' => $topic_text, 'post_time' => $post->post_time, 'poster_id' => $post->poster_id, 'poster_ip' => $post->poster_ip, 'post_status' => $post->post_status, 'post_position' => $post->post_position ) ) )
236
  return false;
237
-
238
  return bp_forums_get_topic_details( $topic_id );
239
  }
240
 
241
  function bp_forums_sticky_topic( $args = '' ) {
242
  global $bp;
243
-
244
  do_action( 'bbpress_init' );
245
-
246
  $defaults = array(
247
  'topic_id' => false,
248
  'mode' => 'stick' // stick/unstick
@@ -250,7 +250,7 @@ function bp_forums_sticky_topic( $args = '' ) {
250
 
251
  $r = wp_parse_args( $args, $defaults );
252
  extract( $r, EXTR_SKIP );
253
-
254
  if ( 'stick' == $mode )
255
  return bb_stick_topic( $topic_id );
256
  else if ( 'unstick' == $mode )
@@ -261,9 +261,9 @@ function bp_forums_sticky_topic( $args = '' ) {
261
 
262
  function bp_forums_openclose_topic( $args = '' ) {
263
  global $bp;
264
-
265
  do_action( 'bbpress_init' );
266
-
267
  $defaults = array(
268
  'topic_id' => false,
269
  'mode' => 'close' // stick/unstick
@@ -271,7 +271,7 @@ function bp_forums_openclose_topic( $args = '' ) {
271
 
272
  $r = wp_parse_args( $args, $defaults );
273
  extract( $r, EXTR_SKIP );
274
-
275
  if ( 'close' == $mode )
276
  return bb_close_topic( $topic_id );
277
  else if ( 'open' == $mode )
@@ -282,9 +282,9 @@ function bp_forums_openclose_topic( $args = '' ) {
282
 
283
  function bp_forums_delete_topic( $args = '' ) {
284
  global $bp;
285
-
286
  do_action( 'bbpress_init' );
287
-
288
  $defaults = array(
289
  'topic_id' => false
290
  );
@@ -295,13 +295,13 @@ function bp_forums_delete_topic( $args = '' ) {
295
  return bb_delete_topic( $topic_id, 1 );
296
  }
297
 
298
- /* Post Functions */
299
 
300
  function bp_forums_get_topic_posts( $args = '' ) {
301
  do_action( 'bbpress_init' );
302
-
303
- $defaults = array(
304
- 'topic_id' => false,
305
  'page' => 1,
306
  'per_page' => 15,
307
  'order' => 'ASC'
@@ -320,9 +320,9 @@ function bp_forums_get_post( $post_id ) {
320
 
321
  function bp_forums_delete_post( $args = '' ) {
322
  global $bp;
323
-
324
  do_action( 'bbpress_init' );
325
-
326
  $defaults = array(
327
  'post_id' => false
328
  );
@@ -330,16 +330,16 @@ function bp_forums_delete_post( $args = '' ) {
330
  $r = wp_parse_args( $args, $defaults );
331
  extract( $r, EXTR_SKIP );
332
 
333
- return bb_delete_post( $post_id, 1 );
334
  }
335
 
336
  function bp_forums_insert_post( $args = '' ) {
337
  global $bp;
338
-
339
  do_action( 'bbpress_init' );
340
 
341
  $defaults = array(
342
- 'post_id' => false,
343
  'topic_id' => false,
344
  'post_text' => '',
345
  'post_time' => date( 'Y-m-d H:i:s' ),
@@ -351,16 +351,16 @@ function bp_forums_insert_post( $args = '' ) {
351
 
352
  $r = wp_parse_args( $args, $defaults );
353
  extract( $r, EXTR_SKIP );
354
-
355
  if ( !$post = bp_forums_get_post( $post_id ) )
356
  $post_id = false;
357
 
358
  if ( !isset( $topic_id ) )
359
  $topic_id = $post->topic_id;
360
-
361
  if ( empty( $post_text ) )
362
  $post_text = $post->post_text;
363
-
364
  if ( !isset( $post_time ) )
365
  $post_time = $post->post_time;
366
 
@@ -377,16 +377,16 @@ add_action( 'bp_forums_new_post', 'bp_core_clear_cache' );
377
 
378
  function bp_forums_filter_caps( $allcaps ) {
379
  global $bp, $wp_roles, $bb_table_prefix;
380
-
381
  $bb_cap = get_usermeta( $bp->loggedin_user->id, $bb_table_prefix . 'capabilities' );
382
 
383
  if ( empty( $bb_cap ) )
384
  return $allcaps;
385
-
386
  $bb_cap = array_keys($bb_cap);
387
  $bb_cap = $wp_roles->get_role( $bb_cap[0] );
388
  $bb_cap = $bb_cap->capabilities;
389
-
390
  return array_merge( (array) $allcaps, (array) $bb_cap );
391
  }
392
  add_filter( 'user_has_cap', 'bp_forums_filter_caps' );
3
  /* Define the parent forum ID */
4
  if ( !defined( 'BP_FORUMS_PARENT_FORUM_ID' ) )
5
  define( 'BP_FORUMS_PARENT_FORUM_ID', 1 );
6
+
7
  if ( !defined( 'BP_FORUMS_SLUG' ) )
8
  define( 'BP_FORUMS_SLUG', 'forums' );
9
 
18
 
19
  /* For internal identification */
20
  $bp->forums->id = 'forums';
21
+
22
  $bp->forums->image_base = BP_PLUGIN_URL . '/bp-forums/images';
23
  $bp->forums->bbconfig = get_site_option( 'bb-config-location' );
24
  $bp->forums->slug = BP_FORUMS_SLUG;
25
+
26
  /* Register this in the active components array */
27
  $bp->active_components[$bp->forums->slug] = $bp->forums->id;
28
 
33
 
34
  function bp_forums_is_installed_correctly() {
35
  global $bp;
36
+
37
  if ( file_exists( $bp->forums->bbconfig ) )
38
  return true;
39
+
40
  return false;
41
  }
42
 
52
  if ( $bp->current_component == $bp->forums->slug ) {
53
  if ( (int) get_site_option( 'bp-disable-forum-directory' ) || !function_exists( 'groups_install' ) )
54
  return false;
55
+
56
  if ( !bp_forums_is_installed_correctly() ) {
57
  bp_core_add_message( __( 'The forums component has not been set up yet.', 'buddypress' ), 'error' );
58
  bp_core_redirect( $bp->root_domain );
59
  }
60
+
61
  $bp->is_directory = true;
62
+
63
+ do_action( 'bbpress_init' );
64
  do_action( 'bp_forums_directory_forums_setup' );
65
  bp_core_load_template( apply_filters( 'bp_forums_template_directory_forums_setup', 'directories/forums/index' ) );
66
  }
69
 
70
  function bp_forums_add_admin_menu() {
71
  global $bp;
72
+
73
  if ( !is_site_admin() )
74
  return false;
75
 
76
  require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-admin.php' );
77
+
78
  /* Add the administration tab under the "Site Admin" tab for site administrators */
79
  add_submenu_page( 'bp-general-settings', __( 'Forums Setup', 'buddypress' ), __( 'Forums Setup', 'buddypress' ), 'manage_options', 'bb-forums-setup', "bp_forums_bbpress_admin" );
80
  }
89
 
90
  function bp_forums_new_forum( $args = '' ) {
91
  do_action( 'bbpress_init' );
92
+
93
+ $defaults = array(
94
+ 'forum_name' => '',
95
+ 'forum_desc' => '',
96
+ 'forum_parent_id' => BP_FORUMS_PARENT_FORUM_ID,
97
+ 'forum_order' => false,
98
  'forum_is_category' => 0
99
  );
100
 
101
  $r = wp_parse_args( $args, $defaults );
102
  extract( $r, EXTR_SKIP );
103
+
104
  return bb_new_forum( array( 'forum_name' => stripslashes( $forum_name ), 'forum_desc' => stripslashes( $forum_desc ), 'forum_parent' => $forum_parent_id, 'forum_order' => $forum_order, 'forum_is_category' => $forum_is_category ) );
105
  }
106
 
107
  function bp_forums_get_forum_topicpost_count( $forum_id ) {
108
  global $wpdb, $bbdb;
109
+
110
  do_action( 'bbpress_init' );
111
 
112
  /* Need to find a bbPress function that does this */
117
 
118
  function bp_forums_get_forum_topics( $args = '' ) {
119
  global $bp;
120
+
121
  do_action( 'bbpress_init' );
122
+
123
  $defaults = array(
124
  'type' => 'newest',
125
+ 'forum_id' => false,
126
+ 'page' => 1,
127
+ 'per_page' => 15,
128
  'exclude' => false,
129
  'show_stickies' => 'all',
130
  'filter' => false // if $type = tag then filter is the tag name, otherwise it's terms to search on.
131
  );
132
+
133
  $r = wp_parse_args( $args, $defaults );
134
  extract( $r, EXTR_SKIP );
135
 
138
  $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'per_page' => $per_page, 'page' => $page, 'number' => $per_page, 'exclude' => $exclude, 'topic_title' => $filter, 'sticky' => $show_stickies ), 'get_latest_topics' );
139
  $topics = $query->results;
140
  break;
141
+
142
  case 'popular':
143
  $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'per_page' => $per_page, 'page' => $page, 'order_by' => 't.topic_posts', 'topic_title' => $filter, 'sticky' => $show_stickies ) );
144
  $topics =& $query->results;
145
  break;
146
+
147
  case 'unreplied':
148
  $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'post_count' => 1, 'per_page' => $per_page, 'page' => $page, 'order_by' => 't.topic_time', 'topic_title' => $filter, 'sticky' => $show_stickies ) );
149
  $topics =& $query->results;
150
+ break;
151
+
152
  case 'personal':
153
  $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'per_page' => $per_page, 'page' => $page, 'topic_author_id' => $bp->loggedin_user->id, 'order_by' => 't.topic_time', 'topic_title' => $filter, 'sticky' => $show_stickies ), 'get_recent_user_threads' );
154
  $topics =& $query->results;
155
  break;
156
+
157
  case 'tag':
158
  $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'tag' => $filter, 'per_page' => $per_page, 'page' => $page, 'order_by' => 't.topic_time', 'sticky' => $show_stickies ) );
159
  $topics =& $query->results;
166
  function bp_forums_get_topic_details( $topic_id ) {
167
  do_action( 'bbpress_init' );
168
 
169
+ $query = new BB_Query( 'topic', 'topic_id=' . $topic_id . '&page=1' /* Page override so bbPress doesn't use the URI */ );
170
 
171
  return $query->results[0];
172
  }
178
 
179
  function bp_forums_new_topic( $args = '' ) {
180
  global $bp;
181
+
182
  do_action( 'bbpress_init' );
183
+
184
  $defaults = array(
185
  'topic_title' => '',
186
  'topic_slug' => '',
197
 
198
  $r = wp_parse_args( $args, $defaults );
199
  extract( $r, EXTR_SKIP );
200
+
201
  if ( empty( $topic_slug ) )
202
  $topic_slug = sanitize_title( $topic_title );
203
+
204
  if ( !$topic_id = bb_insert_topic( array( 'topic_title' => stripslashes( $topic_title ), 'topic_slug' => $topic_slug, 'topic_poster' => $topic_poster, 'topic_poster_name' => $topic_poster_name, 'topic_last_poster' => $topic_last_poster, 'topic_last_poster_name' => $topic_last_poster_name, 'topic_start_time' => $topic_start_time, 'topic_time' => $topic_time, 'topic_open' => $topic_open, 'forum_id' => (int)$forum_id, 'tags' => $topic_tags ) ) )
205
  return false;
206
 
207
  /* Now insert the first post. */
208
  if ( !bp_forums_insert_post( array( 'topic_id' => $topic_id, 'post_text' => $topic_text, 'post_time' => $topic_time, 'poster_id' => $topic_poster ) ) )
209
  return false;
210
+
211
  return $topic_id;
212
  }
213
 
214
  function bp_forums_update_topic( $args = '' ) {
215
  global $bp;
216
+
217
  do_action( 'bbpress_init' );
218
+
219
  $defaults = array(
220
  'topic_id' => false,
221
  'topic_title' => '',
224
 
225
  $r = wp_parse_args( $args, $defaults );
226
  extract( $r, EXTR_SKIP );
227
+
228
  if ( !$topic_id = bb_insert_topic( array( 'topic_id' => $topic_id, 'topic_title' => stripslashes( $topic_title ) ) ) )
229
  return false;
230
+
231
  if ( !$post = bb_get_first_post( $topic_id ) )
232
  return false;
233
 
234
  /* Update the first post */
235
  if ( !$post = bb_insert_post( array( 'post_id' => $post->post_id, 'topic_id' => $topic_id, 'post_text' => $topic_text, 'post_time' => $post->post_time, 'poster_id' => $post->poster_id, 'poster_ip' => $post->poster_ip, 'post_status' => $post->post_status, 'post_position' => $post->post_position ) ) )
236
  return false;
237
+
238
  return bp_forums_get_topic_details( $topic_id );
239
  }
240
 
241
  function bp_forums_sticky_topic( $args = '' ) {
242
  global $bp;
243
+
244
  do_action( 'bbpress_init' );
245
+
246
  $defaults = array(
247
  'topic_id' => false,
248
  'mode' => 'stick' // stick/unstick
250
 
251
  $r = wp_parse_args( $args, $defaults );
252
  extract( $r, EXTR_SKIP );
253
+
254
  if ( 'stick' == $mode )
255
  return bb_stick_topic( $topic_id );
256
  else if ( 'unstick' == $mode )
261
 
262
  function bp_forums_openclose_topic( $args = '' ) {
263
  global $bp;
264
+
265
  do_action( 'bbpress_init' );
266
+
267
  $defaults = array(
268
  'topic_id' => false,
269
  'mode' => 'close' // stick/unstick
271
 
272
  $r = wp_parse_args( $args, $defaults );
273
  extract( $r, EXTR_SKIP );
274
+
275
  if ( 'close' == $mode )
276
  return bb_close_topic( $topic_id );
277
  else if ( 'open' == $mode )
282
 
283
  function bp_forums_delete_topic( $args = '' ) {
284
  global $bp;
285
+
286
  do_action( 'bbpress_init' );
287
+
288
  $defaults = array(
289
  'topic_id' => false
290
  );
295
  return bb_delete_topic( $topic_id, 1 );
296
  }
297
 
298
+ /* Post Functions */
299
 
300
  function bp_forums_get_topic_posts( $args = '' ) {
301
  do_action( 'bbpress_init' );
302
+
303
+ $defaults = array(
304
+ 'topic_id' => false,
305
  'page' => 1,
306
  'per_page' => 15,
307
  'order' => 'ASC'
320
 
321
  function bp_forums_delete_post( $args = '' ) {
322
  global $bp;
323
+
324
  do_action( 'bbpress_init' );
325
+
326
  $defaults = array(
327
  'post_id' => false
328
  );
330
  $r = wp_parse_args( $args, $defaults );
331
  extract( $r, EXTR_SKIP );
332
 
333
+ return bb_delete_post( $post_id, 1 );
334
  }
335
 
336
  function bp_forums_insert_post( $args = '' ) {
337
  global $bp;
338
+
339
  do_action( 'bbpress_init' );
340
 
341
  $defaults = array(
342
+ 'post_id' => false,
343
  'topic_id' => false,
344
  'post_text' => '',
345
  'post_time' => date( 'Y-m-d H:i:s' ),
351
 
352
  $r = wp_parse_args( $args, $defaults );
353
  extract( $r, EXTR_SKIP );
354
+
355
  if ( !$post = bp_forums_get_post( $post_id ) )
356
  $post_id = false;
357
 
358
  if ( !isset( $topic_id ) )
359
  $topic_id = $post->topic_id;
360
+
361
  if ( empty( $post_text ) )
362
  $post_text = $post->post_text;
363
+
364
  if ( !isset( $post_time ) )
365
  $post_time = $post->post_time;
366
 
377
 
378
  function bp_forums_filter_caps( $allcaps ) {
379
  global $bp, $wp_roles, $bb_table_prefix;
380
+
381
  $bb_cap = get_usermeta( $bp->loggedin_user->id, $bb_table_prefix . 'capabilities' );
382
 
383
  if ( empty( $bb_cap ) )
384
  return $allcaps;
385
+
386
  $bb_cap = array_keys($bb_cap);
387
  $bb_cap = $wp_roles->get_role( $bb_cap[0] );
388
  $bb_cap = $bb_cap->capabilities;
389
+
390
  return array_merge( (array) $allcaps, (array) $bb_cap );
391
  }
392
  add_filter( 'user_has_cap', 'bp_forums_filter_caps' );
bp-forums/bb-config.php CHANGED
File without changes
bp-forums/bbpress/bb-admin/admin-base.php CHANGED
@@ -10,11 +10,7 @@ bb_get_admin_header();
10
 
11
  <?php if ( is_callable($bb_admin_page) ) : call_user_func( $bb_admin_page ); else : ?>
12
 
13
- <h2><?php _e( 'Page not found' ); ?></h2>
14
- <?php
15
- bb_admin_notice( __( 'There is no administration page at the requested address. Please check the address you entered and try again.' ), 'error' );
16
- do_action( 'bb_admin_notices' );
17
- ?>
18
 
19
  <?php endif; ?>
20
 
10
 
11
  <?php if ( is_callable($bb_admin_page) ) : call_user_func( $bb_admin_page ); else : ?>
12
 
13
+ <p><?php _e('Nothing to see here.'); ?><p>
 
 
 
 
14
 
15
  <?php endif; ?>
16
 
bp-forums/bbpress/bb-admin/admin.php CHANGED
@@ -16,10 +16,8 @@ require_once( BB_PATH . 'bb-admin/includes/functions.bb-admin.php' );
16
 
17
  $bb_admin_page = bb_find_filename( $_SERVER['PHP_SELF'] );
18
 
19
- $_check_callback = false;
20
  if ( $bb_admin_page == 'admin-base.php' ) {
21
- $bb_admin_page = (string) @$_GET['plugin'];
22
- $_check_callback = true;
23
  }
24
 
25
  wp_enqueue_script( 'common' );
@@ -36,10 +34,4 @@ if ( isset( $_GET['foldmenu'] ) ) {
36
  }
37
  bb_admin_menu_generator();
38
  bb_get_current_admin_menu();
39
-
40
- if ( $_check_callback ) {
41
- if ( empty( $bb_registered_plugin_callbacks ) || empty( $bb_admin_page ) || !in_array( $bb_admin_page, $bb_registered_plugin_callbacks ) ) {
42
- unset( $bb_admin_page );
43
- }
44
- }
45
  ?>
16
 
17
  $bb_admin_page = bb_find_filename( $_SERVER['PHP_SELF'] );
18
 
 
19
  if ( $bb_admin_page == 'admin-base.php' ) {
20
+ $bb_admin_page = $_GET['plugin'];
 
21
  }
22
 
23
  wp_enqueue_script( 'common' );
34
  }
35
  bb_admin_menu_generator();
36
  bb_get_current_admin_menu();
 
 
 
 
 
 
37
  ?>
bp-forums/bbpress/bb-admin/includes/class.bb-install.php CHANGED
@@ -309,9 +309,6 @@ class BB_Install
309
  function get_languages()
310
  {
311
  foreach ( bb_glob( BB_LANG_DIR . '*.mo' ) as $language ) {
312
- if ( substr( $language, 0, 18 ) === 'continents-cities-' ) {
313
- continue;
314
- }
315
  $language = str_replace( '.mo', '', basename( $language ) );
316
  $this->languages[$language] = $language;
317
  }
309
  function get_languages()
310
  {
311
  foreach ( bb_glob( BB_LANG_DIR . '*.mo' ) as $language ) {
 
 
 
312
  $language = str_replace( '.mo', '', basename( $language ) );
313
  $this->languages[$language] = $language;
314
  }
bp-forums/bbpress/bb-admin/includes/defaults.bb-schema.php CHANGED
@@ -113,37 +113,33 @@ $bb_queries['topics'] = "CREATE TABLE IF NOT EXISTS `$bbdb->topics` (
113
  KEY `stickies` (`topic_status`, `topic_sticky`, `topic_time`)
114
  );";
115
 
116
- if ( bb_get_option( 'wp_table_prefix' ) || ( defined( 'BB_SCHEMA_IGNORE_WP_USERS_TABLES' ) && BB_SCHEMA_IGNORE_WP_USERS_TABLES ) ) {
117
- // Don't add user tables
118
- } else {
119
- // users - 'user_login', 'user_nicename' and 'user_registered' indices are inconsistent with WordPress
120
- $bb_queries['users'] = "CREATE TABLE IF NOT EXISTS `$bbdb->users` (
121
- `ID` bigint(20) unsigned NOT NULL auto_increment,
122
- `user_login` varchar(60) NOT NULL default '',
123
- `user_pass` varchar(64) NOT NULL default '',
124
- `user_nicename` varchar(50) NOT NULL default '',
125
- `user_email` varchar(100) NOT NULL default '',
126
- `user_url` varchar(100) NOT NULL default '',
127
- `user_registered` datetime NOT NULL default '0000-00-00 00:00:00',
128
- `user_status` int(11) NOT NULL default 0,
129
- `display_name` varchar(250) NOT NULL default '',
130
- PRIMARY KEY (`ID`),
131
- UNIQUE KEY `user_login` (`user_login`),
132
- UNIQUE KEY `user_nicename` (`user_nicename`),
133
- KEY `user_registered` (`user_registered`)
134
- );";
135
-
136
- // usermeta
137
- $bb_queries['usermeta'] = "CREATE TABLE IF NOT EXISTS `$bbdb->usermeta` (
138
- `umeta_id` bigint(20) NOT NULL auto_increment,
139
- `user_id` bigint(20) NOT NULL default 0,
140
- `meta_key` varchar(255),
141
- `meta_value` longtext,
142
- PRIMARY KEY (`umeta_id`),
143
- KEY `user_id` (`user_id`),
144
- KEY `meta_key` (`meta_key`)
145
- );";
146
- }
147
 
148
  $bb_queries = apply_filters( 'bb_schema_pre_charset', $bb_queries );
149
 
@@ -216,18 +212,6 @@ if ( bb_get_option('wp_table_prefix') || ( defined( 'BB_SCHEMA_IGNORE_WP_USERS_K
216
  $bb_schema_ignore = false;
217
  }
218
 
219
- if ( bb_get_option('wp_table_prefix') || ( defined( 'BB_SCHEMA_IGNORE_WP_USERS_TABLES' ) && BB_SCHEMA_IGNORE_WP_USERS_TABLES ) ) {
220
- if ( $bb_schema_ignore ) {
221
- $bb_schema_ignore['tables'] = array( $bbdb->users, $bbdb->usermeta );
222
- } else {
223
- $bb_schema_ignore = array(
224
- 'tables' => array( $bbdb->users, $bbdb->usermeta ),
225
- 'columns' => array(),
226
- 'indices' => array()
227
- );
228
- }
229
- }
230
-
231
  $bb_schema_ignore = apply_filters( 'bb_schema_ignore', $bb_schema_ignore );
232
 
233
  do_action( 'bb_schema_defined' );
113
  KEY `stickies` (`topic_status`, `topic_sticky`, `topic_time`)
114
  );";
115
 
116
+ // users - 'user_login', 'user_nicename' and 'user_registered' indices are inconsistent with WordPress
117
+ $bb_queries['users'] = "CREATE TABLE IF NOT EXISTS `$bbdb->users` (
118
+ `ID` bigint(20) unsigned NOT NULL auto_increment,
119
+ `user_login` varchar(60) NOT NULL default '',
120
+ `user_pass` varchar(64) NOT NULL default '',
121
+ `user_nicename` varchar(50) NOT NULL default '',
122
+ `user_email` varchar(100) NOT NULL default '',
123
+ `user_url` varchar(100) NOT NULL default '',
124
+ `user_registered` datetime NOT NULL default '0000-00-00 00:00:00',
125
+ `user_status` int(11) NOT NULL default 0,
126
+ `display_name` varchar(250) NOT NULL default '',
127
+ PRIMARY KEY (`ID`),
128
+ UNIQUE KEY `user_login` (`user_login`),
129
+ UNIQUE KEY `user_nicename` (`user_nicename`),
130
+ KEY `user_registered` (`user_registered`)
131
+ );";
132
+
133
+ // usermeta
134
+ $bb_queries['usermeta'] = "CREATE TABLE IF NOT EXISTS `$bbdb->usermeta` (
135
+ `umeta_id` bigint(20) NOT NULL auto_increment,
136
+ `user_id` bigint(20) NOT NULL default 0,
137
+ `meta_key` varchar(255),
138
+ `meta_value` longtext,
139
+ PRIMARY KEY (`umeta_id`),
140
+ KEY `user_id` (`user_id`),
141
+ KEY `meta_key` (`meta_key`)
142
+ );";
 
 
 
 
143
 
144
  $bb_queries = apply_filters( 'bb_schema_pre_charset', $bb_queries );
145
 
212
  $bb_schema_ignore = false;
213
  }
214
 
 
 
 
 
 
 
 
 
 
 
 
 
215
  $bb_schema_ignore = apply_filters( 'bb_schema_ignore', $bb_schema_ignore );
216
 
217
  do_action( 'bb_schema_defined' );
bp-forums/bbpress/bb-admin/includes/functions.bb-admin.php CHANGED
@@ -117,10 +117,6 @@ function bb_admin_menu_generator()
117
  function bb_admin_add_menu( $display_name, $capability, $file_name, $menu_position = false, $class = '', $id = '' )
118
  {
119
  global $bb_menu;
120
- global $bb_registered_plugin_callbacks;
121
- if ( empty( $bb_registered_plugin_callbacks ) ) {
122
- $bb_registered_plugin_callbacks = array();
123
- }
124
 
125
  if ( $display_name && $capability && $file_name ) {
126
  // Get an array of the keys
@@ -168,10 +164,6 @@ function bb_admin_add_menu( $display_name, $capability, $file_name, $menu_positi
168
  $plugin_menu_next++;
169
  }
170
 
171
- if ( strpos( $file_name, '.php' ) === false ) {
172
- $bb_registered_plugin_callbacks[] = $file_name;
173
- }
174
-
175
  // Add the menu item at the given key
176
  $bb_menu[$plugin_menu_next] = array( $display_name, $capability, $file_name, $class, $id );
177
 
@@ -186,15 +178,7 @@ function bb_admin_add_menu( $display_name, $capability, $file_name, $menu_positi
186
  function bb_admin_add_submenu( $display_name, $capability, $file_name, $parent = 'plugins.php' )
187
  {
188
  global $bb_submenu;
189
- global $bb_registered_plugin_callbacks;
190
- if ( empty( $bb_registered_plugin_callbacks ) ) {
191
- $bb_registered_plugin_callbacks = array();
192
- }
193
-
194
  if ( $display_name && $capability && $file_name ) {
195
- if ( strpos( $file_name, '.php' ) === false ) {
196
- $bb_registered_plugin_callbacks[] = $file_name;
197
- }
198
  $bb_submenu[$parent][] = array( $display_name, $capability, $file_name );
199
  ksort( $bb_submenu );
200
  }
@@ -413,13 +397,10 @@ function bb_get_ids_by_role( $role = 'moderator', $sort = 0, $page = 1, $limit =
413
 
414
  function bb_user_row( $user, $role = '', $email = false ) {
415
  $actions = "<a href='" . esc_attr( get_user_profile_link( $user->ID ) ) . "'>" . __('View') . "</a>";
416
- $title = '';
417
- if ( bb_current_user_can( 'edit_user', $user_id ) ) {
418
  $actions .= " | <a href='" . esc_attr( get_profile_tab_link( $user->ID, 'edit' ) ) . "'>" . __('Edit') . "</a>";
419
- $title = " title='" . esc_attr( sprintf( __( 'User ID: %d' ), $user->ID ) ) . "'";
420
- }
421
  $r = "\t<tr id='user-$user->ID'" . get_alt_class("user-$role") . ">\n";
422
- $r .= "\t\t<td class=\"user\">" . bb_get_avatar( $user->ID, 32 ) . "<span class=\"row-title\"><a href='" . get_user_profile_link( $user->ID ) . "'" . $title . ">" . get_user_name( $user->ID ) . "</a></span><div><span class=\"row-actions\">$actions</span>&nbsp;</div></td>\n";
423
  $r .= "\t\t<td><a href='" . get_user_profile_link( $user->ID ) . "'>" . get_user_display_name( $user->ID ) . "</a></td>\n";
424
  if ( $email ) {
425
  $email = bb_get_user_email( $user->ID );
117
  function bb_admin_add_menu( $display_name, $capability, $file_name, $menu_position = false, $class = '', $id = '' )
118
  {
119
  global $bb_menu;
 
 
 
 
120
 
121
  if ( $display_name && $capability && $file_name ) {
122
  // Get an array of the keys
164
  $plugin_menu_next++;
165
  }
166
 
 
 
 
 
167
  // Add the menu item at the given key
168
  $bb_menu[$plugin_menu_next] = array( $display_name, $capability, $file_name, $class, $id );
169
 
178
  function bb_admin_add_submenu( $display_name, $capability, $file_name, $parent = 'plugins.php' )
179
  {
180
  global $bb_submenu;
 
 
 
 
 
181
  if ( $display_name && $capability && $file_name ) {
 
 
 
182
  $bb_submenu[$parent][] = array( $display_name, $capability, $file_name );
183
  ksort( $bb_submenu );
184
  }
397
 
398
  function bb_user_row( $user, $role = '', $email = false ) {
399
  $actions = "<a href='" . esc_attr( get_user_profile_link( $user->ID ) ) . "'>" . __('View') . "</a>";
400
+ if ( bb_current_user_can( 'edit_user', $user_id ) )
 
401
  $actions .= " | <a href='" . esc_attr( get_profile_tab_link( $user->ID, 'edit' ) ) . "'>" . __('Edit') . "</a>";
 
 
402
  $r = "\t<tr id='user-$user->ID'" . get_alt_class("user-$role") . ">\n";
403
+ $r .= "\t\t<td class=\"user\">" . bb_get_avatar( $user->ID, 32 ) . "<span class=\"row-title\"><a href='" . get_user_profile_link( $user->ID ) . "'>" . get_user_name( $user->ID ) . "</a></span><div><span class=\"row-actions\">$actions</span>&nbsp;</div></td>\n";
404
  $r .= "\t\t<td><a href='" . get_user_profile_link( $user->ID ) . "'>" . get_user_display_name( $user->ID ) . "</a></td>\n";
405
  if ( $email ) {
406
  $email = bb_get_user_email( $user->ID );
bp-forums/bbpress/bb-admin/includes/functions.bb-recount.php DELETED
@@ -1,262 +0,0 @@
1
- <?php
2
-
3
- function bb_recount_topic_posts()
4
- {
5
- global $bbdb;
6
-
7
- $statement = __( 'Counting the number of posts in each topic&hellip; %s' );
8
- $result = __( 'Failed!' );
9
-
10
- $sql = "INSERT INTO `$bbdb->topics` (`topic_id`, `topic_posts`) (SELECT `topic_id`, COUNT(`post_status`) as `topic_posts` FROM `$bbdb->posts` WHERE `post_status` = '0' GROUP BY `topic_id`) ON DUPLICATE KEY UPDATE `topic_posts` = VALUES(`topic_posts`);";
11
- if ( is_wp_error( $bbdb->query( $sql ) ) ) {
12
- return sprintf( $statement, $result );
13
- }
14
-
15
- $result = __( 'Complete!' );
16
- return sprintf( $statement, $result );
17
- }
18
-
19
- function bb_recount_topic_voices()
20
- {
21
- global $bbdb;
22
-
23
- $statement = __( 'Counting the number of voices in each topic&hellip; %s' );
24
- $result = __( 'Failed!' );
25
-
26
- $sql_delete = "DELETE FROM `$bbdb->meta` WHERE `object_type` = 'bb_topic' AND `meta_key` = 'voices_count';";
27
- if ( is_wp_error( $bbdb->query( $sql_delete ) ) ) {
28
- return sprintf( $statement, $result );
29
- }
30
-
31
- $sql = "INSERT INTO `$bbdb->meta` (`object_type`, `object_id`, `meta_key`, `meta_value`) (SELECT 'bb_topic', `topic_id`, 'voices_count', COUNT(DISTINCT `poster_id`) as `meta_value` FROM `$bbdb->posts` WHERE `post_status` = '0' GROUP BY `topic_id`);";
32
- if ( is_wp_error( $bbdb->query( $sql ) ) ) {
33
- return sprintf( $statement, $result );
34
- }
35
-
36
- $result = __( 'Complete!' );
37
- return sprintf( $statement, $result );
38
- }
39
-
40
- function bb_recount_topic_deleted_posts()
41
- {
42
- global $bbdb;
43
-
44
- $statement = __( 'Counting the number of deleted posts in each topic&hellip; %s' );
45
- $result = __( 'Failed!' );
46
-
47
- $sql_delete = "DELETE FROM `$bbdb->meta` WHERE `object_type` = 'bb_topic' AND `meta_key` = 'deleted_posts';";
48
- if ( is_wp_error( $bbdb->query( $sql_delete ) ) ) {
49
- return sprintf( $statement, $result );
50
- }
51
-
52
- $sql = "INSERT INTO `$bbdb->meta` (`object_type`, `object_id`, `meta_key`, `meta_value`) (SELECT 'bb_topic', `topic_id`, 'deleted_posts', COUNT(`post_status`) as `meta_value` FROM `$bbdb->posts` WHERE `post_status` != '0' GROUP BY `topic_id`);";
53
- if ( is_wp_error( $bbdb->query( $sql ) ) ) {
54
- return sprintf( $statement, $result );
55
- }
56
-
57
- $result = __( 'Complete!' );
58
- return sprintf( $statement, $result );
59
- }
60
-
61
- function bb_recount_forum_topics()
62
- {
63
- global $bbdb;
64
-
65
- $statement = __( 'Counting the number of topics in each forum&hellip; %s' );
66
- $result = __( 'Failed!' );
67
-
68
- $sql = "INSERT INTO `$bbdb->forums` (`forum_id`, `topics`) (SELECT `forum_id`, COUNT(`topic_status`) as `topics` FROM `$bbdb->topics` WHERE `topic_status` = '0' GROUP BY `forum_id`) ON DUPLICATE KEY UPDATE `topics` = VALUES(`topics`);";
69
- if ( is_wp_error( $bbdb->query( $sql ) ) ) {
70
- return sprintf( $statement, $result );
71
- }
72
-
73
- $result = __( 'Complete!' );
74
- return sprintf( $statement, $result );
75
- }
76
-
77
- function bb_recount_forum_posts()
78
- {
79
- global $bbdb;
80
-
81
- $statement = __( 'Counting the number of posts in each forum&hellip; %s' );
82
- $result = __( 'Failed!' );
83
-
84
- $sql = "INSERT INTO `$bbdb->forums` (`forum_id`, `posts`) (SELECT `forum_id`, COUNT(`post_status`) as `posts` FROM `$bbdb->posts` WHERE `post_status` = '0' GROUP BY `forum_id`) ON DUPLICATE KEY UPDATE `posts` = VALUES(`posts`);";
85
- if ( is_wp_error( $bbdb->query( $sql ) ) ) {
86
- return sprintf( $statement, $result );
87
- }
88
-
89
- $result = __( 'Complete!' );
90
- return sprintf( $statement, $result );
91
- }
92
-
93
- function bb_recount_user_topics_replied()
94
- {
95
- global $bbdb;
96
-
97
- $statement = __( 'Counting the number of topics to which each user has replied&hellip; %s' );
98
- $result = __( 'Failed!' );
99
-
100
- $sql_select = "SELECT `poster_id`, COUNT(DISTINCT `topic_id`) as `_count` FROM `$bbdb->posts` WHERE `post_status` = '0' GROUP BY `poster_id`;";
101
- $insert_rows = $bbdb->get_results( $sql_select );
102
-
103
- if ( is_wp_error( $insert_rows ) ) {
104
- return sprintf( $statement, $result );
105
- }
106
-
107
- $meta_key = $bbdb->prefix . 'topics_replied';
108
-
109
- $insert_values = array();
110
- foreach ( $insert_rows as $insert_row ) {
111
- $insert_values[] = "('$insert_row->poster_id', '$meta_key', '$insert_row->_count')";
112
- }
113
-
114
- if ( !count( $insert_values ) ) {
115
- return sprintf( $statement, $result );
116
- }
117
-
118
- $sql_delete = "DELETE FROM `$bbdb->usermeta` WHERE `meta_key` = '$meta_key';";
119
- if ( is_wp_error( $bbdb->query( $sql_delete ) ) ) {
120
- return sprintf( $statement, $result );
121
- }
122
-
123
- $insert_values = array_chunk( $insert_values, 10000 );
124
- foreach ( $insert_values as $chunk ) {
125
- $chunk = "\n" . join( ",\n", $chunk );
126
- $sql_insert = "INSERT INTO `$bbdb->usermeta` (`user_id`, `meta_key`, `meta_value`) VALUES $chunk;";
127
-
128
- if ( is_wp_error( $bbdb->query( $sql_insert ) ) ) {
129
- return sprintf( $statement, $result );
130
- }
131
- }
132
-
133
- $result = __( 'Complete!' );
134
- return sprintf( $statement, $result );
135
- }
136
-
137
- // TODO - make fast - see #1146
138
- function bb_recount_topic_tags()
139
- {
140
- // Reset tag count to zero
141
- $bbdb->query( "UPDATE $bbdb->topics SET tag_count = 0" );
142
-
143
- // Get all tags
144
- $terms = $wp_taxonomy_object->get_terms( 'bb_topic_tag' );
145
-
146
- if ( !is_wp_error( $terms ) && is_array( $terms ) ) {
147
- $message = __('Counted topic tags');
148
- foreach ( $terms as $term ) {
149
- $topic_ids = bb_get_tagged_topic_ids( $term->term_id );
150
- if ( !is_wp_error( $topic_ids ) && is_array( $topic_ids ) ) {
151
- $bbdb->query(
152
- "UPDATE $bbdb->topics SET tag_count = tag_count + 1 WHERE topic_id IN (" . join( ',', $topic_ids ) . ")"
153
- );
154
- }
155
- unset( $topic_ids );
156
- }
157
- }
158
- unset( $terms, $term );
159
-
160
- return $message;
161
- }
162
-
163
- // TODO - make fast - see #1146
164
- function bb_recount_tag_topics()
165
- {
166
- // Get all tags
167
- $terms = $wp_taxonomy_object->get_terms( 'bb_topic_tag', array( 'hide_empty' => false ) );
168
-
169
- if ( !is_wp_error( $terms ) && is_array( $terms ) ) {
170
- $message = __('Counted tagged topics');
171
- $_terms = array();
172
- foreach ( $terms as $term ) {
173
- $_terms[] = $term->term_id;
174
- }
175
- if ( count( $_terms ) ) {
176
- $wp_taxonomy_object->update_term_count( $_terms, 'bb_topic_tag' );
177
- }
178
- }
179
- unset( $term, $_terms );
180
-
181
- return $message;
182
- }
183
-
184
- // TODO - make fast - see #1146
185
- function bb_recount_tag_delete_empty()
186
- {
187
- // Get all tags
188
- if ( !isset( $terms ) ) {
189
- $terms = $wp_taxonomy_object->get_terms( 'bb_topic_tag', array( 'hide_empty' => false ) );
190
- }
191
-
192
- if ( !is_wp_error( $terms ) && is_array( $terms ) ) {
193
- $message = __('Deleted tags with no topics');
194
- foreach ( $terms as $term ) {
195
- $topic_ids = bb_get_tagged_topic_ids( $term->term_id );
196
- if ( !is_wp_error( $topic_ids ) && is_array( $topic_ids ) ) {
197
- if ( false === $topic_ids || ( is_array( $topic_ids ) && !count( $topic_ids ) ) ) {
198
- bb_destroy_tag( $term->term_taxonomy_id );
199
- }
200
- }
201
- unset( $topic_ids );
202
- }
203
- }
204
- unset( $terms, $term );
205
-
206
- return $message;
207
- }
208
-
209
- function bb_recount_clean_favorites()
210
- {
211
- global $bbdb;
212
-
213
- $statement = __( 'Removing deleted topics from user favorites&hellip; %s' );
214
- $result = __( 'Failed!' );
215
-
216
- $meta_key = $bbdb->prefix . 'favorites';
217
-
218
- $users = $bbdb->get_results( "SELECT `user_id`, `meta_value` AS `favorites` FROM `$bbdb->usermeta` WHERE `meta_key` = '$meta_key';" );
219
- if ( is_wp_error( $users ) ) {
220
- return sprintf( $statement, $result );
221
- }
222
-
223
- $topics = $bbdb->get_col( "SELECT `topic_id` FROM `$bbdb->topics` WHERE `topic_status` = '0';" );
224
-
225
- if ( is_wp_error( $topics ) ) {
226
- return sprintf( $statement, $result );
227
- }
228
-
229
- $values = array();
230
- foreach ( $users as $user ) {
231
- if ( empty( $user->favorites ) || !is_string( $user->favorites ) ) {
232
- continue;
233
- }
234
- $favorites = explode( ',', $user->favorites );
235
- if ( empty( $favorites ) || !is_array( $favorites ) ) {
236
- continue;
237
- }
238
- $favorites = join( ',', array_intersect( $topics, $favorites ) );
239
- $values[] = "('$user->user_id', '$meta_key', '$favorites')";
240
- }
241
-
242
- if ( !count( $values ) ) {
243
- return sprintf( $statement, $result );
244
- }
245
-
246
- $sql_delete = "DELETE FROM `$bbdb->usermeta` WHERE `meta_key` = '$meta_key';";
247
- if ( is_wp_error( $bbdb->query( $sql_delete ) ) ) {
248
- return sprintf( $statement, $result );
249
- }
250
-
251
- $values = array_chunk( $values, 10000 );
252
- foreach ( $values as $chunk ) {
253
- $chunk = "\n" . join( ",\n", $chunk );
254
- $sql_insert = "INSERT INTO `$bbdb->usermeta` (`user_id`, `meta_key`, `meta_value`) VALUES $chunk;";
255
- if ( is_wp_error( $bbdb->query( $sql_insert ) ) ) {
256
- return sprintf( $statement, $result );
257
- }
258
- }
259
-
260
- $result = __( 'Complete!' );
261
- return sprintf( $statement, $result );
262
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-forums/bbpress/bb-admin/includes/functions.bb-upgrade.php CHANGED
@@ -9,25 +9,16 @@ function bb_install() {
9
  return array_filter($alterations);
10
  }
11
 
12
- function bb_upgrade_all()
13
- {
14
- if ( !ini_get( 'safe_mode' ) ) {
15
  set_time_limit(600);
16
- }
17
-
18
- $_do_user_operations = true;
19
- if ( bb_get_option( 'wp_table_prefix' ) || ( defined( 'BB_SCHEMA_IGNORE_WP_USERS_TABLES' ) && BB_SCHEMA_IGNORE_WP_USERS_TABLES ) ) {
20
- $_do_user_operations = false;
21
- }
22
 
23
  $bb_upgrade = array();
24
 
25
  // Pre DB Delta
26
- if ( $_do_user_operations ) {
27
- $bb_upgrade['messages'][] = bb_upgrade_160(); // Break blocked users
28
- $bb_upgrade['messages'][] = bb_upgrade_170(); // Escaping in usermeta
29
- $bb_upgrade['messages'][] = bb_upgrade_180(); // Delete users for real
30
- }
31
  $bb_upgrade['messages'][] = bb_upgrade_190(); // Move topic_resolved to topicmeta
32
  $bb_upgrade['messages'][] = bb_upgrade_200(); // Indices
33
  $bb_upgrade['messages'][] = bb_upgrade_210(); // Convert text slugs to varchar slugs
@@ -46,17 +37,13 @@ function bb_upgrade_all()
46
  // Post DB Delta
47
  $bb_upgrade['messages'][] = bb_upgrade_1000(); // Make forum and topic slugs
48
  $bb_upgrade['messages'][] = bb_upgrade_1010(); // Make sure all forums have a valid parent
49
- if ( $_do_user_operations ) {
50
- $bb_upgrade['messages'][] = bb_upgrade_1020(); // Add a user_nicename to existing users
51
- }
52
  $bb_upgrade['messages'][] = bb_upgrade_1030(); // Move admin_email option to from_email
53
  $bb_upgrade['messages'][] = bb_upgrade_1040(); // Activate Akismet and bozo plugins and convert active plugins to new convention on upgrade only
54
  $bb_upgrade['messages'][] = bb_upgrade_1050(); // Update active theme if present
55
  $bb_upgrade['messages'][] = bb_upgrade_1070(); // trim whitespace from raw_tag
56
  $bb_upgrade['messages'][] = bb_upgrade_1080(); // Convert tags to taxonomy
57
- if ( $_do_user_operations ) {
58
- $bb_upgrade['messages'][] = bb_upgrade_1090(); // Add display names
59
- }
60
  $bb_upgrade['messages'][] = bb_upgrade_1100(); // Replace forum_stickies index with stickies (#876)
61
  $bb_upgrade['messages'][] = bb_upgrade_1110(); // Create plugin directory (#1083)
62
  $bb_upgrade['messages'][] = bb_upgrade_1120(); // Create theme directory (#1083)
9
  return array_filter($alterations);
10
  }
11
 
12
+ function bb_upgrade_all() {
13
+ if ( !ini_get('safe_mode') )
 
14
  set_time_limit(600);
 
 
 
 
 
 
15
 
16
  $bb_upgrade = array();
17
 
18
  // Pre DB Delta
19
+ $bb_upgrade['messages'][] = bb_upgrade_160(); // Break blocked users
20
+ $bb_upgrade['messages'][] = bb_upgrade_170(); // Escaping in usermeta
21
+ $bb_upgrade['messages'][] = bb_upgrade_180(); // Delete users for real
 
 
22
  $bb_upgrade['messages'][] = bb_upgrade_190(); // Move topic_resolved to topicmeta
23
  $bb_upgrade['messages'][] = bb_upgrade_200(); // Indices
24
  $bb_upgrade['messages'][] = bb_upgrade_210(); // Convert text slugs to varchar slugs
37
  // Post DB Delta
38
  $bb_upgrade['messages'][] = bb_upgrade_1000(); // Make forum and topic slugs
39
  $bb_upgrade['messages'][] = bb_upgrade_1010(); // Make sure all forums have a valid parent
40
+ $bb_upgrade['messages'][] = bb_upgrade_1020(); // Add a user_nicename to existing users
 
 
41
  $bb_upgrade['messages'][] = bb_upgrade_1030(); // Move admin_email option to from_email
42
  $bb_upgrade['messages'][] = bb_upgrade_1040(); // Activate Akismet and bozo plugins and convert active plugins to new convention on upgrade only
43
  $bb_upgrade['messages'][] = bb_upgrade_1050(); // Update active theme if present
44
  $bb_upgrade['messages'][] = bb_upgrade_1070(); // trim whitespace from raw_tag
45
  $bb_upgrade['messages'][] = bb_upgrade_1080(); // Convert tags to taxonomy
46
+ $bb_upgrade['messages'][] = bb_upgrade_1090(); // Add display names
 
 
47
  $bb_upgrade['messages'][] = bb_upgrade_1100(); // Replace forum_stickies index with stickies (#876)
48
  $bb_upgrade['messages'][] = bb_upgrade_1110(); // Create plugin directory (#1083)
49
  $bb_upgrade['messages'][] = bb_upgrade_1120(); // Create theme directory (#1083)
bp-forums/bbpress/bb-admin/index.php CHANGED
@@ -29,14 +29,6 @@ $rn_users_average = sprintf(__ngettext('<span>%d</span> user', '<span>%d</span>
29
  $rn_topic_tags_average = bb_get_topic_tags_per_day();
30
  $rn_topic_tags_average = sprintf(__ngettext('<span>%d</span> tag', '<span>%d</span> tags', $rn_topic_tags_average), $rn_topic_tags_average);
31
 
32
- $rn = apply_filters( 'bb_admin_right_now', array(
33
- 'forums' => array( $rn_forums, '-' ),
34
- 'topics' => array( $rn_topics, $rn_topics_average ),
35
- 'posts' => array( $rn_posts, $rn_posts_average ),
36
- 'topic_tags' => array( $rn_topic_tags, $rn_topic_tags_average ),
37
- 'users' => array( $rn_users, $rn_users_average )
38
- ) );
39
-
40
  $bb_admin_body_class = ' bb-admin-dashboard';
41
 
42
  bb_get_admin_header();
@@ -56,24 +48,28 @@ bb_get_admin_header();
56
  <th><?php _e( 'Per Day' ); ?></th>
57
  </tr>
58
  </thead>
59
- <?php
60
- if ( !empty( $rn ) && is_array( $rn ) ) {
61
- ?>
62
  <tbody>
63
- <?php
64
- foreach ( $rn as $rn_row ) {
65
- ?>
66
  <tr>
67
- <td><?php echo $rn_row[0]; ?></td>
68
- <td><?php echo $rn_row[1]; ?></td>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  </tr>
70
- <?php
71
- }
72
- ?>
73
  </tbody>
74
- <?php
75
- }
76
- ?>
77
  </table>
78
  </div>
79
 
29
  $rn_topic_tags_average = bb_get_topic_tags_per_day();
30
  $rn_topic_tags_average = sprintf(__ngettext('<span>%d</span> tag', '<span>%d</span> tags', $rn_topic_tags_average), $rn_topic_tags_average);
31
 
 
 
 
 
 
 
 
 
32
  $bb_admin_body_class = ' bb-admin-dashboard';
33
 
34
  bb_get_admin_header();
48
  <th><?php _e( 'Per Day' ); ?></th>
49
  </tr>
50
  </thead>
 
 
 
51
  <tbody>
 
 
 
52
  <tr>
53
+ <td><?php echo $rn_forums; ?></td>
54
+ <td>-</td>
55
+ </tr>
56
+ <tr>
57
+ <td><?php echo $rn_topics; ?></td>
58
+ <td><?php echo $rn_topics_average; ?></td>
59
+ </tr>
60
+ <tr>
61
+ <td><?php echo $rn_posts; ?></td>
62
+ <td><?php echo $rn_posts_average; ?></td>
63
+ </tr>
64
+ <tr>
65
+ <td><?php echo $rn_topic_tags; ?></td>
66
+ <td><?php echo $rn_topic_tags_average; ?></td>
67
+ </tr>
68
+ <tr>
69
+ <td><?php echo $rn_users; ?></td>
70
+ <td><?php echo $rn_users_average; ?></td>
71
  </tr>
 
 
 
72
  </tbody>
 
 
 
73
  </table>
74
  </div>
75
 
bp-forums/bbpress/bb-admin/tools-recount.php CHANGED
@@ -1,59 +1,164 @@
1
  <?php
2
- require_once( 'admin.php' );
3
- require_once( 'includes/functions.bb-recount.php' );
4
 
5
  if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) ) {
6
  bb_check_admin_referer( 'do-counts' );
7
 
8
- // Stores messages
9
  $messages = array();
10
-
11
- if ( !empty( $_POST['topic-posts'] ) ) {
12
- $messages[] = bb_recount_topic_posts();
 
 
 
 
 
 
13
  }
14
 
15
- if ( !empty( $_POST['topic-voices'] ) ) {
16
- $messages[] = bb_recount_topic_voices();
 
 
 
 
 
 
 
 
 
 
17
  }
18
 
19
- if ( !empty( $_POST['topic-deleted-posts'] ) ) {
20
- $messages[] = bb_recount_topic_deleted_posts();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  }
22
 
23
- if ( !empty( $_POST['forums'] ) ) {
24
- $messages[] = bb_recount_forum_topics();
25
- $messages[] = bb_recount_forum_posts();
 
 
 
 
 
 
 
 
 
 
 
 
26
  }
27
 
28
- if ( !empty( $_POST['topics-replied'] ) ) {
29
- $messages[] = bb_recount_user_topics_replied();
 
 
 
 
 
30
  }
31
 
32
- if ( !empty( $_POST['topic-tag-count'] ) ) {
33
- $messages[] = bb_recount_topic_tags();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  }
35
 
36
- if ( !empty( $_POST['tags-tag-count'] ) ) {
37
- $messages[] = bb_recount_tag_topics();
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  }
39
 
40
- if ( !empty( $_POST['tags-delete-empty'] ) ) {
41
- $messages[] = bb_recount_tag_delete_empty();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  }
43
 
44
- if ( !empty( $_POST['clean-favorites'] ) ) {
45
- $messages[] = bb_recount_clean_favorites();
 
 
 
 
 
 
 
 
 
 
 
 
46
  }
47
 
48
  bb_recount_list();
49
  foreach ( (array) $recount_list as $item ) {
50
  if ( isset($item[2]) && isset($_POST[$item[0]]) && 1 == $_POST[$item[0]] && is_callable($item[2]) ) {
51
- $messages[] = call_user_func( $item[2] );
52
  }
53
  }
54
-
55
- wp_cache_flush();
56
-
57
  if ( count( $messages ) ) {
58
  $messages = join( '</p>' . "\n" . '<p>', $messages );
59
  bb_admin_notice( $messages );
1
  <?php
2
+ require_once('admin.php');
 
3
 
4
  if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) ) {
5
  bb_check_admin_referer( 'do-counts' );
6
 
 
7
  $messages = array();
8
+ if ( isset($_POST['topic-posts']) && 1 == $_POST['topic-posts'] ) {
9
+ if ( $topics = (array) $bbdb->get_results("SELECT topic_id, COUNT(post_id) AS count FROM $bbdb->posts WHERE post_status = '0' GROUP BY topic_id") ) {
10
+ $messages[] = __('Counted posts');
11
+ foreach ($topics as $topic) {
12
+ $topic_id = (int) $topic->topic_id;
13
+ $bbdb->query( $bbdb->prepare( "UPDATE $bbdb->topics SET topic_posts = %s WHERE topic_id = %s" ), $topic->count, $topic_id );
14
+ }
15
+ unset($topics, $topic, $topic_id);
16
+ }
17
  }
18
 
19
+ if ( isset($_POST['topic-voices']) && 1 == $_POST['topic-voices'] ) {
20
+ if ( $topics = (array) $bbdb->get_results("SELECT topic_id FROM $bbdb->topics ORDER BY topic_id") ) {
21
+ $messages[] = __('Counted voices');
22
+ foreach ($topics as $topic) {
23
+ $topic_id = (int) $topic->topic_id;
24
+ if ( $voices = $bbdb->get_col( $bbdb->prepare( "SELECT DISTINCT poster_id FROM $bbdb->posts WHERE topic_id = %s AND post_status = '0';", $topic_id ) ) ) {
25
+ $voices = count( $voices );
26
+ bb_update_topicmeta( $topic_id, 'voices_count', $voices );
27
+ }
28
+ }
29
+ unset($topics, $topic, $topic_id);
30
+ }
31
  }
32
 
33
+ if ( isset($_POST['topic-deleted-posts']) && 1 == $_POST['topic-deleted-posts'] ) {
34
+ $old = (array) $bbdb->get_col("SELECT object_id FROM $bbdb->meta WHERE object_type = 'bb_topics' AND meta_key = 'deleted_posts'");
35
+ $old = array_flip($old);
36
+ if ( $topics = (array) $bbdb->get_results("SELECT topic_id, COUNT(post_id) AS count FROM $bbdb->posts WHERE post_status != '0' GROUP BY topic_id") ) {
37
+ $messages[] = __('Counting deleted posts&#8230;');
38
+ foreach ( $topics as $topic ) {
39
+ bb_update_topicmeta( $topic->topic_id, 'deleted_posts', $topic->count );
40
+ unset($old[$topic->topic_id]);
41
+ }
42
+ unset($topics, $topic);
43
+ }
44
+ if ( $old ) {
45
+ $old = join(',', array_flip($old));
46
+ $bbdb->query("DELETE FROM $bbdb->meta WHERE object_type = 'bb_topic' AND object_id IN ($old) AND meta_key = 'deleted_posts'");
47
+ $messages[] = __('&#8230;counted deleted posts');
48
+ } else {
49
+ $messages[] = __('&#8230;no deleted posts to count');
50
+ }
51
  }
52
 
53
+ if ( isset($_POST['forums']) && 1 == $_POST['forums'] ) {
54
+ if ( $all_forums = (array) $bbdb->get_col("SELECT forum_id FROM $bbdb->forums") ) {
55
+ $messages[] = __('Counted forum topics and posts');
56
+ $all_forums = array_flip( $all_forums );
57
+ $forums = $bbdb->get_results("SELECT forum_id, COUNT(topic_id) AS topic_count, SUM(topic_posts) AS post_count FROM $bbdb->topics WHERE topic_status = 0 GROUP BY forum_id");
58
+ foreach ( (array) $forums as $forum ) {
59
+ $bbdb->query("UPDATE $bbdb->forums SET topics = '$forum->topic_count', posts = '$forum->post_count' WHERE forum_id = '$forum->forum_id'");
60
+ unset($all_forums[$forum->forum_id]);
61
+ }
62
+ if ( $all_forums ) {
63
+ $all_forums = implode(',', array_flip( $all_forums ) );
64
+ $bbdb->query("UPDATE $bbdb->forums SET topics = 0, posts = 0 WHERE forum_id IN ($all_forums)");
65
+ }
66
+ unset($all_forums, $forums, $forum);
67
+ }
68
  }
69
 
70
+ if ( isset($_POST['topics-replied']) && 1 == $_POST['topics-replied'] ) {
71
+ if ( $users = (array) $bbdb->get_col("SELECT ID FROM $bbdb->users") ) {
72
+ $messages[] = __('Counted topics to which each user has replied');
73
+ foreach ( $users as $user )
74
+ bb_update_topics_replied( $user );
75
+ unset($users, $user);
76
+ }
77
  }
78
 
79
+ if ( isset($_POST['topic-tag-count']) && 1 == $_POST['topic-tag-count'] ) {
80
+ // Reset tag count to zero
81
+ $bbdb->query( "UPDATE $bbdb->topics SET tag_count = 0" );
82
+
83
+ // Get all tags
84
+ $terms = $wp_taxonomy_object->get_terms( 'bb_topic_tag' );
85
+
86
+ if ( !is_wp_error( $terms ) && is_array( $terms ) ) {
87
+ $messages[] = __('Counted topic tags');
88
+ foreach ( $terms as $term ) {
89
+ $topic_ids = bb_get_tagged_topic_ids( $term->term_id );
90
+ if ( !is_wp_error( $topic_ids ) && is_array( $topic_ids ) ) {
91
+ $bbdb->query(
92
+ "UPDATE $bbdb->topics SET tag_count = tag_count + 1 WHERE topic_id IN (" . join( ',', $topic_ids ) . ")"
93
+ );
94
+ }
95
+ unset( $topic_ids );
96
+ }
97
+ }
98
+ unset( $terms, $term );
99
  }
100
 
101
+ if ( isset($_POST['tags-tag-count']) && 1 == $_POST['tags-tag-count'] ) {
102
+ // Get all tags
103
+ $terms = $wp_taxonomy_object->get_terms( 'bb_topic_tag', array( 'hide_empty' => false ) );
104
+
105
+ if ( !is_wp_error( $terms ) && is_array( $terms ) ) {
106
+ $messages[] = __('Counted tagged topics');
107
+ $_terms = array();
108
+ foreach ( $terms as $term ) {
109
+ $_terms[] = $term->term_id;
110
+ }
111
+ if ( count( $_terms ) ) {
112
+ $wp_taxonomy_object->update_term_count( $_terms, 'bb_topic_tag' );
113
+ }
114
+ }
115
+ unset( $term, $_terms );
116
  }
117
 
118
+ if ( isset($_POST['tags-delete-empty']) && 1 == $_POST['tags-delete-empty'] ) {
119
+ // Get all tags
120
+ if ( !isset( $terms ) ) {
121
+ $terms = $wp_taxonomy_object->get_terms( 'bb_topic_tag', array( 'hide_empty' => false ) );
122
+ }
123
+
124
+ if ( !is_wp_error( $terms ) && is_array( $terms ) ) {
125
+ $messages[] = __('Deleted tags with no topics');
126
+ foreach ( $terms as $term ) {
127
+ $topic_ids = bb_get_tagged_topic_ids( $term->term_id );
128
+ if ( !is_wp_error( $topic_ids ) && is_array( $topic_ids ) ) {
129
+ if ( false === $topic_ids || ( is_array( $topic_ids ) && !count( $topic_ids ) ) ) {
130
+ bb_destroy_tag( $term->term_taxonomy_id );
131
+ }
132
+ }
133
+ unset( $topic_ids );
134
+ }
135
+ }
136
+ unset( $terms, $term );
137
  }
138
 
139
+ if ( isset($_POST['clean-favorites']) && 1 == $_POST['clean-favorites'] ) {
140
+ $favorites_key = $bbdb->prefix . 'favorites';
141
+ if ( $users = $bbdb->get_results("SELECT user_id AS id, meta_value AS favorites FROM $bbdb->usermeta WHERE meta_key = '" . $favorites_key . "'") ) {
142
+ $messages[] = __('Removed deleted topics from users\' favorites');
143
+ $topics = $bbdb->get_col("SELECT topic_id FROM $bbdb->topics WHERE topic_status = '0'");
144
+ foreach ( $users as $user ) {
145
+ foreach ( explode(',', $user->favorites) as $favorite ) {
146
+ if ( !in_array($favorite, $topics) ) {
147
+ bb_remove_user_favorite( $user->id, $favorite );
148
+ }
149
+ }
150
+ }
151
+ unset($topics, $users, $user, $favorite);
152
+ }
153
  }
154
 
155
  bb_recount_list();
156
  foreach ( (array) $recount_list as $item ) {
157
  if ( isset($item[2]) && isset($_POST[$item[0]]) && 1 == $_POST[$item[0]] && is_callable($item[2]) ) {
158
+ call_user_func( $item[2] );
159
  }
160
  }
161
+
 
 
162
  if ( count( $messages ) ) {
163
  $messages = join( '</p>' . "\n" . '<p>', $messages );
164
  bb_admin_notice( $messages );
bp-forums/bbpress/bb-cron.php CHANGED
@@ -11,10 +11,6 @@
11
 
12
  ignore_user_abort( true );
13
 
14
- if ( !empty( $_POST ) || defined( 'DOING_AJAX' ) || defined( 'DOING_CRON' ) ) {
15
- die();
16
- }
17
-
18
  /**
19
  * Tell bbPress we are doing the CRON task.
20
  *
@@ -25,19 +21,24 @@ define( 'DOING_CRON', true );
25
  /** Setup bbPress environment */
26
  require_once( './bb-load.php' );
27
 
28
- if ( false === $crons = _get_cron_array() ) {
29
- die();
30
  }
31
 
32
- $keys = array_keys( $crons );
33
- $local_time = time();
 
34
 
35
- if ( !is_array( $crons ) || ( isset($keys[0]) && $keys[0] > $local_time ) ) {
36
- die();
 
 
 
 
37
  }
38
 
39
  foreach ( $crons as $timestamp => $cronhooks ) {
40
- if ( $timestamp > $local_time ) {
41
  break;
42
  }
43
  foreach ( $cronhooks as $hook => $keys ) {
@@ -52,3 +53,5 @@ foreach ( $crons as $timestamp => $cronhooks ) {
52
  }
53
  }
54
  }
 
 
11
 
12
  ignore_user_abort( true );
13
 
 
 
 
 
14
  /**
15
  * Tell bbPress we are doing the CRON task.
16
  *
21
  /** Setup bbPress environment */
22
  require_once( './bb-load.php' );
23
 
24
+ if ( $_GET['check'] != backpress_get_option( 'cron_check' ) ) {
25
+ exit;
26
  }
27
 
28
+ if ( bb_get_option( 'doing_cron' ) > time() ) {
29
+ exit;
30
+ }
31
 
32
+ bb_update_option( 'doing_cron', time() + 30 );
33
+
34
+ $crons = _get_cron_array();
35
+ $keys = array_keys( $crons );
36
+ if ( !is_array( $crons ) || $keys[0] > time() ) {
37
+ return;
38
  }
39
 
40
  foreach ( $crons as $timestamp => $cronhooks ) {
41
+ if ( $timestamp > time() ) {
42
  break;
43
  }
44
  foreach ( $cronhooks as $hook => $keys ) {
53
  }
54
  }
55
  }
56
+
57
+ bb_update_option( 'doing_cron', 0 );
bp-forums/bbpress/bb-includes/backpress/functions.formatting.php CHANGED
@@ -1489,15 +1489,14 @@ if ( !function_exists('clean_url') ) :
1489
  *
1490
  * @param string $url The URL to be cleaned.
1491
  * @param array $protocols Optional. An array of acceptable protocols.
1492
- * Defaults to 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn' if not set.
1493
  * @param string $context Optional. How the URL will be used. Default is 'display'.
1494
  * @return string The cleaned $url after the 'cleaned_url' filter is applied.
1495
  */
1496
  function clean_url( $url, $protocols = null, $context = 'display' ) {
1497
  $original_url = $url;
1498
 
1499
- if ( '' == $url )
1500
- return $url;
1501
  $url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\\x80-\\xff]|i', '', $url);
1502
  $strip = array('%0d', '%0a', '%0D', '%0A');
1503
  $url = _deep_replace($strip, $url);
@@ -1512,13 +1511,12 @@ function clean_url( $url, $protocols = null, $context = 'display' ) {
1512
 
1513
  // Replace ampersands and single quotes only when displaying.
1514
  if ( 'display' == $context ) {
1515
- $url = wp_kses_normalize_entities( $url );
1516
- $url = str_replace( '&amp;', '&#038;', $url );
1517
  $url = str_replace( "'", '&#039;', $url );
1518
  }
1519
 
1520
  if ( !is_array($protocols) )
1521
- $protocols = array ('http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn');
1522
  if ( wp_kses_bad_protocol( $url, $protocols ) != $url )
1523
  return '';
1524
 
1489
  *
1490
  * @param string $url The URL to be cleaned.
1491
  * @param array $protocols Optional. An array of acceptable protocols.
1492
+ * Defaults to 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet' if not set.
1493
  * @param string $context Optional. How the URL will be used. Default is 'display'.
1494
  * @return string The cleaned $url after the 'cleaned_url' filter is applied.
1495
  */
1496
  function clean_url( $url, $protocols = null, $context = 'display' ) {
1497
  $original_url = $url;
1498
 
1499
+ if ('' == $url) return $url;
 
1500
  $url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\\x80-\\xff]|i', '', $url);
1501
  $strip = array('%0d', '%0a', '%0D', '%0A');
1502
  $url = _deep_replace($strip, $url);
1511
 
1512
  // Replace ampersands and single quotes only when displaying.
1513
  if ( 'display' == $context ) {
1514
+ $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&#038;$1', $url);
 
1515
  $url = str_replace( "'", '&#039;', $url );
1516
  }
1517
 
1518
  if ( !is_array($protocols) )
1519
+ $protocols = array('http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet');
1520
  if ( wp_kses_bad_protocol( $url, $protocols ) != $url )
1521
  return '';
1522
 
bp-forums/bbpress/bb-includes/backpress/functions.kses.php CHANGED
@@ -1,485 +1,30 @@
1
  <?php
2
- // Last sync [WP17185]
3
 
4
  /**
5
- * kses 0.2.2 - HTML/XHTML filter that only allows some elements and attributes
6
- * Copyright (C) 2002, 2003, 2005 Ulf Harnhammar
7
- *
8
- * This program is free software and open source software; you can redistribute
9
- * it and/or modify it under the terms of the GNU General Public License as
10
- * published by the Free Software Foundation; either version 2 of the License,
11
- * or (at your option) any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful, but WITHOUT
14
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16
- * more details.
17
- *
18
- * You should have received a copy of the GNU General Public License along
19
- * with this program; if not, write to the Free Software Foundation, Inc.,
20
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or visit
21
- * http://www.gnu.org/licenses/gpl.html
22
- *
23
- * [kses strips evil scripts!]
24
  *
25
  * Added wp_ prefix to avoid conflicts with existing kses users
26
  *
27
  * @version 0.2.2
28
  * @copyright (C) 2002, 2003, 2005
29
- * @author Ulf Harnhammar <http://advogato.org/person/metaur/>
30
  *
31
  * @package External
32
  * @subpackage KSES
33
  *
34
- */
35
-
36
- /**
37
- * You can override this in a plugin.
 
 
 
 
38
  *
39
- * @since 1.2.0
40
  */
41
- if ( ! defined( 'BP_CUSTOM_TAGS' ) )
42
- define( 'BP_CUSTOM_TAGS', false );
43
-
44
- if ( ! BP_CUSTOM_TAGS ) {
45
- /**
46
- * Kses global for default allowable HTML tags.
47
- *
48
- * Can be override by using CUSTOM_TAGS constant.
49
- *
50
- * @global array $allowedposttags
51
- * @since 2.0.0
52
- */
53
- $allowedposttags = array(
54
- 'address' => array(),
55
- 'a' => array(
56
- 'class' => array (),
57
- 'href' => array (),
58
- 'id' => array (),
59
- 'title' => array (),
60
- 'rel' => array (),
61
- 'rev' => array (),
62
- 'name' => array (),
63
- 'target' => array()),
64
- 'abbr' => array(
65
- 'class' => array (),
66
- 'title' => array ()),
67
- 'acronym' => array(
68
- 'title' => array ()),
69
- 'article' => array(
70
- 'align' => array (),
71
- 'class' => array (),
72
- 'dir' => array (),
73
- 'lang' => array(),
74
- 'style' => array (),
75
- 'xml:lang' => array(),
76
- ),
77
- 'aside' => array(
78
- 'align' => array (),
79
- 'class' => array (),
80
- 'dir' => array (),
81
- 'lang' => array(),
82
- 'style' => array (),
83
- 'xml:lang' => array(),
84
- ),
85
- 'b' => array(),
86
- 'big' => array(),
87
- 'blockquote' => array(
88
- 'id' => array (),
89
- 'cite' => array (),
90
- 'class' => array(),
91
- 'lang' => array(),
92
- 'xml:lang' => array()),
93
- 'br' => array (
94
- 'class' => array ()),
95
- 'button' => array(
96
- 'disabled' => array (),
97
- 'name' => array (),
98
- 'type' => array (),
99
- 'value' => array ()),
100
- 'caption' => array(
101
- 'align' => array (),
102
- 'class' => array ()),
103
- 'cite' => array (
104
- 'class' => array(),
105
- 'dir' => array(),
106
- 'lang' => array(),
107
- 'title' => array ()),
108
- 'code' => array (
109
- 'style' => array()),
110
- 'col' => array(
111
- 'align' => array (),
112
- 'char' => array (),
113
- 'charoff' => array (),
114
- 'span' => array (),
115
- 'dir' => array(),
116
- 'style' => array (),
117
- 'valign' => array (),
118
- 'width' => array ()),
119
- 'del' => array(
120
- 'datetime' => array ()),
121
- 'dd' => array(),
122
- 'details' => array(
123
- 'align' => array (),
124
- 'class' => array (),
125
- 'dir' => array (),
126
- 'lang' => array(),
127
- 'open' => array (),
128
- 'style' => array (),
129
- 'xml:lang' => array(),
130
- ),
131
- 'div' => array(
132
- 'align' => array (),
133
- 'class' => array (),
134
- 'dir' => array (),
135
- 'lang' => array(),
136
- 'style' => array (),
137
- 'xml:lang' => array()),
138
- 'dl' => array(),
139
- 'dt' => array(),
140
- 'em' => array(),
141
- 'fieldset' => array(),
142
- 'figure' => array(
143
- 'align' => array (),
144
- 'class' => array (),
145
- 'dir' => array (),
146
- 'lang' => array(),
147
- 'style' => array (),
148
- 'xml:lang' => array(),
149
- ),
150
- 'figcaption' => array(
151
- 'align' => array (),
152
- 'class' => array (),
153
- 'dir' => array (),
154
- 'lang' => array(),
155
- 'style' => array (),
156
- 'xml:lang' => array(),
157
- ),
158
- 'font' => array(
159
- 'color' => array (),
160
- 'face' => array (),
161
- 'size' => array ()),
162
- 'footer' => array(
163
- 'align' => array (),
164
- 'class' => array (),
165
- 'dir' => array (),
166
- 'lang' => array(),
167
- 'style' => array (),
168
- 'xml:lang' => array(),
169
- ),
170
- 'form' => array(
171
- 'action' => array (),
172
- 'accept' => array (),
173
- 'accept-charset' => array (),
174
- 'enctype' => array (),
175
- 'method' => array (),
176
- 'name' => array (),
177
- 'target' => array ()),
178
- 'h1' => array(
179
- 'align' => array (),
180
- 'class' => array (),
181
- 'id' => array (),
182
- 'style' => array ()),
183
- 'h2' => array (
184
- 'align' => array (),
185
- 'class' => array (),
186
- 'id' => array (),
187
- 'style' => array ()),
188
- 'h3' => array (
189
- 'align' => array (),
190
- 'class' => array (),
191
- 'id' => array (),
192
- 'style' => array ()),
193
- 'h4' => array (
194
- 'align' => array (),
195
- 'class' => array (),
196
- 'id' => array (),
197
- 'style' => array ()),
198
- 'h5' => array (
199
- 'align' => array (),
200
- 'class' => array (),
201
- 'id' => array (),
202
- 'style' => array ()),
203
- 'h6' => array (
204
- 'align' => array (),
205
- 'class' => array (),
206
- 'id' => array (),
207
- 'style' => array ()),
208
- 'header' => array(
209
- 'align' => array (),
210
- 'class' => array (),
211
- 'dir' => array (),
212
- 'lang' => array(),
213
- 'style' => array (),
214
- 'xml:lang' => array(),
215
- ),
216
- 'hgroup' => array(
217
- 'align' => array (),
218
- 'class' => array (),
219
- 'dir' => array (),
220
- 'lang' => array(),
221
- 'style' => array (),
222
- 'xml:lang' => array(),
223
- ),
224
- 'hr' => array (
225
- 'align' => array (),
226
- 'class' => array (),
227
- 'noshade' => array (),
228
- 'size' => array (),
229
- 'width' => array ()),
230
- 'i' => array(),
231
- 'img' => array(
232
- 'alt' => array (),
233
- 'align' => array (),
234
- 'border' => array (),
235
- 'class' => array (),
236
- 'height' => array (),
237
- 'hspace' => array (),
238
- 'longdesc' => array (),
239
- 'vspace' => array (),
240
- 'src' => array (),
241
- 'style' => array (),
242
- 'width' => array ()),
243
- 'ins' => array(
244
- 'datetime' => array (),
245
- 'cite' => array ()),
246
- 'kbd' => array(),
247
- 'label' => array(
248
- 'for' => array ()),
249
- 'legend' => array(
250
- 'align' => array ()),
251
- 'li' => array (
252
- 'align' => array (),
253
- 'class' => array ()),
254
- 'menu' => array (
255
- 'class' => array (),
256
- 'style' => array (),
257
- 'type' => array ()),
258
- 'nav' => array(
259
- 'align' => array (),
260
- 'class' => array (),
261
- 'dir' => array (),
262
- 'lang' => array(),
263
- 'style' => array (),
264
- 'xml:lang' => array(),
265
- ),
266
- 'p' => array(
267
- 'class' => array (),
268
- 'align' => array (),
269
- 'dir' => array(),
270
- 'lang' => array(),
271
- 'style' => array (),
272
- 'xml:lang' => array()),
273
- 'pre' => array(
274
- 'style' => array(),
275
- 'width' => array ()),
276
- 'q' => array(
277
- 'cite' => array ()),
278
- 's' => array(),
279
- 'span' => array (
280
- 'class' => array (),
281
- 'dir' => array (),
282
- 'align' => array (),
283
- 'lang' => array (),
284
- 'style' => array (),
285
- 'title' => array (),
286
- 'xml:lang' => array()),
287
- 'section' => array(
288
- 'align' => array (),
289
- 'class' => array (),
290
- 'dir' => array (),
291
- 'lang' => array(),
292
- 'style' => array (),
293
- 'xml:lang' => array(),
294
- ),
295
- 'strike' => array(),
296
- 'strong' => array(),
297
- 'sub' => array(),
298
- 'summary' => array(
299
- 'align' => array (),
300
- 'class' => array (),
301
- 'dir' => array (),
302
- 'lang' => array(),
303
- 'style' => array (),
304
- 'xml:lang' => array(),
305
- ),
306
- 'sup' => array(),
307
- 'table' => array(
308
- 'align' => array (),
309
- 'bgcolor' => array (),
310
- 'border' => array (),
311
- 'cellpadding' => array (),
312
- 'cellspacing' => array (),
313
- 'class' => array (),
314
- 'dir' => array(),
315
- 'id' => array(),
316
- 'rules' => array (),
317
- 'style' => array (),
318
- 'summary' => array (),
319
- 'width' => array ()),
320
- 'tbody' => array(
321
- 'align' => array (),
322
- 'char' => array (),
323
- 'charoff' => array (),
324
- 'valign' => array ()),
325
- 'td' => array(
326
- 'abbr' => array (),
327
- 'align' => array (),
328
- 'axis' => array (),
329
- 'bgcolor' => array (),
330
- 'char' => array (),
331
- 'charoff' => array (),
332
- 'class' => array (),
333
- 'colspan' => array (),
334
- 'dir' => array(),
335
- 'headers' => array (),
336
- 'height' => array (),
337
- 'nowrap' => array (),
338
- 'rowspan' => array (),
339
- 'scope' => array (),
340
- 'style' => array (),
341
- 'valign' => array (),
342
- 'width' => array ()),
343
- 'textarea' => array(
344
- 'cols' => array (),
345
- 'rows' => array (),
346
- 'disabled' => array (),
347
- 'name' => array (),
348
- 'readonly' => array ()),
349
- 'tfoot' => array(
350
- 'align' => array (),
351
- 'char' => array (),
352
- 'class' => array (),
353
- 'charoff' => array (),
354
- 'valign' => array ()),
355
- 'th' => array(
356
- 'abbr' => array (),
357
- 'align' => array (),
358
- 'axis' => array (),
359
- 'bgcolor' => array (),
360
- 'char' => array (),
361
- 'charoff' => array (),
362
- 'class' => array (),
363
- 'colspan' => array (),
364
- 'headers' => array (),
365
- 'height' => array (),
366
- 'nowrap' => array (),
367
- 'rowspan' => array (),
368
- 'scope' => array (),
369
- 'valign' => array (),
370
- 'width' => array ()),
371
- 'thead' => array(
372
- 'align' => array (),
373
- 'char' => array (),
374
- 'charoff' => array (),
375
- 'class' => array (),
376
- 'valign' => array ()),
377
- 'title' => array(),
378
- 'tr' => array(
379
- 'align' => array (),
380
- 'bgcolor' => array (),
381
- 'char' => array (),
382
- 'charoff' => array (),
383
- 'class' => array (),
384
- 'style' => array (),
385
- 'valign' => array ()),
386
- 'tt' => array(),
387
- 'u' => array(),
388
- 'ul' => array (
389
- 'class' => array (),
390
- 'style' => array (),
391
- 'type' => array ()),
392
- 'ol' => array (
393
- 'class' => array (),
394
- 'start' => array (),
395
- 'style' => array (),
396
- 'type' => array ()),
397
- 'var' => array ());
398
-
399
- /**
400
- * Kses allowed HTML elements.
401
- *
402
- * @global array $allowedtags
403
- * @since 1.0.0
404
- */
405
- $allowedtags = array(
406
- 'a' => array(
407
- 'href' => array (),
408
- 'title' => array ()),
409
- 'abbr' => array(
410
- 'title' => array ()),
411
- 'acronym' => array(
412
- 'title' => array ()),
413
- 'b' => array(),
414
- 'blockquote' => array(
415
- 'cite' => array ()),
416
- // 'br' => array(),
417
- 'cite' => array (),
418
- 'code' => array(),
419
- 'del' => array(
420
- 'datetime' => array ()),
421
- // 'dd' => array(),
422
- // 'dl' => array(),
423
- // 'dt' => array(),
424
- 'em' => array (), 'i' => array (),
425
- // 'ins' => array('datetime' => array(), 'cite' => array()),
426
- // 'li' => array(),
427
- // 'ol' => array(),
428
- // 'p' => array(),
429
- 'q' => array(
430
- 'cite' => array ()),
431
- 'strike' => array(),
432
- 'strong' => array(),
433
- // 'sub' => array(),
434
- // 'sup' => array(),
435
- // 'u' => array(),
436
- // 'ul' => array(),
437
- );
438
-
439
- $allowedentitynames = array(
440
- 'nbsp', 'iexcl', 'cent', 'pound', 'curren', 'yen',
441
- 'brvbar', 'sect', 'uml', 'copy', 'ordf', 'laquo',
442
- 'not', 'shy', 'reg', 'macr', 'deg', 'plusmn',
443
- 'acute', 'micro', 'para', 'middot', 'cedil', 'ordm',
444
- 'raquo', 'iquest', 'Agrave', 'Aacute', 'Acirc', 'Atilde',
445
- 'Auml', 'Aring', 'AElig', 'Ccedil', 'Egrave', 'Eacute',
446
- 'Ecirc', 'Euml', 'Igrave', 'Iacute', 'Icirc', 'Iuml',
447
- 'ETH', 'Ntilde', 'Ograve', 'Oacute', 'Ocirc', 'Otilde',
448
- 'Ouml', 'times', 'Oslash', 'Ugrave', 'Uacute', 'Ucirc',
449
- 'Uuml', 'Yacute', 'THORN', 'szlig', 'agrave', 'aacute',
450
- 'acirc', 'atilde', 'auml', 'aring', 'aelig', 'ccedil',
451
- 'egrave', 'eacute', 'ecirc', 'euml', 'igrave', 'iacute',
452
- 'icirc', 'iuml', 'eth', 'ntilde', 'ograve', 'oacute',
453
- 'ocirc', 'otilde', 'ouml', 'divide', 'oslash', 'ugrave',
454
- 'uacute', 'ucirc', 'uuml', 'yacute', 'thorn', 'yuml',
455
- 'quot', 'amp', 'lt', 'gt', 'apos', 'OElig',
456
- 'oelig', 'Scaron', 'scaron', 'Yuml', 'circ', 'tilde',
457
- 'ensp', 'emsp', 'thinsp', 'zwnj', 'zwj', 'lrm',
458
- 'rlm', 'ndash', 'mdash', 'lsquo', 'rsquo', 'sbquo',
459
- 'ldquo', 'rdquo', 'bdquo', 'dagger', 'Dagger', 'permil',
460
- 'lsaquo', 'rsaquo', 'euro', 'fnof', 'Alpha', 'Beta',
461
- 'Gamma', 'Delta', 'Epsilon', 'Zeta', 'Eta', 'Theta',
462
- 'Iota', 'Kappa', 'Lambda', 'Mu', 'Nu', 'Xi',
463
- 'Omicron', 'Pi', 'Rho', 'Sigma', 'Tau', 'Upsilon',
464
- 'Phi', 'Chi', 'Psi', 'Omega', 'alpha', 'beta',
465
- 'gamma', 'delta', 'epsilon', 'zeta', 'eta', 'theta',
466
- 'iota', 'kappa', 'lambda', 'mu', 'nu', 'xi',
467
- 'omicron', 'pi', 'rho', 'sigmaf', 'sigma', 'tau',
468
- 'upsilon', 'phi', 'chi', 'psi', 'omega', 'thetasym',
469
- 'upsih', 'piv', 'bull', 'hellip', 'prime', 'Prime',
470
- 'oline', 'frasl', 'weierp', 'image', 'real', 'trade',
471
- 'alefsym', 'larr', 'uarr', 'rarr', 'darr', 'harr',
472
- 'crarr', 'lArr', 'uArr', 'rArr', 'dArr', 'hArr',
473
- 'forall', 'part', 'exist', 'empty', 'nabla', 'isin',
474
- 'notin', 'ni', 'prod', 'sum', 'minus', 'lowast',
475
- 'radic', 'prop', 'infin', 'ang', 'and', 'or',
476
- 'cap', 'cup', 'int', 'sim', 'cong', 'asymp',
477
- 'ne', 'equiv', 'le', 'ge', 'sub', 'sup',
478
- 'nsub', 'sube', 'supe', 'oplus', 'otimes', 'perp',
479
- 'sdot', 'lceil', 'rceil', 'lfloor', 'rfloor', 'lang',
480
- 'rang', 'loz', 'spades', 'clubs', 'hearts', 'diams',
481
- );
482
- }
483
 
484
  /**
485
  * Filters content and keeps only allowable HTML elements.
@@ -490,9 +35,9 @@ if ( ! BP_CUSTOM_TAGS ) {
490
  * call this function.
491
  *
492
  * The default allowed protocols are 'http', 'https', 'ftp', 'mailto', 'news',
493
- * 'irc', 'gopher', 'nntp', 'feed', 'telnet, 'mms', 'rtsp' and 'svn'. This
494
- * covers all common link protocols, except for 'javascript' which should not
495
- * be allowed for untrusted users.
496
  *
497
  * @since 1.0.0
498
  *
@@ -501,8 +46,7 @@ if ( ! BP_CUSTOM_TAGS ) {
501
  * @param array $allowed_protocols Optional. Allowed protocol in links.
502
  * @return string Filtered content with only allowed HTML elements
503
  */
504
- function wp_kses($string, $allowed_html, $allowed_protocols = array ()) {
505
- $allowed_protocols = wp_parse_args( $allowed_protocols, apply_filters('kses_allowed_protocols', array ('http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn') ));
506
  $string = wp_kses_no_null($string);
507
  $string = wp_kses_js_entities($string);
508
  $string = wp_kses_normalize_entities($string);
@@ -556,18 +100,8 @@ function wp_kses_split($string, $allowed_html, $allowed_protocols) {
556
  global $pass_allowed_html, $pass_allowed_protocols;
557
  $pass_allowed_html = $allowed_html;
558
  $pass_allowed_protocols = $allowed_protocols;
559
- return preg_replace_callback( '%((<!--.*?(-->|$))|(<[^>]*(>|$)|>))%', '_wp_kses_split_callback', $string );
560
- }
561
-
562
- /**
563
- * Callback for wp_kses_split.
564
- *
565
- * @since 3.1.0
566
- * @access private
567
- */
568
- function _wp_kses_split_callback( $match ) {
569
- global $pass_allowed_html, $pass_allowed_protocols;
570
- return wp_kses_split2( $match[1], $pass_allowed_html, $pass_allowed_protocols );
571
  }
572
 
573
  /**
@@ -652,7 +186,7 @@ function wp_kses_attr($element, $attr, $allowed_html, $allowed_protocols) {
652
  # Is there a closing XHTML slash at the end of the attributes?
653
 
654
  $xhtml_slash = '';
655
- if (preg_match('%\s*/\s*$%', $attr))
656
  $xhtml_slash = ' /';
657
 
658
  # Are any attributes allowed at all for this element?
@@ -690,19 +224,6 @@ function wp_kses_attr($element, $attr, $allowed_html, $allowed_protocols) {
690
  break;
691
  }
692
 
693
- if ( strtolower($arreach['name']) == 'style' ) {
694
- $orig_value = $arreach['value'];
695
-
696
- $value = safecss_filter_attr($orig_value);
697
-
698
- if ( empty($value) )
699
- continue;
700
-
701
- $arreach['value'] = $value;
702
-
703
- $arreach['whole'] = str_replace($orig_value, $value, $arreach['whole']);
704
- }
705
-
706
  if ($ok)
707
  $attr2 .= ' '.$arreach['whole']; # it passed them
708
  } # if !is_array($current)
@@ -778,11 +299,11 @@ function wp_kses_hair($attr, $allowed_protocols) {
778
 
779
  case 2 : # attribute value, a URL after href= for instance
780
 
781
- if (preg_match('%^"([^"]*)"(\s+|/?$)%', $attr, $match))
782
  # "value"
783
  {
784
  $thisval = $match[1];
785
- if ( in_array(strtolower($attrname), $uris) )
786
  $thisval = wp_kses_bad_protocol($thisval, $allowed_protocols);
787
 
788
  if(FALSE === array_key_exists($attrname, $attrarr)) {
@@ -794,11 +315,11 @@ function wp_kses_hair($attr, $allowed_protocols) {
794
  break;
795
  }
796
 
797
- if (preg_match("%^'([^']*)'(\s+|/?$)%", $attr, $match))
798
  # 'value'
799
  {
800
  $thisval = $match[1];
801
- if ( in_array(strtolower($attrname), $uris) )
802
  $thisval = wp_kses_bad_protocol($thisval, $allowed_protocols);
803
 
804
  if(FALSE === array_key_exists($attrname, $attrarr)) {
@@ -810,11 +331,11 @@ function wp_kses_hair($attr, $allowed_protocols) {
810
  break;
811
  }
812
 
813
- if (preg_match("%^([^\s\"']+)(\s+|/?$)%", $attr, $match))
814
  # value
815
  {
816
  $thisval = $match[1];
817
- if ( in_array(strtolower($attrname), $uris) )
818
  $thisval = wp_kses_bad_protocol($thisval, $allowed_protocols);
819
 
820
  if(FALSE === array_key_exists($attrname, $attrarr)) {
@@ -853,10 +374,10 @@ function wp_kses_hair($attr, $allowed_protocols) {
853
  * @since 1.0.0
854
  *
855
  * @param string $value Attribute value
856
- * @param string $vless Whether the value is valueless. Use 'y' or 'n'
857
  * @param string $checkname What $checkvalue is checking for.
858
  * @param mixed $checkvalue What constraint the value should pass
859
- * @return bool Whether check passes
860
  */
861
  function wp_kses_check_attr_val($value, $vless, $checkname, $checkvalue) {
862
  $ok = true;
@@ -932,6 +453,7 @@ function wp_kses_check_attr_val($value, $vless, $checkname, $checkvalue) {
932
  */
933
  function wp_kses_bad_protocol($string, $allowed_protocols) {
934
  $string = wp_kses_no_null($string);
 
935
  $string2 = $string.'a';
936
 
937
  while ($string != $string2) {
@@ -1037,9 +559,14 @@ function wp_kses_html_error($string) {
1037
  * @return string Sanitized content
1038
  */
1039
  function wp_kses_bad_protocol_once($string, $allowed_protocols) {
1040
- $string2 = preg_split( '/:|&#0*58;|&#x0*3a;/i', $string, 2 );
1041
- if ( isset($string2[1]) && ! preg_match('%/\?%', $string2[0]) )
1042
- $string = wp_kses_bad_protocol_once2( $string2[0], $allowed_protocols ) . trim( $string2[1] );
 
 
 
 
 
1043
 
1044
  return $string;
1045
  }
@@ -1053,19 +580,31 @@ function wp_kses_bad_protocol_once($string, $allowed_protocols) {
1053
  * @access private
1054
  * @since 1.0.0
1055
  *
1056
- * @param string $string URI scheme to check against the whitelist
1057
- * @param string $allowed_protocols Allowed protocols
1058
  * @return string Sanitized content
1059
  */
1060
- function wp_kses_bad_protocol_once2( $string, $allowed_protocols ) {
 
 
 
 
 
 
 
 
 
 
 
1061
  $string2 = wp_kses_decode_entities($string);
1062
  $string2 = preg_replace('/\s/', '', $string2);
1063
  $string2 = wp_kses_no_null($string2);
 
 
1064
  $string2 = strtolower($string2);
1065
 
1066
  $allowed = false;
1067
- foreach ( (array) $allowed_protocols as $one_protocol )
1068
- if ( strtolower($one_protocol) == $string2 ) {
1069
  $allowed = true;
1070
  break;
1071
  }
@@ -1094,34 +633,13 @@ function wp_kses_normalize_entities($string) {
1094
 
1095
  # Change back the allowed entities in our entity whitelist
1096
 
1097
- $string = preg_replace_callback('/&amp;([A-Za-z]{2,8});/', 'wp_kses_named_entities', $string);
1098
- $string = preg_replace_callback('/&amp;#(0*[0-9]{1,7});/', 'wp_kses_normalize_entities2', $string);
1099
- $string = preg_replace_callback('/&amp;#[Xx](0*[0-9A-Fa-f]{1,6});/', 'wp_kses_normalize_entities3', $string);
1100
 
1101
  return $string;
1102
  }
1103
 
1104
- /**
1105
- * Callback for wp_kses_normalize_entities() regular expression.
1106
- *
1107
- * This function only accepts valid named entity references, which are finite,
1108
- * case-sensitive, and highly scrutinized by HTML and XML validators.
1109
- *
1110
- * @since 3.0.0
1111
- *
1112
- * @param array $matches preg_replace_callback() matches array
1113
- * @return string Correctly encoded entity
1114
- */
1115
- function wp_kses_named_entities($matches) {
1116
- global $allowedentitynames;
1117
-
1118
- if ( empty($matches[1]) )
1119
- return '';
1120
-
1121
- $i = $matches[1];
1122
- return ( ( ! in_array($i, $allowedentitynames) ) ? "&amp;$i;" : "&$i;" );
1123
- }
1124
-
1125
  /**
1126
  * Callback for wp_kses_normalize_entities() regular expression.
1127
  *
@@ -1135,18 +653,11 @@ function wp_kses_named_entities($matches) {
1135
  * @return string Correctly encoded entity
1136
  */
1137
  function wp_kses_normalize_entities2($matches) {
1138
- if ( empty($matches[1]) )
1139
  return '';
1140
 
1141
  $i = $matches[1];
1142
- if (valid_unicode($i)) {
1143
- $i = str_pad(ltrim($i,'0'), 3, '0', STR_PAD_LEFT);
1144
- $i = "&#$i;";
1145
- } else {
1146
- $i = "&amp;#$i;";
1147
- }
1148
-
1149
- return $i;
1150
  }
1151
 
1152
  /**
@@ -1161,11 +672,11 @@ function wp_kses_normalize_entities2($matches) {
1161
  * @return string Correctly encoded entity
1162
  */
1163
  function wp_kses_normalize_entities3($matches) {
1164
- if ( empty($matches[1]) )
1165
  return '';
1166
 
1167
- $hexchars = $matches[1];
1168
- return ( ( ! valid_unicode(hexdec($hexchars)) ) ? "&amp;#x$hexchars;" : '&#x'.ltrim($hexchars,'0').';' );
1169
  }
1170
 
1171
  /**
@@ -1194,160 +705,8 @@ function valid_unicode($i) {
1194
  * @return string Content after decoded entities
1195
  */
1196
  function wp_kses_decode_entities($string) {
1197
- $string = preg_replace_callback('/&#([0-9]+);/', '_wp_kses_decode_entities_chr', $string);
1198
- $string = preg_replace_callback('/&#[Xx]([0-9A-Fa-f]+);/', '_wp_kses_decode_entities_chr_hexdec', $string);
1199
 
1200
  return $string;
1201
  }
1202
-
1203
- /**
1204
- * Regex callback for wp_kses_decode_entities()
1205
- *
1206
- * @param array $match preg match
1207
- * @return string
1208
- */
1209
- function _wp_kses_decode_entities_chr( $match ) {
1210
- return chr( $match[1] );
1211
- }
1212
-
1213
- /**
1214
- * Regex callback for wp_kses_decode_entities()
1215
- *
1216
- * @param array $match preg match
1217
- * @return string
1218
- */
1219
- function _wp_kses_decode_entities_chr_hexdec( $match ) {
1220
- return chr( hexdec( $match[1] ) );
1221
- }
1222
-
1223
- /**
1224
- * Sanitize content with allowed HTML Kses rules.
1225
- *
1226
- * @since 1.0.0
1227
- * @uses $allowedtags
1228
- *
1229
- * @param string $data Content to filter, expected to be escaped with slashes
1230
- * @return string Filtered content
1231
- */
1232
- function wp_filter_kses($data) {
1233
- global $allowedtags;
1234
- return addslashes( wp_kses(stripslashes( $data ), $allowedtags) );
1235
- }
1236
-
1237
- /**
1238
- * Sanitize content with allowed HTML Kses rules.
1239
- *
1240
- * @since 2.9.0
1241
- * @uses $allowedtags
1242
- *
1243
- * @param string $data Content to filter, expected to not be escaped
1244
- * @return string Filtered content
1245
- */
1246
- function wp_kses_data($data) {
1247
- global $allowedtags;
1248
- return wp_kses( $data , $allowedtags );
1249
- }
1250
-
1251
- /**
1252
- * Sanitize content for allowed HTML tags for post content.
1253
- *
1254
- * Post content refers to the page contents of the 'post' type and not $_POST
1255
- * data from forms.
1256
- *
1257
- * @since 2.0.0
1258
- * @uses $allowedposttags
1259
- *
1260
- * @param string $data Post content to filter, expected to be escaped with slashes
1261
- * @return string Filtered post content with allowed HTML tags and attributes intact.
1262
- */
1263
- function wp_filter_post_kses($data) {
1264
- global $allowedposttags;
1265
- return addslashes ( wp_kses(stripslashes( $data ), $allowedposttags) );
1266
- }
1267
-
1268
- /**
1269
- * Sanitize content for allowed HTML tags for post content.
1270
- *
1271
- * Post content refers to the page contents of the 'post' type and not $_POST
1272
- * data from forms.
1273
- *
1274
- * @since 2.9.0
1275
- * @uses $allowedposttags
1276
- *
1277
- * @param string $data Post content to filter
1278
- * @return string Filtered post content with allowed HTML tags and attributes intact.
1279
- */
1280
- function wp_kses_post($data) {
1281
- global $allowedposttags;
1282
- return wp_kses( $data , $allowedposttags );
1283
- }
1284
-
1285
- /**
1286
- * Strips all of the HTML in the content.
1287
- *
1288
- * @since 2.1.0
1289
- *
1290
- * @param string $data Content to strip all HTML from
1291
- * @return string Filtered content without any HTML
1292
- */
1293
- function wp_filter_nohtml_kses($data) {
1294
- return addslashes ( wp_kses(stripslashes( $data ), array()) );
1295
- }
1296
-
1297
- // ! function kses_init_filters()
1298
- // ! function kses_remove_filters()
1299
- // ! function kses_init()
1300
-
1301
- /**
1302
- * Inline CSS filter
1303
- *
1304
- * @since 2.8.1
1305
- */
1306
- function safecss_filter_attr( $css, $deprecated = '' ) {
1307
- if ( !empty( $deprecated ) )
1308
- _deprecated_argument( __FUNCTION__, '2.8.1' ); // Never implemented
1309
-
1310
- $css = wp_kses_no_null($css);
1311
- $css = str_replace(array("\n","\r","\t"), '', $css);
1312
-
1313
- if ( preg_match( '%[\\(&=}]|/\*%', $css ) ) // remove any inline css containing \ ( & } = or comments
1314
- return '';
1315
-
1316
- $css_array = explode( ';', trim( $css ) );
1317
- $allowed_attr = apply_filters( 'safe_style_css', array( 'text-align', 'margin', 'color', 'float',
1318
- 'border', 'background', 'background-color', 'border-bottom', 'border-bottom-color',
1319
- 'border-bottom-style', 'border-bottom-width', 'border-collapse', 'border-color', 'border-left',
1320
- 'border-left-color', 'border-left-style', 'border-left-width', 'border-right', 'border-right-color',
1321
- 'border-right-style', 'border-right-width', 'border-spacing', 'border-style', 'border-top',
1322
- 'border-top-color', 'border-top-style', 'border-top-width', 'border-width', 'caption-side',
1323
- 'clear', 'cursor', 'direction', 'font', 'font-family', 'font-size', 'font-style',
1324
- 'font-variant', 'font-weight', 'height', 'letter-spacing', 'line-height', 'margin-bottom',
1325
- 'margin-left', 'margin-right', 'margin-top', 'overflow', 'padding', 'padding-bottom',
1326
- 'padding-left', 'padding-right', 'padding-top', 'text-decoration', 'text-indent', 'vertical-align',
1327
- 'width' ) );
1328
-
1329
- if ( empty($allowed_attr) )
1330
- return $css;
1331
-
1332
- $css = '';
1333
- foreach ( $css_array as $css_item ) {
1334
- if ( $css_item == '' )
1335
- continue;
1336
- $css_item = trim( $css_item );
1337
- $found = false;
1338
- if ( strpos( $css_item, ':' ) === false ) {
1339
- $found = true;
1340
- } else {
1341
- $parts = split( ':', $css_item );
1342
- if ( in_array( trim( $parts[0] ), $allowed_attr ) )
1343
- $found = true;
1344
- }
1345
- if ( $found ) {
1346
- if( $css != '' )
1347
- $css .= ';';
1348
- $css .= $css_item;
1349
- }
1350
- }
1351
-
1352
- return $css;
1353
- }
1
  <?php
2
+ // Last sync [WP11537]
3
 
4
  /**
5
+ * HTML/XHTML filter that only allows some elements and attributes
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  *
7
  * Added wp_ prefix to avoid conflicts with existing kses users
8
  *
9
  * @version 0.2.2
10
  * @copyright (C) 2002, 2003, 2005
11
+ * @author Ulf Harnhammar <metaur@users.sourceforge.net>
12
  *
13
  * @package External
14
  * @subpackage KSES
15
  *
16
+ * @internal
17
+ * *** CONTACT INFORMATION ***
18
+ * E-mail: metaur at users dot sourceforge dot net
19
+ * Web page: http://sourceforge.net/projects/kses
20
+ * Paper mail: Ulf Harnhammar
21
+ * Ymergatan 17 C
22
+ * 753 25 Uppsala
23
+ * SWEDEN
24
  *
25
+ * [kses strips evil scripts!]
26
  */
27
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
  /**
30
  * Filters content and keeps only allowable HTML elements.
35
  * call this function.
36
  *
37
  * The default allowed protocols are 'http', 'https', 'ftp', 'mailto', 'news',
38
+ * 'irc', 'gopher', 'nntp', 'feed', and finally 'telnet. This covers all common
39
+ * link protocols, except for 'javascript' which should not be allowed for
40
+ * untrusted users.
41
  *
42
  * @since 1.0.0
43
  *
46
  * @param array $allowed_protocols Optional. Allowed protocol in links.
47
  * @return string Filtered content with only allowed HTML elements
48
  */
49
+ function wp_kses($string, $allowed_html, $allowed_protocols = array ('http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet')) {
 
50
  $string = wp_kses_no_null($string);
51
  $string = wp_kses_js_entities($string);
52
  $string = wp_kses_normalize_entities($string);
100
  global $pass_allowed_html, $pass_allowed_protocols;
101
  $pass_allowed_html = $allowed_html;
102
  $pass_allowed_protocols = $allowed_protocols;
103
+ return preg_replace_callback('%((<!--.*?(-->|$))|(<[^>]*(>|$)|>))%',
104
+ create_function('$match', 'global $pass_allowed_html, $pass_allowed_protocols; return wp_kses_split2($match[1], $pass_allowed_html, $pass_allowed_protocols);'), $string);
 
 
 
 
 
 
 
 
 
 
105
  }
106
 
107
  /**
186
  # Is there a closing XHTML slash at the end of the attributes?
187
 
188
  $xhtml_slash = '';
189
+ if (preg_match('%\s/\s*$%', $attr))
190
  $xhtml_slash = ' /';
191
 
192
  # Are any attributes allowed at all for this element?
224
  break;
225
  }
226
 
 
 
 
 
 
 
 
 
 
 
 
 
 
227
  if ($ok)
228
  $attr2 .= ' '.$arreach['whole']; # it passed them
229
  } # if !is_array($current)
299
 
300
  case 2 : # attribute value, a URL after href= for instance
301
 
302
+ if (preg_match('/^"([^"]*)"(\s+|$)/', $attr, $match))
303
  # "value"
304
  {
305
  $thisval = $match[1];
306
+ if ( in_array($attrname, $uris) )
307
  $thisval = wp_kses_bad_protocol($thisval, $allowed_protocols);
308
 
309
  if(FALSE === array_key_exists($attrname, $attrarr)) {
315
  break;
316
  }
317
 
318
+ if (preg_match("/^'([^']*)'(\s+|$)/", $attr, $match))
319
  # 'value'
320
  {
321
  $thisval = $match[1];
322
+ if ( in_array($attrname, $uris) )
323
  $thisval = wp_kses_bad_protocol($thisval, $allowed_protocols);
324
 
325
  if(FALSE === array_key_exists($attrname, $attrarr)) {
331
  break;
332
  }
333
 
334
+ if (preg_match("%^([^\s\"']+)(\s+|$)%", $attr, $match))
335
  # value
336
  {
337
  $thisval = $match[1];
338
+ if ( in_array($attrname, $uris) )
339
  $thisval = wp_kses_bad_protocol($thisval, $allowed_protocols);
340
 
341
  if(FALSE === array_key_exists($attrname, $attrarr)) {
374
  * @since 1.0.0
375
  *
376
  * @param string $value Attribute value
377
+ * @param string $vless Whether the value is valueless or not. Use 'y' or 'n'
378
  * @param string $checkname What $checkvalue is checking for.
379
  * @param mixed $checkvalue What constraint the value should pass
380
+ * @return bool Whether check passes (true) or not (false)
381
  */
382
  function wp_kses_check_attr_val($value, $vless, $checkname, $checkvalue) {
383
  $ok = true;
453
  */
454
  function wp_kses_bad_protocol($string, $allowed_protocols) {
455
  $string = wp_kses_no_null($string);
456
+ $string = preg_replace('/\xad+/', '', $string); # deals with Opera "feature"
457
  $string2 = $string.'a';
458
 
459
  while ($string != $string2) {
559
  * @return string Sanitized content
560
  */
561
  function wp_kses_bad_protocol_once($string, $allowed_protocols) {
562
+ global $_kses_allowed_protocols;
563
+ $_kses_allowed_protocols = $allowed_protocols;
564
+
565
+ $string2 = preg_split('/:|&#58;|&#x3a;/i', $string, 2);
566
+ if ( isset($string2[1]) && !preg_match('%/\?%', $string2[0]) )
567
+ $string = wp_kses_bad_protocol_once2($string2[0]) . trim($string2[1]);
568
+ else
569
+ $string = preg_replace_callback('/^((&[^;]*;|[\sA-Za-z0-9])*)'.'(:|&#58;|&#[Xx]3[Aa];)\s*/', 'wp_kses_bad_protocol_once2', $string);
570
 
571
  return $string;
572
  }
580
  * @access private
581
  * @since 1.0.0
582
  *
583
+ * @param mixed $matches string or preg_replace_callback() matches array to check for bad protocols
 
584
  * @return string Sanitized content
585
  */
586
+ function wp_kses_bad_protocol_once2($matches) {
587
+ global $_kses_allowed_protocols;
588
+
589
+ if ( is_array($matches) ) {
590
+ if ( ! isset($matches[1]) || empty($matches[1]) )
591
+ return '';
592
+
593
+ $string = $matches[1];
594
+ } else {
595
+ $string = $matches;
596
+ }
597
+
598
  $string2 = wp_kses_decode_entities($string);
599
  $string2 = preg_replace('/\s/', '', $string2);
600
  $string2 = wp_kses_no_null($string2);
601
+ $string2 = preg_replace('/\xad+/', '', $string2);
602
+ # deals with Opera "feature"
603
  $string2 = strtolower($string2);
604
 
605
  $allowed = false;
606
+ foreach ( (array) $_kses_allowed_protocols as $one_protocol)
607
+ if (strtolower($one_protocol) == $string2) {
608
  $allowed = true;
609
  break;
610
  }
633
 
634
  # Change back the allowed entities in our entity whitelist
635
 
636
+ $string = preg_replace('/&amp;([A-Za-z][A-Za-z0-9]{0,19});/', '&\\1;', $string);
637
+ $string = preg_replace_callback('/&amp;#0*([0-9]{1,5});/', 'wp_kses_normalize_entities2', $string);
638
+ $string = preg_replace_callback('/&amp;#([Xx])0*(([0-9A-Fa-f]{2}){1,2});/', 'wp_kses_normalize_entities3', $string);
639
 
640
  return $string;
641
  }
642
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
643
  /**
644
  * Callback for wp_kses_normalize_entities() regular expression.
645
  *
653
  * @return string Correctly encoded entity
654
  */
655
  function wp_kses_normalize_entities2($matches) {
656
+ if ( ! isset($matches[1]) || empty($matches[1]) )
657
  return '';
658
 
659
  $i = $matches[1];
660
+ return ( ( ! valid_unicode($i) ) || ($i > 65535) ? "&amp;#$i;" : "&#$i;" );
 
 
 
 
 
 
 
661
  }
662
 
663
  /**
672
  * @return string Correctly encoded entity
673
  */
674
  function wp_kses_normalize_entities3($matches) {
675
+ if ( ! isset($matches[2]) || empty($matches[2]) )
676
  return '';
677
 
678
+ $hexchars = $matches[2];
679
+ return ( ( ! valid_unicode(hexdec($hexchars)) ) ? "&amp;#x$hexchars;" : "&#x$hexchars;" );
680
  }
681
 
682
  /**
705
  * @return string Content after decoded entities
706
  */
707
  function wp_kses_decode_entities($string) {
708
+ $string = preg_replace_callback('/&#([0-9]+);/', create_function('$match', 'return chr($match[1]);'), $string);
709
+ $string = preg_replace_callback('/&#[Xx]([0-9A-Fa-f]+);/', create_function('$match', 'return chr(hexdec($match[1]));'), $string);
710
 
711
  return $string;
712
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-forums/bbpress/bb-includes/class.bp-options.php CHANGED
@@ -25,6 +25,9 @@ class BP_Options
25
  case 'cron_uri':
26
  return bb_get_uri( 'bb-cron.php', array( 'check' => BP_Options::get( 'cron_check' ) ), BB_URI_CONTEXT_WP_HTTP_REQUEST );
27
  break;
 
 
 
28
  case 'wp_http_version':
29
  return 'bbPress/' . bb_get_option( 'version' );
30
  break;
25
  case 'cron_uri':
26
  return bb_get_uri( 'bb-cron.php', array( 'check' => BP_Options::get( 'cron_check' ) ), BB_URI_CONTEXT_WP_HTTP_REQUEST );
27
  break;
28
+ case 'cron_check':
29
+ return bb_hash( '187425' );
30
+ break;
31
  case 'wp_http_version':
32
  return 'bbPress/' . bb_get_option( 'version' );
33
  break;
bp-forums/bbpress/bb-includes/functions.bb-core.php CHANGED
@@ -351,45 +351,16 @@ function bb_timer_stop($display = 0, $precision = 3) { //if called like bb_timer
351
  }
352
 
353
  // GMT -> so many minutes ago
354
- function bb_since( $original, $args = '' )
355
- {
356
- $defaults = array(
357
- 'levels' => 1,
358
- 'separator' => ', '
359
- );
360
-
361
- // $args used to be $do_more
362
- // $do_more = 0 is equivalent to $args['levels'] = 1
363
- // $do_more = 1 is equivalent to $args['levels'] = 2
364
- if ( !is_array( $args ) ) {
365
- $args = array(
366
- 'levels' => abs( (integer) $args ) + 1
367
- );
368
- }
369
-
370
- $args = wp_parse_args( $args, $defaults );
371
- extract( $args, EXTR_SKIP );
372
 
373
- $today = (integer) time();
374
-
375
- if ( !is_numeric( $original ) ) {
376
- if ( $today < $_original = bb_gmtstrtotime( str_replace( ',', ' ', $original ) ) ) { // Looks like bb_since was called twice
377
  return $original;
378
- } else {
379
  $original = $_original;
380
- }
381
- }
382
-
383
- $seconds = $today - ( (integer) $original );
384
- if ( 0 === $seconds ) {
385
- return sprintf( _n( '%d second', '%d seconds', 0 ), 0 );
386
- }
387
-
388
- $levels = abs( (integer) $levels );
389
- if ( 0 === $levels ) {
390
- return '';
391
  }
392
-
393
  // array of time period chunks
394
  $chunks = array(
395
  ( 60 * 60 * 24 * 365 ), // years
@@ -401,35 +372,33 @@ function bb_since( $original, $args = '' )
401
  ( 1 ) // seconds
402
  );
403
 
404
- $caught = 0;
405
- $parts = array();
406
- for ( $i = 0; $i < count( $chunks ); $i++ ) {
407
- if ( ( $count = floor( $seconds / $chunks[$i] ) ) || $caught ) {
408
- if ( $count ) {
409
- $trans = array(
410
- _n( '%d year', '%d years', $count ),
411
- _n( '%d month', '%d months', $count ),
412
- _n( '%d week', '%d weeks', $count ),
413
- _n( '%d day', '%d days', $count ),
414
- _n( '%d hour', '%d hours', $count ),
415
- _n( '%d minute', '%d minutes', $count ),
416
- _n( '%d second', '%d seconds', $count )
417
- );
418
- $parts[] = sprintf( $trans[$i], $count );
419
- }
420
- $caught++;
421
- $seconds = $seconds - ( $count * $chunks[$i] );
422
- }
423
- if ( $caught === $levels ) {
424
  break;
425
- }
426
  }
427
 
428
- if ( empty( $parts ) ) {
429
- return sprintf( _n( '%d second', '%d seconds', 0 ), 0 );
430
- }
 
 
 
 
 
 
 
 
431
 
432
- return join( $separator, $parts );
 
 
 
 
 
433
  }
434
 
435
  function bb_current_time( $type = 'timestamp' ) {
@@ -732,13 +701,9 @@ function bb_repermalink() {
732
  $user = bb_get_current_user(); // Attempt to go to the current users profile
733
  } else {
734
  if ( bb_get_option( 'mod_rewrite' ) === 'slugs') {
735
- if ( !$user = bb_get_user_by_nicename( $id ) ) {
736
- $user = bb_get_user( $id );
737
- }
738
  } else {
739
- if ( !$user = bb_get_user( $id ) ) {
740
- $user = bb_get_user_by_nicename( $id );
741
- }
742
  }
743
  }
744
 
351
  }
352
 
353
  // GMT -> so many minutes ago
354
+ function bb_since( $original, $do_more = 0 ) {
355
+ $today = time();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
356
 
357
+ if ( !is_numeric($original) ) {
358
+ if ( $today < $_original = bb_gmtstrtotime( str_replace(',', ' ', $original) ) ) // Looks like bb_since was called twice
 
 
359
  return $original;
360
+ else
361
  $original = $_original;
 
 
 
 
 
 
 
 
 
 
 
362
  }
363
+
364
  // array of time period chunks
365
  $chunks = array(
366
  ( 60 * 60 * 24 * 365 ), // years
372
  ( 1 ) // seconds
373
  );
374
 
375
+ $since = $today - $original;
376
+
377
+ for ($i = 0, $j = count($chunks); $i < $j; $i++) {
378
+ $seconds = $chunks[$i];
379
+
380
+ if ( 0 != $count = floor($since / $seconds) )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
381
  break;
 
382
  }
383
 
384
+ $trans = array(
385
+ _n( '%d year', '%d years', $count ),
386
+ _n( '%d month', '%d months', $count ),
387
+ _n( '%d week', '%d weeks', $count ),
388
+ _n( '%d day', '%d days', $count ),
389
+ _n( '%d hour', '%d hours', $count ),
390
+ _n( '%d minute', '%d minutes', $count ),
391
+ _n( '%d second', '%d seconds', $count )
392
+ );
393
+
394
+ $print = sprintf( $trans[$i], $count );
395
 
396
+ if ( $do_more && $i + 1 < $j) {
397
+ $seconds2 = $chunks[$i + 1];
398
+ if ( 0 != $count2 = floor( ($since - $seconds * $count) / $seconds2) )
399
+ $print .= sprintf( $trans[$i + 1], $count2 );
400
+ }
401
+ return $print;
402
  }
403
 
404
  function bb_current_time( $type = 'timestamp' ) {
701
  $user = bb_get_current_user(); // Attempt to go to the current users profile
702
  } else {
703
  if ( bb_get_option( 'mod_rewrite' ) === 'slugs') {
704
+ $user = bb_get_user_by_nicename( $id ); // Get by the user_nicename
 
 
705
  } else {
706
+ $user = bb_get_user( $id ); // Get by the ID
 
 
707
  }
708
  }
709
 
bp-forums/bbpress/bb-includes/functions.bb-deprecated.php CHANGED
@@ -640,11 +640,8 @@ function bb_pull_cols( $obj_array ) {
640
 
641
  // $length parameter is deprecated
642
  function bb_random_pass( $length ) {
643
- bb_log_deprecated('function', __FUNCTION__, 'bb_generate_password');
644
- if ( 12 < (int) $length ) {
645
- $length = 12;
646
- }
647
- return bb_generate_password( $length );
648
  }
649
 
650
  // Old RSS related functions
640
 
641
  // $length parameter is deprecated
642
  function bb_random_pass( $length ) {
643
+ bb_log_deprecated('function', __FUNCTION__, 'wp_generate_password');
644
+ return wp_generate_password();
 
 
 
645
  }
646
 
647
  // Old RSS related functions
bp-forums/bbpress/bb-includes/functions.bb-meta.php CHANGED
@@ -297,7 +297,7 @@ function bb_get_option( $option )
297
  $r = $bb_locale->text_direction;
298
  break;
299
  case 'version':
300
- return '1.0.4'; // Don't filter
301
  break;
302
  case 'bb_db_version' :
303
  return '2078'; // Don't filter
297
  $r = $bb_locale->text_direction;
298
  break;
299
  case 'version':
300
+ return '1.0.2'; // Don't filter
301
  break;
302
  case 'bb_db_version' :
303
  return '2078'; // Don't filter
bp-forums/bbpress/bb-includes/functions.bb-pluggable.php CHANGED
@@ -368,19 +368,20 @@ function bb_create_nonce($action = -1) {
368
  }
369
  endif;
370
 
371
- function _bb_get_key( $key, $default_key = false )
372
- {
373
- global $bb_default_secret_key;
 
 
374
 
375
- if ( defined( $key ) && '' != constant( $key ) && $bb_default_secret_key != constant( $key ) ) {
376
  return constant( $key );
377
  }
378
 
379
- return '';
380
  }
381
 
382
- function _bb_get_salt( $constants, $option = false )
383
- {
384
  if ( !is_array( $constants ) ) {
385
  $constants = array( $constants );
386
  }
@@ -397,7 +398,7 @@ function _bb_get_salt( $constants, $option = false )
397
  }
398
  $salt = bb_get_option( $option );
399
  if ( empty( $salt ) ) {
400
- $salt = bb_generate_password( 64 );
401
  bb_update_option( $option, $salt );
402
  }
403
  return $salt;
@@ -418,29 +419,27 @@ if ( !function_exists( 'bb_salt' ) ) :
418
  *
419
  * @return string Salt value for the given scheme
420
  */
421
- function bb_salt( $scheme = 'auth' )
422
- {
423
- // Deprecated
424
  $secret_key = _bb_get_key( 'BB_SECRET_KEY' );
425
 
426
  switch ($scheme) {
427
  case 'auth':
428
- $secret_key = _bb_get_key( 'BB_AUTH_KEY' );
429
  $salt = _bb_get_salt( array( 'BB_AUTH_SALT', 'BB_SECRET_SALT' ) );
430
  break;
431
 
432
  case 'secure_auth':
433
- $secret_key = _bb_get_key( 'BB_SECURE_AUTH_KEY' );
434
  $salt = _bb_get_salt( 'BB_SECURE_AUTH_SALT' );
435
  break;
436
 
437
  case 'logged_in':
438
- $secret_key = _bb_get_key( 'BB_LOGGED_IN_KEY' );
439
  $salt = _bb_get_salt( 'BB_LOGGED_IN_SALT' );
440
  break;
441
 
442
  case 'nonce':
443
- $secret_key = _bb_get_key( 'BB_NONCE_KEY' );
444
  $salt = _bb_get_salt( 'BB_NONCE_SALT' );
445
  break;
446
 
368
  }
369
  endif;
370
 
371
+ function _bb_get_key( $key, $default_key = false ) {
372
+ if ( !$default_key ) {
373
+ global $bb_default_secret_key;
374
+ $default_key = $bb_default_secret_key;
375
+ }
376
 
377
+ if ( defined( $key ) && '' != constant( $key ) && $default_key != constant( $key ) ) {
378
  return constant( $key );
379
  }
380
 
381
+ return $default_key;
382
  }
383
 
384
+ function _bb_get_salt( $constants, $option = false ) {
 
385
  if ( !is_array( $constants ) ) {
386
  $constants = array( $constants );
387
  }
398
  }
399
  $salt = bb_get_option( $option );
400
  if ( empty( $salt ) ) {
401
+ $salt = bb_generate_password();
402
  bb_update_option( $option, $salt );
403
  }
404
  return $salt;
419
  *
420
  * @return string Salt value for the given scheme
421
  */
422
+ function bb_salt($scheme = 'auth') {
 
 
423
  $secret_key = _bb_get_key( 'BB_SECRET_KEY' );
424
 
425
  switch ($scheme) {
426
  case 'auth':
427
+ $secret_key = _bb_get_key( 'BB_AUTH_KEY', $secret_key );
428
  $salt = _bb_get_salt( array( 'BB_AUTH_SALT', 'BB_SECRET_SALT' ) );
429
  break;
430
 
431
  case 'secure_auth':
432
+ $secret_key = _bb_get_key( 'BB_SECURE_AUTH_KEY', $secret_key );
433
  $salt = _bb_get_salt( 'BB_SECURE_AUTH_SALT' );
434
  break;
435
 
436
  case 'logged_in':
437
+ $secret_key = _bb_get_key( 'BB_LOGGED_IN_KEY', $secret_key );
438
  $salt = _bb_get_salt( 'BB_LOGGED_IN_SALT' );
439
  break;
440
 
441
  case 'nonce':
442
+ $secret_key = _bb_get_key( 'BB_NONCE_KEY', $secret_key );
443
  $salt = _bb_get_salt( 'BB_NONCE_SALT' );
444
  break;
445
 
bp-forums/bbpress/bb-includes/functions.bb-posts.php CHANGED
@@ -94,7 +94,6 @@ function bb_cache_first_posts( $_topics = false, $author_cache = true ) {
94
  function bb_cache_posts( $query, $post_id_query = false ) {
95
  global $bbdb;
96
 
97
- $_query = '';
98
  $_query_post_ids = array();
99
  $_query_posts = array();
100
  $_cached_posts = array();
94
  function bb_cache_posts( $query, $post_id_query = false ) {
95
  global $bbdb;
96
 
 
97
  $_query_post_ids = array();
98
  $_query_posts = array();
99
  $_cached_posts = array();
bp-forums/bbpress/bb-includes/functions.bb-template.php CHANGED
@@ -254,13 +254,13 @@ function bb_post_template() {
254
  function post_form( $args = array() ) {
255
  global $page, $topic, $forum;
256
 
 
 
 
257
  $defaults = array(
258
  'h2' => '',
259
  'last_page_only' => true
260
  );
261
- if ( is_string( $args ) ) {
262
- $defaults['h2'] = $args;
263
- }
264
  $args = wp_parse_args( $args, $defaults );
265
  extract( $args, EXTR_SKIP );
266
 
@@ -1523,13 +1523,17 @@ function bb_get_topic_move_dropdown( $args = '' )
1523
  if ( !$dropdown )
1524
  return;
1525
 
1526
- $r = $before . '<form id="topic-move" method="post" action="' . bb_get_uri( 'bb-admin/topic-move.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN ) . '"><fieldset><div>' . "\n";
 
 
1527
  $r .= '<input type="hidden" name="topic_id" value="' . $topic->topic_id . '" />' . "\n";
1528
  $r .= '<label for="forum-id">'. __( 'Move to' ) . '</label>' . "\n";
1529
  $r .= $dropdown . "\n";
1530
  $r .= bb_nonce_field( 'move-topic_' . $topic->topic_id, '_wpnonce', true , false );
1531
  $r .= '<input type="submit" name="Submit" value="' . __( 'Move' ) . '" />' . "\n";
1532
- $r .= '</div></fieldset></form>' . $after;
 
 
1533
 
1534
  return $r;
1535
  }
@@ -3502,9 +3506,6 @@ function _bb_time_function_return( $time, $args ) {
3502
  case 'mysql' :
3503
  $format = 'Y-m-d H:i:s';
3504
  break;
3505
- case 'datetime' :
3506
- $format = bb_get_option( 'datetime_format' );
3507
- break;
3508
  endswitch;
3509
 
3510
  if ( $args['localize'] ) {
254
  function post_form( $args = array() ) {
255
  global $page, $topic, $forum;
256
 
257
+ if ( is_string( $args ) ) {
258
+ $args['h2'] = $args;
259
+ }
260
  $defaults = array(
261
  'h2' => '',
262
  'last_page_only' => true
263
  );
 
 
 
264
  $args = wp_parse_args( $args, $defaults );
265
  extract( $args, EXTR_SKIP );
266
 
1523
  if ( !$dropdown )
1524
  return;
1525
 
1526
+ $r = $before . '<form id="topic-move" method="post" action="' . bb_get_uri( 'bb-admin/topic-move.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN ) . '">' . "\n";
1527
+ $r .= '<fieldset>' . "\n";
1528
+ $r .= '<div>' . "\n";
1529
  $r .= '<input type="hidden" name="topic_id" value="' . $topic->topic_id . '" />' . "\n";
1530
  $r .= '<label for="forum-id">'. __( 'Move to' ) . '</label>' . "\n";
1531
  $r .= $dropdown . "\n";
1532
  $r .= bb_nonce_field( 'move-topic_' . $topic->topic_id, '_wpnonce', true , false );
1533
  $r .= '<input type="submit" name="Submit" value="' . __( 'Move' ) . '" />' . "\n";
1534
+ $r .= '</div>' . "\n";
1535
+ $r .= '</fieldset>' . "\n";
1536
+ $r .= '</form>' . $after;
1537
 
1538
  return $r;
1539
  }
3506
  case 'mysql' :
3507
  $format = 'Y-m-d H:i:s';
3508
  break;
 
 
 
3509
  endswitch;
3510
 
3511
  if ( $args['localize'] ) {
bp-forums/bbpress/bb-includes/functions.bb-users.php CHANGED
@@ -252,48 +252,37 @@ function bb_update_user( $user_id, $user_email, $user_url, $display_name ) {
252
  * @param string $user_login
253
  * @return bool
254
  */
255
- function bb_reset_email( $user_login )
256
- {
257
  global $bbdb;
258
 
259
  $user_login = sanitize_user( $user_login, true );
260
 
261
- if ( !$user = $bbdb->get_row( $bbdb->prepare( "SELECT * FROM $bbdb->users WHERE user_login = %s", $user_login ) ) ) {
262
- return new WP_Error( 'user_does_not_exist', __( 'The specified user does not exist.' ) );
263
- }
264
 
265
- $resetkey = substr( md5( bb_generate_password() ), 0, 15 );
266
  bb_update_usermeta( $user->ID, 'newpwdkey', $resetkey );
267
 
268
- $reseturi = bb_get_uri(
269
- 'bb-reset-password.php',
270
- array( 'key' => $resetkey ),
271
- BB_URI_CONTEXT_TEXT + BB_URI_CONTEXT_BB_USER_FORMS
272
- );
273
-
274
  $message = sprintf(
275
- __( "If you wanted to reset your password, you may do so by visiting the following address:\n\n%s\n\nIf you don't want to reset your password, just ignore this email. Thanks!" ),
276
- $reseturi
277
- );
278
- $message = apply_filters( 'bb_reset_email_message', $message, $user, $reseturi, $resetkey );
279
-
280
- $subject = sprintf(
281
- __( '%s: Password Reset' ),
282
- bb_get_option( 'name' )
283
  );
284
- $subject = apply_filters( 'bb_reset_email_subject', $subject, $user );
285
 
286
  $mail_result = bb_mail(
287
  bb_get_user_email( $user->ID ),
288
- $subject,
289
  $message
290
  );
291
 
292
- if ( !$mail_result ) {
293
- return new WP_Error( 'sending_mail_failed', __( 'The email containing the password reset link could not be sent.' ) );
 
 
294
  }
295
-
296
- return true;
297
  }
298
 
299
  /**
@@ -308,42 +297,29 @@ function bb_reset_email( $user_login )
308
  * @param string $key
309
  * @return unknown
310
  */
311
- function bb_reset_password( $key )
312
- {
313
  global $bbdb;
314
-
315
  $key = sanitize_user( $key, true );
316
-
317
- if ( empty( $key ) || !is_string( $key ) ) {
318
- return new WP_Error( 'invalid_key', __( 'Invalid key' ) );
319
- }
320
-
321
- if ( !$user_id = $bbdb->get_var( $bbdb->prepare( "SELECT user_id FROM $bbdb->usermeta WHERE meta_key = 'newpwdkey' AND meta_value = %s", $key ) ) ) {
322
- return new WP_Error( 'invalid_key', __( 'Invalid key' ) );
323
- }
324
-
325
- $user = new BP_User( $user_id );
326
-
327
- if ( !$user || is_wp_error( $user ) ) {
328
- return new WP_Error( 'invalid_key', __( 'Invalid key' ) );
329
- }
330
-
331
- if ( bb_has_broken_pass( $user->ID ) ) {
332
- bb_block_current_user();
333
- }
334
-
335
- if ( !$user->has_cap( 'change_user_password', $user->ID ) ) {
336
- return new WP_Error( 'permission_denied', __( 'You are not allowed to change your password.' ) );
337
- }
338
-
339
- $newpass = bb_generate_password();
340
- bb_update_user_password( $user->ID, $newpass );
341
- if ( !bb_send_pass( $user->ID, $newpass ) ) {
342
- return new WP_Error( 'sending_mail_failed', __( 'The email containing the new password could not be sent.' ) );
343
  }
344
-
345
- bb_update_usermeta( $user->ID, 'newpwdkey', '' );
346
- return true;
347
  }
348
 
349
  /**
@@ -381,30 +357,16 @@ function bb_update_user_password( $user_id, $password ) {
381
  * @param string $pass
382
  * @return bool
383
  */
384
- function bb_send_pass( $user, $pass )
385
- {
386
- if ( !$user = bb_get_user( $user ) ) {
387
  return false;
388
- }
389
 
390
- $message = sprintf(
391
- __( "Your username is: %1\$s \nYour password is: %2\$s \nYou can now log in: %3\$s \n\nEnjoy!" ),
392
- $user->user_login,
393
- $pass,
394
- bb_get_uri( null, null, BB_URI_CONTEXT_TEXT )
395
- );
396
- $message = apply_filters( 'bb_send_pass_message', $message, $user, $pass );
397
-
398
- $subject = sprintf(
399
- __( '%s: Password' ),
400
- bb_get_option( 'name' )
401
- );
402
- $subject = apply_filters( 'bb_send_pass_subject', $subject, $user );
403
 
404
  return bb_mail(
405
  bb_get_user_email( $user->ID ),
406
- $subject,
407
- $message
408
  );
409
  }
410
 
252
  * @param string $user_login
253
  * @return bool
254
  */
255
+ function bb_reset_email( $user_login ) {
 
256
  global $bbdb;
257
 
258
  $user_login = sanitize_user( $user_login, true );
259
 
260
+ if ( !$user = $bbdb->get_row( $bbdb->prepare( "SELECT * FROM $bbdb->users WHERE user_login = %s", $user_login ) ) )
261
+ return new WP_Error('user_does_not_exist', __('The specified user does not exist.'));
 
262
 
263
+ $resetkey = substr(md5(bb_generate_password()), 0, 15);
264
  bb_update_usermeta( $user->ID, 'newpwdkey', $resetkey );
265
 
 
 
 
 
 
 
266
  $message = sprintf(
267
+ __("If you wanted to reset your password, you may do so by visiting the following address:\n\n%s\n\nIf you don't want to reset your password, just ignore this email. Thanks!"),
268
+ bb_get_uri(
269
+ 'bb-reset-password.php',
270
+ array('key' => $resetkey),
271
+ BB_URI_CONTEXT_TEXT + BB_URI_CONTEXT_BB_USER_FORMS
272
+ )
 
 
273
  );
 
274
 
275
  $mail_result = bb_mail(
276
  bb_get_user_email( $user->ID ),
277
+ bb_get_option('name') . ': ' . __('Password Reset'),
278
  $message
279
  );
280
 
281
+ if (!$mail_result) {
282
+ return new WP_Error('sending_mail_failed', __('The email containing the password reset link could not be sent.'));
283
+ } else {
284
+ return true;
285
  }
 
 
286
  }
287
 
288
  /**
297
  * @param string $key
298
  * @return unknown
299
  */
300
+ function bb_reset_password( $key ) {
 
301
  global $bbdb;
 
302
  $key = sanitize_user( $key, true );
303
+ if ( empty( $key ) )
304
+ return new WP_Error('key_not_found', __('Key not found.'));
305
+ if ( !$user_id = $bbdb->get_var( $bbdb->prepare( "SELECT user_id FROM $bbdb->usermeta WHERE meta_key = 'newpwdkey' AND meta_value = %s", $key ) ) )
306
+ return new WP_Error('key_not_found', __('Key not found.'));
307
+ if ( $user = new BP_User( $user_id ) ) {
308
+ if ( bb_has_broken_pass( $user->ID ) )
309
+ bb_block_current_user();
310
+ if ( !$user->has_cap( 'change_user_password', $user->ID ) )
311
+ return new WP_Error('permission_denied', __('You are not allowed to change your password.'));
312
+ $newpass = bb_generate_password();
313
+ bb_update_user_password( $user->ID, $newpass );
314
+ if (!bb_send_pass( $user->ID, $newpass )) {
315
+ return new WP_Error('sending_mail_failed', __('The email containing the new password could not be sent.'));
316
+ } else {
317
+ bb_update_usermeta( $user->ID, 'newpwdkey', '' );
318
+ return true;
319
+ }
320
+ } else {
321
+ return new WP_Error('key_not_found', __('Key not found.'));
 
 
 
 
 
 
 
 
322
  }
 
 
 
323
  }
324
 
325
  /**
357
  * @param string $pass
358
  * @return bool
359
  */
360
+ function bb_send_pass( $user, $pass ) {
361
+ if ( !$user = bb_get_user( $user ) )
 
362
  return false;
 
363
 
364
+ $message = __("Your username is: %1\$s \nYour password is: %2\$s \nYou can now log in: %3\$s \n\nEnjoy!");
 
 
 
 
 
 
 
 
 
 
 
 
365
 
366
  return bb_mail(
367
  bb_get_user_email( $user->ID ),
368
+ bb_get_option('name') . ': ' . __('Password'),
369
+ sprintf($message, $user->user_login, $pass, bb_get_uri(null, null, BB_URI_CONTEXT_TEXT))
370
  );
371
  }
372
 
bp-forums/bbpress/bb-includes/js/jquery/interface.js CHANGED
@@ -9,5 +9,4 @@
9
  *
10
  *
11
  */
12
- eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('k.f2={2r:u(M){E q.1E(u(){if(!M.aR||!M.aZ)E;D el=q;el.2l={aq:M.aq||cO,aR:M.aR,aZ:M.aZ,8e:M.8e||\'fV\',aJ:M.aJ||\'fV\',2Y:M.2Y&&2g M.2Y==\'u\'?M.2Y:I,3i:M.2Y&&2g M.3i==\'u\'?M.3i:I,7U:M.7U&&2g M.7U==\'u\'?M.7U:I,as:k(M.aR,q),8f:k(M.aZ,q),H:M.H||8J,67:M.67||0};el.2l.8f.2G().B(\'W\',\'9R\').eq(0).B({W:el.2l.aq+\'U\',19:\'2B\'}).2T();el.2l.as.1E(u(2N){q.7X=2N}).gC(u(){k(q).2R(el.2l.aJ)},u(){k(q).4i(el.2l.aJ)}).1J(\'5h\',u(e){if(el.2l.67==q.7X)E;el.2l.as.eq(el.2l.67).4i(el.2l.8e).2T().eq(q.7X).2R(el.2l.8e).2T();el.2l.8f.eq(el.2l.67).5w({W:0},el.2l.H,u(){q.14.19=\'1o\';if(el.2l.3i){el.2l.3i.1D(el,[q])}}).2T().eq(q.7X).1Y().5w({W:el.2l.aq},el.2l.H,u(){q.14.19=\'2B\';if(el.2l.2Y){el.2l.2Y.1D(el,[q])}}).2T();if(el.2l.7U){el.2l.7U.1D(el,[q,el.2l.8f.K(q.7X),el.2l.as.K(el.2l.67),el.2l.8f.K(el.2l.67)])}el.2l.67=q.7X}).eq(0).2R(el.2l.8e).2T();k(q).B(\'W\',k(q).B(\'W\')).B(\'2U\',\'2K\')})}};k.fn.gN=k.f2.2r;k.aA={2r:u(M){E q.1E(u(){D el=q;D 7E=2*18.2Q/f1;D an=2*18.2Q;if(k(el).B(\'Y\')!=\'2s\'&&k(el).B(\'Y\')!=\'1P\'){k(el).B(\'Y\',\'2s\')}el.1l={1R:k(M.1R,q),2F:M.2F,6q:M.6q,aD:M.aD,an:an,1N:k.1a.2o(q),Y:k.1a.3w(q),26:18.2Q/2,bi:M.bi,8p:M.6r,6r:[],aG:I,7E:2*18.2Q/f1};el.1l.fB=(el.1l.1N.w-el.1l.2F)/2;el.1l.7D=(el.1l.1N.h-el.1l.6q-el.1l.6q*el.1l.8p)/2;el.1l.2D=2*18.2Q/el.1l.1R.1N();el.1l.ba=el.1l.1N.w/2;el.1l.b9=el.1l.1N.h/2-el.1l.6q*el.1l.8p;D ak=1h.3F(\'22\');k(ak).B({Y:\'1P\',3I:1,Q:0,O:0});k(el).1S(ak);el.1l.1R.1E(u(2N){a6=k(\'1T\',q).K(0);W=T(el.1l.6q*el.1l.8p);if(k.3a.4t){3E=1h.3F(\'1T\');k(3E).B(\'Y\',\'1P\');3E.2J=a6.2J;3E.14.5E=\'gE 9n:9w.9y.cC(1G=60, 14=1, gB=0, gA=0, gv=0, gF=0)\'}P{3E=1h.3F(\'3E\');if(3E.fD){4L=3E.fD("2d");3E.14.Y=\'1P\';3E.14.W=W+\'U\';3E.14.Z=el.1l.2F+\'U\';3E.W=W;3E.Z=el.1l.2F;4L.gu();4L.gO(0,W);4L.gk(1,-1);4L.gp(a6,0,0,el.1l.2F,W);4L.6H();4L.gm="gG-4l";D ap=4L.hy(0,0,0,W);ap.fs(1,"fr(1V, 1V, 1V, 1)");ap.fs(0,"fr(1V, 1V, 1V, 0.6)");4L.hx=ap;if(hA.hB.3J(\'hw\')!=-1){4L.hv()}P{4L.hu(0,0,el.1l.2F,W)}}}el.1l.6r[2N]=3E;k(ak).1S(3E)}).1J(\'9z\',u(e){el.1l.aG=1b;el.1l.H=el.1l.7E*0.1*el.1l.H/18.3S(el.1l.H);E I}).1J(\'8B\',u(e){el.1l.aG=I;E I});k.aA.7T(el);el.1l.H=el.1l.7E*0.2;el.1l.ht=1X.6V(u(){el.1l.26+=el.1l.H;if(el.1l.26>an)el.1l.26=0;k.aA.7T(el)},20);k(el).1J(\'8B\',u(){el.1l.H=el.1l.7E*0.2*el.1l.H/18.3S(el.1l.H)}).1J(\'3D\',u(e){if(el.1l.aG==I){1s=k.1a.4a(e);fz=el.1l.1N.w-1s.x+el.1l.Y.x;el.1l.H=el.1l.bi*el.1l.7E*(el.1l.1N.w/2-fz)/(el.1l.1N.w/2)}})})},7T:u(el){el.1l.1R.1E(u(2N){b8=el.1l.26+2N*el.1l.2D;x=el.1l.fB*18.5H(b8);y=el.1l.7D*18.83(b8);f9=T(2a*(el.1l.7D+y)/(2*el.1l.7D));fk=(el.1l.7D+y)/(2*el.1l.7D);Z=T((el.1l.2F-el.1l.aD)*fk+el.1l.aD);W=T(Z*el.1l.6q/el.1l.2F);q.14.Q=el.1l.b9+y-W/2+"U";q.14.O=el.1l.ba+x-Z/2+"U";q.14.Z=Z+"U";q.14.W=W+"U";q.14.3I=f9;el.1l.6r[2N].14.Q=T(el.1l.b9+y+W-1-W/2)+"U";el.1l.6r[2N].14.O=T(el.1l.ba+x-Z/2)+"U";el.1l.6r[2N].14.Z=Z+"U";el.1l.6r[2N].14.W=T(W*el.1l.8p)+"U"})}};k.fn.hI=k.aA.2r;k.23({G:{c8:u(p,n,1W,1H,1m){E((-18.5H(p*18.2Q)/2)+0.5)*1H+1W},hK:u(p,n,1W,1H,1m){E 1H*(n/=1m)*n*n+1W},fl:u(p,n,1W,1H,1m){E-1H*((n=n/1m-1)*n*n*n-1)+1W},hm:u(p,n,1W,1H,1m){if((n/=1m/2)<1)E 1H/2*n*n*n*n+1W;E-1H/2*((n-=2)*n*n*n-2)+1W},8l:u(p,n,1W,1H,1m){if((n/=1m)<(1/2.75)){E 1H*(7.aB*n*n)+1W}P if(n<(2/2.75)){E 1H*(7.aB*(n-=(1.5/2.75))*n+.75)+1W}P if(n<(2.5/2.75)){E 1H*(7.aB*(n-=(2.25/2.75))*n+.gY)+1W}P{E 1H*(7.aB*(n-=(2.h2/2.75))*n+.gX)+1W}},cr:u(p,n,1W,1H,1m){if(k.G.8l)E 1H-k.G.8l(p,1m-n,0,1H,1m)+1W;E 1W+1H},gW:u(p,n,1W,1H,1m){if(k.G.cr&&k.G.8l)if(n<1m/2)E k.G.cr(p,n*2,0,1H,1m)*.5+1W;E k.G.8l(p,n*2-1m,0,1H,1m)*.5+1H*.5+1W;E 1W+1H},gQ:u(p,n,1W,1H,1m){D a,s;if(n==0)E 1W;if((n/=1m)==1)E 1W+1H;a=1H*0.3;p=1m*.3;if(a<18.3S(1H)){a=1H;s=p/4}P{s=p/(2*18.2Q)*18.cb(1H/a)}E-(a*18.6b(2,10*(n-=1))*18.83((n*1m-s)*(2*18.2Q)/p))+1W},gT:u(p,n,1W,1H,1m){D a,s;if(n==0)E 1W;if((n/=1m/2)==2)E 1W+1H;a=1H*0.3;p=1m*.3;if(a<18.3S(1H)){a=1H;s=p/4}P{s=p/(2*18.2Q)*18.cb(1H/a)}E a*18.6b(2,-10*n)*18.83((n*1m-s)*(2*18.2Q)/p)+1H+1W},gV:u(p,n,1W,1H,1m){D a,s;if(n==0)E 1W;if((n/=1m/2)==2)E 1W+1H;a=1H*0.3;p=1m*.3;if(a<18.3S(1H)){a=1H;s=p/4}P{s=p/(2*18.2Q)*18.cb(1H/a)}if(n<1){E-.5*(a*18.6b(2,10*(n-=1))*18.83((n*1m-s)*(2*18.2Q)/p))+1W}E a*18.6b(2,-10*(n-=1))*18.83((n*1m-s)*(2*18.2Q)/p)*.5+1H+1W}}});k.6n={2r:u(M){E q.1E(u(){D el=q;el.1F={1R:k(M.1R,q),1Z:k(M.1Z,q),1M:k.1a.3w(q),2F:M.2F,ax:M.ax,7Y:M.7Y,ge:M.ge,51:M.51,6x:M.6x};k.6n.aH(el,0);k(1X).1J(\'gU\',u(){el.1F.1M=k.1a.3w(el);k.6n.aH(el,0);k.6n.7T(el)});k.6n.7T(el);el.1F.1R.1J(\'9z\',u(){k(el.1F.ax,q).K(0).14.19=\'2B\'}).1J(\'8B\',u(){k(el.1F.ax,q).K(0).14.19=\'1o\'});k(1h).1J(\'3D\',u(e){D 1s=k.1a.4a(e);D 5s=0;if(el.1F.51&&el.1F.51==\'cv\')D aI=1s.x-el.1F.1M.x-(el.4c-el.1F.2F*el.1F.1R.1N())/2-el.1F.2F/2;P if(el.1F.51&&el.1F.51==\'2L\')D aI=1s.x-el.1F.1M.x-el.4c+el.1F.2F*el.1F.1R.1N();P D aI=1s.x-el.1F.1M.x;D fP=18.6b(1s.y-el.1F.1M.y-el.5W/2,2);el.1F.1R.1E(u(2N){45=18.ez(18.6b(aI-2N*el.1F.2F,2)+fP);45-=el.1F.2F/2;45=45<0?0:45;45=45>el.1F.7Y?el.1F.7Y:45;45=el.1F.7Y-45;bB=el.1F.6x*45/el.1F.7Y;q.14.Z=el.1F.2F+bB+\'U\';q.14.O=el.1F.2F*2N+5s+\'U\';5s+=bB});k.6n.aH(el,5s)})})},aH:u(el,5s){if(el.1F.51)if(el.1F.51==\'cv\')el.1F.1Z.K(0).14.O=(el.4c-el.1F.2F*el.1F.1R.1N())/2-5s/2+\'U\';P if(el.1F.51==\'O\')el.1F.1Z.K(0).14.O=-5s/el.1F.1R.1N()+\'U\';P if(el.1F.51==\'2L\')el.1F.1Z.K(0).14.O=(el.4c-el.1F.2F*el.1F.1R.1N())-5s/2+\'U\';el.1F.1Z.K(0).14.Z=el.1F.2F*el.1F.1R.1N()+5s+\'U\'},7T:u(el){el.1F.1R.1E(u(2N){q.14.Z=el.1F.2F+\'U\';q.14.O=el.1F.2F*2N+\'U\'})}};k.fn.hi=k.6n.2r;k.N={1c:S,8R:S,3A:S,2I:S,4y:S,cl:S,1d:S,2h:S,1R:S,5o:u(){k.N.8R.5o();if(k.N.3A){k.N.3A.2G()}},4w:u(){k.N.1R=S;k.N.2h=S;k.N.4y=k.N.1d.2y;if(k.N.1c.B(\'19\')==\'2B\'){if(k.N.1d.1f.fx){3m(k.N.1d.1f.fx.1u){1e\'c6\':k.N.1c.7a(k.N.1d.1f.fx.1m,k.N.5o);1r;1e\'1z\':k.N.1c.fq(k.N.1d.1f.fx.1m,k.N.5o);1r;1e\'a7\':k.N.1c.g3(k.N.1d.1f.fx.1m,k.N.5o);1r}}P{k.N.1c.2G()}if(k.N.1d.1f.3i)k.N.1d.1f.3i.1D(k.N.1d,[k.N.1c,k.N.3A])}P{k.N.5o()}1X.bH(k.N.2I)},dQ:u(){D 1d=k.N.1d;D 4d=k.N.aY(1d);if(1d&&4d.3o!=k.N.4y&&4d.3o.1g>=1d.1f.aL){k.N.4y=4d.3o;k.N.cl=4d.3o;81={2n:k(1d).1p(\'hj\')||\'2n\',2y:4d.3o};k.hl({1u:\'hk\',81:k.hf(81),he:u(fZ){1d.1f.4e=k(\'3o\',fZ);1N=1d.1f.4e.1N();if(1N>0){D 5p=\'\';1d.1f.4e.1E(u(2N){5p+=\'<8P 4I="\'+k(\'2y\',q).3g()+\'" 8K="\'+2N+\'" 14="9b: ad;">\'+k(\'3g\',q).3g()+\'</8P>\'});if(1d.1f.aU){D 3M=k(\'2y\',1d.1f.4e.K(0)).3g();1d.2y=4d.3j+3M+1d.1f.3N+4d.66;k.N.6J(1d,4d.3o.1g!=3M.1g?(4d.3j.1g+4d.3o.1g):3M.1g,4d.3o.1g!=3M.1g?(4d.3j.1g+3M.1g):3M.1g)}if(1N>0){k.N.cj(1d,5p)}P{k.N.4w()}}P{k.N.4w()}},5N:1d.1f.aN})}},cj:u(1d,5p){k.N.8R.3x(5p);k.N.1R=k(\'8P\',k.N.8R.K(0));k.N.1R.9z(k.N.di).1J(\'5h\',k.N.dj);D Y=k.1a.3w(1d);D 1N=k.1a.2o(1d);k.N.1c.B(\'Q\',Y.y+1N.hb+\'U\').B(\'O\',Y.x+\'U\').2R(1d.1f.aM);if(k.N.3A){k.N.3A.B(\'19\',\'2B\').B(\'Q\',Y.y+1N.hb+\'U\').B(\'O\',Y.x+\'U\').B(\'Z\',k.N.1c.B(\'Z\')).B(\'W\',k.N.1c.B(\'W\'))}k.N.2h=0;k.N.1R.K(0).3l=1d.1f.7H;k.N.8Q(1d,1d.1f.4e.K(0),\'7J\');if(k.N.1c.B(\'19\')==\'1o\'){if(1d.1f.bV){D cp=k.1a.aT(1d,1b);D cm=k.1a.6U(1d,1b);k.N.1c.B(\'Z\',1d.4c-(k.dF?(cp.l+cp.r+cm.l+cm.r):0)+\'U\')}if(1d.1f.fx){3m(1d.1f.fx.1u){1e\'c6\':k.N.1c.7f(1d.1f.fx.1m);1r;1e\'1z\':k.N.1c.fo(1d.1f.fx.1m);1r;1e\'a7\':k.N.1c.gb(1d.1f.fx.1m);1r}}P{k.N.1c.1Y()}if(k.N.1d.1f.2Y)k.N.1d.1f.2Y.1D(k.N.1d,[k.N.1c,k.N.3A])}},dO:u(){D 1d=q;if(1d.1f.4e){k.N.4y=1d.2y;k.N.cl=1d.2y;D 5p=\'\';1d.1f.4e.1E(u(2N){2y=k(\'2y\',q).3g().6c();fY=1d.2y.6c();if(2y.3J(fY)==0){5p+=\'<8P 4I="\'+k(\'2y\',q).3g()+\'" 8K="\'+2N+\'" 14="9b: ad;">\'+k(\'3g\',q).3g()+\'</8P>\'}});if(5p!=\'\'){k.N.cj(1d,5p);q.1f.9x=1b;E}}1d.1f.4e=S;q.1f.9x=I},6J:u(2n,26,2T){if(2n.b1){D 6t=2n.b1();6t.hp(1b);6t.dI("ck",26);6t.ha("ck",-2T+26);6t.8C()}P if(2n.aF){2n.aF(26,2T)}P{if(2n.5q){2n.5q=26;2n.dN=2T}}2n.6K()},f0:u(2n){if(2n.5q)E 2n.5q;P if(2n.b1){D 6t=1h.6J.dZ();D eX=6t.h9();E 0-eX.dI(\'ck\',-h6)}},aY:u(2n){D 4P={2y:2n.2y,3j:\'\',66:\'\',3o:\'\'};if(2n.1f.aQ){D 8N=I;D 5q=k.N.f0(2n)||0;D 4T=4P.2y.7C(2n.1f.3N);24(D i=0;i<4T.1g;i++){if((4P.3j.1g+4T[i].1g>=5q||5q==0)&&!8N){if(4P.3j.1g<=5q)4P.3o=4T[i];P 4P.66+=4T[i]+(4T[i]!=\'\'?2n.1f.3N:\'\');8N=1b}P if(8N){4P.66+=4T[i]+(4T[i]!=\'\'?2n.1f.3N:\'\')}if(!8N){4P.3j+=4T[i]+(4T.1g>1?2n.1f.3N:\'\')}}}P{4P.3o=4P.2y}E 4P},bU:u(e){1X.bH(k.N.2I);D 1d=k.N.aY(q);D 3K=e.7L||e.7K||-1;if(/13|27|35|36|38|40|9/.48(3K)&&k.N.1R){if(1X.2k){1X.2k.bT=1b;1X.2k.c0=I}P{e.aP();e.aW()}if(k.N.2h!=S)k.N.1R.K(k.N.2h||0).3l=\'\';P k.N.2h=-1;3m(3K){1e 9:1e 13:if(k.N.2h==-1)k.N.2h=0;D 2h=k.N.1R.K(k.N.2h||0);D 3M=2h.5C(\'4I\');q.2y=1d.3j+3M+q.1f.3N+1d.66;k.N.4y=1d.3o;k.N.6J(q,1d.3j.1g+3M.1g+q.1f.3N.1g,1d.3j.1g+3M.1g+q.1f.3N.1g);k.N.4w();if(q.1f.68){4u=T(2h.5C(\'8K\'))||0;k.N.8Q(q,q.1f.4e.K(4u),\'68\')}if(q.7W)q.7W(I);E 3K!=13;1r;1e 27:q.2y=1d.3j+k.N.4y+q.1f.3N+1d.66;q.1f.4e=S;k.N.4w();if(q.7W)q.7W(I);E I;1r;1e 35:k.N.2h=k.N.1R.1N()-1;1r;1e 36:k.N.2h=0;1r;1e 38:k.N.2h--;if(k.N.2h<0)k.N.2h=k.N.1R.1N()-1;1r;1e 40:k.N.2h++;if(k.N.2h==k.N.1R.1N())k.N.2h=0;1r}k.N.8Q(q,q.1f.4e.K(k.N.2h||0),\'7J\');k.N.1R.K(k.N.2h||0).3l=q.1f.7H;if(k.N.1R.K(k.N.2h||0).7W)k.N.1R.K(k.N.2h||0).7W(I);if(q.1f.aU){D aK=k.N.1R.K(k.N.2h||0).5C(\'4I\');q.2y=1d.3j+aK+q.1f.3N+1d.66;if(k.N.4y.1g!=aK.1g)k.N.6J(q,1d.3j.1g+k.N.4y.1g,1d.3j.1g+aK.1g)}E I}k.N.dO.1D(q);if(q.1f.9x==I){if(1d.3o!=k.N.4y&&1d.3o.1g>=q.1f.aL)k.N.2I=1X.9T(k.N.dQ,q.1f.54);if(k.N.1R){k.N.4w()}}E 1b},8Q:u(2n,3o,1u){if(2n.1f[1u]){D 81={};ar=3o.f3(\'*\');24(i=0;i<ar.1g;i++){81[ar[i].4Y]=ar[i].7c.h4}2n.1f[1u].1D(2n,[81])}},di:u(e){if(k.N.1R){if(k.N.2h!=S)k.N.1R.K(k.N.2h||0).3l=\'\';k.N.1R.K(k.N.2h||0).3l=\'\';k.N.2h=T(q.5C(\'8K\'))||0;k.N.1R.K(k.N.2h||0).3l=k.N.1d.1f.7H}},dj:u(2k){1X.bH(k.N.2I);2k=2k||k.2k.gS(1X.2k);2k.aP();2k.aW();D 1d=k.N.aY(k.N.1d);D 3M=q.5C(\'4I\');k.N.1d.2y=1d.3j+3M+k.N.1d.1f.3N+1d.66;k.N.4y=q.5C(\'4I\');k.N.6J(k.N.1d,1d.3j.1g+3M.1g+k.N.1d.1f.3N.1g,1d.3j.1g+3M.1g+k.N.1d.1f.3N.1g);k.N.4w();if(k.N.1d.1f.68){4u=T(q.5C(\'8K\'))||0;k.N.8Q(k.N.1d,k.N.1d.1f.4e.K(4u),\'68\')}E I},eJ:u(e){3K=e.7L||e.7K||-1;if(/13|27|35|36|38|40/.48(3K)&&k.N.1R){if(1X.2k){1X.2k.bT=1b;1X.2k.c0=I}P{e.aP();e.aW()}E I}},2r:u(M){if(!M.aN||!k.1a){E}if(!k.N.1c){if(k.3a.4t){k(\'2e\',1h).1S(\'<3A 14="19:1o;Y:1P;5E:9n:9w.9y.cC(1G=0);" id="ds" 2J="ek:I;" ej="0" ep="cD"></3A>\');k.N.3A=k(\'#ds\')}k(\'2e\',1h).1S(\'<22 id="dr" 14="Y: 1P; Q: 0; O: 0; z-cZ: h3; 19: 1o;"><9h 14="6w: 0;8F: 0; h1-14: 1o; z-cZ: h0;">&7k;</9h></22>\');k.N.1c=k(\'#dr\');k.N.8R=k(\'9h\',k.N.1c)}E q.1E(u(){if(q.4Y!=\'ch\'&&q.5C(\'1u\')!=\'3g\')E;q.1f={};q.1f.aN=M.aN;q.1f.aL=18.3S(T(M.aL)||1);q.1f.aM=M.aM?M.aM:\'\';q.1f.7H=M.7H?M.7H:\'\';q.1f.68=M.68&&M.68.1K==2A?M.68:S;q.1f.2Y=M.2Y&&M.2Y.1K==2A?M.2Y:S;q.1f.3i=M.3i&&M.3i.1K==2A?M.3i:S;q.1f.7J=M.7J&&M.7J.1K==2A?M.7J:S;q.1f.bV=M.bV||I;q.1f.aQ=M.aQ||I;q.1f.3N=q.1f.aQ?(M.3N||\', \'):\'\';q.1f.aU=M.aU?1b:I;q.1f.54=18.3S(T(M.54)||aC);if(M.fx&&M.fx.1K==7M){if(!M.fx.1u||!/c6|1z|a7/.48(M.fx.1u)){M.fx.1u=\'1z\'}if(M.fx.1u==\'1z\'&&!k.fx.1z)E;if(M.fx.1u==\'a7\'&&!k.fx.61)E;M.fx.1m=18.3S(T(M.fx.1m)||8J);if(M.fx.1m>q.1f.54){M.fx.1m=q.1f.54-2a}q.1f.fx=M.fx}q.1f.4e=S;q.1f.9x=I;k(q).1p(\'bU\',\'eN\').6K(u(){k.N.1d=q;k.N.4y=q.2y}).dH(k.N.eJ).6y(k.N.bU).5B(u(){k.N.2I=1X.9T(k.N.4w,hM)})})}};k.fn.hR=k.N.2r;k.1y={2I:S,4Q:S,29:S,2D:10,26:u(el,4J,2D,eG){k.1y.4Q=el;k.1y.29=4J;k.1y.2D=T(2D)||10;k.1y.2I=1X.6V(k.1y.eF,T(eG)||40)},eF:u(){24(i=0;i<k.1y.29.1g;i++){if(!k.1y.29[i].2X){k.1y.29[i].2X=k.23(k.1a.7G(k.1y.29[i]),k.1a.74(k.1y.29[i]),k.1a.6z(k.1y.29[i]))}P{k.1y.29[i].2X.t=k.1y.29[i].3d;k.1y.29[i].2X.l=k.1y.29[i].3c}if(k.1y.4Q.A&&k.1y.4Q.A.7q==1b){69={x:k.1y.4Q.A.2v,y:k.1y.4Q.A.2q,1C:k.1y.4Q.A.1B.1C,hb:k.1y.4Q.A.1B.hb}}P{69=k.23(k.1a.7G(k.1y.4Q),k.1a.74(k.1y.4Q))}if(k.1y.29[i].2X.t>0&&k.1y.29[i].2X.y+k.1y.29[i].2X.t>69.y){k.1y.29[i].3d-=k.1y.2D}P if(k.1y.29[i].2X.t<=k.1y.29[i].2X.h&&k.1y.29[i].2X.t+k.1y.29[i].2X.hb<69.y+69.hb){k.1y.29[i].3d+=k.1y.2D}if(k.1y.29[i].2X.l>0&&k.1y.29[i].2X.x+k.1y.29[i].2X.l>69.x){k.1y.29[i].3c-=k.1y.2D}P if(k.1y.29[i].2X.l<=k.1y.29[i].2X.hP&&k.1y.29[i].2X.l+k.1y.29[i].2X.1C<69.x+69.1C){k.1y.29[i].3c+=k.1y.2D}}},8o:u(){1X.5T(k.1y.2I);k.1y.4Q=S;k.1y.29=S;24(i in k.1y.29){k.1y.29[i].2X=S}}};k.11={1c:S,F:S,4U:u(){E q.1E(u(){if(q.9I){q.A.5e.3q(\'5v\',k.11.bN);q.A=S;q.9I=I;if(k.3a.4t){q.bE="eN"}P{q.14.hq=\'\';q.14.e1=\'\';q.14.e7=\'\'}}})},bN:u(e){if(k.11.F!=S){k.11.9A(e);E I}D C=q.3U;k(1h).1J(\'3D\',k.11.bX).1J(\'5P\',k.11.9A);C.A.1s=k.1a.4a(e);C.A.4B=C.A.1s;C.A.7q=I;C.A.ho=q!=q.3U;k.11.F=C;if(C.A.5i&&q!=q.3U){bS=k.1a.3w(C.31);bQ=k.1a.2o(C);bR={x:T(k.B(C,\'O\'))||0,y:T(k.B(C,\'Q\'))||0};dx=C.A.4B.x-bS.x-bQ.1C/2-bR.x;dy=C.A.4B.y-bS.y-bQ.hb/2-bR.y;k.3b.5c(C,[dx,dy])}E k.7n||I},ea:u(e){D C=k.11.F;C.A.7q=1b;D 9G=C.14;C.A.7V=k.B(C,\'19\');C.A.4n=k.B(C,\'Y\');if(!C.A.cz)C.A.cz=C.A.4n;C.A.2c={x:T(k.B(C,\'O\'))||0,y:T(k.B(C,\'Q\'))||0};C.A.9B=0;C.A.ai=0;if(k.3a.4t){D bW=k.1a.6U(C,1b);C.A.9B=bW.l||0;C.A.ai=bW.t||0}C.A.1B=k.23(k.1a.3w(C),k.1a.2o(C));if(C.A.4n!=\'2s\'&&C.A.4n!=\'1P\'){9G.Y=\'2s\'}k.11.1c.5o();D 5g=C.fI(1b);k(5g).B({19:\'2B\',O:\'2P\',Q:\'2P\'});5g.14.5K=\'0\';5g.14.5z=\'0\';5g.14.5k=\'0\';5g.14.5j=\'0\';k.11.1c.1S(5g);D 3Y=k.11.1c.K(0).14;if(C.A.bD){3Y.Z=\'9F\';3Y.W=\'9F\'}P{3Y.W=C.A.1B.hb+\'U\';3Y.Z=C.A.1B.1C+\'U\'}3Y.19=\'2B\';3Y.5K=\'2P\';3Y.5z=\'2P\';3Y.5k=\'2P\';3Y.5j=\'2P\';k.23(C.A.1B,k.1a.2o(5g));if(C.A.2V){if(C.A.2V.O){C.A.2c.x+=C.A.1s.x-C.A.1B.x-C.A.2V.O;C.A.1B.x=C.A.1s.x-C.A.2V.O}if(C.A.2V.Q){C.A.2c.y+=C.A.1s.y-C.A.1B.y-C.A.2V.Q;C.A.1B.y=C.A.1s.y-C.A.2V.Q}if(C.A.2V.2L){C.A.2c.x+=C.A.1s.x-C.A.1B.x-C.A.1B.hb+C.A.2V.2L;C.A.1B.x=C.A.1s.x-C.A.1B.1C+C.A.2V.2L}if(C.A.2V.4D){C.A.2c.y+=C.A.1s.y-C.A.1B.y-C.A.1B.hb+C.A.2V.4D;C.A.1B.y=C.A.1s.y-C.A.1B.hb+C.A.2V.4D}}C.A.2v=C.A.2c.x;C.A.2q=C.A.2c.y;if(C.A.8s||C.A.2p==\'94\'){8U=k.1a.6U(C.31,1b);C.A.1B.x=C.8t+(k.3a.4t?0:k.3a.7I?-8U.l:8U.l);C.A.1B.y=C.8G+(k.3a.4t?0:k.3a.7I?-8U.t:8U.t);k(C.31).1S(k.11.1c.K(0))}if(C.A.2p){k.11.c5(C);C.A.5t.2p=k.11.ce}if(C.A.5i){k.3b.ct(C)}3Y.O=C.A.1B.x-C.A.9B+\'U\';3Y.Q=C.A.1B.y-C.A.ai+\'U\';3Y.Z=C.A.1B.1C+\'U\';3Y.W=C.A.1B.hb+\'U\';k.11.F.A.9E=I;if(C.A.gx){C.A.5t.6a=k.11.c7}if(C.A.3I!=I){k.11.1c.B(\'3I\',C.A.3I)}if(C.A.1G){k.11.1c.B(\'1G\',C.A.1G);if(1X.71){k.11.1c.B(\'5E\',\'8V(1G=\'+C.A.1G*2a+\')\')}}if(C.A.7O){k.11.1c.2R(C.A.7O);k.11.1c.K(0).7c.14.19=\'1o\'}if(C.A.4o)C.A.4o.1D(C,[5g,C.A.2c.x,C.A.2c.y]);if(k.1x&&k.1x.8D>0){k.1x.ed(C)}if(C.A.46==I){9G.19=\'1o\'}E I},c5:u(C){if(C.A.2p.1K==b0){if(C.A.2p==\'94\'){C.A.28=k.23({x:0,y:0},k.1a.2o(C.31));D 8S=k.1a.6U(C.31,1b);C.A.28.w=C.A.28.1C-8S.l-8S.r;C.A.28.h=C.A.28.hb-8S.t-8S.b}P if(C.A.2p==\'1h\'){D bY=k.1a.bm();C.A.28={x:0,y:0,w:bY.w,h:bY.h}}}P if(C.A.2p.1K==7F){C.A.28={x:T(C.A.2p[0])||0,y:T(C.A.2p[1])||0,w:T(C.A.2p[2])||0,h:T(C.A.2p[3])||0}}C.A.28.dx=C.A.28.x-C.A.1B.x;C.A.28.dy=C.A.28.y-C.A.1B.y},9H:u(F){if(F.A.8s||F.A.2p==\'94\'){k(\'2e\',1h).1S(k.11.1c.K(0))}k.11.1c.5o().2G().B(\'1G\',1);if(1X.71){k.11.1c.B(\'5E\',\'8V(1G=2a)\')}},9A:u(e){k(1h).3q(\'3D\',k.11.bX).3q(\'5P\',k.11.9A);if(k.11.F==S){E}D F=k.11.F;k.11.F=S;if(F.A.7q==I){E I}if(F.A.44==1b){k(F).B(\'Y\',F.A.4n)}D 9G=F.14;if(F.5i){k.11.1c.B(\'9b\',\'8j\')}if(F.A.7O){k.11.1c.4i(F.A.7O)}if(F.A.6N==I){if(F.A.fx>0){if(!F.A.1O||F.A.1O==\'4j\'){D x=12 k.fx(F,{1m:F.A.fx},\'O\');x.1L(F.A.2c.x,F.A.8y)}if(!F.A.1O||F.A.1O==\'49\'){D y=12 k.fx(F,{1m:F.A.fx},\'Q\');y.1L(F.A.2c.y,F.A.8v)}}P{if(!F.A.1O||F.A.1O==\'4j\')F.14.O=F.A.8y+\'U\';if(!F.A.1O||F.A.1O==\'49\')F.14.Q=F.A.8v+\'U\'}k.11.9H(F);if(F.A.46==I){k(F).B(\'19\',F.A.7V)}}P if(F.A.fx>0){F.A.9E=1b;D dh=I;if(k.1x&&k.1t&&F.A.44){dh=k.1a.3w(k.1t.1c.K(0))}k.11.1c.5w({O:dh?dh.x:F.A.1B.x,Q:dh?dh.y:F.A.1B.y},F.A.fx,u(){F.A.9E=I;if(F.A.46==I){F.14.19=F.A.7V}k.11.9H(F)})}P{k.11.9H(F);if(F.A.46==I){k(F).B(\'19\',F.A.7V)}}if(k.1x&&k.1x.8D>0){k.1x.eO(F)}if(k.1t&&F.A.44){k.1t.fC(F)}if(F.A.2Z&&(F.A.8y!=F.A.2c.x||F.A.8v!=F.A.2c.y)){F.A.2Z.1D(F,F.A.b3||[0,0,F.A.8y,F.A.8v])}if(F.A.3T)F.A.3T.1D(F);E I},c7:u(x,y,dx,dy){if(dx!=0)dx=T((dx+(q.A.gx*dx/18.3S(dx))/2)/q.A.gx)*q.A.gx;if(dy!=0)dy=T((dy+(q.A.gy*dy/18.3S(dy))/2)/q.A.gy)*q.A.gy;E{dx:dx,dy:dy,x:0,y:0}},ce:u(x,y,dx,dy){dx=18.3L(18.3r(dx,q.A.28.dx),q.A.28.w+q.A.28.dx-q.A.1B.1C);dy=18.3L(18.3r(dy,q.A.28.dy),q.A.28.h+q.A.28.dy-q.A.1B.hb);E{dx:dx,dy:dy,x:0,y:0}},bX:u(e){if(k.11.F==S||k.11.F.A.9E==1b){E}D F=k.11.F;F.A.4B=k.1a.4a(e);if(F.A.7q==I){45=18.ez(18.6b(F.A.1s.x-F.A.4B.x,2)+18.6b(F.A.1s.y-F.A.4B.y,2));if(45<F.A.6M){E}P{k.11.ea(e)}}D dx=F.A.4B.x-F.A.1s.x;D dy=F.A.4B.y-F.A.1s.y;24(D i in F.A.5t){D 3y=F.A.5t[i].1D(F,[F.A.2c.x+dx,F.A.2c.y+dy,dx,dy]);if(3y&&3y.1K==7M){dx=i!=\'7R\'?3y.dx:(3y.x-F.A.2c.x);dy=i!=\'7R\'?3y.dy:(3y.y-F.A.2c.y)}}F.A.2v=F.A.1B.x+dx-F.A.9B;F.A.2q=F.A.1B.y+dy-F.A.ai;if(F.A.5i&&(F.A.3H||F.A.2Z)){k.3b.3H(F,F.A.2v,F.A.2q)}if(F.A.4m)F.A.4m.1D(F,[F.A.2c.x+dx,F.A.2c.y+dy]);if(!F.A.1O||F.A.1O==\'4j\'){F.A.8y=F.A.2c.x+dx;k.11.1c.K(0).14.O=F.A.2v+\'U\'}if(!F.A.1O||F.A.1O==\'49\'){F.A.8v=F.A.2c.y+dy;k.11.1c.K(0).14.Q=F.A.2q+\'U\'}if(k.1x&&k.1x.8D>0){k.1x.al(F)}E I},2r:u(o){if(!k.11.1c){k(\'2e\',1h).1S(\'<22 id="e8"></22>\');k.11.1c=k(\'#e8\');D el=k.11.1c.K(0);D 4J=el.14;4J.Y=\'1P\';4J.19=\'1o\';4J.9b=\'8j\';4J.eu=\'1o\';4J.2U=\'2K\';if(1X.71){el.bE="e4"}P{4J.gi=\'1o\';4J.e7=\'1o\';4J.e1=\'1o\'}}if(!o){o={}}E q.1E(u(){if(q.9I||!k.1a)E;if(1X.71){q.gh=u(){E I};q.gj=u(){E I}}D el=q;D 5e=o.3v?k(q).gf(o.3v):k(q);if(k.3a.4t){5e.1E(u(){q.bE="e4"})}P{5e.B(\'-gI-7R-8C\',\'1o\');5e.B(\'7R-8C\',\'1o\');5e.B(\'-gH-7R-8C\',\'1o\')}q.A={5e:5e,6N:o.6N?1b:I,46:o.46?1b:I,44:o.44?o.44:I,5i:o.5i?o.5i:I,8s:o.8s?o.8s:I,3I:o.3I?T(o.3I)||0:I,1G:o.1G?2m(o.1G):I,fx:T(o.fx)||S,6R:o.6R?o.6R:I,5t:{},1s:{},4o:o.4o&&o.4o.1K==2A?o.4o:I,3T:o.3T&&o.3T.1K==2A?o.3T:I,2Z:o.2Z&&o.2Z.1K==2A?o.2Z:I,1O:/49|4j/.48(o.1O)?o.1O:I,6M:o.6M?T(o.6M)||0:0,2V:o.2V?o.2V:I,bD:o.bD?1b:I,7O:o.7O||I};if(o.5t&&o.5t.1K==2A)q.A.5t.7R=o.5t;if(o.4m&&o.4m.1K==2A)q.A.4m=o.4m;if(o.2p&&((o.2p.1K==b0&&(o.2p==\'94\'||o.2p==\'1h\'))||(o.2p.1K==7F&&o.2p.1g==4))){q.A.2p=o.2p}if(o.2O){q.A.2O=o.2O}if(o.6a){if(2g o.6a==\'gz\'){q.A.gx=T(o.6a)||1;q.A.gy=T(o.6a)||1}P if(o.6a.1g==2){q.A.gx=T(o.6a[0])||1;q.A.gy=T(o.6a[1])||1}}if(o.3H&&o.3H.1K==2A){q.A.3H=o.3H}q.9I=1b;5e.1E(u(){q.3U=el});5e.1J(\'5v\',k.11.bN)})}};k.fn.23({aS:k.11.4U,7t:k.11.2r});k.1x={du:u(5J,5G,7Q,7S){E 5J<=k.11.F.A.2v&&(5J+7Q)>=(k.11.F.A.2v+k.11.F.A.1B.w)&&5G<=k.11.F.A.2q&&(5G+7S)>=(k.11.F.A.2q+k.11.F.A.1B.h)?1b:I},cV:u(5J,5G,7Q,7S){E!(5J>(k.11.F.A.2v+k.11.F.A.1B.w)||(5J+7Q)<k.11.F.A.2v||5G>(k.11.F.A.2q+k.11.F.A.1B.h)||(5G+7S)<k.11.F.A.2q)?1b:I},1s:u(5J,5G,7Q,7S){E 5J<k.11.F.A.4B.x&&(5J+7Q)>k.11.F.A.4B.x&&5G<k.11.F.A.4B.y&&(5G+7S)>k.11.F.A.4B.y?1b:I},5r:I,3Q:{},8D:0,3P:{},ed:u(C){if(k.11.F==S){E}D i;k.1x.3Q={};D bJ=I;24(i in k.1x.3P){if(k.1x.3P[i]!=S){D 1j=k.1x.3P[i].K(0);if(k(k.11.F).is(\'.\'+1j.1i.a)){if(1j.1i.m==I){1j.1i.p=k.23(k.1a.7G(1j),k.1a.74(1j));1j.1i.m=1b}if(1j.1i.ac){k.1x.3P[i].2R(1j.1i.ac)}k.1x.3Q[i]=k.1x.3P[i];if(k.1t&&1j.1i.s&&k.11.F.A.44){1j.1i.el=k(\'.\'+1j.1i.a,1j);C.14.19=\'1o\';k.1t.cT(1j);1j.1i.ay=k.1t.8x(k.1p(1j,\'id\')).7l;C.14.19=C.A.7V;bJ=1b}if(1j.1i.9i){1j.1i.9i.1D(k.1x.3P[i].K(0),[k.11.F])}}}}if(bJ){k.1t.26()}},dS:u(){k.1x.3Q={};24(i in k.1x.3P){if(k.1x.3P[i]!=S){D 1j=k.1x.3P[i].K(0);if(k(k.11.F).is(\'.\'+1j.1i.a)){1j.1i.p=k.23(k.1a.7G(1j),k.1a.74(1j));if(1j.1i.ac){k.1x.3P[i].2R(1j.1i.ac)}k.1x.3Q[i]=k.1x.3P[i];if(k.1t&&1j.1i.s&&k.11.F.A.44){1j.1i.el=k(\'.\'+1j.1i.a,1j);C.14.19=\'1o\';k.1t.cT(1j);C.14.19=C.A.7V}}}}},al:u(e){if(k.11.F==S){E}k.1x.5r=I;D i;D bK=I;D eQ=0;24(i in k.1x.3Q){D 1j=k.1x.3Q[i].K(0);if(k.1x.5r==I&&k.1x[1j.1i.t](1j.1i.p.x,1j.1i.p.y,1j.1i.p.1C,1j.1i.p.hb)){if(1j.1i.hc&&1j.1i.h==I){k.1x.3Q[i].2R(1j.1i.hc)}if(1j.1i.h==I&&1j.1i.7x){bK=1b}1j.1i.h=1b;k.1x.5r=1j;if(k.1t&&1j.1i.s&&k.11.F.A.44){k.1t.1c.K(0).3l=1j.1i.eV;k.1t.al(1j)}eQ++}P if(1j.1i.h==1b){if(1j.1i.7y){1j.1i.7y.1D(1j,[e,k.11.1c.K(0).7c,1j.1i.fx])}if(1j.1i.hc){k.1x.3Q[i].4i(1j.1i.hc)}1j.1i.h=I}}if(k.1t&&!k.1x.5r&&k.11.F.44){k.1t.1c.K(0).14.19=\'1o\'}if(bK){k.1x.5r.1i.7x.1D(k.1x.5r,[e,k.11.1c.K(0).7c])}},eO:u(e){D i;24(i in k.1x.3Q){D 1j=k.1x.3Q[i].K(0);if(1j.1i.ac){k.1x.3Q[i].4i(1j.1i.ac)}if(1j.1i.hc){k.1x.3Q[i].4i(1j.1i.hc)}if(1j.1i.s){k.1t.7s[k.1t.7s.1g]=i}if(1j.1i.9l&&1j.1i.h==1b){1j.1i.h=I;1j.1i.9l.1D(1j,[e,1j.1i.fx])}1j.1i.m=I;1j.1i.h=I}k.1x.3Q={}},4U:u(){E q.1E(u(){if(q.9j){if(q.1i.s){id=k.1p(q,\'id\');k.1t.5L[id]=S;k(\'.\'+q.1i.a,q).aS()}k.1x.3P[\'d\'+q.c2]=S;q.9j=I;q.f=S}})},2r:u(o){E q.1E(u(){if(q.9j==1b||!o.3C||!k.1a||!k.11){E}q.1i={a:o.3C,ac:o.9J||I,hc:o.a5||I,eV:o.58||I,9l:o.gq||o.9l||I,7x:o.7x||o.dC||I,7y:o.7y||o.fO||I,9i:o.9i||I,t:o.6I&&(o.6I==\'du\'||o.6I==\'cV\')?o.6I:\'1s\',fx:o.fx?o.fx:I,m:I,h:I};if(o.cQ==1b&&k.1t){id=k.1p(q,\'id\');k.1t.5L[id]=q.1i.a;q.1i.s=1b;if(o.2Z){q.1i.2Z=o.2Z;q.1i.ay=k.1t.8x(id).7l}}q.9j=1b;q.c2=T(18.6o()*c9);k.1x.3P[\'d\'+q.c2]=k(q);k.1x.8D++})}};k.fn.23({dR:k.1x.4U,do:k.1x.2r});k.gD=k.1x.dS;k.3B={1c:S,8L:u(){3g=q.2y;if(!3g)E;14={dz:k(q).B(\'dz\')||\'\',4A:k(q).B(\'4A\')||\'\',8Z:k(q).B(\'8Z\')||\'\',dP:k(q).B(\'dP\')||\'\',dT:k(q).B(\'dT\')||\'\',dU:k(q).B(\'dU\')||\'\',c3:k(q).B(\'c3\')||\'\',dY:k(q).B(\'dY\')||\'\'};k.3B.1c.B(14);3x=k.3B.dX(3g);3x=3x.4E(12 bb("\\\\n","g"),"<br />");k.3B.1c.3x(\'gL\');ci=k.3B.1c.K(0).4c;k.3B.1c.3x(3x);Z=k.3B.1c.K(0).4c+ci;if(q.6l.2M&&Z>q.6l.2M[0]){Z=q.6l.2M[0]}q.14.Z=Z+\'U\';if(q.4Y==\'cf\'){W=k.3B.1c.K(0).5W+ci;if(q.6l.2M&&W>q.6l.2M[1]){W=q.6l.2M[1]}q.14.W=W+\'U\'}},dX:u(3g){cg={\'&\':\'&gK;\',\'<\':\'&gJ;\',\'>\':\'&gt;\',\'"\':\'&gs;\'};24(i in cg){3g=3g.4E(12 bb(i,\'g\'),cg[i])}E 3g},2r:u(2M){if(k.3B.1c==S){k(\'2e\',1h).1S(\'<22 id="dE" 14="Y: 1P; Q: 0; O: 0; 3n: 2K;"></22>\');k.3B.1c=k(\'#dE\')}E q.1E(u(){if(/cf|ch/.48(q.4Y)){if(q.4Y==\'ch\'){dB=q.5C(\'1u\');if(!/3g|gr/.48(dB)){E}}if(2M&&(2M.1K==bn||(2M.1K==7F&&2M.1g==2))){if(2M.1K==bn)2M=[2M,2M];P{2M[0]=T(2M[0])||8J;2M[1]=T(2M[1])||8J}q.6l={2M:2M}}k(q).5B(k.3B.8L).6y(k.3B.8L).dH(k.3B.8L);k.3B.8L.1D(q)}})}};k.fn.kc=k.3B.2r;k.4K=u(e){if(/^kd$|^ke$|^ka$|^6L$|^k9$|^k5$|^k4$|^k6$|^k7$|^2e$|^k8$|^kf$|^kg$|^kn$|^ko$|^kp$|^kq$/i.48(e.9N))E I;P E 1b};k.fx.a0=u(e,65){D c=e.7c;D cs=c.14;cs.Y=65.Y;cs.5K=65.3G.t;cs.5j=65.3G.l;cs.5k=65.3G.b;cs.5z=65.3G.r;cs.Q=65.Q+\'U\';cs.O=65.O+\'U\';e.31.ew(c,e);e.31.km(e)};k.fx.9P=u(e){if(!k.4K(e))E I;D t=k(e);D es=e.14;D 73=I;if(t.B(\'19\')==\'1o\'){5Y=t.B(\'3n\');t.B(\'3n\',\'2K\').1Y();73=1b}D V={};V.Y=t.B(\'Y\');V.1q=k.1a.2o(e);V.3G=k.1a.cy(e);D co=e.4Z?e.4Z.ei:t.B(\'hU\');V.Q=T(t.B(\'Q\'))||0;V.O=T(t.B(\'O\'))||0;D eo=\'kl\'+T(18.6o()*c9);D 6u=1h.3F(/^1T$|^br$|^kh$|^hr$|^8C$|^kj$|^8T$|^3A$|^kk$|^k3$|^k2$|^9h$|^dl$|^jM$/i.48(e.9N)?\'22\':e.9N);k.1p(6u,\'id\',eo);D jN=k(6u).2R(\'jO\');D 4h=6u.14;D Q=0;D O=0;if(V.Y==\'2s\'||V.Y==\'1P\'){Q=V.Q;O=V.O}4h.Q=Q+\'U\';4h.O=O+\'U\';4h.Y=V.Y!=\'2s\'&&V.Y!=\'1P\'?\'2s\':V.Y;4h.W=V.1q.hb+\'U\';4h.Z=V.1q.1C+\'U\';4h.5K=V.3G.t;4h.5z=V.3G.r;4h.5k=V.3G.b;4h.5j=V.3G.l;4h.2U=\'2K\';if(k.3a.4t){4h.ei=co}P{4h.jK=co}if(k.3a=="4t"){es.5E="8V(1G="+0.ex*2a+")"}es.1G=0.ex;e.31.ew(6u,e);6u.jF(e);es.5K=\'2P\';es.5z=\'2P\';es.5k=\'2P\';es.5j=\'2P\';es.Y=\'1P\';es.eu=\'1o\';es.Q=\'2P\';es.O=\'2P\';if(73){t.2G();es.3n=5Y}E{V:V,3p:k(6u)}};k.fx.8E={jE:[0,1V,1V],jG:[eD,1V,1V],jH:[e6,e6,jI],jP:[0,0,0],ks:[0,0,1V],jY:[dv,42,42],jZ:[0,1V,1V],k0:[0,0,7w],k1:[0,7w,7w],jX:[cn,cn,cn],jS:[0,2a,0],jR:[jT,jU,eb],jV:[7w,0,7w],kr:[85,eb,47],kP:[1V,eA,0],kN:[kO,50,kx],kF:[7w,0,0],kD:[ku,f8,kt],ky:[kH,0,9C],kL:[1V,0,1V],kM:[1V,kJ,0],kv:[0,6C,0],kA:[75,0,kE],kC:[eD,eB,eA],kG:[kI,kB,eB],kw:[e0,1V,1V],kz:[eL,kK,eL],kQ:[9C,9C,9C],jC:[1V,iy,iz],iA:[1V,1V,e0],iB:[0,1V,0],ix:[1V,0,1V],iv:[6C,0,0],iq:[0,0,6C],ip:[6C,6C,0],ir:[1V,dv,0],it:[1V,ah,iu],iC:[6C,0,6C],iD:[1V,0,0],iK:[ah,ah,ah],iL:[1V,1V,1V],iM:[1V,1V,0]};k.fx.6D=u(4x,dm){if(k.fx.8E[4x])E{r:k.fx.8E[4x][0],g:k.fx.8E[4x][1],b:k.fx.8E[4x][2]};P if(2W=/^6Y\\(\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*\\)$/.a4(4x))E{r:T(2W[1]),g:T(2W[2]),b:T(2W[3])};P if(2W=/6Y\\(\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*\\)$/.a4(4x))E{r:2m(2W[1])*2.55,g:2m(2W[2])*2.55,b:2m(2W[3])*2.55};P if(2W=/^#([a-fA-79-9])([a-fA-79-9])([a-fA-79-9])$/.a4(4x))E{r:T("77"+2W[1]+2W[1]),g:T("77"+2W[2]+2W[2]),b:T("77"+2W[3]+2W[3])};P if(2W=/^#([a-fA-79-9]{2})([a-fA-79-9]{2})([a-fA-79-9]{2})$/.a4(4x))E{r:T("77"+2W[1]),g:T("77"+2W[2]),b:T("77"+2W[3])};P E dm==1b?I:{r:1V,g:1V,b:1V}};k.fx.dD={5Q:1,5b:1,5O:1,4S:1,4D:1,4A:1,W:1,O:1,c3:1,iI:1,5k:1,5j:1,5z:1,5K:1,8b:1,6x:1,8c:1,av:1,1G:1,iE:1,iF:1,5n:1,4X:1,5U:1,5M:1,2L:1,jD:1,Q:1,Z:1,3I:1};k.fx.dA={7i:1,iG:1,iH:1,io:1,im:1,4x:1,i2:1};k.fx.8A=[\'i3\',\'i4\',\'i5\',\'i1\'];k.fx.cc={\'cd\':[\'2E\',\'dK\'],\'a8\':[\'2E\',\'bh\'],\'6w\':[\'6w\',\'\'],\'8F\':[\'8F\',\'\']};k.fn.23({5w:u(5X,H,G,J){E q.1w(u(){D a1=k.H(H,G,J);D e=12 k.dM(q,a1,5X)})},c4:u(H,J){E q.1w(u(){D a1=k.H(H,J);D e=12 k.c4(q,a1)})},8o:u(2D){E q.1E(u(){if(q.6d)k.by(q,2D)})},i0:u(2D){E q.1E(u(){if(q.6d)k.by(q,2D);if(q.1w&&q.1w[\'fx\'])q.1w.fx=[]})}});k.23({c4:u(2f,M){D z=q,3t;z.2D=u(){if(k.fQ(M.21))M.21.1D(2f)};z.2I=6V(u(){z.2D()},M.1m);2f.6d=z},G:{c8:u(p,n,1W,1H,1m){E((-18.5H(p*18.2Q)/2)+0.5)*1H+1W}},dM:u(2f,M,5X){D z=q,3t;D y=2f.14;D fR=k.B(2f,"2U");D 72=k.B(2f,"19");D 2j={};z.9O=(12 7g()).7z();M.G=M.G&&k.G[M.G]?M.G:\'c8\';z.ag=u(2w,43){if(k.fx.dD[2w]){if(43==\'1Y\'||43==\'2G\'||43==\'3R\'){if(!2f.6v)2f.6v={};D r=2m(k.6E(2f,2w));2f.6v[2w]=r&&r>-c9?r:(2m(k.B(2f,2w))||0);43=43==\'3R\'?(72==\'1o\'?\'1Y\':\'2G\'):43;M[43]=1b;2j[2w]=43==\'1Y\'?[0,2f.6v[2w]]:[2f.6v[2w],0];if(2w!=\'1G\')y[2w]=2j[2w][0]+(2w!=\'3I\'&&2w!=\'8Z\'?\'U\':\'\');P k.1p(y,"1G",2j[2w][0])}P{2j[2w]=[2m(k.6E(2f,2w)),2m(43)||0]}}P if(k.fx.dA[2w])2j[2w]=[k.fx.6D(k.6E(2f,2w)),k.fx.6D(43)];P if(/^6w$|8F$|2E$|a8$|cd$/i.48(2w)){D m=43.4E(/\\s+/g,\' \').4E(/6Y\\s*\\(\\s*/g,\'6Y(\').4E(/\\s*,\\s*/g,\',\').4E(/\\s*\\)/g,\')\').d5(/([^\\s]+)/g);3m(2w){1e\'6w\':1e\'8F\':1e\'cd\':1e\'a8\':m[3]=m[3]||m[1]||m[0];m[2]=m[2]||m[0];m[1]=m[1]||m[0];24(D i=0;i<k.fx.8A.1g;i++){D 64=k.fx.cc[2w][0]+k.fx.8A[i]+k.fx.cc[2w][1];2j[64]=2w==\'a8\'?[k.fx.6D(k.6E(2f,64)),k.fx.6D(m[i])]:[2m(k.6E(2f,64)),2m(m[i])]}1r;1e\'2E\':24(D i=0;i<m.1g;i++){D bd=2m(m[i]);D a9=!hX(bd)?\'dK\':(!/cu|1o|2K|hY|hZ|i6|i7|ii|ij|ik|il/i.48(m[i])?\'bh\':I);if(a9){24(D j=0;j<k.fx.8A.1g;j++){64=\'2E\'+k.fx.8A[j]+a9;2j[64]=a9==\'bh\'?[k.fx.6D(k.6E(2f,64)),k.fx.6D(m[i])]:[2m(k.6E(2f,64)),bd]}}P{y[\'ie\']=m[i]}}1r}}P{y[2w]=43}E I};24(p in 5X){if(p==\'14\'){D 5f=k.bl(5X[p]);24(7A in 5f){q.ag(7A,5f[7A])}}P if(p==\'3l\'){if(1h.af)24(D i=0;i<1h.af.1g;i++){D 7e=1h.af[i].7e||1h.af[i].i9||S;if(7e){24(D j=0;j<7e.1g;j++){if(7e[j].i8==\'.\'+5X[p]){D 6X=12 bb(\'\\.\'+5X[p]+\' {\');D 5Z=7e[j].14.9X;D 5f=k.bl(5Z.4E(6X,\'\').4E(/}/g,\'\'));24(7A in 5f){q.ag(7A,5f[7A])}}}}}}P{q.ag(p,5X[p])}}y.19=72==\'1o\'?\'2B\':72;y.2U=\'2K\';z.2D=u(){D t=(12 7g()).7z();if(t>M.1m+z.9O){5T(z.2I);z.2I=S;24(p in 2j){if(p=="1G")k.1p(y,"1G",2j[p][1]);P if(2g 2j[p][1]==\'8T\')y[p]=\'6Y(\'+2j[p][1].r+\',\'+2j[p][1].g+\',\'+2j[p][1].b+\')\';P y[p]=2j[p][1]+(p!=\'3I\'&&p!=\'8Z\'?\'U\':\'\')}if(M.2G||M.1Y)24(D p in 2f.6v)if(p=="1G")k.1p(y,p,2f.6v[p]);P y[p]="";y.19=M.2G?\'1o\':(72!=\'1o\'?72:\'2B\');y.2U=fR;2f.6d=S;if(k.fQ(M.21))M.21.1D(2f)}P{D n=t-q.9O;D 8w=n/M.1m;24(p in 2j){if(2g 2j[p][1]==\'8T\'){y[p]=\'6Y(\'+T(k.G[M.G](8w,n,2j[p][0].r,(2j[p][1].r-2j[p][0].r),M.1m))+\',\'+T(k.G[M.G](8w,n,2j[p][0].g,(2j[p][1].g-2j[p][0].g),M.1m))+\',\'+T(k.G[M.G](8w,n,2j[p][0].b,(2j[p][1].b-2j[p][0].b),M.1m))+\')\'}P{D bz=k.G[M.G](8w,n,2j[p][0],(2j[p][1]-2j[p][0]),M.1m);if(p=="1G")k.1p(y,"1G",bz);P y[p]=bz+(p!=\'3I\'&&p!=\'8Z\'?\'U\':\'\')}}}};z.2I=6V(u(){z.2D()},13);2f.6d=z},by:u(2f,2D){if(2D)2f.6d.9O-=iO;P{1X.5T(2f.6d.2I);2f.6d=S;k.2H(2f,"fx")}}});k.bl=u(5Z){D 5f={};if(2g 5Z==\'4V\'){5Z=5Z.6c().7C(\';\');24(D i=0;i<5Z.1g;i++){6X=5Z[i].7C(\':\');if(6X.1g==2){5f[k.g6(6X[0].4E(/\\-(\\w)/g,u(m,c){E c.jo()}))]=k.g6(6X[1])}}}E 5f};k.fn.23({g3:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.61(q,H,J,\'4F\',G)})},gb:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.61(q,H,J,\'4r\',G)})},jl:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.61(q,H,J,\'fJ\',G)})},jk:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.61(q,H,J,\'O\',G)})},jg:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.61(q,H,J,\'2L\',G)})},jf:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.61(q,H,J,\'fh\',G)})}});k.fx.61=u(e,H,J,2S,G){if(!k.4K(e)){k.2H(e,\'1n\');E I}D z=q;z.el=k(e);z.1N=k.1a.2o(e);z.G=2g J==\'4V\'?J:G||S;if(!e.4s)e.4s=z.el.B(\'19\');if(2S==\'fJ\'){2S=z.el.B(\'19\')==\'1o\'?\'4r\':\'4F\'}P if(2S==\'fh\'){2S=z.el.B(\'19\')==\'1o\'?\'2L\':\'O\'}z.el.1Y();z.H=H;z.J=2g J==\'u\'?J:S;z.fx=k.fx.9P(e);z.2S=2S;z.21=u(){if(z.J&&z.J.1K==2A){z.J.1D(z.el.K(0))}if(z.2S==\'4r\'||z.2S==\'2L\'){z.el.B(\'19\',z.el.K(0).4s==\'1o\'?\'2B\':z.el.K(0).4s)}P{z.el.2G()}k.fx.a0(z.fx.3p.K(0),z.fx.V);k.2H(z.el.K(0),\'1n\')};3m(z.2S){1e\'4F\':63=12 k.fx(z.fx.3p.K(0),k.H(z.H,z.G,z.21),\'W\');63.1L(z.fx.V.1q.hb,0);1r;1e\'4r\':z.fx.3p.B(\'W\',\'9R\');z.el.1Y();63=12 k.fx(z.fx.3p.K(0),k.H(z.H,z.G,z.21),\'W\');63.1L(0,z.fx.V.1q.hb);1r;1e\'O\':63=12 k.fx(z.fx.3p.K(0),k.H(z.H,z.G,z.21),\'Z\');63.1L(z.fx.V.1q.1C,0);1r;1e\'2L\':z.fx.3p.B(\'Z\',\'9R\');z.el.1Y();63=12 k.fx(z.fx.3p.K(0),k.H(z.H,z.G,z.21),\'Z\');63.1L(0,z.fx.V.1q.1C);1r}};k.fn.ji=u(5D,J){E q.1w(\'1n\',u(){if(!k.4K(q)){k.2H(q,\'1n\');E I}D e=12 k.fx.f4(q,5D,J);e.bp()})};k.fx.f4=u(e,5D,J){D z=q;z.el=k(e);z.el.1Y();z.J=J;z.5D=T(5D)||40;z.V={};z.V.Y=z.el.B(\'Y\');z.V.Q=T(z.el.B(\'Q\'))||0;z.V.O=T(z.el.B(\'O\'))||0;if(z.V.Y!=\'2s\'&&z.V.Y!=\'1P\'){z.el.B(\'Y\',\'2s\')}z.3V=5;z.5y=1;z.bp=u(){z.5y++;z.e=12 k.fx(z.el.K(0),{1m:jj,21:u(){z.e=12 k.fx(z.el.K(0),{1m:80,21:u(){z.5D=T(z.5D/2);if(z.5y<=z.3V)z.bp();P{z.el.B(\'Y\',z.V.Y).B(\'Q\',z.V.Q+\'U\').B(\'O\',z.V.O+\'U\');k.2H(z.el.K(0),\'1n\');if(z.J&&z.J.1K==2A){z.J.1D(z.el.K(0))}}}},\'Q\');z.e.1L(z.V.Q-z.5D,z.V.Q)}},\'Q\');z.e.1L(z.V.Q,z.V.Q-z.5D)}};k.fn.23({jy:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.4f(q,H,J,\'4r\',\'4l\',G)})},jz:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.4f(q,H,J,\'4r\',\'in\',G)})},jA:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.4f(q,H,J,\'4r\',\'3R\',G)})},jB:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.4f(q,H,J,\'4F\',\'4l\',G)})},jx:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.4f(q,H,J,\'4F\',\'in\',G)})},jw:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.4f(q,H,J,\'4F\',\'3R\',G)})},js:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.4f(q,H,J,\'O\',\'4l\',G)})},jt:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.4f(q,H,J,\'O\',\'in\',G)})},ju:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.4f(q,H,J,\'O\',\'3R\',G)})},jv:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.4f(q,H,J,\'2L\',\'4l\',G)})},je:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.4f(q,H,J,\'2L\',\'in\',G)})},jd:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.4f(q,H,J,\'2L\',\'3R\',G)})}});k.fx.4f=u(e,H,J,2S,1u,G){if(!k.4K(e)){k.2H(e,\'1n\');E I}D z=q;z.el=k(e);z.G=2g J==\'4V\'?J:G||S;z.V={};z.V.Y=z.el.B(\'Y\');z.V.Q=z.el.B(\'Q\');z.V.O=z.el.B(\'O\');if(!e.4s)e.4s=z.el.B(\'19\');if(1u==\'3R\'){1u=z.el.B(\'19\')==\'1o\'?\'in\':\'4l\'}z.el.1Y();if(z.V.Y!=\'2s\'&&z.V.Y!=\'1P\'){z.el.B(\'Y\',\'2s\')}z.1u=1u;J=2g J==\'u\'?J:S;8H=1;3m(2S){1e\'4F\':z.e=12 k.fx(z.el.K(0),k.H(H-15,z.G,J),\'Q\');z.62=2m(z.V.Q)||0;z.9K=z.fG;8H=-1;1r;1e\'4r\':z.e=12 k.fx(z.el.K(0),k.H(H-15,z.G,J),\'Q\');z.62=2m(z.V.Q)||0;z.9K=z.fG;1r;1e\'2L\':z.e=12 k.fx(z.el.K(0),k.H(H-15,z.G,J),\'O\');z.62=2m(z.V.O)||0;z.9K=z.fy;1r;1e\'O\':z.e=12 k.fx(z.el.K(0),k.H(H-15,z.G,J),\'O\');z.62=2m(z.V.O)||0;z.9K=z.fy;8H=-1;1r}z.e2=12 k.fx(z.el.K(0),k.H(H,z.G,u(){z.el.B(z.V);if(z.1u==\'4l\'){z.el.B(\'19\',\'1o\')}P z.el.B(\'19\',z.el.K(0).4s==\'1o\'?\'2B\':z.el.K(0).4s);k.2H(z.el.K(0),\'1n\')}),\'1G\');if(1u==\'in\'){z.e.1L(z.62+2a*8H,z.62);z.e2.1L(0,1)}P{z.e.1L(z.62,z.62+2a*8H);z.e2.1L(1,0)}};k.fn.23({j0:u(H,W,J,G){E q.1w(\'1n\',u(){12 k.fx.9L(q,H,W,J,\'fp\',G)})},iW:u(H,W,J,G){E q.1w(\'1n\',u(){12 k.fx.9L(q,H,W,J,\'9M\',G)})},iV:u(H,W,J,G){E q.1w(\'1n\',u(){12 k.fx.9L(q,H,W,J,\'3R\',G)})}});k.fx.9L=u(e,H,W,J,1u,G){if(!k.4K(e)){k.2H(e,\'1n\');E I}D z=q;z.el=k(e);z.G=2g J==\'4V\'?J:G||S;z.J=2g J==\'u\'?J:S;if(1u==\'3R\'){1u=z.el.B(\'19\')==\'1o\'?\'9M\':\'fp\'}z.H=H;z.W=W&&W.1K==bn?W:20;z.fx=k.fx.9P(e);z.1u=1u;z.21=u(){if(z.J&&z.J.1K==2A){z.J.1D(z.el.K(0))}if(z.1u==\'9M\'){z.el.1Y()}P{z.el.2G()}k.fx.a0(z.fx.3p.K(0),z.fx.V);k.2H(z.el.K(0),\'1n\')};if(z.1u==\'9M\'){z.el.1Y();z.fx.3p.B(\'W\',z.W+\'U\').B(\'Z\',\'9R\');z.ef=12 k.fx(z.fx.3p.K(0),k.H(z.H,z.G,u(){z.ef=12 k.fx(z.fx.3p.K(0),k.H(z.H,z.G,z.21),\'W\');z.ef.1L(z.W,z.fx.V.1q.hb)}),\'Z\');z.ef.1L(0,z.fx.V.1q.1C)}P{z.ef=12 k.fx(z.fx.3p.K(0),k.H(z.H,z.G,u(){z.ef=12 k.fx(z.fx.3p.K(0),k.H(z.H,z.G,z.21),\'Z\');z.ef.1L(z.fx.V.1q.1C,0)}),\'W\');z.ef.1L(z.fx.V.1q.hb,z.W)}};k.fn.iR=u(H,4x,J,G){E q.1w(\'fv\',u(){q.6W=k(q).1p("14")||\'\';G=2g J==\'4V\'?J:G||S;J=2g J==\'u\'?J:S;D 9S=k(q).B(\'7i\');D 8I=q.31;7d(9S==\'cu\'&&8I){9S=k(8I).B(\'7i\');8I=8I.31}k(q).B(\'7i\',4x);if(2g q.6W==\'8T\')q.6W=q.6W["9X"];k(q).5w({\'7i\':9S},H,G,u(){k.2H(q,\'fv\');if(2g k(q).1p("14")==\'8T\'){k(q).1p("14")["9X"]="";k(q).1p("14")["9X"]=q.6W}P{k(q).1p("14",q.6W)}if(J)J.1D(q)})})};k.fn.23({iT:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.5m(q,H,J,\'49\',\'6g\',G)})},iU:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.5m(q,H,J,\'4j\',\'6g\',G)})},j1:u(H,J,G){E q.1w(\'1n\',u(){if(k.B(q,\'19\')==\'1o\'){12 k.fx.5m(q,H,J,\'4j\',\'6Z\',G)}P{12 k.fx.5m(q,H,J,\'4j\',\'6g\',G)}})},j2:u(H,J,G){E q.1w(\'1n\',u(){if(k.B(q,\'19\')==\'1o\'){12 k.fx.5m(q,H,J,\'49\',\'6Z\',G)}P{12 k.fx.5m(q,H,J,\'49\',\'6g\',G)}})},j9:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.5m(q,H,J,\'49\',\'6Z\',G)})},ja:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.5m(q,H,J,\'4j\',\'6Z\',G)})}});k.fx.5m=u(e,H,J,2S,1u,G){if(!k.4K(e)){k.2H(e,\'1n\');E I}D z=q;D 73=I;z.el=k(e);z.G=2g J==\'4V\'?J:G||S;z.J=2g J==\'u\'?J:S;z.1u=1u;z.H=H;z.2i=k.1a.2o(e);z.V={};z.V.Y=z.el.B(\'Y\');z.V.19=z.el.B(\'19\');if(z.V.19==\'1o\'){5Y=z.el.B(\'3n\');z.el.1Y();73=1b}z.V.Q=z.el.B(\'Q\');z.V.O=z.el.B(\'O\');if(73){z.el.2G();z.el.B(\'3n\',5Y)}z.V.Z=z.2i.w+\'U\';z.V.W=z.2i.h+\'U\';z.V.2U=z.el.B(\'2U\');z.2i.Q=T(z.V.Q)||0;z.2i.O=T(z.V.O)||0;if(z.V.Y!=\'2s\'&&z.V.Y!=\'1P\'){z.el.B(\'Y\',\'2s\')}z.el.B(\'2U\',\'2K\').B(\'W\',1u==\'6Z\'&&2S==\'49\'?1:z.2i.h+\'U\').B(\'Z\',1u==\'6Z\'&&2S==\'4j\'?1:z.2i.w+\'U\');z.21=u(){z.el.B(z.V);if(z.1u==\'6g\')z.el.2G();P z.el.1Y();k.2H(z.el.K(0),\'1n\')};3m(2S){1e\'49\':z.eh=12 k.fx(z.el.K(0),k.H(H-15,z.G,J),\'W\');z.et=12 k.fx(z.el.K(0),k.H(z.H,z.G,z.21),\'Q\');if(z.1u==\'6g\'){z.eh.1L(z.2i.h,0);z.et.1L(z.2i.Q,z.2i.Q+z.2i.h/2)}P{z.eh.1L(0,z.2i.h);z.et.1L(z.2i.Q+z.2i.h/2,z.2i.Q)}1r;1e\'4j\':z.eh=12 k.fx(z.el.K(0),k.H(H-15,z.G,J),\'Z\');z.et=12 k.fx(z.el.K(0),k.H(z.H,z.G,z.21),\'O\');if(z.1u==\'6g\'){z.eh.1L(z.2i.w,0);z.et.1L(z.2i.O,z.2i.O+z.2i.w/2)}P{z.eh.1L(0,z.2i.w);z.et.1L(z.2i.O+z.2i.w/2,z.2i.O)}1r}};k.fn.bg=u(H,3V,J){E q.1w(\'1n\',u(){if(!k.4K(q)){k.2H(q,\'1n\');E I}D fx=12 k.fx.bg(q,H,3V,J);fx.bf()})};k.fx.bg=u(el,H,3V,J){D z=q;z.3V=3V;z.5y=1;z.el=el;z.H=H;z.J=J;k(z.el).1Y();z.bf=u(){z.5y++;z.e=12 k.fx(z.el,k.H(z.H,u(){z.ef=12 k.fx(z.el,k.H(z.H,u(){if(z.5y<=z.3V)z.bf();P{k.2H(z.el,\'1n\');if(z.J&&z.J.1K==2A){z.J.1D(z.el)}}}),\'1G\');z.ef.1L(0,1)}),\'1G\');z.e.1L(1,0)}};k.fn.23({jb:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.6G(q,H,1,2a,1b,J,\'fa\',G)})},jc:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.6G(q,H,2a,1,1b,J,\'b4\',G)})},j8:u(H,J,G){E q.1w(\'1n\',u(){D G=G||\'fl\';12 k.fx.6G(q,H,2a,f8,1b,J,\'6h\',G)})},6G:u(H,57,30,6H,J,G){E q.1w(\'1n\',u(){12 k.fx.6G(q,H,57,30,6H,J,\'6G\',G)})}});k.fx.6G=u(e,H,57,30,6H,J,1u,G){if(!k.4K(e)){k.2H(e,\'1n\');E I}D z=q;z.el=k(e);z.57=T(57)||2a;z.30=T(30)||2a;z.G=2g J==\'4V\'?J:G||S;z.J=2g J==\'u\'?J:S;z.1m=k.H(H).1m;z.6H=6H||S;z.2i=k.1a.2o(e);z.V={Z:z.el.B(\'Z\'),W:z.el.B(\'W\'),4A:z.el.B(\'4A\')||\'2a%\',Y:z.el.B(\'Y\'),19:z.el.B(\'19\'),Q:z.el.B(\'Q\'),O:z.el.B(\'O\'),2U:z.el.B(\'2U\'),4S:z.el.B(\'4S\'),5O:z.el.B(\'5O\'),5Q:z.el.B(\'5Q\'),5b:z.el.B(\'5b\'),5M:z.el.B(\'5M\'),5U:z.el.B(\'5U\'),5n:z.el.B(\'5n\'),4X:z.el.B(\'4X\')};z.Z=T(z.V.Z)||e.4c||0;z.W=T(z.V.W)||e.5W||0;z.Q=T(z.V.Q)||0;z.O=T(z.V.O)||0;1q=[\'em\',\'U\',\'j7\',\'%\'];24(i in 1q){if(z.V.4A.3J(1q[i])>0){z.fg=1q[i];z.4A=2m(z.V.4A)}if(z.V.4S.3J(1q[i])>0){z.fc=1q[i];z.bw=2m(z.V.4S)||0}if(z.V.5O.3J(1q[i])>0){z.fe=1q[i];z.bc=2m(z.V.5O)||0}if(z.V.5Q.3J(1q[i])>0){z.fL=1q[i];z.bA=2m(z.V.5Q)||0}if(z.V.5b.3J(1q[i])>0){z.g8=1q[i];z.bt=2m(z.V.5b)||0}if(z.V.5M.3J(1q[i])>0){z.g4=1q[i];z.bx=2m(z.V.5M)||0}if(z.V.5U.3J(1q[i])>0){z.g9=1q[i];z.bv=2m(z.V.5U)||0}if(z.V.5n.3J(1q[i])>0){z.gc=1q[i];z.bj=2m(z.V.5n)||0}if(z.V.4X.3J(1q[i])>0){z.fK=1q[i];z.b7=2m(z.V.4X)||0}}if(z.V.Y!=\'2s\'&&z.V.Y!=\'1P\'){z.el.B(\'Y\',\'2s\')}z.el.B(\'2U\',\'2K\');z.1u=1u;3m(z.1u){1e\'fa\':z.4b=z.Q+z.2i.h/2;z.5a=z.Q;z.4k=z.O+z.2i.w/2;z.59=z.O;1r;1e\'b4\':z.5a=z.Q+z.2i.h/2;z.4b=z.Q;z.59=z.O+z.2i.w/2;z.4k=z.O;1r;1e\'6h\':z.5a=z.Q-z.2i.h/4;z.4b=z.Q;z.59=z.O-z.2i.w/4;z.4k=z.O;1r}z.be=I;z.t=(12 7g).7z();z.4w=u(){5T(z.2I);z.2I=S};z.2D=u(){if(z.be==I){z.el.1Y();z.be=1b}D t=(12 7g).7z();D n=t-z.t;D p=n/z.1m;if(t>=z.1m+z.t){9T(u(){o=1;if(z.1u){t=z.5a;l=z.59;if(z.1u==\'6h\')o=0}z.bs(z.30,l,t,1b,o)},13);z.4w()}P{o=1;if(!k.G||!k.G[z.G]){s=((-18.5H(p*18.2Q)/2)+0.5)*(z.30-z.57)+z.57}P{s=k.G[z.G](p,n,z.57,(z.30-z.57),z.1m)}if(z.1u){if(!k.G||!k.G[z.G]){t=((-18.5H(p*18.2Q)/2)+0.5)*(z.5a-z.4b)+z.4b;l=((-18.5H(p*18.2Q)/2)+0.5)*(z.59-z.4k)+z.4k;if(z.1u==\'6h\')o=((-18.5H(p*18.2Q)/2)+0.5)*(-0.9Y)+0.9Y}P{t=k.G[z.G](p,n,z.4b,(z.5a-z.4b),z.1m);l=k.G[z.G](p,n,z.4k,(z.59-z.4k),z.1m);if(z.1u==\'6h\')o=k.G[z.G](p,n,0.9Y,-0.9Y,z.1m)}}z.bs(s,l,t,I,o)}};z.2I=6V(u(){z.2D()},13);z.bs=u(4q,O,Q,fM,1G){z.el.B(\'W\',z.W*4q/2a+\'U\').B(\'Z\',z.Z*4q/2a+\'U\').B(\'O\',O+\'U\').B(\'Q\',Q+\'U\').B(\'4A\',z.4A*4q/2a+z.fg);if(z.bw)z.el.B(\'4S\',z.bw*4q/2a+z.fc);if(z.bc)z.el.B(\'5O\',z.bc*4q/2a+z.fe);if(z.bA)z.el.B(\'5Q\',z.bA*4q/2a+z.fL);if(z.bt)z.el.B(\'5b\',z.bt*4q/2a+z.g8);if(z.bx)z.el.B(\'5M\',z.bx*4q/2a+z.g4);if(z.bv)z.el.B(\'5U\',z.bv*4q/2a+z.g9);if(z.bj)z.el.B(\'5n\',z.bj*4q/2a+z.gc);if(z.b7)z.el.B(\'4X\',z.b7*4q/2a+z.fK);if(z.1u==\'6h\'){if(1X.71)z.el.K(0).14.5E="8V(1G="+1G*2a+")";z.el.K(0).14.1G=1G}if(fM){if(z.6H){z.el.B(z.V)}if(z.1u==\'b4\'||z.1u==\'6h\'){z.el.B(\'19\',\'1o\');if(z.1u==\'6h\'){if(1X.71)z.el.K(0).14.5E="8V(1G="+2a+")";z.el.K(0).14.1G=1}}P z.el.B(\'19\',\'2B\');if(z.J)z.J.1D(z.el.K(0));k.2H(z.el.K(0),\'1n\')}}};k.fn.23({9U:u(H,1O,G){o=k.H(H);E q.1w(\'1n\',u(){12 k.fx.9U(q,o,1O,G)})},j6:u(H,1O,G){E q.1E(u(){k(\'a[@3h*="#"]\',q).5h(u(e){fW=q.3h.7C(\'#\');k(\'#\'+fW[1]).9U(H,1O,G);E I})})}});k.fx.9U=u(e,o,1O,G){D z=q;z.o=o;z.e=e;z.1O=/fT|gd/.48(1O)?1O:I;z.G=G;p=k.1a.3w(e);s=k.1a.6z();z.4w=u(){5T(z.2I);z.2I=S;k.2H(z.e,\'1n\')};z.t=(12 7g).7z();s.h=s.h>s.ih?(s.h-s.ih):s.h;s.w=s.w>s.iw?(s.w-s.iw):s.w;z.5a=p.y>s.h?s.h:p.y;z.59=p.x>s.w?s.w:p.x;z.4b=s.t;z.4k=s.l;z.2D=u(){D t=(12 7g).7z();D n=t-z.t;D p=n/z.o.1m;if(t>=z.o.1m+z.t){z.4w();9T(u(){z.d3(z.5a,z.59)},13)}P{if(!z.1O||z.1O==\'fT\'){if(!k.G||!k.G[z.G]){9V=((-18.5H(p*18.2Q)/2)+0.5)*(z.5a-z.4b)+z.4b}P{9V=k.G[z.G](p,n,z.4b,(z.5a-z.4b),z.o.1m)}}P{9V=z.4b}if(!z.1O||z.1O==\'gd\'){if(!k.G||!k.G[z.G]){9W=((-18.5H(p*18.2Q)/2)+0.5)*(z.59-z.4k)+z.4k}P{9W=k.G[z.G](p,n,z.4k,(z.59-z.4k),z.o.1m)}}P{9W=z.4k}z.d3(9V,9W)}};z.d3=u(t,l){1X.j4(l,t)};z.2I=6V(u(){z.2D()},13)};k.fn.cY=u(3V,J){E q.1w(\'1n\',u(){if(!k.4K(q)){k.2H(q,\'1n\');E I}D e=12 k.fx.cY(q,3V,J);e.cG()})};k.fx.cY=u(e,3V,J){D z=q;z.el=k(e);z.el.1Y();z.3V=T(3V)||3;z.J=J;z.5y=1;z.V={};z.V.Y=z.el.B(\'Y\');z.V.Q=T(z.el.B(\'Q\'))||0;z.V.O=T(z.el.B(\'O\'))||0;if(z.V.Y!=\'2s\'&&z.V.Y!=\'1P\'){z.el.B(\'Y\',\'2s\')}z.cG=u(){z.5y++;z.e=12 k.fx(z.el.K(0),{1m:60,21:u(){z.e=12 k.fx(z.el.K(0),{1m:60,21:u(){z.e=12 k.fx(e,{1m:60,21:u(){if(z.5y<=z.3V)z.cG();P{z.el.B(\'Y\',z.V.Y).B(\'Q\',z.V.Q+\'U\').B(\'O\',z.V.O+\'U\');k.2H(z.el.K(0),\'1n\');if(z.J&&z.J.1K==2A){z.J.1D(z.el.K(0))}}}},\'O\');z.e.1L(z.V.O-20,z.V.O)}},\'O\');z.e.1L(z.V.O+20,z.V.O-20)}},\'O\');z.e.1L(z.V.O,z.V.O+20)}};k.fn.23({fo:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.1z(q,H,J,\'4F\',\'in\',G)})},fq:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.1z(q,H,J,\'4F\',\'4l\',G)})},iY:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.1z(q,H,J,\'4F\',\'3R\',G)})},iX:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.1z(q,H,J,\'4r\',\'in\',G)})},jr:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.1z(q,H,J,\'4r\',\'4l\',G)})},jq:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.1z(q,H,J,\'4r\',\'3R\',G)})},jp:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.1z(q,H,J,\'O\',\'in\',G)})},jn:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.1z(q,H,J,\'O\',\'4l\',G)})},jm:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.1z(q,H,J,\'O\',\'3R\',G)})},iP:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.1z(q,H,J,\'2L\',\'in\',G)})},ic:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.1z(q,H,J,\'2L\',\'4l\',G)})},ib:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.1z(q,H,J,\'2L\',\'3R\',G)})}});k.fx.1z=u(e,H,J,2S,1u,G){if(!k.4K(e)){k.2H(e,\'1n\');E I}D z=q;z.el=k(e);z.G=2g J==\'4V\'?J:G||S;z.J=2g J==\'u\'?J:S;if(1u==\'3R\'){1u=z.el.B(\'19\')==\'1o\'?\'in\':\'4l\'}if(!e.4s)e.4s=z.el.B(\'19\');z.el.1Y();z.H=H;z.fx=k.fx.9P(e);z.1u=1u;z.2S=2S;z.21=u(){if(z.1u==\'4l\')z.el.B(\'3n\',\'2K\');k.fx.a0(z.fx.3p.K(0),z.fx.V);if(z.1u==\'in\'){z.el.B(\'19\',z.el.K(0).4s==\'1o\'?\'2B\':z.el.K(0).4s)}P{z.el.B(\'19\',\'1o\');z.el.B(\'3n\',\'dd\')}if(z.J&&z.J.1K==2A){z.J.1D(z.el.K(0))}k.2H(z.el.K(0),\'1n\')};3m(z.2S){1e\'4F\':z.ef=12 k.fx(z.el.K(0),k.H(z.H,z.G,z.21),\'Q\');z.7v=12 k.fx(z.fx.3p.K(0),k.H(z.H,z.G),\'W\');if(z.1u==\'in\'){z.ef.1L(-z.fx.V.1q.hb,0);z.7v.1L(0,z.fx.V.1q.hb)}P{z.ef.1L(0,-z.fx.V.1q.hb);z.7v.1L(z.fx.V.1q.hb,0)}1r;1e\'4r\':z.ef=12 k.fx(z.el.K(0),k.H(z.H,z.G,z.21),\'Q\');if(z.1u==\'in\'){z.ef.1L(z.fx.V.1q.hb,0)}P{z.ef.1L(0,z.fx.V.1q.hb)}1r;1e\'O\':z.ef=12 k.fx(z.el.K(0),k.H(z.H,z.G,z.21),\'O\');z.7v=12 k.fx(z.fx.3p.K(0),k.H(z.H,z.G),\'Z\');if(z.1u==\'in\'){z.ef.1L(-z.fx.V.1q.1C,0);z.7v.1L(0,z.fx.V.1q.1C)}P{z.ef.1L(0,-z.fx.V.1q.1C);z.7v.1L(z.fx.V.1q.1C,0)}1r;1e\'2L\':z.ef=12 k.fx(z.el.K(0),k.H(z.H,z.G,z.21),\'O\');if(z.1u==\'in\'){z.ef.1L(z.fx.V.1q.1C,0)}P{z.ef.1L(0,z.fx.V.1q.1C)}1r}};k.3f=S;k.fn.ig=u(o){E q.1w(\'1n\',u(){12 k.fx.dG(q,o)})};k.fx.dG=u(e,o){if(k.3f==S){k(\'2e\',1h).1S(\'<22 id="3f"></22>\');k.3f=k(\'#3f\')}k.3f.B(\'19\',\'2B\').B(\'Y\',\'1P\');D z=q;z.el=k(e);if(!o||!o.30){E}if(o.30.1K==b0&&1h.9e(o.30)){o.30=1h.9e(o.30)}P if(!o.30.dq){E}if(!o.1m){o.1m=g5}z.1m=o.1m;z.30=o.30;z.8r=o.3l;z.21=o.21;if(z.8r){k.3f.2R(z.8r)}z.a3=0;z.a2=0;if(k.dF){z.a3=(T(k.3f.B(\'5b\'))||0)+(T(k.3f.B(\'5O\'))||0)+(T(k.3f.B(\'4X\'))||0)+(T(k.3f.B(\'5U\'))||0);z.a2=(T(k.3f.B(\'4S\'))||0)+(T(k.3f.B(\'5Q\'))||0)+(T(k.3f.B(\'5M\'))||0)+(T(k.3f.B(\'5n\'))||0)}z.26=k.23(k.1a.3w(z.el.K(0)),k.1a.2o(z.el.K(0)));z.2T=k.23(k.1a.3w(z.30),k.1a.2o(z.30));z.26.1C-=z.a3;z.26.hb-=z.a2;z.2T.1C-=z.a3;z.2T.hb-=z.a2;z.J=o.21;k.3f.B(\'Z\',z.26.1C+\'U\').B(\'W\',z.26.hb+\'U\').B(\'Q\',z.26.y+\'U\').B(\'O\',z.26.x+\'U\').5w({Q:z.2T.y,O:z.2T.x,Z:z.2T.1C,W:z.2T.hb},z.1m,u(){if(z.8r)k.3f.4i(z.8r);k.3f.B(\'19\',\'1o\');if(z.21&&z.21.1K==2A){z.21.1D(z.el.K(0),[z.30])}k.2H(z.el.K(0),\'1n\')})};k.1v={M:{2E:10,ec:\'1Q/iJ.eZ\',e3:\'<1T 2J="1Q/6g.da" />\',eW:0.8,d8:\'iN a6\',dc:\'57\',3W:8J},jQ:I,jW:I,6j:S,8m:I,8k:I,d1:u(2k){if(!k.1v.8k||k.1v.8m)E;D 3K=2k.7L||2k.7K||-1;3m(3K){1e 35:if(k.1v.6j)k.1v.26(S,k(\'a[@4I=\'+k.1v.6j+\']:jJ\').K(0));1r;1e 36:if(k.1v.6j)k.1v.26(S,k(\'a[@4I=\'+k.1v.6j+\']:jL\').K(0));1r;1e 37:1e 8:1e 33:1e 80:1e kb:D 9p=k(\'#87\');if(9p.K(0).53!=S){9p.K(0).53.1D(9p.K(0))}1r;1e 38:1r;1e 39:1e 34:1e 32:1e gl:1e 78:D 9k=k(\'#88\');if(9k.K(0).53!=S){9k.K(0).53.1D(9k.K(0))}1r;1e 40:1r;1e 27:k.1v.au();1r}},7q:u(M){if(M)k.23(k.1v.M,M);if(1X.2k){k(\'2e\',1h).1J(\'6y\',k.1v.d1)}P{k(1h).1J(\'6y\',k.1v.d1)}k(\'a\').1E(u(){el=k(q);en=el.1p(\'4I\')||\'\';e9=el.1p(\'3h\')||\'\';ev=/\\.da|\\.gw|\\.8X|\\.eZ|\\.gn/g;if(e9.6c().d5(ev)!=S&&en.6c().3J(\'eU\')==0){el.1J(\'5h\',k.1v.26)}});if(k.3a.4t){3A=1h.3F(\'3A\');k(3A).1p({id:\'cN\',2J:\'ek:I;\',ej:\'cD\',ep:\'cD\'}).B({19:\'1o\',Y:\'1P\',Q:\'0\',O:\'0\',5E:\'9n:9w.9y.cC(1G=0)\'});k(\'2e\').1S(3A)}8n=1h.3F(\'22\');k(8n).1p(\'id\',\'cP\').B({Y:\'1P\',19:\'1o\',Q:\'0\',O:\'0\',1G:0}).1S(1h.8M(\' \')).1J(\'5h\',k.1v.au);6A=1h.3F(\'22\');k(6A).1p(\'id\',\'eK\').B({4X:k.1v.M.2E+\'U\'}).1S(1h.8M(\' \'));cE=1h.3F(\'22\');k(cE).1p(\'id\',\'dg\').B({4X:k.1v.M.2E+\'U\',5n:k.1v.M.2E+\'U\'}).1S(1h.8M(\' \'));cF=1h.3F(\'a\');k(cF).1p({id:\'gg\',3h:\'#\'}).B({Y:\'1P\',2L:k.1v.M.2E+\'U\',Q:\'0\'}).1S(k.1v.M.e3).1J(\'5h\',k.1v.au);7m=1h.3F(\'22\');k(7m).1p(\'id\',\'cM\').B({Y:\'2s\',cA:\'O\',6w:\'0 9F\',3I:1}).1S(6A).1S(cE).1S(cF);2b=1h.3F(\'1T\');2b.2J=k.1v.M.ec;k(2b).1p(\'id\',\'eM\').B({Y:\'1P\'});4G=1h.3F(\'a\');k(4G).1p({id:\'87\',3h:\'#\'}).B({Y:\'1P\',19:\'1o\',2U:\'2K\',ey:\'1o\'}).1S(1h.8M(\' \'));4M=1h.3F(\'a\');k(4M).1p({id:\'88\',3h:\'#\'}).B({Y:\'1P\',2U:\'2K\',ey:\'1o\'}).1S(1h.8M(\' \'));1Z=1h.3F(\'22\');k(1Z).1p(\'id\',\'eE\').B({19:\'1o\',Y:\'2s\',2U:\'2K\',cA:\'O\',6w:\'0 9F\',Q:\'0\',O:\'0\',3I:2}).1S([2b,4G,4M]);6F=1h.3F(\'22\');k(6F).1p(\'id\',\'ao\').B({19:\'1o\',Y:\'1P\',2U:\'2K\',Q:\'0\',O:\'0\',cA:\'cv\',7i:\'cu\',hC:\'0\'}).1S([1Z,7m]);k(\'2e\').1S(8n).1S(6F)},26:u(e,C){el=C?k(C):k(q);9t=el.1p(\'4I\');D 6B,4u,4G,4M;if(9t!=\'eU\'){k.1v.6j=9t;8Y=k(\'a[@4I=\'+9t+\']\');6B=8Y.1N();4u=8Y.cZ(C?C:q);4G=8Y.K(4u-1);4M=8Y.K(4u+1)}89=el.1p(\'3h\');6A=el.1p(\'4g\');3O=k.1a.6z();8n=k(\'#cP\');if(!k.1v.8k){k.1v.8k=1b;if(k.3a.4t){k(\'#cN\').B(\'W\',18.3r(3O.ih,3O.h)+\'U\').B(\'Z\',18.3r(3O.iw,3O.w)+\'U\').1Y()}8n.B(\'W\',18.3r(3O.ih,3O.h)+\'U\').B(\'Z\',18.3r(3O.iw,3O.w)+\'U\').1Y().fX(cO,k.1v.M.eW,u(){k.1v.cw(89,6A,3O,6B,4u,4G,4M)});k(\'#ao\').B(\'Z\',18.3r(3O.iw,3O.w)+\'U\')}P{k(\'#87\').K(0).53=S;k(\'#88\').K(0).53=S;k.1v.cw(89,6A,3O,6B,4u,4G,4M)}E I},cw:u(89,gP,3O,6B,4u,4G,4M){k(\'#cW\').bk();aX=k(\'#87\');aX.2G();aO=k(\'#88\');aO.2G();2b=k(\'#eM\');1Z=k(\'#eE\');6F=k(\'#ao\');7m=k(\'#cM\').B(\'3n\',\'2K\');k(\'#eK\').3x(6A);k.1v.8m=1b;if(6B)k(\'#dg\').3x(k.1v.M.d8+\' \'+(4u+1)+\' \'+k.1v.M.dc+\' \'+6B);if(4G){aX.K(0).53=u(){q.5B();k.1v.26(S,4G);E I}}if(4M){aO.K(0).53=u(){q.5B();k.1v.26(S,4M);E I}}2b.1Y();82=k.1a.2o(1Z.K(0));56=18.3r(82.1C,2b.K(0).Z+k.1v.M.2E*2);6f=18.3r(82.hb,2b.K(0).W+k.1v.M.2E*2);2b.B({O:(56-2b.K(0).Z)/2+\'U\',Q:(6f-2b.K(0).W)/2+\'U\'});1Z.B({Z:56+\'U\',W:6f+\'U\'}).1Y();dw=k.1a.bm();6F.B(\'Q\',3O.t+(dw.h/15)+\'U\');if(6F.B(\'19\')==\'1o\'){6F.1Y().7f(k.1v.M.3W)}6k=12 9s;k(6k).1p(\'id\',\'cW\').1J(\'hJ\',u(){56=6k.Z+k.1v.M.2E*2;6f=6k.W+k.1v.M.2E*2;2b.2G();1Z.5w({W:6f},82.hb!=6f?k.1v.M.3W:1,u(){1Z.5w({Z:56},82.1C!=56?k.1v.M.3W:1,u(){1Z.bG(6k);k(6k).B({Y:\'1P\',O:k.1v.M.2E+\'U\',Q:k.1v.M.2E+\'U\'}).7f(k.1v.M.3W,u(){db=k.1a.2o(7m.K(0));if(4G){aX.B({O:k.1v.M.2E+\'U\',Q:k.1v.M.2E+\'U\',Z:56/2-k.1v.M.2E*3+\'U\',W:6f-k.1v.M.2E*2+\'U\'}).1Y()}if(4M){aO.B({O:56/2+k.1v.M.2E*2+\'U\',Q:k.1v.M.2E+\'U\',Z:56/2-k.1v.M.2E*3+\'U\',W:6f-k.1v.M.2E*2+\'U\'}).1Y()}7m.B({Z:56+\'U\',Q:-db.hb+\'U\',3n:\'dd\'}).5w({Q:-1},k.1v.M.3W,u(){k.1v.8m=I})})})})});6k.2J=89},au:u(){k(\'#cW\').bk();k(\'#ao\').2G();k(\'#cM\').B(\'3n\',\'2K\');k(\'#cP\').fX(cO,0,u(){k(q).2G();if(k.3a.4t){k(\'#cN\').2G()}});k(\'#87\').K(0).53=S;k(\'#88\').K(0).53=S;k.1v.6j=S;k.1v.8k=I;k.1v.8m=I;E I}};k.R={1A:S,41:S,F:S,1s:S,1q:S,Y:S,9a:u(e){k.R.F=(q.d0)?q.d0:q;k.R.1s=k.1a.4a(e);k.R.1q={Z:T(k(k.R.F).B(\'Z\'))||0,W:T(k(k.R.F).B(\'W\'))||0};k.R.Y={Q:T(k(k.R.F).B(\'Q\'))||0,O:T(k(k.R.F).B(\'O\'))||0};k(1h).1J(\'3D\',k.R.cR).1J(\'5P\',k.R.cK);if(2g k.R.F.1k.g2===\'u\'){k.R.F.1k.g2.1D(k.R.F)}E I},cK:u(e){k(1h).3q(\'3D\',k.R.cR).3q(\'5P\',k.R.cK);if(2g k.R.F.1k.fN===\'u\'){k.R.F.1k.fN.1D(k.R.F)}k.R.F=S},cR:u(e){if(!k.R.F){E}1s=k.1a.4a(e);7p=k.R.Y.Q-k.R.1s.y+1s.y;7r=k.R.Y.O-k.R.1s.x+1s.x;7p=18.3r(18.3L(7p,k.R.F.1k.8g-k.R.1q.W),k.R.F.1k.7h);7r=18.3r(18.3L(7r,k.R.F.1k.8h-k.R.1q.Z),k.R.F.1k.70);if(2g k.R.F.1k.4m===\'u\'){D 8a=k.R.F.1k.4m.1D(k.R.F,[7r,7p]);if(2g 8a==\'hh\'&&8a.1g==2){7r=8a[0];7p=8a[1]}}k.R.F.14.Q=7p+\'U\';k.R.F.14.O=7r+\'U\';E I},26:u(e){k(1h).1J(\'3D\',k.R.8j).1J(\'5P\',k.R.8o);k.R.1A=q.1A;k.R.41=q.41;k.R.1s=k.1a.4a(e);k.R.1q={Z:T(k(q.1A).B(\'Z\'))||0,W:T(k(q.1A).B(\'W\'))||0};k.R.Y={Q:T(k(q.1A).B(\'Q\'))||0,O:T(k(q.1A).B(\'O\'))||0};if(k.R.1A.1k.4o){k.R.1A.1k.4o.1D(k.R.1A,[q])}E I},8o:u(){k(1h).3q(\'3D\',k.R.8j).3q(\'5P\',k.R.8o);if(k.R.1A.1k.3T){k.R.1A.1k.3T.1D(k.R.1A,[k.R.41])}k.R.1A=S;k.R.41=S},6i:u(dx,az){E 18.3L(18.3r(k.R.1q.Z+dx*az,k.R.1A.1k.av),k.R.1A.1k.6x)},6m:u(dy,az){E 18.3L(18.3r(k.R.1q.W+dy*az,k.R.1A.1k.8c),k.R.1A.1k.8b)},fb:u(W){E 18.3L(18.3r(W,k.R.1A.1k.8c),k.R.1A.1k.8b)},8j:u(e){if(k.R.1A==S){E}1s=k.1a.4a(e);dx=1s.x-k.R.1s.x;dy=1s.y-k.R.1s.y;1I={Z:k.R.1q.Z,W:k.R.1q.W};2z={Q:k.R.Y.Q,O:k.R.Y.O};3m(k.R.41){1e\'e\':1I.Z=k.R.6i(dx,1);1r;1e\'fj\':1I.Z=k.R.6i(dx,1);1I.W=k.R.6m(dy,1);1r;1e\'w\':1I.Z=k.R.6i(dx,-1);2z.O=k.R.Y.O-1I.Z+k.R.1q.Z;1r;1e\'5F\':1I.Z=k.R.6i(dx,-1);2z.O=k.R.Y.O-1I.Z+k.R.1q.Z;1I.W=k.R.6m(dy,1);1r;1e\'76\':1I.W=k.R.6m(dy,-1);2z.Q=k.R.Y.Q-1I.W+k.R.1q.W;1I.Z=k.R.6i(dx,-1);2z.O=k.R.Y.O-1I.Z+k.R.1q.Z;1r;1e\'n\':1I.W=k.R.6m(dy,-1);2z.Q=k.R.Y.Q-1I.W+k.R.1q.W;1r;1e\'at\':1I.W=k.R.6m(dy,-1);2z.Q=k.R.Y.Q-1I.W+k.R.1q.W;1I.Z=k.R.6i(dx,1);1r;1e\'s\':1I.W=k.R.6m(dy,1);1r}if(k.R.1A.1k.4v){if(k.R.41==\'n\'||k.R.41==\'s\')4p=1I.W*k.R.1A.1k.4v;P 4p=1I.Z;4W=k.R.fb(4p*k.R.1A.1k.4v);4p=4W/k.R.1A.1k.4v;3m(k.R.41){1e\'n\':1e\'76\':1e\'at\':2z.Q+=1I.W-4W;1r}3m(k.R.41){1e\'76\':1e\'w\':1e\'5F\':2z.O+=1I.Z-4p;1r}1I.W=4W;1I.Z=4p}if(2z.Q<k.R.1A.1k.7h){4W=1I.W+2z.Q-k.R.1A.1k.7h;2z.Q=k.R.1A.1k.7h;if(k.R.1A.1k.4v){4p=4W/k.R.1A.1k.4v;3m(k.R.41){1e\'76\':1e\'w\':1e\'5F\':2z.O+=1I.Z-4p;1r}1I.Z=4p}1I.W=4W}if(2z.O<k.R.1A.1k.70){4p=1I.Z+2z.O-k.R.1A.1k.70;2z.O=k.R.1A.1k.70;if(k.R.1A.1k.4v){4W=4p*k.R.1A.1k.4v;3m(k.R.41){1e\'n\':1e\'76\':1e\'at\':2z.Q+=1I.W-4W;1r}1I.W=4W}1I.Z=4p}if(2z.Q+1I.W>k.R.1A.1k.8g){1I.W=k.R.1A.1k.8g-2z.Q;if(k.R.1A.1k.4v){1I.Z=1I.W/k.R.1A.1k.4v}}if(2z.O+1I.Z>k.R.1A.1k.8h){1I.Z=k.R.1A.1k.8h-2z.O;if(k.R.1A.1k.4v){1I.W=1I.Z*k.R.1A.1k.4v}}D 6p=I;if(k.R.1A.1k.f7){6p=k.R.1A.1k.f7.1D(k.R.1A,[1I,2z]);if(6p){if(6p.1q){k.23(1I,6p.1q)}if(6p.Y){k.23(2z,6p.Y)}}}8d=k.R.1A.14;8d.O=2z.O+\'U\';8d.Q=2z.Q+\'U\';8d.Z=1I.Z+\'U\';8d.W=1I.W+\'U\';E I},2r:u(M){if(!M||!M.3Z||M.3Z.1K!=7M){E}E q.1E(u(){D el=q;el.1k=M;el.1k.av=M.av||10;el.1k.8c=M.8c||10;el.1k.6x=M.6x||6P;el.1k.8b=M.8b||6P;el.1k.7h=M.7h||-aC;el.1k.70=M.70||-aC;el.1k.8h=M.8h||6P;el.1k.8g=M.8g||6P;d6=k(el).B(\'Y\');if(!(d6==\'2s\'||d6==\'1P\')){el.14.Y=\'2s\'}fS=/n|at|e|fj|s|5F|w|76/g;24(i in el.1k.3Z){if(i.6c().d5(fS)!=S){if(el.1k.3Z[i].1K==b0){3v=k(el.1k.3Z[i]);if(3v.1N()>0){el.1k.3Z[i]=3v.K(0)}}if(el.1k.3Z[i].4Y){el.1k.3Z[i].1A=el;el.1k.3Z[i].41=i;k(el.1k.3Z[i]).1J(\'5v\',k.R.26)}}}if(el.1k.5S){if(2g el.1k.5S===\'4V\'){aV=k(el.1k.5S);if(aV.1N()>0){aV.1E(u(){q.d0=el});aV.1J(\'5v\',k.R.9a)}}P if(el.1k.5S==1b){k(q).1J(\'5v\',k.R.9a)}}})},4U:u(){E q.1E(u(){D el=q;24(i in el.1k.3Z){el.1k.3Z[i].1A=S;el.1k.3Z[i].41=S;k(el.1k.3Z[i]).3q(\'5v\',k.R.26)}if(el.1k.5S){if(2g el.1k.5S===\'4V\'){3v=k(el.1k.5S);if(3v.1N()>0){3v.3q(\'5v\',k.R.9a)}}P if(el.1k.5S==1b){k(q).3q(\'5v\',k.R.9a)}}el.1k=S})}};k.fn.23({hz:k.R.2r,hs:k.R.4U});k.2C=S;k.7n=I;k.3k=S;k.7o=[];k.9v=u(e){D 3K=e.7L||e.7K||-1;if(3K==17||3K==16){k.7n=1b}};k.9u=u(e){k.7n=I};k.dL=u(e){q.f.1s=k.1a.4a(e);q.f.1M=k.23(k.1a.3w(q),k.1a.2o(q));q.f.3e=k.1a.6z(q);q.f.1s.x-=q.f.1M.x;q.f.1s.y-=q.f.1M.y;k(q).1S(k.2C.K(0));if(q.f.hc)k.2C.2R(q.f.hc).B(\'19\',\'2B\');k.2C.B({19:\'2B\',Z:\'2P\',W:\'2P\'});if(q.f.o){k.2C.B(\'1G\',q.f.o)}k.3k=q;k.96=I;k.7o=[];q.f.el.1E(u(){q.1M={x:q.8t+(q.4Z&&!k.3a.7I?T(q.4Z.5b)||0:0)+(k.3k.3c||0),y:q.8G+(q.4Z&&!k.3a.7I?T(q.4Z.4S)||0:0)+(k.3k.3d||0),1C:q.4c,hb:q.5W};if(q.s==1b){if(k.7n==I){q.s=I;k(q).4i(k.3k.f.7j)}P{k.96=1b;k.7o[k.7o.1g]=k.1p(q,\'id\')}}});k.am.1D(q,[e]);k(1h).1J(\'3D\',k.am).1J(\'5P\',k.cX);E I};k.am=u(e){if(!k.3k)E;k.fd.1D(k.3k,[e])};k.fd=u(e){if(!k.3k)E;D 1s=k.1a.4a(e);D 3e=k.1a.6z(k.3k);1s.x+=3e.l-q.f.3e.l-q.f.1M.x;1s.y+=3e.t-q.f.3e.t-q.f.1M.y;D 93=18.3L(1s.x,q.f.1s.x);D 5F=18.3L(18.3S(1s.x-q.f.1s.x),18.3S(q.f.3e.w-93));D 99=18.3L(1s.y,q.f.1s.y);D 9g=18.3L(18.3S(1s.y-q.f.1s.y),18.3S(q.f.3e.h-99));if(q.3d>0&&1s.y-20<q.3d){D 3X=18.3L(3e.t,10);99-=3X;9g+=3X;q.3d-=3X}P if(q.3d+q.f.1M.h<q.f.3e.h&&1s.y+20>q.3d+q.f.1M.h){D 3X=18.3L(q.f.3e.h-q.3d,10);q.3d+=3X;if(q.3d!=3e.t)9g+=3X}if(q.3c>0&&1s.x-20<q.3c){D 3X=18.3L(3e.l,10);93-=3X;5F+=3X;q.3c-=3X}P if(q.3c+q.f.1M.w<q.f.3e.w&&1s.x+20>q.3c+q.f.1M.w){D 3X=18.3L(q.f.3e.w-q.3c,10);q.3c+=3X;if(q.3c!=3e.l)5F+=3X}k.2C.B({O:93+\'U\',Q:99+\'U\',Z:5F+\'U\',W:9g+\'U\'});k.2C.l=93+q.f.3e.l;k.2C.t=99+q.f.3e.t;k.2C.r=k.2C.l+5F;k.2C.b=k.2C.t+9g;k.96=I;q.f.el.1E(u(){aw=k.7o.3J(k.1p(q,\'id\'));if(!(q.1M.x>k.2C.r||(q.1M.x+q.1M.1C)<k.2C.l||q.1M.y>k.2C.b||(q.1M.y+q.1M.hb)<k.2C.t)){k.96=1b;if(q.s!=1b){q.s=1b;k(q).2R(k.3k.f.7j)}if(aw!=-1){q.s=I;k(q).4i(k.3k.f.7j)}}P if((q.s==1b)&&(aw==-1)){q.s=I;k(q).4i(k.3k.f.7j)}P if((!q.s)&&(k.7n==1b)&&(aw!=-1)){q.s=1b;k(q).2R(k.3k.f.7j)}});E I};k.cX=u(e){if(!k.3k)E;k.g0.1D(k.3k,[e])};k.g0=u(e){k(1h).3q(\'3D\',k.am).3q(\'5P\',k.cX);if(!k.3k)E;k.2C.B(\'19\',\'1o\');if(q.f.hc)k.2C.4i(q.f.hc);k.3k=I;k(\'2e\').1S(k.2C.K(0));if(k.96==1b){if(q.f.98)q.f.98(k.cJ(k.1p(q,\'id\')))}P{if(q.f.9d)q.f.9d(k.cJ(k.1p(q,\'id\')))}k.7o=[]};k.cJ=u(s){D h=\'\';D o=[];if(a=k(\'#\'+s)){a.K(0).f.el.1E(u(){if(q.s==1b){if(h.1g>0){h+=\'&\'}h+=s+\'[]=\'+k.1p(q,\'id\');o[o.1g]=k.1p(q,\'id\')}})}E{7l:h,o:o}};k.fn.gZ=u(o){if(!k.2C){k(\'2e\',1h).1S(\'<22 id="2C"></22>\').1J(\'7B\',k.9v).1J(\'6y\',k.9u);k.2C=k(\'#2C\');k.2C.B({Y:\'1P\',19:\'1o\'});if(1X.2k){k(\'2e\',1h).1J(\'7B\',k.9v).1J(\'6y\',k.9u)}P{k(1h).1J(\'7B\',k.9v).1J(\'6y\',k.9u)}}if(!o){o={}}E q.1E(u(){if(q.eP)E;q.eP=1b;q.f={a:o.3C,o:o.1G?2m(o.1G):I,7j:o.eS?o.eS:I,hc:o.58?o.58:I,98:o.98?o.98:I,9d:o.9d?o.9d:I};q.f.el=k(\'.\'+o.3C);k(q).1J(\'5v\',k.dL).B(\'Y\',\'2s\')})};k.3b={bM:1,eH:u(3t){D 3t=3t;E q.1E(u(){q.4z.6s.1E(u(ab){k.3b.5c(q,3t[ab])})})},K:u(){D 3t=[];q.1E(u(cL){if(q.bI){3t[cL]=[];D C=q;D 1q=k.1a.2o(q);q.4z.6s.1E(u(ab){D x=q.8t;D y=q.8G;92=T(x*2a/(1q.w-q.4c));91=T(y*2a/(1q.h-q.5W));3t[cL][ab]=[92||0,91||0,x||0,y||0]})}});E 3t},ct:u(C){C.A.fu=C.A.28.w-C.A.1B.1C;C.A.fw=C.A.28.h-C.A.1B.hb;if(C.9r.4z.bC){9Z=C.9r.4z.6s.K(C.bF+1);if(9Z){C.A.28.w=(T(k(9Z).B(\'O\'))||0)+C.A.1B.1C;C.A.28.h=(T(k(9Z).B(\'Q\'))||0)+C.A.1B.hb}9Q=C.9r.4z.6s.K(C.bF-1);if(9Q){D cU=T(k(9Q).B(\'O\'))||0;D cH=T(k(9Q).B(\'O\'))||0;C.A.28.x+=cU;C.A.28.y+=cH;C.A.28.w-=cU;C.A.28.h-=cH}}C.A.g7=C.A.28.w-C.A.1B.1C;C.A.eC=C.A.28.h-C.A.1B.hb;if(C.A.2O){C.A.gx=((C.A.28.w-C.A.1B.1C)/C.A.2O)||1;C.A.gy=((C.A.28.h-C.A.1B.hb)/C.A.2O)||1;C.A.fU=C.A.g7/C.A.2O;C.A.fH=C.A.eC/C.A.2O}C.A.28.dx=C.A.28.x-C.A.2c.x;C.A.28.dy=C.A.28.y-C.A.2c.y;k.11.1c.B(\'9b\',\'ad\')},3H:u(C,x,y){if(C.A.2O){fE=T(x/C.A.fU);92=fE*2a/C.A.2O;ft=T(y/C.A.fH);91=ft*2a/C.A.2O}P{92=T(x*2a/C.A.fu);91=T(y*2a/C.A.fw)}C.A.b3=[92||0,91||0,x||0,y||0];if(C.A.3H)C.A.3H.1D(C,C.A.b3)},eI:u(2k){3K=2k.7L||2k.7K||-1;3m(3K){1e 35:k.3b.5c(q.3U,[ae,ae]);1r;1e 36:k.3b.5c(q.3U,[-ae,-ae]);1r;1e 37:k.3b.5c(q.3U,[-q.3U.A.gx||-1,0]);1r;1e 38:k.3b.5c(q.3U,[0,-q.3U.A.gy||-1]);1r;1e 39:k.3b.5c(q.3U,[q.3U.A.gx||1,0]);1r;1e 40:k.11.5c(q.3U,[0,q.3U.A.gy||1]);1r}},5c:u(C,Y){if(!C.A){E}C.A.1B=k.23(k.1a.3w(C),k.1a.2o(C));C.A.2c={x:T(k.B(C,\'O\'))||0,y:T(k.B(C,\'Q\'))||0};C.A.4n=k.B(C,\'Y\');if(C.A.4n!=\'2s\'&&C.A.4n!=\'1P\'){C.14.Y=\'2s\'}k.11.c5(C);k.3b.ct(C);dx=T(Y[0])||0;dy=T(Y[1])||0;2v=C.A.2c.x+dx;2q=C.A.2c.y+dy;if(C.A.2O){3y=k.11.c7.1D(C,[2v,2q,dx,dy]);if(3y.1K==7M){dx=3y.dx;dy=3y.dy}2v=C.A.2c.x+dx;2q=C.A.2c.y+dy}3y=k.11.ce.1D(C,[2v,2q,dx,dy]);if(3y&&3y.1K==7M){dx=3y.dx;dy=3y.dy}2v=C.A.2c.x+dx;2q=C.A.2c.y+dy;if(C.A.5i&&(C.A.3H||C.A.2Z)){k.3b.3H(C,2v,2q)}2v=!C.A.1O||C.A.1O==\'4j\'?2v:C.A.2c.x||0;2q=!C.A.1O||C.A.1O==\'49\'?2q:C.A.2c.y||0;C.14.O=2v+\'U\';C.14.Q=2q+\'U\'},2r:u(o){E q.1E(u(){if(q.bI==1b||!o.3C||!k.1a||!k.11||!k.1x){E}5x=k(o.3C,q);if(5x.1N()==0){E}D 4N={2p:\'94\',5i:1b,3H:o.3H&&o.3H.1K==2A?o.3H:S,2Z:o.2Z&&o.2Z.1K==2A?o.2Z:S,3v:q,1G:o.1G||I};if(o.2O&&T(o.2O)){4N.2O=T(o.2O)||1;4N.2O=4N.2O>0?4N.2O:1}if(5x.1N()==1)5x.7t(4N);P{k(5x.K(0)).7t(4N);4N.3v=S;5x.7t(4N)}5x.7B(k.3b.eI);5x.1p(\'bM\',k.3b.bM++);q.bI=1b;q.4z={};q.4z.er=4N.er;q.4z.2O=4N.2O;q.4z.6s=5x;q.4z.bC=o.bC?1b:I;bZ=q;bZ.4z.6s.1E(u(2N){q.bF=2N;q.9r=bZ});if(o.3t&&o.3t.1K==7F){24(i=o.3t.1g-1;i>=0;i--){if(o.3t[i].1K==7F&&o.3t[i].1g==2){el=q.4z.6s.K(i);if(el.4Y){k.3b.5c(el,o.3t[i])}}}}})}};k.fn.23({hN:k.3b.2r,hS:k.3b.eH,hG:k.3b.K});k.2u={5I:[],eg:u(){q.5B();X=q.31;id=k.1p(X,\'id\');if(k.2u.5I[id]!=S){1X.5T(k.2u.5I[id])}1z=X.L.3u+1;if(X.L.1Q.1g<1z){1z=1}1Q=k(\'1T\',X.L.5u);X.L.3u=1z;if(1Q.1N()>0){1Q.7a(X.L.3W,k.2u.95)}},dp:u(){q.5B();X=q.31;id=k.1p(X,\'id\');if(k.2u.5I[id]!=S){1X.5T(k.2u.5I[id])}1z=X.L.3u-1;1Q=k(\'1T\',X.L.5u);if(1z<1){1z=X.L.1Q.1g}X.L.3u=1z;if(1Q.1N()>0){1Q.7a(X.L.3W,k.2u.95)}},2I:u(c){X=1h.9e(c);if(X.L.6o){1z=X.L.3u;7d(1z==X.L.3u){1z=1+T(18.6o()*X.L.1Q.1g)}}P{1z=X.L.3u+1;if(X.L.1Q.1g<1z){1z=1}}1Q=k(\'1T\',X.L.5u);X.L.3u=1z;if(1Q.1N()>0){1Q.7a(X.L.3W,k.2u.95)}},go:u(o){D X;if(o&&o.1K==7M){if(o.2b){X=1h.9e(o.2b.X);5N=1X.hn.3h.7C("#");o.2b.6S=S;if(5N.1g==2){1z=T(5N[1]);1Y=5N[1].4E(1z,\'\');if(k.1p(X,\'id\')!=1Y){1z=1}}P{1z=1}}if(o.90){o.90.5B();X=o.90.31.31;id=k.1p(X,\'id\');if(k.2u.5I[id]!=S){1X.5T(k.2u.5I[id])}5N=o.90.3h.7C("#");1z=T(5N[1]);1Y=5N[1].4E(1z,\'\');if(k.1p(X,\'id\')!=1Y){1z=1}}if(X.L.1Q.1g<1z||1z<1){1z=1}X.L.3u=1z;52=k.1a.2o(X);dt=k.1a.aT(X);d9=k.1a.6U(X);if(X.L.3z){X.L.3z.o.B(\'19\',\'1o\')}if(X.L.3s){X.L.3s.o.B(\'19\',\'1o\')}if(X.L.2b){y=T(dt.t)+T(d9.t);if(X.L.1U){if(X.L.1U.5A==\'Q\'){y+=X.L.1U.4C.hb}P{52.h-=X.L.1U.4C.hb}}if(X.L.2x){if(X.L.2x&&X.L.2x.6Q==\'Q\'){y+=X.L.2x.4C.hb}P{52.h-=X.L.2x.4C.hb}}if(!X.L.c1){X.L.df=o.2b?o.2b.W:(T(X.L.2b.B(\'W\'))||0);X.L.c1=o.2b?o.2b.Z:(T(X.L.2b.B(\'Z\'))||0)}X.L.2b.B(\'Q\',y+(52.h-X.L.df)/2+\'U\');X.L.2b.B(\'O\',(52.1C-X.L.c1)/2+\'U\');X.L.2b.B(\'19\',\'2B\')}1Q=k(\'1T\',X.L.5u);if(1Q.1N()>0){1Q.7a(X.L.3W,k.2u.95)}P{aj=k(\'a\',X.L.1U.o).K(1z-1);k(aj).2R(X.L.1U.5R);D 1T=12 9s();1T.X=k.1p(X,\'id\');1T.1z=1z-1;1T.2J=X.L.1Q[X.L.3u-1].2J;if(1T.21){1T.6S=S;k.2u.19.1D(1T)}P{1T.6S=k.2u.19}if(X.L.2x){X.L.2x.o.3x(X.L.1Q[1z-1].6L)}}}},95:u(){X=q.31.31;X.L.5u.B(\'19\',\'1o\');if(X.L.1U.5R){aj=k(\'a\',X.L.1U.o).4i(X.L.1U.5R).K(X.L.3u-1);k(aj).2R(X.L.1U.5R)}D 1T=12 9s();1T.X=k.1p(X,\'id\');1T.1z=X.L.3u-1;1T.2J=X.L.1Q[X.L.3u-1].2J;if(1T.21){1T.6S=S;k.2u.19.1D(1T)}P{1T.6S=k.2u.19}if(X.L.2x){X.L.2x.o.3x(X.L.1Q[X.L.3u-1].6L)}},19:u(){X=1h.9e(q.X);if(X.L.3z){X.L.3z.o.B(\'19\',\'1o\')}if(X.L.3s){X.L.3s.o.B(\'19\',\'1o\')}52=k.1a.2o(X);y=0;if(X.L.1U){if(X.L.1U.5A==\'Q\'){y+=X.L.1U.4C.hb}P{52.h-=X.L.1U.4C.hb}}if(X.L.2x){if(X.L.2x&&X.L.2x.6Q==\'Q\'){y+=X.L.2x.4C.hb}P{52.h-=X.L.2x.4C.hb}}hg=k(\'.ca\',X);y=y+(52.h-q.W)/2;x=(52.1C-q.Z)/2;X.L.5u.B(\'Q\',y+\'U\').B(\'O\',x+\'U\').3x(\'<1T 2J="\'+q.2J+\'" />\');X.L.5u.7f(X.L.3W);3s=X.L.3u+1;if(3s>X.L.1Q.1g){3s=1}3z=X.L.3u-1;if(3z<1){3z=X.L.1Q.1g}X.L.3s.o.B(\'19\',\'2B\').B(\'Q\',y+\'U\').B(\'O\',x+2*q.Z/3+\'U\').B(\'Z\',q.Z/3+\'U\').B(\'W\',q.W+\'U\').1p(\'4g\',X.L.1Q[3s-1].6L);X.L.3s.o.K(0).3h=\'#\'+3s+k.1p(X,\'id\');X.L.3z.o.B(\'19\',\'2B\').B(\'Q\',y+\'U\').B(\'O\',x+\'U\').B(\'Z\',q.Z/3+\'U\').B(\'W\',q.W+\'U\').1p(\'4g\',X.L.1Q[3z-1].6L);X.L.3z.o.K(0).3h=\'#\'+3z+k.1p(X,\'id\')},2r:u(o){if(!o||!o.1Z||k.2u.5I[o.1Z])E;D 1Z=k(\'#\'+o.1Z);D el=1Z.K(0);if(el.14.Y!=\'1P\'&&el.14.Y!=\'2s\'){el.14.Y=\'2s\'}el.14.2U=\'2K\';if(1Z.1N()==0)E;el.L={};el.L.1Q=o.1Q?o.1Q:[];el.L.6o=o.6o&&o.6o==1b||I;97=el.f3(\'hL\');24(i=0;i<97.1g;i++){7Z=el.L.1Q.1g;el.L.1Q[7Z]={2J:97[i].2J,6L:97[i].4g||97[i].hD||\'\'}}if(el.L.1Q.1g==0){E}el.L.4n=k.23(k.1a.3w(el),k.1a.2o(el));el.L.b5=k.1a.aT(el);el.L.bu=k.1a.6U(el);t=T(el.L.b5.t)+T(el.L.bu.t);b=T(el.L.b5.b)+T(el.L.bu.b);k(\'1T\',el).bk();el.L.3W=o.3W?o.3W:g5;if(o.5A||o.9f||o.5R){el.L.1U={};1Z.1S(\'<22 6T="g1"></22>\');el.L.1U.o=k(\'.g1\',el);if(o.9f){el.L.1U.9f=o.9f;el.L.1U.o.2R(o.9f)}if(o.5R){el.L.1U.5R=o.5R}el.L.1U.o.B(\'Y\',\'1P\').B(\'Z\',el.L.4n.w+\'U\');if(o.5A&&o.5A==\'Q\'){el.L.1U.5A=\'Q\';el.L.1U.o.B(\'Q\',t+\'U\')}P{el.L.1U.5A=\'4D\';el.L.1U.o.B(\'4D\',b+\'U\')}el.L.1U.aE=o.aE?o.aE:\' \';24(D i=0;i<el.L.1Q.1g;i++){7Z=T(i)+1;el.L.1U.o.1S(\'<a 3h="#\'+7Z+o.1Z+\'" 6T="gR" 4g="\'+el.L.1Q[i].6L+\'">\'+7Z+\'</a>\'+(7Z!=el.L.1Q.1g?el.L.1U.aE:\'\'))}k(\'a\',el.L.1U.o).1J(\'5h\',u(){k.2u.go({90:q})});el.L.1U.4C=k.1a.2o(el.L.1U.o.K(0))}if(o.6Q||o.9c){el.L.2x={};1Z.1S(\'<22 6T="dn">&7k;</22>\');el.L.2x.o=k(\'.dn\',el);if(o.9c){el.L.2x.9c=o.9c;el.L.2x.o.2R(o.9c)}el.L.2x.o.B(\'Y\',\'1P\').B(\'Z\',el.L.4n.w+\'U\');if(o.6Q&&o.6Q==\'Q\'){el.L.2x.6Q=\'Q\';el.L.2x.o.B(\'Q\',(el.L.1U&&el.L.1U.5A==\'Q\'?el.L.1U.4C.hb+t:t)+\'U\')}P{el.L.2x.6Q=\'4D\';el.L.2x.o.B(\'4D\',(el.L.1U&&el.L.1U.5A==\'4D\'?el.L.1U.4C.hb+b:b)+\'U\')}el.L.2x.4C=k.1a.2o(el.L.2x.o.K(0))}if(o.9D){el.L.3s={9D:o.9D};1Z.1S(\'<a 3h="#2\'+o.1Z+\'" 6T="eY">&7k;</a>\');el.L.3s.o=k(\'.eY\',el);el.L.3s.o.B(\'Y\',\'1P\').B(\'19\',\'1o\').B(\'2U\',\'2K\').B(\'4A\',\'eR\').2R(el.L.3s.9D);el.L.3s.o.1J(\'5h\',k.2u.eg)}if(o.9o){el.L.3z={9o:o.9o};1Z.1S(\'<a 3h="#0\'+o.1Z+\'" 6T="ee">&7k;</a>\');el.L.3z.o=k(\'.ee\',el);el.L.3z.o.B(\'Y\',\'1P\').B(\'19\',\'1o\').B(\'2U\',\'2K\').B(\'4A\',\'eR\').2R(el.L.3z.9o);el.L.3z.o.1J(\'5h\',k.2u.dp)}1Z.bG(\'<22 6T="ca"></22>\');el.L.5u=k(\'.ca\',el);el.L.5u.B(\'Y\',\'1P\').B(\'Q\',\'2P\').B(\'O\',\'2P\').B(\'19\',\'1o\');if(o.2b){1Z.bG(\'<22 6T="dW" 14="19: 1o;"><1T 2J="\'+o.2b+\'" /></22>\');el.L.2b=k(\'.dW\',el);el.L.2b.B(\'Y\',\'1P\');D 1T=12 9s();1T.X=o.1Z;1T.2J=o.2b;if(1T.21){1T.6S=S;k.2u.go({2b:1T})}P{1T.6S=u(){k.2u.go({2b:q})}}}P{k.2u.go({1Z:el})}if(o.cS){fi=T(o.cS)*aC}k.2u.5I[o.1Z]=o.cS?1X.6V(\'k.2u.2I(\\\'\'+o.1Z+\'\\\')\',fi):S}};k.X=k.2u.2r;k.1t={7s:[],5L:{},1c:I,7u:S,26:u(){if(k.11.F==S){E}D 4O,3G,c,cs;k.1t.1c.K(0).3l=k.11.F.A.6R;4O=k.1t.1c.K(0).14;4O.19=\'2B\';k.1t.1c.1B=k.23(k.1a.3w(k.1t.1c.K(0)),k.1a.2o(k.1t.1c.K(0)));4O.Z=k.11.F.A.1B.1C+\'U\';4O.W=k.11.F.A.1B.hb+\'U\';3G=k.1a.cy(k.11.F);4O.5K=3G.t;4O.5z=3G.r;4O.5k=3G.b;4O.5j=3G.l;if(k.11.F.A.46==1b){c=k.11.F.fI(1b);cs=c.14;cs.5K=\'2P\';cs.5z=\'2P\';cs.5k=\'2P\';cs.5j=\'2P\';cs.19=\'2B\';k.1t.1c.5o().1S(c)}k(k.11.F).f5(k.1t.1c.K(0));k.11.F.14.19=\'1o\'},fC:u(e){if(!e.A.44&&k.1x.5r.cQ){if(e.A.3T)e.A.3T.1D(F);k(e).B(\'Y\',e.A.cz||e.A.4n);k(e).aS();k(k.1x.5r).f6(e)}k.1t.1c.4i(e.A.6R).3x(\'&7k;\');k.1t.7u=S;D 4O=k.1t.1c.K(0).14;4O.19=\'1o\';k.1t.1c.f5(e);if(e.A.fx>0){k(e).7f(e.A.fx)}k(\'2e\').1S(k.1t.1c.K(0));D 86=[];D 8q=I;24(D i=0;i<k.1t.7s.1g;i++){D 1j=k.1x.3P[k.1t.7s[i]].K(0);D id=k.1p(1j,\'id\');D 8i=k.1t.8x(id);if(1j.1i.ay!=8i.7l){1j.1i.ay=8i.7l;if(8q==I&&1j.1i.2Z){8q=1j.1i.2Z}8i.id=id;86[86.1g]=8i}}k.1t.7s=[];if(8q!=I&&86.1g>0){8q(86)}},al:u(e,o){if(!k.11.F)E;D 6e=I;D i=0;if(e.1i.el.1N()>0){24(i=e.1i.el.1N();i>0;i--){if(e.1i.el.K(i-1)!=k.11.F){if(!e.5V.b2){if((e.1i.el.K(i-1).1M.y+e.1i.el.K(i-1).1M.hb/2)>k.11.F.A.2q){6e=e.1i.el.K(i-1)}P{1r}}P{if((e.1i.el.K(i-1).1M.x+e.1i.el.K(i-1).1M.1C/2)>k.11.F.A.2v&&(e.1i.el.K(i-1).1M.y+e.1i.el.K(i-1).1M.hb/2)>k.11.F.A.2q){6e=e.1i.el.K(i-1)}}}}}if(6e&&k.1t.7u!=6e){k.1t.7u=6e;k(6e).h5(k.1t.1c.K(0))}P if(!6e&&(k.1t.7u!=S||k.1t.1c.K(0).31!=e)){k.1t.7u=S;k(e).1S(k.1t.1c.K(0))}k.1t.1c.K(0).14.19=\'2B\'},cT:u(e){if(k.11.F==S){E}e.1i.el.1E(u(){q.1M=k.23(k.1a.74(q),k.1a.7G(q))})},8x:u(s){D i;D h=\'\';D o={};if(s){if(k.1t.5L[s]){o[s]=[];k(\'#\'+s+\' .\'+k.1t.5L[s]).1E(u(){if(h.1g>0){h+=\'&\'}h+=s+\'[]=\'+k.1p(q,\'id\');o[s][o[s].1g]=k.1p(q,\'id\')})}P{24(a in s){if(k.1t.5L[s[a]]){o[s[a]]=[];k(\'#\'+s[a]+\' .\'+k.1t.5L[s[a]]).1E(u(){if(h.1g>0){h+=\'&\'}h+=s[a]+\'[]=\'+k.1p(q,\'id\');o[s[a]][o[s[a]].1g]=k.1p(q,\'id\')})}}}}P{24(i in k.1t.5L){o[i]=[];k(\'#\'+i+\' .\'+k.1t.5L[i]).1E(u(){if(h.1g>0){h+=\'&\'}h+=i+\'[]=\'+k.1p(q,\'id\');o[i][o[i].1g]=k.1p(q,\'id\')})}}E{7l:h,o:o}},fF:u(e){if(!e.dq){E}E q.1E(u(){if(!q.5V||!k(e).is(\'.\'+q.5V.3C))k(e).2R(q.5V.3C);k(e).7t(q.5V.A)})},4U:u(){E q.1E(u(){k(\'.\'+q.5V.3C).aS();k(q).dR();q.5V=S;q.fm=S})},2r:u(o){if(o.3C&&k.1a&&k.11&&k.1x){if(!k.1t.1c){k(\'2e\',1h).1S(\'<22 id="e5">&7k;</22>\');k.1t.1c=k(\'#e5\');k.1t.1c.K(0).14.19=\'1o\'}q.do({3C:o.3C,9J:o.9J?o.9J:I,a5:o.a5?o.a5:I,58:o.58?o.58:I,7x:o.7x||o.dC,7y:o.7y||o.fO,cQ:1b,2Z:o.2Z||o.ia,fx:o.fx?o.fx:I,46:o.46?1b:I,6I:o.6I?o.6I:\'cV\'});E q.1E(u(){D A={6N:o.6N?1b:I,ff:6P,1G:o.1G?2m(o.1G):I,6R:o.58?o.58:I,fx:o.fx?o.fx:I,44:1b,46:o.46?1b:I,3v:o.3v?o.3v:S,2p:o.2p?o.2p:S,4o:o.4o&&o.4o.1K==2A?o.4o:I,4m:o.4m&&o.4m.1K==2A?o.4m:I,3T:o.3T&&o.3T.1K==2A?o.3T:I,1O:/49|4j/.48(o.1O)?o.1O:I,6M:o.6M?T(o.6M)||0:I,2V:o.2V?o.2V:I};k(\'.\'+o.3C,q).7t(A);q.fm=1b;q.5V={3C:o.3C,6N:o.6N?1b:I,ff:6P,1G:o.1G?2m(o.1G):I,6R:o.58?o.58:I,fx:o.fx?o.fx:I,44:1b,46:o.46?1b:I,3v:o.3v?o.3v:S,2p:o.2p?o.2p:S,b2:o.b2?1b:I,A:A}})}}};k.fn.23({j3:k.1t.2r,f6:k.1t.fF,iS:k.1t.4U});k.iZ=k.1t.8x;k.2t={6O:S,7b:I,9m:S,6K:u(e){k.2t.7b=1b;k.2t.1Y(e,q,1b)},cq:u(e){if(k.2t.6O!=q)E;k.2t.7b=I;k.2t.2G(e,q)},1Y:u(e,el,7b){if(k.2t.6O!=S)E;if(!el){el=q}k.2t.6O=el;1M=k.23(k.1a.3w(el),k.1a.2o(el));8u=k(el);4g=8u.1p(\'4g\');3h=8u.1p(\'3h\');if(4g){k.2t.9m=4g;8u.1p(\'4g\',\'\');k(\'#eT\').3x(4g);if(3h)k(\'#bL\').3x(3h.4E(\'jh://\',\'\'));P k(\'#bL\').3x(\'\');1c=k(\'#8z\');if(el.4H.3l){1c.K(0).3l=el.4H.3l}P{1c.K(0).3l=\'\'}bo=k.1a.2o(1c.K(0));ga=7b&&el.4H.Y==\'bO\'?\'4D\':el.4H.Y;3m(ga){1e\'Q\':2q=1M.y-bo.hb;2v=1M.x;1r;1e\'O\':2q=1M.y;2v=1M.x-bo.1C;1r;1e\'2L\':2q=1M.y;2v=1M.x+1M.1C;1r;1e\'bO\':k(\'2e\').1J(\'3D\',k.2t.3D);1s=k.1a.4a(e);2q=1s.y+15;2v=1s.x+15;1r;ad:2q=1M.y+1M.hb;2v=1M.x;1r}1c.B({Q:2q+\'U\',O:2v+\'U\'});if(el.4H.54==I){1c.1Y()}P{1c.7f(el.4H.54)}if(el.4H.2Y)el.4H.2Y.1D(el);8u.1J(\'8B\',k.2t.2G).1J(\'5B\',k.2t.cq)}},3D:u(e){if(k.2t.6O==S){k(\'2e\').3q(\'3D\',k.2t.3D);E}1s=k.1a.4a(e);k(\'#8z\').B({Q:1s.y+15+\'U\',O:1s.x+15+\'U\'})},2G:u(e,el){if(!el){el=q}if(k.2t.7b!=1b&&k.2t.6O==el){k.2t.6O=S;k(\'#8z\').7a(1);k(el).1p(\'4g\',k.2t.9m).3q(\'8B\',k.2t.2G).3q(\'5B\',k.2t.cq);if(el.4H.3i)el.4H.3i.1D(el);k.2t.9m=S}},2r:u(M){if(!k.2t.1c){k(\'2e\').1S(\'<22 id="8z"><22 id="eT"></22><22 id="bL"></22></22>\');k(\'#8z\').B({Y:\'1P\',3I:6P,19:\'1o\'});k.2t.1c=1b}E q.1E(u(){if(k.1p(q,\'4g\')){q.4H={Y:/Q|4D|O|2L|bO/.48(M.Y)?M.Y:\'4D\',3l:M.3l?M.3l:I,54:M.54?M.54:I,2Y:M.2Y&&M.2Y.1K==2A?M.2Y:I,3i:M.3i&&M.3i.1K==2A?M.3i:I};D el=k(q);el.1J(\'9z\',k.2t.1Y);el.1J(\'6K\',k.2t.6K)}})}};k.fn.hO=k.2t.2r;k.84={bq:u(e){3K=e.7L||e.7K||-1;if(3K==9){if(1X.2k){1X.2k.bT=1b;1X.2k.c0=I}P{e.aP();e.aW()}if(q.b1){1h.6J.dZ().3g="\\t";q.dV=u(){q.6K();q.dV=S}}P if(q.aF){26=q.5q;2T=q.dN;q.2y=q.2y.hd(0,26)+"\\t"+q.2y.h8(2T);q.aF(26+1,26+1);q.6K()}E I}},4U:u(){E q.1E(u(){if(q.7P&&q.7P==1b){k(q).3q(\'7B\',k.84.bq);q.7P=I}})},2r:u(){E q.1E(u(){if(q.4Y==\'cf\'&&(!q.7P||q.7P==I)){k(q).1J(\'7B\',k.84.bq);q.7P=1b}})}};k.fn.23({j5:k.84.2r,hH:k.84.4U});k.1a={3w:u(e){D x=0;D y=0;D es=e.14;D bP=I;if(k(e).B(\'19\')==\'1o\'){D 5Y=es.3n;D 9q=es.Y;bP=1b;es.3n=\'2K\';es.19=\'2B\';es.Y=\'1P\'}D el=e;7d(el){x+=el.8t+(el.4Z&&!k.3a.7I?T(el.4Z.5b)||0:0);y+=el.8G+(el.4Z&&!k.3a.7I?T(el.4Z.4S)||0:0);el=el.dJ}el=e;7d(el&&el.4Y&&el.4Y.6c()!=\'2e\'){x-=el.3c||0;y-=el.3d||0;el=el.31}if(bP==1b){es.19=\'1o\';es.Y=9q;es.3n=5Y}E{x:x,y:y}},7G:u(el){D x=0,y=0;7d(el){x+=el.8t||0;y+=el.8G||0;el=el.dJ}E{x:x,y:y}},2o:u(e){D w=k.B(e,\'Z\');D h=k.B(e,\'W\');D 1C=0;D hb=0;D es=e.14;if(k(e).B(\'19\')!=\'1o\'){1C=e.4c;hb=e.5W}P{D 5Y=es.3n;D 9q=es.Y;es.3n=\'2K\';es.19=\'2B\';es.Y=\'1P\';1C=e.4c;hb=e.5W;es.19=\'1o\';es.Y=9q;es.3n=5Y}E{w:w,h:h,1C:1C,hb:hb}},74:u(el){E{1C:el.4c||0,hb:el.5W||0}},bm:u(e){D h,w,de;if(e){w=e.8W;h=e.8O}P{de=1h.5d;w=1X.d4||aa.d4||(de&&de.8W)||1h.2e.8W;h=1X.cB||aa.cB||(de&&de.8O)||1h.2e.8O}E{w:w,h:h}},6z:u(e){D t=0,l=0,w=0,h=0,iw=0,ih=0;if(e&&e.9N.6c()!=\'2e\'){t=e.3d;l=e.3c;w=e.d7;h=e.d2;iw=0;ih=0}P{if(1h.5d){t=1h.5d.3d;l=1h.5d.3c;w=1h.5d.d7;h=1h.5d.d2}P if(1h.2e){t=1h.2e.3d;l=1h.2e.3c;w=1h.2e.d7;h=1h.2e.d2}iw=aa.d4||1h.5d.8W||1h.2e.8W||0;ih=aa.cB||1h.5d.8O||1h.2e.8O||0}E{t:t,l:l,w:w,h:h,iw:iw,ih:ih}},cy:u(e,7N){D el=k(e);D t=el.B(\'5K\')||\'\';D r=el.B(\'5z\')||\'\';D b=el.B(\'5k\')||\'\';D l=el.B(\'5j\')||\'\';if(7N)E{t:T(t)||0,r:T(r)||0,b:T(b)||0,l:T(l)};P E{t:t,r:r,b:b,l:l}},aT:u(e,7N){D el=k(e);D t=el.B(\'5M\')||\'\';D r=el.B(\'5U\')||\'\';D b=el.B(\'5n\')||\'\';D l=el.B(\'4X\')||\'\';if(7N)E{t:T(t)||0,r:T(r)||0,b:T(b)||0,l:T(l)};P E{t:t,r:r,b:b,l:l}},6U:u(e,7N){D el=k(e);D t=el.B(\'4S\')||\'\';D r=el.B(\'5O\')||\'\';D b=el.B(\'5Q\')||\'\';D l=el.B(\'5b\')||\'\';if(7N)E{t:T(t)||0,r:T(r)||0,b:T(b)||0,l:T(l)||0};P E{t:t,r:r,b:b,l:l}},4a:u(2k){D x=2k.hT||(2k.gM+(1h.5d.3c||1h.2e.3c))||0;D y=2k.ki||(2k.iQ+(1h.5d.3d||1h.2e.3d))||0;E{x:x,y:y}},cI:u(4R,cx){cx(4R);4R=4R.7c;7d(4R){k.1a.cI(4R,cx);4R=4R.hQ}},h7:u(4R){k.1a.cI(4R,u(el){24(D 1p in el){if(2g el[1p]===\'u\'){el[1p]=S}}})},hV:u(el,1O){D 5l=k.1a.6z();D b6=k.1a.2o(el);if(!1O||1O==\'49\')k(el).B({Q:5l.t+((18.3r(5l.h,5l.ih)-5l.t-b6.hb)/2)+\'U\'});if(!1O||1O==\'4j\')k(el).B({O:5l.l+((18.3r(5l.w,5l.iw)-5l.l-b6.1C)/2)+\'U\'})},hW:u(el,dk){D 1Q=k(\'1T[@2J*="8X"]\',el||1h),8X;1Q.1E(u(){8X=q.2J;q.2J=dk;q.14.5E="9n:9w.9y.hE(2J=\'"+8X+"\')"})}};[].3J||(7F.hF.3J=u(v,n){n=(n==S)?0:n;D m=q.1g;24(D i=n;i<m;i++)if(q[i]==v)E i;E-1});',62,1293,'||||||||||||||||||||jQuery||||||this||||function||||||dragCfg|css|elm|var|return|dragged|easing|speed|false|callback|get|ss|options|iAuto|left|else|top|iResize|null|parseInt|px|oldStyle|height|slideshow|position|width||iDrag|new||style||||Math|display|iUtil|true|helper|subject|case|autoCFG|length|document|dropCfg|iEL|resizeOptions|carouselCfg|duration|interfaceFX|none|attr|sizes|break|pointer|iSort|type|ImageBox|queue|iDrop|iAutoscroller|slide|resizeElement|oC|wb|apply|each|fisheyeCfg|opacity|delta|newSizes|bind|constructor|custom|pos|size|axis|absolute|images|items|append|img|slideslinks|255|firstNum|window|show|container||complete|div|extend|for||start||cont|elsToScroll|100|loader|oR||body|elem|typeof|selectedItem|oldP|props|event|accordionCfg|parseFloat|field|getSize|containment|ny|build|relative|iTooltip|islideshow|nx|tp|slideCaption|value|newPosition|Function|block|selectHelper|step|border|itemWidth|hide|dequeue|timer|src|hidden|right|limit|nr|fractions|0px|PI|addClass|direction|end|overflow|cursorAt|result|parentData|onShow|onChange|to|parentNode|||||||||browser|iSlider|scrollLeft|scrollTop|scr|transferHelper|text|href|onHide|pre|selectdrug|className|switch|visibility|item|wrapper|unbind|max|nextslide|values|currentslide|handle|getPosition|html|newCoords|prevslide|iframe|iExpander|accept|mousemove|canvas|createElement|margins|onSlide|zIndex|indexOf|pressedKey|min|valueToAdd|multipleSeparator|pageSize|zones|highlighted|toggle|abs|onStop|dragElem|times|fadeDuration|diff|dhs|handlers||resizeDirection||vp|so|distance|ghosting||test|vertically|getPointer|startTop|offsetWidth|subjectValue|lastSuggestion|DropOutDirectiont|title|wrs|removeClass|horizontally|startLeft|out|onDrag|oP|onStart|nWidth|percent|down|ifxFirstDisplay|msie|iteration|ratio|clear|color|lastValue|slideCfg|fontSize|currentPointer|dimm|bottom|replace|up|prevImage|tooltipCFG|rel|els|fxCheckTag|context|nextImage|params|shs|fieldData|elToScroll|nodeEl|borderTopWidth|chunks|destroy|string|nHeight|paddingLeft|tagName|currentStyle||halign|slidePos|onclick|delay||containerW|from|helperclass|endLeft|endTop|borderLeftWidth|dragmoveBy|documentElement|dhe|newStyles|clonedEl|click|si|marginLeft|marginBottom|clientScroll|OpenClose|paddingBottom|empty|toWrite|selectionStart|overzone|toAdd|onDragModifier|holder|mousedown|animate|toDrag|cnt|marginRight|linksPosition|blur|getAttribute|hight|filter|sw|zoney|cos|slideshows|zonex|marginTop|collected|paddingTop|url|borderRightWidth|mouseup|borderBottomWidth|activeLinkClass|dragHandle|clearInterval|paddingRight|sortCfg|offsetHeight|prop|oldVisibility|styles||BlindDirection|point|fxh|nmp|old|post|currentPanel|onSelect|elementData|grid|pow|toLowerCase|animationHandler|cur|containerH|close|puff|getWidth|currentRel|imageEl|Expander|getHeight|iFisheye|random|newDimensions|itemHeight|reflections|sliders|selRange|wr|orig|margin|maxWidth|keyup|getScroll|captionText|totalImages|128|parseColor|curCSS|outerContainer|Scale|restore|tolerance|selection|focus|caption|snapDistance|revert|current|3000|captionPosition|hpc|onload|class|getBorder|setInterval|oldStyleAttr|rule|rgb|open|minLeft|ActiveXObject|oldDisplay|restoreStyle|getSizeLite||nw|0x||F0|fadeOut|focused|firstChild|while|cssRules|fadeIn|Date|minTop|backgroundColor|sc|nbsp|hash|captionEl|selectKeyHelper|selectCurrent|newTop|init|newLeft|changed|Draggable|inFrontOf|efx|139|onHover|onOut|getTime|np|keydown|split|radiusY|increment|Array|getPositionLite|selectClass|opera|onHighlight|keyCode|charCode|Object|toInteger|frameClass|hasTabsEnabled|zonew|user|zoneh|positionItems|onClick|oD|scrollIntoView|accordionPos|proximity|indic||data|containerSize|sin|iTTabs||ts|ImageBoxPrevImage|ImageBoxNextImage|imageSrc|newPos|maxHeight|minHeight|elS|activeClass|panels|maxBottom|maxRight|ser|move|opened|bounceout|animationInProgress|overlay|stop|reflectionSize|fnc|classname|insideParent|offsetLeft|jEl|nRy|pr|serialize|nRx|tooltipHelper|cssSides|mouseout|select|count|namedColors|padding|offsetTop|directionIncrement|parentEl|400|dir|expand|createTextNode|finishedPre|clientHeight|li|applyOn|content|contBorders|object|parentBorders|alpha|clientWidth|png|gallery|fontWeight|link|yproc|xproc|sx|parent|showImage|selectedone|imgs|onselect|sy|startDrag|cursor|captionClass|onselectstop|getElementById|linksClass|sh|ul|onActivate|isDroppable|nextEl|onDrop|oldTitle|progid|prevslideClass|prevEl|oldPosition|SliderContainer|Image|linkRel|selectKeyUp|selectKeyDown|DXImageTransform|inCache|Microsoft|mouseover|dragstop|diffX|211|nextslideClass|prot|auto|dEs|hidehelper|isDraggable|activeclass|unit|DoFold|unfold|nodeName|startTime|buildWrapper|prev|1px|oldColor|setTimeout|ScrollTo|st|sl|cssText|9999|next|destroyWrapper|opt|diffHeight|diffWidth|exec|hoverclass|image|blind|borderColor|sideEnd|self|key||default|2000|styleSheets|getValues|192|diffY|lnk|reflexions|checkhover|selectcheck|maxRotation|ImageBoxOuterContainer|gradient|panelHeight|childs|headers|ne|hideImage|minWidth|iIndex|itemsText|os|side|iCarousel|5625|1000|itemMinWidth|linksSeparator|setSelectionRange|protectRotation|positionContainer|posx|hoverClass|valToAdd|minchars|helperClass|source|nextImageEl|preventDefault|multiple|headerSelector|DraggableDestroy|getPadding|autofill|handleEl|stopPropagation|prevImageEl|getFieldValues|panelSelector|String|createTextRange|floats|lastSi|shrink|oPad|windowSize|paddingLeftSize|angle|paddingY|paddingX|RegExp|borderRightSize|floatVal|firstStep|pulse|Pulsate|Color|rotationSpeed|paddingBottomSize|remove|parseStyle|getClient|Number|helperSize|bounce|doTab||zoom|borderLeftSize|oBor|paddingRightSize|borderTopSize|paddingTopSize|stopAnim|pValue|borderBottomSize|extraWidth|restricted|autoSize|unselectable|SliderIteration|prepend|clearTimeout|isSlider|oneIsSortable|applyOnHover|tooltipURL|tabindex|draginit|mouse|restoreStyles|sliderSize|sliderPos|parentPos|cancelBubble|autocomplete|inputWidth|oldBorder|dragmove|clnt|sliderEl|returnValue|loaderWidth|idsa|letterSpacing|pause|getContainment|fade|snapToGrid|linear|10000|slideshowHolder|asin|cssSidesEnd|borderWidth|fitToContainer|TEXTAREA|entities|INPUT|spacer|writeItems|character|currentValue|paddings|169|oldFloat|borders|hidefocused|bouncein||modifyContainer|transparent|center|loadImage|func|getMargins|initialPosition|textAlign|innerHeight|Alpha|no|captionImages|closeEl|shake|prevTop|traverseDOM|Selectserialize|stopDrag|slider|ImageBoxCaption|ImageBoxIframe|300|ImageBoxOverlay|sortable|moveDrag|autoplay|measure|prevLeft|intersect|ImageBoxCurrentImage|selectstop|Shake|index|dragEl|keyPressed|scrollHeight|scroll|innerWidth|match|elPosition|scrollWidth|textImage|slideBor|jpg|captionSize|textImageFrom|visible||loaderHeight|ImageBoxCaptionImages||hoverItem|clickItem|emptyGIF||notColor|slideshowCaption|Droppable|goprev|childNodes|autocompleteHelper|autocompleteIframe|slidePad|fit|165|clientSize|||fontFamily|colorCssProps|elType|onhover|cssProps|expanderHelper|boxModel|itransferTo|keypress|moveStart|offsetParent|Width|selectstart|fxe|selectionEnd|checkCache|fontStyle|update|DroppableDestroy|remeasure|fontStretch|fontVariant|onblur|slideshowLoader|htmlEntities|wordSpacing|createRange|224|KhtmlUserSelect||closeHTML|on|sortHelper|245|userSelect|dragHelper|hrefAttr|dragstart|107|loaderSRC|highlight|slideshowPrevslide||gonext||styleFloat|frameborder|javascript|||relAttr|wid|scrolling||onslide|||listStyle|imageTypes|insertBefore|999|textDecoration|sqrt|140|230|maxy|240|ImageBoxContainer|doScroll|interval|set|dragmoveByKey|protect|ImageBoxCaptionText|144|ImageBoxLoader|off|checkdrop|isSelectable|hlt|30px|selectedclass|tooltipTitle|imagebox|shc|overlayOpacity|selRange2|slideshowNextSlide|gif|getSelectionStart|360|iAccordion|getElementsByTagName|iBounce|after|SortableAddItem|onResize|150|itemZIndex|grow|getHeightMinMax|borderTopUnit|selectcheckApply|borderRightUnit|zindex|fontUnit|togglehor|time|se|parte|easeout|isSortable||SlideInUp|fold|SlideOutUp|rgba|addColorStop|yfrac|containerMaxx|interfaceColorFX|containerMaxy||leftUnit|mousex||radiusX|check|getContext|xfrac|addItem|topUnit|fracH|cloneNode|togglever|paddingLeftUnit|borderBottomUnit|finish|onDragStop|onout|posy|isFunction|oldOverflow|directions|vertical|fracW|fakeAccordionClass|parts|fadeTo|inputValue|xml|selectstopApply|slideshowLinks|onDragStart|BlindUp|paddingTopUnit|500|trim|maxx|borderLeftUnit|paddingRightUnit|filteredPosition|BlindDown|paddingBottomUnit|horizontal|valign|find|ImageBoxClose|onselectstart|mozUserSelect|ondragstart|scale|110|globalCompositeOperation|bmp||drawImage|ondrop|password|quot||save|starty|jpeg|||number|startx|finishOpacity|hover|recallDroppables|flipv|finishx|destination|khtml|moz|lt|amp|pW|clientX|Accordion|translate|captiontext|elasticin|slideshowLink|fix|elasticout|resize|elasticboth|bounceboth|984375|9375|Selectable|30002|list|625|30001|nodeValue|before|100000|purgeEvents|substr|duplicate|moveEnd|||substring|success|param|par|array|Fisheye|name|POST|ajax|easeboth|location|fromHandler|collapse|MozUserSelect||ResizableDestroy|rotationTimer|fillRect|fill|WebKit|fillStyle|createLinearGradient|Resizable|navigator|appVersion|lineHeigt|alt|AlphaImageLoader|prototype|SliderGetValues|DisableTabs|Carousel|load|easein|IMG|200|Slider|ToolTip|wh|nextSibling|Autocomplete|SliderSetValues|pageX|float|centerEl|fixPNG|isNaN|dotted|dashed|stopAll|Left|outlineColor|Top|Right|Bottom|solid|double|selectorText|rules|onchange|SlideToggleRight|SlideOutRight||borderStyle||TransferTo||groove|ridge|inset|outset|borderTopColor||borderRightColor|olive|navy|orange||pink|203|maroon||magenta|182|193|lightyellow|lime|purple|red|outlineOffset|outlineWidth|borderBottomColor|borderLeftColor|lineHeight|loading|silver|white|yellow|Showing|100000000|SlideInRight|clientY|Highlight|SortableDestroy|CloseVertically|CloseHorizontally|FoldToggle|UnFold|SlideInDown|SlideToggleUp|SortSerialize|Fold|SwitchHorizontally|SwitchVertically|Sortable|scrollTo|EnableTabs|ScrollToAnchors|pt|Puff|OpenVertically|OpenHorizontally|Grow|Shrink|DropToggleRight|DropInRight|BlindToggleHorizontally|BlindRight|http|Bounce|120|BlindLeft|BlindToggleVertically|SlideToggleLeft|SlideOutLeft|toUpperCase|SlideInLeft|SlideToggleDown|SlideOutDown|DropOutLeft|DropInLeft|DropToggleLeft|DropOutRight|DropToggleUp|DropInUp|DropOutDown|DropInDown|DropToggleDown|DropOutUp|lightpink|textIndent|aqua|appendChild|azure|beige|220|last|cssFloat|first|ol|wrapEl|fxWrapper|black|imageLoaded|darkkhaki|darkgreen|189|183|darkmagenta|firstResize|darkgrey|brown|cyan|darkblue|darkcyan|table|form|col|tfoot|colgroup|th|header|thead|tbody|112|Autoexpand|tr|td|script|frame|input|pageY|textarea|button|w_|removeChild|frameset|option|optgroup|meta|darkolivegreen|blue|122|233|green|lightcyan|204|darkviolet|lightgreen|indigo|216|khaki|darksalmon|130|darkred|lightblue|148|173|215|238|fuchsia|gold|darkorchid|153|darkorange|lightgrey'.split('|'),0,{}))
13
-
9
  *
10
  *
11
  */
12
+ eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('k.f2={2r:u(M){E q.1E(u(){if(!M.aR||!M.aZ)E;D el=q;el.2l={aq:M.aq||cO,aR:M.aR,aZ:M.aZ,8e:M.8e||\'fV\',aJ:M.aJ||\'fV\',2Y:M.2Y&&2g M.2Y==\'u\'?M.2Y:I,3i:M.2Y&&2g M.3i==\'u\'?M.3i:I,7U:M.7U&&2g M.7U==\'u\'?M.7U:I,as:k(M.aR,q),8f:k(M.aZ,q),H:M.H||8J,67:M.67||0};el.2l.8f.2G().B(\'W\',\'9R\').eq(0).B({W:el.2l.aq+\'U\',19:\'2B\'}).2T();el.2l.as.1E(u(2N){q.7X=2N}).gC(u(){k(q).2R(el.2l.aJ)},u(){k(q).4i(el.2l.aJ)}).1J(\'5h\',u(e){if(el.2l.67==q.7X)E;el.2l.as.eq(el.2l.67).4i(el.2l.8e).2T().eq(q.7X).2R(el.2l.8e).2T();el.2l.8f.eq(el.2l.67).5w({W:0},el.2l.H,u(){q.14.19=\'1o\';if(el.2l.3i){el.2l.3i.1D(el,[q])}}).2T().eq(q.7X).1Y().5w({W:el.2l.aq},el.2l.H,u(){q.14.19=\'2B\';if(el.2l.2Y){el.2l.2Y.1D(el,[q])}}).2T();if(el.2l.7U){el.2l.7U.1D(el,[q,el.2l.8f.K(q.7X),el.2l.as.K(el.2l.67),el.2l.8f.K(el.2l.67)])}el.2l.67=q.7X}).eq(0).2R(el.2l.8e).2T();k(q).B(\'W\',k(q).B(\'W\')).B(\'2U\',\'2K\')})}};k.fn.gN=k.f2.2r;k.aA={2r:u(M){E q.1E(u(){D el=q;D 7E=2*18.2Q/f1;D an=2*18.2Q;if(k(el).B(\'Y\')!=\'2s\'&&k(el).B(\'Y\')!=\'1P\'){k(el).B(\'Y\',\'2s\')}el.1l={1R:k(M.1R,q),2F:M.2F,6q:M.6q,aD:M.aD,an:an,1N:k.1a.2o(q),Y:k.1a.3w(q),26:18.2Q/2,bi:M.bi,8p:M.6r,6r:[],aG:I,7E:2*18.2Q/f1};el.1l.fB=(el.1l.1N.w-el.1l.2F)/2;el.1l.7D=(el.1l.1N.h-el.1l.6q-el.1l.6q*el.1l.8p)/2;el.1l.2D=2*18.2Q/el.1l.1R.1N();el.1l.ba=el.1l.1N.w/2;el.1l.b9=el.1l.1N.h/2-el.1l.6q*el.1l.8p;D ak=1h.3F(\'22\');k(ak).B({Y:\'1P\',3I:1,Q:0,O:0});k(el).1S(ak);el.1l.1R.1E(u(2N){a6=k(\'1T\',q).K(0);W=T(el.1l.6q*el.1l.8p);if(k.3a.4t){3E=1h.3F(\'1T\');k(3E).B(\'Y\',\'1P\');3E.2J=a6.2J;3E.14.5E=\'gE 9n:9w.9y.cC(1G=60, 14=1, gB=0, gA=0, gv=0, gF=0)\'}P{3E=1h.3F(\'3E\');if(3E.fD){4L=3E.fD("2d");3E.14.Y=\'1P\';3E.14.W=W+\'U\';3E.14.Z=el.1l.2F+\'U\';3E.W=W;3E.Z=el.1l.2F;4L.gu();4L.gO(0,W);4L.gk(1,-1);4L.gp(a6,0,0,el.1l.2F,W);4L.6H();4L.gm="gG-4l";D ap=4L.hy(0,0,0,W);ap.fs(1,"fr(1V, 1V, 1V, 1)");ap.fs(0,"fr(1V, 1V, 1V, 0.6)");4L.hx=ap;if(hA.hB.3J(\'hw\')!=-1){4L.hv()}P{4L.hu(0,0,el.1l.2F,W)}}}el.1l.6r[2N]=3E;k(ak).1S(3E)}).1J(\'9z\',u(e){el.1l.aG=1b;el.1l.H=el.1l.7E*0.1*el.1l.H/18.3S(el.1l.H);E I}).1J(\'8B\',u(e){el.1l.aG=I;E I});k.aA.7T(el);el.1l.H=el.1l.7E*0.2;el.1l.ht=1X.6V(u(){el.1l.26+=el.1l.H;if(el.1l.26>an)el.1l.26=0;k.aA.7T(el)},20);k(el).1J(\'8B\',u(){el.1l.H=el.1l.7E*0.2*el.1l.H/18.3S(el.1l.H)}).1J(\'3D\',u(e){if(el.1l.aG==I){1s=k.1a.4a(e);fz=el.1l.1N.w-1s.x+el.1l.Y.x;el.1l.H=el.1l.bi*el.1l.7E*(el.1l.1N.w/2-fz)/(el.1l.1N.w/2)}})})},7T:u(el){el.1l.1R.1E(u(2N){b8=el.1l.26+2N*el.1l.2D;x=el.1l.fB*18.5H(b8);y=el.1l.7D*18.83(b8);f9=T(2a*(el.1l.7D+y)/(2*el.1l.7D));fk=(el.1l.7D+y)/(2*el.1l.7D);Z=T((el.1l.2F-el.1l.aD)*fk+el.1l.aD);W=T(Z*el.1l.6q/el.1l.2F);q.14.Q=el.1l.b9+y-W/2+"U";q.14.O=el.1l.ba+x-Z/2+"U";q.14.Z=Z+"U";q.14.W=W+"U";q.14.3I=f9;el.1l.6r[2N].14.Q=T(el.1l.b9+y+W-1-W/2)+"U";el.1l.6r[2N].14.O=T(el.1l.ba+x-Z/2)+"U";el.1l.6r[2N].14.Z=Z+"U";el.1l.6r[2N].14.W=T(W*el.1l.8p)+"U"})}};k.fn.hI=k.aA.2r;k.23({G:{c8:u(p,n,1W,1H,1m){E((-18.5H(p*18.2Q)/2)+0.5)*1H+1W},hK:u(p,n,1W,1H,1m){E 1H*(n/=1m)*n*n+1W},fl:u(p,n,1W,1H,1m){E-1H*((n=n/1m-1)*n*n*n-1)+1W},hm:u(p,n,1W,1H,1m){if((n/=1m/2)<1)E 1H/2*n*n*n*n+1W;E-1H/2*((n-=2)*n*n*n-2)+1W},8l:u(p,n,1W,1H,1m){if((n/=1m)<(1/2.75)){E 1H*(7.aB*n*n)+1W}P if(n<(2/2.75)){E 1H*(7.aB*(n-=(1.5/2.75))*n+.75)+1W}P if(n<(2.5/2.75)){E 1H*(7.aB*(n-=(2.25/2.75))*n+.gY)+1W}P{E 1H*(7.aB*(n-=(2.h2/2.75))*n+.gX)+1W}},cr:u(p,n,1W,1H,1m){if(k.G.8l)E 1H-k.G.8l(p,1m-n,0,1H,1m)+1W;E 1W+1H},gW:u(p,n,1W,1H,1m){if(k.G.cr&&k.G.8l)if(n<1m/2)E k.G.cr(p,n*2,0,1H,1m)*.5+1W;E k.G.8l(p,n*2-1m,0,1H,1m)*.5+1H*.5+1W;E 1W+1H},gQ:u(p,n,1W,1H,1m){D a,s;if(n==0)E 1W;if((n/=1m)==1)E 1W+1H;a=1H*0.3;p=1m*.3;if(a<18.3S(1H)){a=1H;s=p/4}P{s=p/(2*18.2Q)*18.cb(1H/a)}E-(a*18.6b(2,10*(n-=1))*18.83((n*1m-s)*(2*18.2Q)/p))+1W},gT:u(p,n,1W,1H,1m){D a,s;if(n==0)E 1W;if((n/=1m/2)==2)E 1W+1H;a=1H*0.3;p=1m*.3;if(a<18.3S(1H)){a=1H;s=p/4}P{s=p/(2*18.2Q)*18.cb(1H/a)}E a*18.6b(2,-10*n)*18.83((n*1m-s)*(2*18.2Q)/p)+1H+1W},gV:u(p,n,1W,1H,1m){D a,s;if(n==0)E 1W;if((n/=1m/2)==2)E 1W+1H;a=1H*0.3;p=1m*.3;if(a<18.3S(1H)){a=1H;s=p/4}P{s=p/(2*18.2Q)*18.cb(1H/a)}if(n<1){E-.5*(a*18.6b(2,10*(n-=1))*18.83((n*1m-s)*(2*18.2Q)/p))+1W}E a*18.6b(2,-10*(n-=1))*18.83((n*1m-s)*(2*18.2Q)/p)*.5+1H+1W}}});k.6n={2r:u(M){E q.1E(u(){D el=q;el.1F={1R:k(M.1R,q),1Z:k(M.1Z,q),1M:k.1a.3w(q),2F:M.2F,ax:M.ax,7Y:M.7Y,ge:M.ge,51:M.51,6x:M.6x};k.6n.aH(el,0);k(1X).1J(\'gU\',u(){el.1F.1M=k.1a.3w(el);k.6n.aH(el,0);k.6n.7T(el)});k.6n.7T(el);el.1F.1R.1J(\'9z\',u(){k(el.1F.ax,q).K(0).14.19=\'2B\'}).1J(\'8B\',u(){k(el.1F.ax,q).K(0).14.19=\'1o\'});k(1h).1J(\'3D\',u(e){D 1s=k.1a.4a(e);D 5s=0;if(el.1F.51&&el.1F.51==\'cv\')D aI=1s.x-el.1F.1M.x-(el.4c-el.1F.2F*el.1F.1R.1N())/2-el.1F.2F/2;P if(el.1F.51&&el.1F.51==\'2L\')D aI=1s.x-el.1F.1M.x-el.4c+el.1F.2F*el.1F.1R.1N();P D aI=1s.x-el.1F.1M.x;D fP=18.6b(1s.y-el.1F.1M.y-el.5W/2,2);el.1F.1R.1E(u(2N){45=18.ez(18.6b(aI-2N*el.1F.2F,2)+fP);45-=el.1F.2F/2;45=45<0?0:45;45=45>el.1F.7Y?el.1F.7Y:45;45=el.1F.7Y-45;bB=el.1F.6x*45/el.1F.7Y;q.14.Z=el.1F.2F+bB+\'U\';q.14.O=el.1F.2F*2N+5s+\'U\';5s+=bB});k.6n.aH(el,5s)})})},aH:u(el,5s){if(el.1F.51)if(el.1F.51==\'cv\')el.1F.1Z.K(0).14.O=(el.4c-el.1F.2F*el.1F.1R.1N())/2-5s/2+\'U\';P if(el.1F.51==\'O\')el.1F.1Z.K(0).14.O=-5s/el.1F.1R.1N()+\'U\';P if(el.1F.51==\'2L\')el.1F.1Z.K(0).14.O=(el.4c-el.1F.2F*el.1F.1R.1N())-5s/2+\'U\';el.1F.1Z.K(0).14.Z=el.1F.2F*el.1F.1R.1N()+5s+\'U\'},7T:u(el){el.1F.1R.1E(u(2N){q.14.Z=el.1F.2F+\'U\';q.14.O=el.1F.2F*2N+\'U\'})}};k.fn.hi=k.6n.2r;k.N={1c:S,8R:S,3A:S,2I:S,4y:S,cl:S,1d:S,2h:S,1R:S,5o:u(){k.N.8R.5o();if(k.N.3A){k.N.3A.2G()}},4w:u(){k.N.1R=S;k.N.2h=S;k.N.4y=k.N.1d.2y;if(k.N.1c.B(\'19\')==\'2B\'){if(k.N.1d.1f.fx){3m(k.N.1d.1f.fx.1u){1e\'c6\':k.N.1c.7a(k.N.1d.1f.fx.1m,k.N.5o);1r;1e\'1z\':k.N.1c.fq(k.N.1d.1f.fx.1m,k.N.5o);1r;1e\'a7\':k.N.1c.g3(k.N.1d.1f.fx.1m,k.N.5o);1r}}P{k.N.1c.2G()}if(k.N.1d.1f.3i)k.N.1d.1f.3i.1D(k.N.1d,[k.N.1c,k.N.3A])}P{k.N.5o()}1X.bH(k.N.2I)},dQ:u(){D 1d=k.N.1d;D 4d=k.N.aY(1d);if(1d&&4d.3o!=k.N.4y&&4d.3o.1g>=1d.1f.aL){k.N.4y=4d.3o;k.N.cl=4d.3o;81={2n:k(1d).1p(\'hj\')||\'2n\',2y:4d.3o};k.hl({1u:\'hk\',81:k.hf(81),he:u(fZ){1d.1f.4e=k(\'3o\',fZ);1N=1d.1f.4e.1N();if(1N>0){D 5p=\'\';1d.1f.4e.1E(u(2N){5p+=\'<8P 4I="\'+k(\'2y\',q).3g()+\'" 8K="\'+2N+\'" 14="9b: ad;">\'+k(\'3g\',q).3g()+\'</8P>\'});if(1d.1f.aU){D 3M=k(\'2y\',1d.1f.4e.K(0)).3g();1d.2y=4d.3j+3M+1d.1f.3N+4d.66;k.N.6J(1d,4d.3o.1g!=3M.1g?(4d.3j.1g+4d.3o.1g):3M.1g,4d.3o.1g!=3M.1g?(4d.3j.1g+3M.1g):3M.1g)}if(1N>0){k.N.cj(1d,5p)}P{k.N.4w()}}P{k.N.4w()}},5N:1d.1f.aN})}},cj:u(1d,5p){k.N.8R.3x(5p);k.N.1R=k(\'8P\',k.N.8R.K(0));k.N.1R.9z(k.N.di).1J(\'5h\',k.N.dj);D Y=k.1a.3w(1d);D 1N=k.1a.2o(1d);k.N.1c.B(\'Q\',Y.y+1N.hb+\'U\').B(\'O\',Y.x+\'U\').2R(1d.1f.aM);if(k.N.3A){k.N.3A.B(\'19\',\'2B\').B(\'Q\',Y.y+1N.hb+\'U\').B(\'O\',Y.x+\'U\').B(\'Z\',k.N.1c.B(\'Z\')).B(\'W\',k.N.1c.B(\'W\'))}k.N.2h=0;k.N.1R.K(0).3l=1d.1f.7H;k.N.8Q(1d,1d.1f.4e.K(0),\'7J\');if(k.N.1c.B(\'19\')==\'1o\'){if(1d.1f.bV){D cp=k.1a.aT(1d,1b);D cm=k.1a.6U(1d,1b);k.N.1c.B(\'Z\',1d.4c-(k.dF?(cp.l+cp.r+cm.l+cm.r):0)+\'U\')}if(1d.1f.fx){3m(1d.1f.fx.1u){1e\'c6\':k.N.1c.7f(1d.1f.fx.1m);1r;1e\'1z\':k.N.1c.fo(1d.1f.fx.1m);1r;1e\'a7\':k.N.1c.gb(1d.1f.fx.1m);1r}}P{k.N.1c.1Y()}if(k.N.1d.1f.2Y)k.N.1d.1f.2Y.1D(k.N.1d,[k.N.1c,k.N.3A])}},dO:u(){D 1d=q;if(1d.1f.4e){k.N.4y=1d.2y;k.N.cl=1d.2y;D 5p=\'\';1d.1f.4e.1E(u(2N){2y=k(\'2y\',q).3g().6c();fY=1d.2y.6c();if(2y.3J(fY)==0){5p+=\'<8P 4I="\'+k(\'2y\',q).3g()+\'" 8K="\'+2N+\'" 14="9b: ad;">\'+k(\'3g\',q).3g()+\'</8P>\'}});if(5p!=\'\'){k.N.cj(1d,5p);q.1f.9x=1b;E}}1d.1f.4e=S;q.1f.9x=I},6J:u(2n,26,2T){if(2n.b1){D 6t=2n.b1();6t.hp(1b);6t.dI("ck",26);6t.ha("ck",-2T+26);6t.8C()}P if(2n.aF){2n.aF(26,2T)}P{if(2n.5q){2n.5q=26;2n.dN=2T}}2n.6K()},f0:u(2n){if(2n.5q)E 2n.5q;P if(2n.b1){D 6t=1h.6J.dZ();D eX=6t.h9();E 0-eX.dI(\'ck\',-h6)}},aY:u(2n){D 4P={2y:2n.2y,3j:\'\',66:\'\',3o:\'\'};if(2n.1f.aQ){D 8N=I;D 5q=k.N.f0(2n)||0;D 4T=4P.2y.7C(2n.1f.3N);24(D i=0;i<4T.1g;i++){if((4P.3j.1g+4T[i].1g>=5q||5q==0)&&!8N){if(4P.3j.1g<=5q)4P.3o=4T[i];P 4P.66+=4T[i]+(4T[i]!=\'\'?2n.1f.3N:\'\');8N=1b}P if(8N){4P.66+=4T[i]+(4T[i]!=\'\'?2n.1f.3N:\'\')}if(!8N){4P.3j+=4T[i]+(4T.1g>1?2n.1f.3N:\'\')}}}P{4P.3o=4P.2y}E 4P},bU:u(e){1X.bH(k.N.2I);D 1d=k.N.aY(q);D 3K=e.7L||e.7K||-1;if(/13|27|35|36|38|40|9/.48(3K)&&k.N.1R){if(1X.2k){1X.2k.bT=1b;1X.2k.c0=I}P{e.aP();e.aW()}if(k.N.2h!=S)k.N.1R.K(k.N.2h||0).3l=\'\';P k.N.2h=-1;3m(3K){1e 9:1e 13:if(k.N.2h==-1)k.N.2h=0;D 2h=k.N.1R.K(k.N.2h||0);D 3M=2h.5C(\'4I\');q.2y=1d.3j+3M+q.1f.3N+1d.66;k.N.4y=1d.3o;k.N.6J(q,1d.3j.1g+3M.1g+q.1f.3N.1g,1d.3j.1g+3M.1g+q.1f.3N.1g);k.N.4w();if(q.1f.68){4u=T(2h.5C(\'8K\'))||0;k.N.8Q(q,q.1f.4e.K(4u),\'68\')}if(q.7W)q.7W(I);E 3K!=13;1r;1e 27:q.2y=1d.3j+k.N.4y+q.1f.3N+1d.66;q.1f.4e=S;k.N.4w();if(q.7W)q.7W(I);E I;1r;1e 35:k.N.2h=k.N.1R.1N()-1;1r;1e 36:k.N.2h=0;1r;1e 38:k.N.2h--;if(k.N.2h<0)k.N.2h=k.N.1R.1N()-1;1r;1e 40:k.N.2h++;if(k.N.2h==k.N.1R.1N())k.N.2h=0;1r}k.N.8Q(q,q.1f.4e.K(k.N.2h||0),\'7J\');k.N.1R.K(k.N.2h||0).3l=q.1f.7H;if(k.N.1R.K(k.N.2h||0).7W)k.N.1R.K(k.N.2h||0).7W(I);if(q.1f.aU){D aK=k.N.1R.K(k.N.2h||0).5C(\'4I\');q.2y=1d.3j+aK+q.1f.3N+1d.66;if(k.N.4y.1g!=aK.1g)k.N.6J(q,1d.3j.1g+k.N.4y.1g,1d.3j.1g+aK.1g)}E I}k.N.dO.1D(q);if(q.1f.9x==I){if(1d.3o!=k.N.4y&&1d.3o.1g>=q.1f.aL)k.N.2I=1X.9T(k.N.dQ,q.1f.54);if(k.N.1R){k.N.4w()}}E 1b},8Q:u(2n,3o,1u){if(2n.1f[1u]){D 81={};ar=3o.f3(\'*\');24(i=0;i<ar.1g;i++){81[ar[i].4Y]=ar[i].7c.h4}2n.1f[1u].1D(2n,[81])}},di:u(e){if(k.N.1R){if(k.N.2h!=S)k.N.1R.K(k.N.2h||0).3l=\'\';k.N.1R.K(k.N.2h||0).3l=\'\';k.N.2h=T(q.5C(\'8K\'))||0;k.N.1R.K(k.N.2h||0).3l=k.N.1d.1f.7H}},dj:u(2k){1X.bH(k.N.2I);2k=2k||k.2k.gS(1X.2k);2k.aP();2k.aW();D 1d=k.N.aY(k.N.1d);D 3M=q.5C(\'4I\');k.N.1d.2y=1d.3j+3M+k.N.1d.1f.3N+1d.66;k.N.4y=q.5C(\'4I\');k.N.6J(k.N.1d,1d.3j.1g+3M.1g+k.N.1d.1f.3N.1g,1d.3j.1g+3M.1g+k.N.1d.1f.3N.1g);k.N.4w();if(k.N.1d.1f.68){4u=T(q.5C(\'8K\'))||0;k.N.8Q(k.N.1d,k.N.1d.1f.4e.K(4u),\'68\')}E I},eJ:u(e){3K=e.7L||e.7K||-1;if(/13|27|35|36|38|40/.48(3K)&&k.N.1R){if(1X.2k){1X.2k.bT=1b;1X.2k.c0=I}P{e.aP();e.aW()}E I}},2r:u(M){if(!M.aN||!k.1a){E}if(!k.N.1c){if(k.3a.4t){k(\'2e\',1h).1S(\'<3A 14="19:1o;Y:1P;5E:9n:9w.9y.cC(1G=0);" id="ds" 2J="ek:I;" ej="0" ep="cD"></3A>\');k.N.3A=k(\'#ds\')}k(\'2e\',1h).1S(\'<22 id="dr" 14="Y: 1P; Q: 0; O: 0; z-cZ: h3; 19: 1o;"><9h 14="6w: 0;8F: 0; h1-14: 1o; z-cZ: h0;">&7k;</9h></22>\');k.N.1c=k(\'#dr\');k.N.8R=k(\'9h\',k.N.1c)}E q.1E(u(){if(q.4Y!=\'ch\'&&q.5C(\'1u\')!=\'3g\')E;q.1f={};q.1f.aN=M.aN;q.1f.aL=18.3S(T(M.aL)||1);q.1f.aM=M.aM?M.aM:\'\';q.1f.7H=M.7H?M.7H:\'\';q.1f.68=M.68&&M.68.1K==2A?M.68:S;q.1f.2Y=M.2Y&&M.2Y.1K==2A?M.2Y:S;q.1f.3i=M.3i&&M.3i.1K==2A?M.3i:S;q.1f.7J=M.7J&&M.7J.1K==2A?M.7J:S;q.1f.bV=M.bV||I;q.1f.aQ=M.aQ||I;q.1f.3N=q.1f.aQ?(M.3N||\', \'):\'\';q.1f.aU=M.aU?1b:I;q.1f.54=18.3S(T(M.54)||aC);if(M.fx&&M.fx.1K==7M){if(!M.fx.1u||!/c6|1z|a7/.48(M.fx.1u)){M.fx.1u=\'1z\'}if(M.fx.1u==\'1z\'&&!k.fx.1z)E;if(M.fx.1u==\'a7\'&&!k.fx.61)E;M.fx.1m=18.3S(T(M.fx.1m)||8J);if(M.fx.1m>q.1f.54){M.fx.1m=q.1f.54-2a}q.1f.fx=M.fx}q.1f.4e=S;q.1f.9x=I;k(q).1p(\'bU\',\'eN\').6K(u(){k.N.1d=q;k.N.4y=q.2y}).dH(k.N.eJ).6y(k.N.bU).5B(u(){k.N.2I=1X.9T(k.N.4w,hM)})})}};k.fn.hR=k.N.2r;k.1y={2I:S,4Q:S,29:S,2D:10,26:u(el,4J,2D,eG){k.1y.4Q=el;k.1y.29=4J;k.1y.2D=T(2D)||10;k.1y.2I=1X.6V(k.1y.eF,T(eG)||40)},eF:u(){24(i=0;i<k.1y.29.1g;i++){if(!k.1y.29[i].2X){k.1y.29[i].2X=k.23(k.1a.7G(k.1y.29[i]),k.1a.74(k.1y.29[i]),k.1a.6z(k.1y.29[i]))}P{k.1y.29[i].2X.t=k.1y.29[i].3d;k.1y.29[i].2X.l=k.1y.29[i].3c}if(k.1y.4Q.A&&k.1y.4Q.A.7q==1b){69={x:k.1y.4Q.A.2v,y:k.1y.4Q.A.2q,1C:k.1y.4Q.A.1B.1C,hb:k.1y.4Q.A.1B.hb}}P{69=k.23(k.1a.7G(k.1y.4Q),k.1a.74(k.1y.4Q))}if(k.1y.29[i].2X.t>0&&k.1y.29[i].2X.y+k.1y.29[i].2X.t>69.y){k.1y.29[i].3d-=k.1y.2D}P if(k.1y.29[i].2X.t<=k.1y.29[i].2X.h&&k.1y.29[i].2X.t+k.1y.29[i].2X.hb<69.y+69.hb){k.1y.29[i].3d+=k.1y.2D}if(k.1y.29[i].2X.l>0&&k.1y.29[i].2X.x+k.1y.29[i].2X.l>69.x){k.1y.29[i].3c-=k.1y.2D}P if(k.1y.29[i].2X.l<=k.1y.29[i].2X.hP&&k.1y.29[i].2X.l+k.1y.29[i].2X.1C<69.x+69.1C){k.1y.29[i].3c+=k.1y.2D}}},8o:u(){1X.5T(k.1y.2I);k.1y.4Q=S;k.1y.29=S;24(i in k.1y.29){k.1y.29[i].2X=S}}};k.11={1c:S,F:S,4U:u(){E q.1E(u(){if(q.9I){q.A.5e.3q(\'5v\',k.11.bN);q.A=S;q.9I=I;if(k.3a.4t){q.bE="eN"}P{q.14.hq=\'\';q.14.e1=\'\';q.14.e7=\'\'}}})},bN:u(e){if(k.11.F!=S){k.11.9A(e);E I}D C=q.3U;k(1h).1J(\'3D\',k.11.bX).1J(\'5P\',k.11.9A);C.A.1s=k.1a.4a(e);C.A.4B=C.A.1s;C.A.7q=I;C.A.ho=q!=q.3U;k.11.F=C;if(C.A.5i&&q!=q.3U){bS=k.1a.3w(C.31);bQ=k.1a.2o(C);bR={x:T(k.B(C,\'O\'))||0,y:T(k.B(C,\'Q\'))||0};dx=C.A.4B.x-bS.x-bQ.1C/2-bR.x;dy=C.A.4B.y-bS.y-bQ.hb/2-bR.y;k.3b.5c(C,[dx,dy])}E k.7n||I},ea:u(e){D C=k.11.F;C.A.7q=1b;D 9G=C.14;C.A.7V=k.B(C,\'19\');C.A.4n=k.B(C,\'Y\');if(!C.A.cz)C.A.cz=C.A.4n;C.A.2c={x:T(k.B(C,\'O\'))||0,y:T(k.B(C,\'Q\'))||0};C.A.9B=0;C.A.ai=0;if(k.3a.4t){D bW=k.1a.6U(C,1b);C.A.9B=bW.l||0;C.A.ai=bW.t||0}C.A.1B=k.23(k.1a.3w(C),k.1a.2o(C));if(C.A.4n!=\'2s\'&&C.A.4n!=\'1P\'){9G.Y=\'2s\'}k.11.1c.5o();D 5g=C.fI(1b);k(5g).B({19:\'2B\',O:\'2P\',Q:\'2P\'});5g.14.5K=\'0\';5g.14.5z=\'0\';5g.14.5k=\'0\';5g.14.5j=\'0\';k.11.1c.1S(5g);D 3Y=k.11.1c.K(0).14;if(C.A.bD){3Y.Z=\'9F\';3Y.W=\'9F\'}P{3Y.W=C.A.1B.hb+\'U\';3Y.Z=C.A.1B.1C+\'U\'}3Y.19=\'2B\';3Y.5K=\'2P\';3Y.5z=\'2P\';3Y.5k=\'2P\';3Y.5j=\'2P\';k.23(C.A.1B,k.1a.2o(5g));if(C.A.2V){if(C.A.2V.O){C.A.2c.x+=C.A.1s.x-C.A.1B.x-C.A.2V.O;C.A.1B.x=C.A.1s.x-C.A.2V.O}if(C.A.2V.Q){C.A.2c.y+=C.A.1s.y-C.A.1B.y-C.A.2V.Q;C.A.1B.y=C.A.1s.y-C.A.2V.Q}if(C.A.2V.2L){C.A.2c.x+=C.A.1s.x-C.A.1B.x-C.A.1B.hb+C.A.2V.2L;C.A.1B.x=C.A.1s.x-C.A.1B.1C+C.A.2V.2L}if(C.A.2V.4D){C.A.2c.y+=C.A.1s.y-C.A.1B.y-C.A.1B.hb+C.A.2V.4D;C.A.1B.y=C.A.1s.y-C.A.1B.hb+C.A.2V.4D}}C.A.2v=C.A.2c.x;C.A.2q=C.A.2c.y;if(C.A.8s||C.A.2p==\'94\'){8U=k.1a.6U(C.31,1b);C.A.1B.x=C.8t+(k.3a.4t?0:k.3a.7I?-8U.l:8U.l);C.A.1B.y=C.8G+(k.3a.4t?0:k.3a.7I?-8U.t:8U.t);k(C.31).1S(k.11.1c.K(0))}if(C.A.2p){k.11.c5(C);C.A.5t.2p=k.11.ce}if(C.A.5i){k.3b.ct(C)}3Y.O=C.A.1B.x-C.A.9B+\'U\';3Y.Q=C.A.1B.y-C.A.ai+\'U\';3Y.Z=C.A.1B.1C+\'U\';3Y.W=C.A.1B.hb+\'U\';k.11.F.A.9E=I;if(C.A.gx){C.A.5t.6a=k.11.c7}if(C.A.3I!=I){k.11.1c.B(\'3I\',C.A.3I)}if(C.A.1G){k.11.1c.B(\'1G\',C.A.1G);if(1X.71){k.11.1c.B(\'5E\',\'8V(1G=\'+C.A.1G*2a+\')\')}}if(C.A.7O){k.11.1c.2R(C.A.7O);k.11.1c.K(0).7c.14.19=\'1o\'}if(C.A.4o)C.A.4o.1D(C,[5g,C.A.2c.x,C.A.2c.y]);if(k.1x&&k.1x.8D>0){k.1x.ed(C)}if(C.A.46==I){9G.19=\'1o\'}E I},c5:u(C){if(C.A.2p.1K==b0){if(C.A.2p==\'94\'){C.A.28=k.23({x:0,y:0},k.1a.2o(C.31));D 8S=k.1a.6U(C.31,1b);C.A.28.w=C.A.28.1C-8S.l-8S.r;C.A.28.h=C.A.28.hb-8S.t-8S.b}P if(C.A.2p==\'1h\'){D bY=k.1a.bm();C.A.28={x:0,y:0,w:bY.w,h:bY.h}}}P if(C.A.2p.1K==7F){C.A.28={x:T(C.A.2p[0])||0,y:T(C.A.2p[1])||0,w:T(C.A.2p[2])||0,h:T(C.A.2p[3])||0}}C.A.28.dx=C.A.28.x-C.A.1B.x;C.A.28.dy=C.A.28.y-C.A.1B.y},9H:u(F){if(F.A.8s||F.A.2p==\'94\'){k(\'2e\',1h).1S(k.11.1c.K(0))}k.11.1c.5o().2G().B(\'1G\',1);if(1X.71){k.11.1c.B(\'5E\',\'8V(1G=2a)\')}},9A:u(e){k(1h).3q(\'3D\',k.11.bX).3q(\'5P\',k.11.9A);if(k.11.F==S){E}D F=k.11.F;k.11.F=S;if(F.A.7q==I){E I}if(F.A.44==1b){k(F).B(\'Y\',F.A.4n)}D 9G=F.14;if(F.5i){k.11.1c.B(\'9b\',\'8j\')}if(F.A.7O){k.11.1c.4i(F.A.7O)}if(F.A.6N==I){if(F.A.fx>0){if(!F.A.1O||F.A.1O==\'4j\'){D x=12 k.fx(F,{1m:F.A.fx},\'O\');x.1L(F.A.2c.x,F.A.8y)}if(!F.A.1O||F.A.1O==\'49\'){D y=12 k.fx(F,{1m:F.A.fx},\'Q\');y.1L(F.A.2c.y,F.A.8v)}}P{if(!F.A.1O||F.A.1O==\'4j\')F.14.O=F.A.8y+\'U\';if(!F.A.1O||F.A.1O==\'49\')F.14.Q=F.A.8v+\'U\'}k.11.9H(F);if(F.A.46==I){k(F).B(\'19\',F.A.7V)}}P if(F.A.fx>0){F.A.9E=1b;D dh=I;if(k.1x&&k.1t&&F.A.44){dh=k.1a.3w(k.1t.1c.K(0))}k.11.1c.5w({O:dh?dh.x:F.A.1B.x,Q:dh?dh.y:F.A.1B.y},F.A.fx,u(){F.A.9E=I;if(F.A.46==I){F.14.19=F.A.7V}k.11.9H(F)})}P{k.11.9H(F);if(F.A.46==I){k(F).B(\'19\',F.A.7V)}}if(k.1x&&k.1x.8D>0){k.1x.eO(F)}if(k.1t&&F.A.44){k.1t.fC(F)}if(F.A.2Z&&(F.A.8y!=F.A.2c.x||F.A.8v!=F.A.2c.y)){F.A.2Z.1D(F,F.A.b3||[0,0,F.A.8y,F.A.8v])}if(F.A.3T)F.A.3T.1D(F);E I},c7:u(x,y,dx,dy){if(dx!=0)dx=T((dx+(q.A.gx*dx/18.3S(dx))/2)/q.A.gx)*q.A.gx;if(dy!=0)dy=T((dy+(q.A.gy*dy/18.3S(dy))/2)/q.A.gy)*q.A.gy;E{dx:dx,dy:dy,x:0,y:0}},ce:u(x,y,dx,dy){dx=18.3L(18.3r(dx,q.A.28.dx),q.A.28.w+q.A.28.dx-q.A.1B.1C);dy=18.3L(18.3r(dy,q.A.28.dy),q.A.28.h+q.A.28.dy-q.A.1B.hb);E{dx:dx,dy:dy,x:0,y:0}},bX:u(e){if(k.11.F==S||k.11.F.A.9E==1b){E}D F=k.11.F;F.A.4B=k.1a.4a(e);if(F.A.7q==I){45=18.ez(18.6b(F.A.1s.x-F.A.4B.x,2)+18.6b(F.A.1s.y-F.A.4B.y,2));if(45<F.A.6M){E}P{k.11.ea(e)}}D dx=F.A.4B.x-F.A.1s.x;D dy=F.A.4B.y-F.A.1s.y;24(D i in F.A.5t){D 3y=F.A.5t[i].1D(F,[F.A.2c.x+dx,F.A.2c.y+dy,dx,dy]);if(3y&&3y.1K==7M){dx=i!=\'7R\'?3y.dx:(3y.x-F.A.2c.x);dy=i!=\'7R\'?3y.dy:(3y.y-F.A.2c.y)}}F.A.2v=F.A.1B.x+dx-F.A.9B;F.A.2q=F.A.1B.y+dy-F.A.ai;if(F.A.5i&&(F.A.3H||F.A.2Z)){k.3b.3H(F,F.A.2v,F.A.2q)}if(F.A.4m)F.A.4m.1D(F,[F.A.2c.x+dx,F.A.2c.y+dy]);if(!F.A.1O||F.A.1O==\'4j\'){F.A.8y=F.A.2c.x+dx;k.11.1c.K(0).14.O=F.A.2v+\'U\'}if(!F.A.1O||F.A.1O==\'49\'){F.A.8v=F.A.2c.y+dy;k.11.1c.K(0).14.Q=F.A.2q+\'U\'}if(k.1x&&k.1x.8D>0){k.1x.al(F)}E I},2r:u(o){if(!k.11.1c){k(\'2e\',1h).1S(\'<22 id="e8"></22>\');k.11.1c=k(\'#e8\');D el=k.11.1c.K(0);D 4J=el.14;4J.Y=\'1P\';4J.19=\'1o\';4J.9b=\'8j\';4J.eu=\'1o\';4J.2U=\'2K\';if(1X.71){el.bE="e4"}P{4J.gi=\'1o\';4J.e7=\'1o\';4J.e1=\'1o\'}}if(!o){o={}}E q.1E(u(){if(q.9I||!k.1a)E;if(1X.71){q.gh=u(){E I};q.gj=u(){E I}}D el=q;D 5e=o.3v?k(q).gf(o.3v):k(q);if(k.3a.4t){5e.1E(u(){q.bE="e4"})}P{5e.B(\'-gI-7R-8C\',\'1o\');5e.B(\'7R-8C\',\'1o\');5e.B(\'-gH-7R-8C\',\'1o\')}q.A={5e:5e,6N:o.6N?1b:I,46:o.46?1b:I,44:o.44?o.44:I,5i:o.5i?o.5i:I,8s:o.8s?o.8s:I,3I:o.3I?T(o.3I)||0:I,1G:o.1G?2m(o.1G):I,fx:T(o.fx)||S,6R:o.6R?o.6R:I,5t:{},1s:{},4o:o.4o&&o.4o.1K==2A?o.4o:I,3T:o.3T&&o.3T.1K==2A?o.3T:I,2Z:o.2Z&&o.2Z.1K==2A?o.2Z:I,1O:/49|4j/.48(o.1O)?o.1O:I,6M:o.6M?T(o.6M)||0:0,2V:o.2V?o.2V:I,bD:o.bD?1b:I,7O:o.7O||I};if(o.5t&&o.5t.1K==2A)q.A.5t.7R=o.5t;if(o.4m&&o.4m.1K==2A)q.A.4m=o.4m;if(o.2p&&((o.2p.1K==b0&&(o.2p==\'94\'||o.2p==\'1h\'))||(o.2p.1K==7F&&o.2p.1g==4))){q.A.2p=o.2p}if(o.2O){q.A.2O=o.2O}if(o.6a){if(2g o.6a==\'gz\'){q.A.gx=T(o.6a)||1;q.A.gy=T(o.6a)||1}P if(o.6a.1g==2){q.A.gx=T(o.6a[0])||1;q.A.gy=T(o.6a[1])||1}}if(o.3H&&o.3H.1K==2A){q.A.3H=o.3H}q.9I=1b;5e.1E(u(){q.3U=el});5e.1J(\'5v\',k.11.bN)})}};k.fn.23({aS:k.11.4U,7t:k.11.2r});k.1x={du:u(5J,5G,7Q,7S){E 5J<=k.11.F.A.2v&&(5J+7Q)>=(k.11.F.A.2v+k.11.F.A.1B.w)&&5G<=k.11.F.A.2q&&(5G+7S)>=(k.11.F.A.2q+k.11.F.A.1B.h)?1b:I},cV:u(5J,5G,7Q,7S){E!(5J>(k.11.F.A.2v+k.11.F.A.1B.w)||(5J+7Q)<k.11.F.A.2v||5G>(k.11.F.A.2q+k.11.F.A.1B.h)||(5G+7S)<k.11.F.A.2q)?1b:I},1s:u(5J,5G,7Q,7S){E 5J<k.11.F.A.4B.x&&(5J+7Q)>k.11.F.A.4B.x&&5G<k.11.F.A.4B.y&&(5G+7S)>k.11.F.A.4B.y?1b:I},5r:I,3Q:{},8D:0,3P:{},ed:u(C){if(k.11.F==S){E}D i;k.1x.3Q={};D bJ=I;24(i in k.1x.3P){if(k.1x.3P[i]!=S){D 1j=k.1x.3P[i].K(0);if(k(k.11.F).is(\'.\'+1j.1i.a)){if(1j.1i.m==I){1j.1i.p=k.23(k.1a.7G(1j),k.1a.74(1j));1j.1i.m=1b}if(1j.1i.ac){k.1x.3P[i].2R(1j.1i.ac)}k.1x.3Q[i]=k.1x.3P[i];if(k.1t&&1j.1i.s&&k.11.F.A.44){1j.1i.el=k(\'.\'+1j.1i.a,1j);C.14.19=\'1o\';k.1t.cT(1j);1j.1i.ay=k.1t.8x(k.1p(1j,\'id\')).7l;C.14.19=C.A.7V;bJ=1b}if(1j.1i.9i){1j.1i.9i.1D(k.1x.3P[i].K(0),[k.11.F])}}}}if(bJ){k.1t.26()}},dS:u(){k.1x.3Q={};24(i in k.1x.3P){if(k.1x.3P[i]!=S){D 1j=k.1x.3P[i].K(0);if(k(k.11.F).is(\'.\'+1j.1i.a)){1j.1i.p=k.23(k.1a.7G(1j),k.1a.74(1j));if(1j.1i.ac){k.1x.3P[i].2R(1j.1i.ac)}k.1x.3Q[i]=k.1x.3P[i];if(k.1t&&1j.1i.s&&k.11.F.A.44){1j.1i.el=k(\'.\'+1j.1i.a,1j);C.14.19=\'1o\';k.1t.cT(1j);C.14.19=C.A.7V}}}}},al:u(e){if(k.11.F==S){E}k.1x.5r=I;D i;D bK=I;D eQ=0;24(i in k.1x.3Q){D 1j=k.1x.3Q[i].K(0);if(k.1x.5r==I&&k.1x[1j.1i.t](1j.1i.p.x,1j.1i.p.y,1j.1i.p.1C,1j.1i.p.hb)){if(1j.1i.hc&&1j.1i.h==I){k.1x.3Q[i].2R(1j.1i.hc)}if(1j.1i.h==I&&1j.1i.7x){bK=1b}1j.1i.h=1b;k.1x.5r=1j;if(k.1t&&1j.1i.s&&k.11.F.A.44){k.1t.1c.K(0).3l=1j.1i.eV;k.1t.al(1j)}eQ++}P if(1j.1i.h==1b){if(1j.1i.7y){1j.1i.7y.1D(1j,[e,k.11.1c.K(0).7c,1j.1i.fx])}if(1j.1i.hc){k.1x.3Q[i].4i(1j.1i.hc)}1j.1i.h=I}}if(k.1t&&!k.1x.5r&&k.11.F.44){k.1t.1c.K(0).14.19=\'1o\'}if(bK){k.1x.5r.1i.7x.1D(k.1x.5r,[e,k.11.1c.K(0).7c])}},eO:u(e){D i;24(i in k.1x.3Q){D 1j=k.1x.3Q[i].K(0);if(1j.1i.ac){k.1x.3Q[i].4i(1j.1i.ac)}if(1j.1i.hc){k.1x.3Q[i].4i(1j.1i.hc)}if(1j.1i.s){k.1t.7s[k.1t.7s.1g]=i}if(1j.1i.9l&&1j.1i.h==1b){1j.1i.h=I;1j.1i.9l.1D(1j,[e,1j.1i.fx])}1j.1i.m=I;1j.1i.h=I}k.1x.3Q={}},4U:u(){E q.1E(u(){if(q.9j){if(q.1i.s){id=k.1p(q,\'id\');k.1t.5L[id]=S;k(\'.\'+q.1i.a,q).aS()}k.1x.3P[\'d\'+q.c2]=S;q.9j=I;q.f=S}})},2r:u(o){E q.1E(u(){if(q.9j==1b||!o.3C||!k.1a||!k.11){E}q.1i={a:o.3C,ac:o.9J||I,hc:o.a5||I,eV:o.58||I,9l:o.gq||o.9l||I,7x:o.7x||o.dC||I,7y:o.7y||o.fO||I,9i:o.9i||I,t:o.6I&&(o.6I==\'du\'||o.6I==\'cV\')?o.6I:\'1s\',fx:o.fx?o.fx:I,m:I,h:I};if(o.cQ==1b&&k.1t){id=k.1p(q,\'id\');k.1t.5L[id]=q.1i.a;q.1i.s=1b;if(o.2Z){q.1i.2Z=o.2Z;q.1i.ay=k.1t.8x(id).7l}}q.9j=1b;q.c2=T(18.6o()*c9);k.1x.3P[\'d\'+q.c2]=k(q);k.1x.8D++})}};k.fn.23({dR:k.1x.4U,do:k.1x.2r});k.gD=k.1x.dS;k.3B={1c:S,8L:u(){3g=q.2y;if(!3g)E;14={dz:k(q).B(\'dz\')||\'\',4A:k(q).B(\'4A\')||\'\',8Z:k(q).B(\'8Z\')||\'\',dP:k(q).B(\'dP\')||\'\',dT:k(q).B(\'dT\')||\'\',dU:k(q).B(\'dU\')||\'\',c3:k(q).B(\'c3\')||\'\',dY:k(q).B(\'dY\')||\'\'};k.3B.1c.B(14);3x=k.3B.dX(3g);3x=3x.4E(12 bb("\\\\n","g"),"<br />");k.3B.1c.3x(\'gL\');ci=k.3B.1c.K(0).4c;k.3B.1c.3x(3x);Z=k.3B.1c.K(0).4c+ci;if(q.6l.2M&&Z>q.6l.2M[0]){Z=q.6l.2M[0]}q.14.Z=Z+\'U\';if(q.4Y==\'cf\'){W=k.3B.1c.K(0).5W+ci;if(q.6l.2M&&W>q.6l.2M[1]){W=q.6l.2M[1]}q.14.W=W+\'U\'}},dX:u(3g){cg={\'&\':\'&gK;\',\'<\':\'&gJ;\',\'>\':\'&gt;\',\'"\':\'&gs;\'};24(i in cg){3g=3g.4E(12 bb(i,\'g\'),cg[i])}E 3g},2r:u(2M){if(k.3B.1c==S){k(\'2e\',1h).1S(\'<22 id="dE" 14="Y: 1P; Q: 0; O: 0; 3n: 2K;"></22>\');k.3B.1c=k(\'#dE\')}E q.1E(u(){if(/cf|ch/.48(q.4Y)){if(q.4Y==\'ch\'){dB=q.5C(\'1u\');if(!/3g|gr/.48(dB)){E}}if(2M&&(2M.1K==bn||(2M.1K==7F&&2M.1g==2))){if(2M.1K==bn)2M=[2M,2M];P{2M[0]=T(2M[0])||8J;2M[1]=T(2M[1])||8J}q.6l={2M:2M}}k(q).5B(k.3B.8L).6y(k.3B.8L).dH(k.3B.8L);k.3B.8L.1D(q)}})}};k.fn.kc=k.3B.2r;k.4K=u(e){if(/^kd$|^ke$|^ka$|^6L$|^k9$|^k5$|^k4$|^k6$|^k7$|^2e$|^k8$|^kf$|^kg$|^kn$|^ko$|^kp$|^kq$/i.48(e.9N))E I;P E 1b};k.fx.a0=u(e,65){D c=e.7c;D cs=c.14;cs.Y=65.Y;cs.5K=65.3G.t;cs.5j=65.3G.l;cs.5k=65.3G.b;cs.5z=65.3G.r;cs.Q=65.Q+\'U\';cs.O=65.O+\'U\';e.31.ew(c,e);e.31.km(e)};k.fx.9P=u(e){if(!k.4K(e))E I;D t=k(e);D es=e.14;D 73=I;if(t.B(\'19\')==\'1o\'){5Y=t.B(\'3n\');t.B(\'3n\',\'2K\').1Y();73=1b}D V={};V.Y=t.B(\'Y\');V.1q=k.1a.2o(e);V.3G=k.1a.cy(e);D co=e.4Z?e.4Z.ei:t.B(\'hU\');V.Q=T(t.B(\'Q\'))||0;V.O=T(t.B(\'O\'))||0;D eo=\'kl\'+T(18.6o()*c9);D 6u=1h.3F(/^1T$|^br$|^kh$|^hr$|^8C$|^kj$|^8T$|^3A$|^kk$|^k3$|^k2$|^9h$|^dl$|^jM$/i.48(e.9N)?\'22\':e.9N);k.1p(6u,\'id\',eo);D jN=k(6u).2R(\'jO\');D 4h=6u.14;D Q=0;D O=0;if(V.Y==\'2s\'||V.Y==\'1P\'){Q=V.Q;O=V.O}4h.Q=Q+\'U\';4h.O=O+\'U\';4h.Y=V.Y!=\'2s\'&&V.Y!=\'1P\'?\'2s\':V.Y;4h.W=V.1q.hb+\'U\';4h.Z=V.1q.1C+\'U\';4h.5K=V.3G.t;4h.5z=V.3G.r;4h.5k=V.3G.b;4h.5j=V.3G.l;4h.2U=\'2K\';if(k.3a.4t){4h.ei=co}P{4h.jK=co}if(k.3a=="4t"){es.5E="8V(1G="+0.ex*2a+")"}es.1G=0.ex;e.31.ew(6u,e);6u.jF(e);es.5K=\'2P\';es.5z=\'2P\';es.5k=\'2P\';es.5j=\'2P\';es.Y=\'1P\';es.eu=\'1o\';es.Q=\'2P\';es.O=\'2P\';if(73){t.2G();es.3n=5Y}E{V:V,3p:k(6u)}};k.fx.8E={jE:[0,1V,1V],jG:[eD,1V,1V],jH:[e6,e6,jI],jP:[0,0,0],ks:[0,0,1V],jY:[dv,42,42],jZ:[0,1V,1V],k0:[0,0,7w],k1:[0,7w,7w],jX:[cn,cn,cn],jS:[0,2a,0],jR:[jT,jU,eb],jV:[7w,0,7w],kr:[85,eb,47],kP:[1V,eA,0],kN:[kO,50,kx],kF:[7w,0,0],kD:[ku,f8,kt],ky:[kH,0,9C],kL:[1V,0,1V],kM:[1V,kJ,0],kv:[0,6C,0],kA:[75,0,kE],kC:[eD,eB,eA],kG:[kI,kB,eB],kw:[e0,1V,1V],kz:[eL,kK,eL],kQ:[9C,9C,9C],jC:[1V,iy,iz],iA:[1V,1V,e0],iB:[0,1V,0],ix:[1V,0,1V],iv:[6C,0,0],iq:[0,0,6C],ip:[6C,6C,0],ir:[1V,dv,0],it:[1V,ah,iu],iC:[6C,0,6C],iD:[1V,0,0],iK:[ah,ah,ah],iL:[1V,1V,1V],iM:[1V,1V,0]};k.fx.6D=u(4x,dm){if(k.fx.8E[4x])E{r:k.fx.8E[4x][0],g:k.fx.8E[4x][1],b:k.fx.8E[4x][2]};P if(2W=/^6Y\\(\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*\\)$/.a4(4x))E{r:T(2W[1]),g:T(2W[2]),b:T(2W[3])};P if(2W=/6Y\\(\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*\\)$/.a4(4x))E{r:2m(2W[1])*2.55,g:2m(2W[2])*2.55,b:2m(2W[3])*2.55};P if(2W=/^#([a-fA-79-9])([a-fA-79-9])([a-fA-79-9])$/.a4(4x))E{r:T("77"+2W[1]+2W[1]),g:T("77"+2W[2]+2W[2]),b:T("77"+2W[3]+2W[3])};P if(2W=/^#([a-fA-79-9]{2})([a-fA-79-9]{2})([a-fA-79-9]{2})$/.a4(4x))E{r:T("77"+2W[1]),g:T("77"+2W[2]),b:T("77"+2W[3])};P E dm==1b?I:{r:1V,g:1V,b:1V}};k.fx.dD={5Q:1,5b:1,5O:1,4S:1,4D:1,4A:1,W:1,O:1,c3:1,iI:1,5k:1,5j:1,5z:1,5K:1,8b:1,6x:1,8c:1,av:1,1G:1,iE:1,iF:1,5n:1,4X:1,5U:1,5M:1,2L:1,jD:1,Q:1,Z:1,3I:1};k.fx.dA={7i:1,iG:1,iH:1,io:1,im:1,4x:1,i2:1};k.fx.8A=[\'i3\',\'i4\',\'i5\',\'i1\'];k.fx.cc={\'cd\':[\'2E\',\'dK\'],\'a8\':[\'2E\',\'bh\'],\'6w\':[\'6w\',\'\'],\'8F\':[\'8F\',\'\']};k.fn.23({5w:u(5X,H,G,J){E q.1w(u(){D a1=k.H(H,G,J);D e=12 k.dM(q,a1,5X)})},c4:u(H,J){E q.1w(u(){D a1=k.H(H,J);D e=12 k.c4(q,a1)})},8o:u(2D){E q.1E(u(){if(q.6d)k.by(q,2D)})},i0:u(2D){E q.1E(u(){if(q.6d)k.by(q,2D);if(q.1w&&q.1w[\'fx\'])q.1w.fx=[]})}});k.23({c4:u(2f,M){D z=q,3t;z.2D=u(){if(k.fQ(M.21))M.21.1D(2f)};z.2I=6V(u(){z.2D()},M.1m);2f.6d=z},G:{c8:u(p,n,1W,1H,1m){E((-18.5H(p*18.2Q)/2)+0.5)*1H+1W}},dM:u(2f,M,5X){D z=q,3t;D y=2f.14;D fR=k.B(2f,"2U");D 72=k.B(2f,"19");D 2j={};z.9O=(12 7g()).7z();M.G=M.G&&k.G[M.G]?M.G:\'c8\';z.ag=u(2w,43){if(k.fx.dD[2w]){if(43==\'1Y\'||43==\'2G\'||43==\'3R\'){if(!2f.6v)2f.6v={};D r=2m(k.6E(2f,2w));2f.6v[2w]=r&&r>-c9?r:(2m(k.B(2f,2w))||0);43=43==\'3R\'?(72==\'1o\'?\'1Y\':\'2G\'):43;M[43]=1b;2j[2w]=43==\'1Y\'?[0,2f.6v[2w]]:[2f.6v[2w],0];if(2w!=\'1G\')y[2w]=2j[2w][0]+(2w!=\'3I\'&&2w!=\'8Z\'?\'U\':\'\');P k.1p(y,"1G",2j[2w][0])}P{2j[2w]=[2m(k.6E(2f,2w)),2m(43)||0]}}P if(k.fx.dA[2w])2j[2w]=[k.fx.6D(k.6E(2f,2w)),k.fx.6D(43)];P if(/^6w$|8F$|2E$|a8$|cd$/i.48(2w)){D m=43.4E(/\\s+/g,\' \').4E(/6Y\\s*\\(\\s*/g,\'6Y(\').4E(/\\s*,\\s*/g,\',\').4E(/\\s*\\)/g,\')\').d5(/([^\\s]+)/g);3m(2w){1e\'6w\':1e\'8F\':1e\'cd\':1e\'a8\':m[3]=m[3]||m[1]||m[0];m[2]=m[2]||m[0];m[1]=m[1]||m[0];24(D i=0;i<k.fx.8A.1g;i++){D 64=k.fx.cc[2w][0]+k.fx.8A[i]+k.fx.cc[2w][1];2j[64]=2w==\'a8\'?[k.fx.6D(k.6E(2f,64)),k.fx.6D(m[i])]:[2m(k.6E(2f,64)),2m(m[i])]}1r;1e\'2E\':24(D i=0;i<m.1g;i++){D bd=2m(m[i]);D a9=!hX(bd)?\'dK\':(!/cu|1o|2K|hY|hZ|i6|i7|ii|ij|ik|il/i.48(m[i])?\'bh\':I);if(a9){24(D j=0;j<k.fx.8A.1g;j++){64=\'2E\'+k.fx.8A[j]+a9;2j[64]=a9==\'bh\'?[k.fx.6D(k.6E(2f,64)),k.fx.6D(m[i])]:[2m(k.6E(2f,64)),bd]}}P{y[\'ie\']=m[i]}}1r}}P{y[2w]=43}E I};24(p in 5X){if(p==\'14\'){D 5f=k.bl(5X[p]);24(7A in 5f){q.ag(7A,5f[7A])}}P if(p==\'3l\'){if(1h.af)24(D i=0;i<1h.af.1g;i++){D 7e=1h.af[i].7e||1h.af[i].i9||S;if(7e){24(D j=0;j<7e.1g;j++){if(7e[j].i8==\'.\'+5X[p]){D 6X=12 bb(\'\\.\'+5X[p]+\' {\');D 5Z=7e[j].14.9X;D 5f=k.bl(5Z.4E(6X,\'\').4E(/}/g,\'\'));24(7A in 5f){q.ag(7A,5f[7A])}}}}}}P{q.ag(p,5X[p])}}y.19=72==\'1o\'?\'2B\':72;y.2U=\'2K\';z.2D=u(){D t=(12 7g()).7z();if(t>M.1m+z.9O){5T(z.2I);z.2I=S;24(p in 2j){if(p=="1G")k.1p(y,"1G",2j[p][1]);P if(2g 2j[p][1]==\'8T\')y[p]=\'6Y(\'+2j[p][1].r+\',\'+2j[p][1].g+\',\'+2j[p][1].b+\')\';P y[p]=2j[p][1]+(p!=\'3I\'&&p!=\'8Z\'?\'U\':\'\')}if(M.2G||M.1Y)24(D p in 2f.6v)if(p=="1G")k.1p(y,p,2f.6v[p]);P y[p]="";y.19=M.2G?\'1o\':(72!=\'1o\'?72:\'2B\');y.2U=fR;2f.6d=S;if(k.fQ(M.21))M.21.1D(2f)}P{D n=t-q.9O;D 8w=n/M.1m;24(p in 2j){if(2g 2j[p][1]==\'8T\'){y[p]=\'6Y(\'+T(k.G[M.G](8w,n,2j[p][0].r,(2j[p][1].r-2j[p][0].r),M.1m))+\',\'+T(k.G[M.G](8w,n,2j[p][0].g,(2j[p][1].g-2j[p][0].g),M.1m))+\',\'+T(k.G[M.G](8w,n,2j[p][0].b,(2j[p][1].b-2j[p][0].b),M.1m))+\')\'}P{D bz=k.G[M.G](8w,n,2j[p][0],(2j[p][1]-2j[p][0]),M.1m);if(p=="1G")k.1p(y,"1G",bz);P y[p]=bz+(p!=\'3I\'&&p!=\'8Z\'?\'U\':\'\')}}}};z.2I=6V(u(){z.2D()},13);2f.6d=z},by:u(2f,2D){if(2D)2f.6d.9O-=iO;P{1X.5T(2f.6d.2I);2f.6d=S;k.2H(2f,"fx")}}});k.bl=u(5Z){D 5f={};if(2g 5Z==\'4V\'){5Z=5Z.6c().7C(\';\');24(D i=0;i<5Z.1g;i++){6X=5Z[i].7C(\':\');if(6X.1g==2){5f[k.g6(6X[0].4E(/\\-(\\w)/g,u(m,c){E c.jo()}))]=k.g6(6X[1])}}}E 5f};k.fn.23({g3:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.61(q,H,J,\'4F\',G)})},gb:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.61(q,H,J,\'4r\',G)})},jl:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.61(q,H,J,\'fJ\',G)})},jk:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.61(q,H,J,\'O\',G)})},jg:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.61(q,H,J,\'2L\',G)})},jf:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.61(q,H,J,\'fh\',G)})}});k.fx.61=u(e,H,J,2S,G){if(!k.4K(e)){k.2H(e,\'1n\');E I}D z=q;z.el=k(e);z.1N=k.1a.2o(e);z.G=2g J==\'4V\'?J:G||S;if(!e.4s)e.4s=z.el.B(\'19\');if(2S==\'fJ\'){2S=z.el.B(\'19\')==\'1o\'?\'4r\':\'4F\'}P if(2S==\'fh\'){2S=z.el.B(\'19\')==\'1o\'?\'2L\':\'O\'}z.el.1Y();z.H=H;z.J=2g J==\'u\'?J:S;z.fx=k.fx.9P(e);z.2S=2S;z.21=u(){if(z.J&&z.J.1K==2A){z.J.1D(z.el.K(0))}if(z.2S==\'4r\'||z.2S==\'2L\'){z.el.B(\'19\',z.el.K(0).4s==\'1o\'?\'2B\':z.el.K(0).4s)}P{z.el.2G()}k.fx.a0(z.fx.3p.K(0),z.fx.V);k.2H(z.el.K(0),\'1n\')};3m(z.2S){1e\'4F\':63=12 k.fx(z.fx.3p.K(0),k.H(z.H,z.G,z.21),\'W\');63.1L(z.fx.V.1q.hb,0);1r;1e\'4r\':z.fx.3p.B(\'W\',\'9R\');z.el.1Y();63=12 k.fx(z.fx.3p.K(0),k.H(z.H,z.G,z.21),\'W\');63.1L(0,z.fx.V.1q.hb);1r;1e\'O\':63=12 k.fx(z.fx.3p.K(0),k.H(z.H,z.G,z.21),\'Z\');63.1L(z.fx.V.1q.1C,0);1r;1e\'2L\':z.fx.3p.B(\'Z\',\'9R\');z.el.1Y();63=12 k.fx(z.fx.3p.K(0),k.H(z.H,z.G,z.21),\'Z\');63.1L(0,z.fx.V.1q.1C);1r}};k.fn.ji=u(5D,J){E q.1w(\'1n\',u(){if(!k.4K(q)){k.2H(q,\'1n\');E I}D e=12 k.fx.f4(q,5D,J);e.bp()})};k.fx.f4=u(e,5D,J){D z=q;z.el=k(e);z.el.1Y();z.J=J;z.5D=T(5D)||40;z.V={};z.V.Y=z.el.B(\'Y\');z.V.Q=T(z.el.B(\'Q\'))||0;z.V.O=T(z.el.B(\'O\'))||0;if(z.V.Y!=\'2s\'&&z.V.Y!=\'1P\'){z.el.B(\'Y\',\'2s\')}z.3V=5;z.5y=1;z.bp=u(){z.5y++;z.e=12 k.fx(z.el.K(0),{1m:jj,21:u(){z.e=12 k.fx(z.el.K(0),{1m:80,21:u(){z.5D=T(z.5D/2);if(z.5y<=z.3V)z.bp();P{z.el.B(\'Y\',z.V.Y).B(\'Q\',z.V.Q+\'U\').B(\'O\',z.V.O+\'U\');k.2H(z.el.K(0),\'1n\');if(z.J&&z.J.1K==2A){z.J.1D(z.el.K(0))}}}},\'Q\');z.e.1L(z.V.Q-z.5D,z.V.Q)}},\'Q\');z.e.1L(z.V.Q,z.V.Q-z.5D)}};k.fn.23({jy:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.4f(q,H,J,\'4r\',\'4l\',G)})},jz:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.4f(q,H,J,\'4r\',\'in\',G)})},jA:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.4f(q,H,J,\'4r\',\'3R\',G)})},jB:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.4f(q,H,J,\'4F\',\'4l\',G)})},jx:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.4f(q,H,J,\'4F\',\'in\',G)})},jw:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.4f(q,H,J,\'4F\',\'3R\',G)})},js:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.4f(q,H,J,\'O\',\'4l\',G)})},jt:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.4f(q,H,J,\'O\',\'in\',G)})},ju:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.4f(q,H,J,\'O\',\'3R\',G)})},jv:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.4f(q,H,J,\'2L\',\'4l\',G)})},je:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.4f(q,H,J,\'2L\',\'in\',G)})},jd:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.4f(q,H,J,\'2L\',\'3R\',G)})}});k.fx.4f=u(e,H,J,2S,1u,G){if(!k.4K(e)){k.2H(e,\'1n\');E I}D z=q;z.el=k(e);z.G=2g J==\'4V\'?J:G||S;z.V={};z.V.Y=z.el.B(\'Y\');z.V.Q=z.el.B(\'Q\');z.V.O=z.el.B(\'O\');if(!e.4s)e.4s=z.el.B(\'19\');if(1u==\'3R\'){1u=z.el.B(\'19\')==\'1o\'?\'in\':\'4l\'}z.el.1Y();if(z.V.Y!=\'2s\'&&z.V.Y!=\'1P\'){z.el.B(\'Y\',\'2s\')}z.1u=1u;J=2g J==\'u\'?J:S;8H=1;3m(2S){1e\'4F\':z.e=12 k.fx(z.el.K(0),k.H(H-15,z.G,J),\'Q\');z.62=2m(z.V.Q)||0;z.9K=z.fG;8H=-1;1r;1e\'4r\':z.e=12 k.fx(z.el.K(0),k.H(H-15,z.G,J),\'Q\');z.62=2m(z.V.Q)||0;z.9K=z.fG;1r;1e\'2L\':z.e=12 k.fx(z.el.K(0),k.H(H-15,z.G,J),\'O\');z.62=2m(z.V.O)||0;z.9K=z.fy;1r;1e\'O\':z.e=12 k.fx(z.el.K(0),k.H(H-15,z.G,J),\'O\');z.62=2m(z.V.O)||0;z.9K=z.fy;8H=-1;1r}z.e2=12 k.fx(z.el.K(0),k.H(H,z.G,u(){z.el.B(z.V);if(z.1u==\'4l\'){z.el.B(\'19\',\'1o\')}P z.el.B(\'19\',z.el.K(0).4s==\'1o\'?\'2B\':z.el.K(0).4s);k.2H(z.el.K(0),\'1n\')}),\'1G\');if(1u==\'in\'){z.e.1L(z.62+2a*8H,z.62);z.e2.1L(0,1)}P{z.e.1L(z.62,z.62+2a*8H);z.e2.1L(1,0)}};k.fn.23({j0:u(H,W,J,G){E q.1w(\'1n\',u(){12 k.fx.9L(q,H,W,J,\'fp\',G)})},iW:u(H,W,J,G){E q.1w(\'1n\',u(){12 k.fx.9L(q,H,W,J,\'9M\',G)})},iV:u(H,W,J,G){E q.1w(\'1n\',u(){12 k.fx.9L(q,H,W,J,\'3R\',G)})}});k.fx.9L=u(e,H,W,J,1u,G){if(!k.4K(e)){k.2H(e,\'1n\');E I}D z=q;z.el=k(e);z.G=2g J==\'4V\'?J:G||S;z.J=2g J==\'u\'?J:S;if(1u==\'3R\'){1u=z.el.B(\'19\')==\'1o\'?\'9M\':\'fp\'}z.H=H;z.W=W&&W.1K==bn?W:20;z.fx=k.fx.9P(e);z.1u=1u;z.21=u(){if(z.J&&z.J.1K==2A){z.J.1D(z.el.K(0))}if(z.1u==\'9M\'){z.el.1Y()}P{z.el.2G()}k.fx.a0(z.fx.3p.K(0),z.fx.V);k.2H(z.el.K(0),\'1n\')};if(z.1u==\'9M\'){z.el.1Y();z.fx.3p.B(\'W\',z.W+\'U\').B(\'Z\',\'9R\');z.ef=12 k.fx(z.fx.3p.K(0),k.H(z.H,z.G,u(){z.ef=12 k.fx(z.fx.3p.K(0),k.H(z.H,z.G,z.21),\'W\');z.ef.1L(z.W,z.fx.V.1q.hb)}),\'Z\');z.ef.1L(0,z.fx.V.1q.1C)}P{z.ef=12 k.fx(z.fx.3p.K(0),k.H(z.H,z.G,u(){z.ef=12 k.fx(z.fx.3p.K(0),k.H(z.H,z.G,z.21),\'Z\');z.ef.1L(z.fx.V.1q.1C,0)}),\'W\');z.ef.1L(z.fx.V.1q.hb,z.W)}};k.fn.iR=u(H,4x,J,G){E q.1w(\'fv\',u(){q.6W=k(q).1p("14")||\'\';G=2g J==\'4V\'?J:G||S;J=2g J==\'u\'?J:S;D 9S=k(q).B(\'7i\');D 8I=q.31;7d(9S==\'cu\'&&8I){9S=k(8I).B(\'7i\');8I=8I.31}k(q).B(\'7i\',4x);if(2g q.6W==\'8T\')q.6W=q.6W["9X"];k(q).5w({\'7i\':9S},H,G,u(){k.2H(q,\'fv\');if(2g k(q).1p("14")==\'8T\'){k(q).1p("14")["9X"]="";k(q).1p("14")["9X"]=q.6W}P{k(q).1p("14",q.6W)}if(J)J.1D(q)})})};k.fn.23({iT:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.5m(q,H,J,\'49\',\'6g\',G)})},iU:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.5m(q,H,J,\'4j\',\'6g\',G)})},j1:u(H,J,G){E q.1w(\'1n\',u(){if(k.B(q,\'19\')==\'1o\'){12 k.fx.5m(q,H,J,\'4j\',\'6Z\',G)}P{12 k.fx.5m(q,H,J,\'4j\',\'6g\',G)}})},j2:u(H,J,G){E q.1w(\'1n\',u(){if(k.B(q,\'19\')==\'1o\'){12 k.fx.5m(q,H,J,\'49\',\'6Z\',G)}P{12 k.fx.5m(q,H,J,\'49\',\'6g\',G)}})},j9:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.5m(q,H,J,\'49\',\'6Z\',G)})},ja:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.5m(q,H,J,\'4j\',\'6Z\',G)})}});k.fx.5m=u(e,H,J,2S,1u,G){if(!k.4K(e)){k.2H(e,\'1n\');E I}D z=q;D 73=I;z.el=k(e);z.G=2g J==\'4V\'?J:G||S;z.J=2g J==\'u\'?J:S;z.1u=1u;z.H=H;z.2i=k.1a.2o(e);z.V={};z.V.Y=z.el.B(\'Y\');z.V.19=z.el.B(\'19\');if(z.V.19==\'1o\'){5Y=z.el.B(\'3n\');z.el.1Y();73=1b}z.V.Q=z.el.B(\'Q\');z.V.O=z.el.B(\'O\');if(73){z.el.2G();z.el.B(\'3n\',5Y)}z.V.Z=z.2i.w+\'U\';z.V.W=z.2i.h+\'U\';z.V.2U=z.el.B(\'2U\');z.2i.Q=T(z.V.Q)||0;z.2i.O=T(z.V.O)||0;if(z.V.Y!=\'2s\'&&z.V.Y!=\'1P\'){z.el.B(\'Y\',\'2s\')}z.el.B(\'2U\',\'2K\').B(\'W\',1u==\'6Z\'&&2S==\'49\'?1:z.2i.h+\'U\').B(\'Z\',1u==\'6Z\'&&2S==\'4j\'?1:z.2i.w+\'U\');z.21=u(){z.el.B(z.V);if(z.1u==\'6g\')z.el.2G();P z.el.1Y();k.2H(z.el.K(0),\'1n\')};3m(2S){1e\'49\':z.eh=12 k.fx(z.el.K(0),k.H(H-15,z.G,J),\'W\');z.et=12 k.fx(z.el.K(0),k.H(z.H,z.G,z.21),\'Q\');if(z.1u==\'6g\'){z.eh.1L(z.2i.h,0);z.et.1L(z.2i.Q,z.2i.Q+z.2i.h/2)}P{z.eh.1L(0,z.2i.h);z.et.1L(z.2i.Q+z.2i.h/2,z.2i.Q)}1r;1e\'4j\':z.eh=12 k.fx(z.el.K(0),k.H(H-15,z.G,J),\'Z\');z.et=12 k.fx(z.el.K(0),k.H(z.H,z.G,z.21),\'O\');if(z.1u==\'6g\'){z.eh.1L(z.2i.w,0);z.et.1L(z.2i.O,z.2i.O+z.2i.w/2)}P{z.eh.1L(0,z.2i.w);z.et.1L(z.2i.O+z.2i.w/2,z.2i.O)}1r}};k.fn.bg=u(H,3V,J){E q.1w(\'1n\',u(){if(!k.4K(q)){k.2H(q,\'1n\');E I}D fx=12 k.fx.bg(q,H,3V,J);fx.bf()})};k.fx.bg=u(el,H,3V,J){D z=q;z.3V=3V;z.5y=1;z.el=el;z.H=H;z.J=J;k(z.el).1Y();z.bf=u(){z.5y++;z.e=12 k.fx(z.el,k.H(z.H,u(){z.ef=12 k.fx(z.el,k.H(z.H,u(){if(z.5y<=z.3V)z.bf();P{k.2H(z.el,\'1n\');if(z.J&&z.J.1K==2A){z.J.1D(z.el)}}}),\'1G\');z.ef.1L(0,1)}),\'1G\');z.e.1L(1,0)}};k.fn.23({jb:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.6G(q,H,1,2a,1b,J,\'fa\',G)})},jc:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.6G(q,H,2a,1,1b,J,\'b4\',G)})},j8:u(H,J,G){E q.1w(\'1n\',u(){D G=G||\'fl\';12 k.fx.6G(q,H,2a,f8,1b,J,\'6h\',G)})},6G:u(H,57,30,6H,J,G){E q.1w(\'1n\',u(){12 k.fx.6G(q,H,57,30,6H,J,\'6G\',G)})}});k.fx.6G=u(e,H,57,30,6H,J,1u,G){if(!k.4K(e)){k.2H(e,\'1n\');E I}D z=q;z.el=k(e);z.57=T(57)||2a;z.30=T(30)||2a;z.G=2g J==\'4V\'?J:G||S;z.J=2g J==\'u\'?J:S;z.1m=k.H(H).1m;z.6H=6H||S;z.2i=k.1a.2o(e);z.V={Z:z.el.B(\'Z\'),W:z.el.B(\'W\'),4A:z.el.B(\'4A\')||\'2a%\',Y:z.el.B(\'Y\'),19:z.el.B(\'19\'),Q:z.el.B(\'Q\'),O:z.el.B(\'O\'),2U:z.el.B(\'2U\'),4S:z.el.B(\'4S\'),5O:z.el.B(\'5O\'),5Q:z.el.B(\'5Q\'),5b:z.el.B(\'5b\'),5M:z.el.B(\'5M\'),5U:z.el.B(\'5U\'),5n:z.el.B(\'5n\'),4X:z.el.B(\'4X\')};z.Z=T(z.V.Z)||e.4c||0;z.W=T(z.V.W)||e.5W||0;z.Q=T(z.V.Q)||0;z.O=T(z.V.O)||0;1q=[\'em\',\'U\',\'j7\',\'%\'];24(i in 1q){if(z.V.4A.3J(1q[i])>0){z.fg=1q[i];z.4A=2m(z.V.4A)}if(z.V.4S.3J(1q[i])>0){z.fc=1q[i];z.bw=2m(z.V.4S)||0}if(z.V.5O.3J(1q[i])>0){z.fe=1q[i];z.bc=2m(z.V.5O)||0}if(z.V.5Q.3J(1q[i])>0){z.fL=1q[i];z.bA=2m(z.V.5Q)||0}if(z.V.5b.3J(1q[i])>0){z.g8=1q[i];z.bt=2m(z.V.5b)||0}if(z.V.5M.3J(1q[i])>0){z.g4=1q[i];z.bx=2m(z.V.5M)||0}if(z.V.5U.3J(1q[i])>0){z.g9=1q[i];z.bv=2m(z.V.5U)||0}if(z.V.5n.3J(1q[i])>0){z.gc=1q[i];z.bj=2m(z.V.5n)||0}if(z.V.4X.3J(1q[i])>0){z.fK=1q[i];z.b7=2m(z.V.4X)||0}}if(z.V.Y!=\'2s\'&&z.V.Y!=\'1P\'){z.el.B(\'Y\',\'2s\')}z.el.B(\'2U\',\'2K\');z.1u=1u;3m(z.1u){1e\'fa\':z.4b=z.Q+z.2i.h/2;z.5a=z.Q;z.4k=z.O+z.2i.w/2;z.59=z.O;1r;1e\'b4\':z.5a=z.Q+z.2i.h/2;z.4b=z.Q;z.59=z.O+z.2i.w/2;z.4k=z.O;1r;1e\'6h\':z.5a=z.Q-z.2i.h/4;z.4b=z.Q;z.59=z.O-z.2i.w/4;z.4k=z.O;1r}z.be=I;z.t=(12 7g).7z();z.4w=u(){5T(z.2I);z.2I=S};z.2D=u(){if(z.be==I){z.el.1Y();z.be=1b}D t=(12 7g).7z();D n=t-z.t;D p=n/z.1m;if(t>=z.1m+z.t){9T(u(){o=1;if(z.1u){t=z.5a;l=z.59;if(z.1u==\'6h\')o=0}z.bs(z.30,l,t,1b,o)},13);z.4w()}P{o=1;if(!k.G||!k.G[z.G]){s=((-18.5H(p*18.2Q)/2)+0.5)*(z.30-z.57)+z.57}P{s=k.G[z.G](p,n,z.57,(z.30-z.57),z.1m)}if(z.1u){if(!k.G||!k.G[z.G]){t=((-18.5H(p*18.2Q)/2)+0.5)*(z.5a-z.4b)+z.4b;l=((-18.5H(p*18.2Q)/2)+0.5)*(z.59-z.4k)+z.4k;if(z.1u==\'6h\')o=((-18.5H(p*18.2Q)/2)+0.5)*(-0.9Y)+0.9Y}P{t=k.G[z.G](p,n,z.4b,(z.5a-z.4b),z.1m);l=k.G[z.G](p,n,z.4k,(z.59-z.4k),z.1m);if(z.1u==\'6h\')o=k.G[z.G](p,n,0.9Y,-0.9Y,z.1m)}}z.bs(s,l,t,I,o)}};z.2I=6V(u(){z.2D()},13);z.bs=u(4q,O,Q,fM,1G){z.el.B(\'W\',z.W*4q/2a+\'U\').B(\'Z\',z.Z*4q/2a+\'U\').B(\'O\',O+\'U\').B(\'Q\',Q+\'U\').B(\'4A\',z.4A*4q/2a+z.fg);if(z.bw)z.el.B(\'4S\',z.bw*4q/2a+z.fc);if(z.bc)z.el.B(\'5O\',z.bc*4q/2a+z.fe);if(z.bA)z.el.B(\'5Q\',z.bA*4q/2a+z.fL);if(z.bt)z.el.B(\'5b\',z.bt*4q/2a+z.g8);if(z.bx)z.el.B(\'5M\',z.bx*4q/2a+z.g4);if(z.bv)z.el.B(\'5U\',z.bv*4q/2a+z.g9);if(z.bj)z.el.B(\'5n\',z.bj*4q/2a+z.gc);if(z.b7)z.el.B(\'4X\',z.b7*4q/2a+z.fK);if(z.1u==\'6h\'){if(1X.71)z.el.K(0).14.5E="8V(1G="+1G*2a+")";z.el.K(0).14.1G=1G}if(fM){if(z.6H){z.el.B(z.V)}if(z.1u==\'b4\'||z.1u==\'6h\'){z.el.B(\'19\',\'1o\');if(z.1u==\'6h\'){if(1X.71)z.el.K(0).14.5E="8V(1G="+2a+")";z.el.K(0).14.1G=1}}P z.el.B(\'19\',\'2B\');if(z.J)z.J.1D(z.el.K(0));k.2H(z.el.K(0),\'1n\')}}};k.fn.23({9U:u(H,1O,G){o=k.H(H);E q.1w(\'1n\',u(){12 k.fx.9U(q,o,1O,G)})},j6:u(H,1O,G){E q.1E(u(){k(\'a[@3h*="#"]\',q).5h(u(e){fW=q.3h.7C(\'#\');k(\'#\'+fW[1]).9U(H,1O,G);E I})})}});k.fx.9U=u(e,o,1O,G){D z=q;z.o=o;z.e=e;z.1O=/fT|gd/.48(1O)?1O:I;z.G=G;p=k.1a.3w(e);s=k.1a.6z();z.4w=u(){5T(z.2I);z.2I=S;k.2H(z.e,\'1n\')};z.t=(12 7g).7z();s.h=s.h>s.ih?(s.h-s.ih):s.h;s.w=s.w>s.iw?(s.w-s.iw):s.w;z.5a=p.y>s.h?s.h:p.y;z.59=p.x>s.w?s.w:p.x;z.4b=s.t;z.4k=s.l;z.2D=u(){D t=(12 7g).7z();D n=t-z.t;D p=n/z.o.1m;if(t>=z.o.1m+z.t){z.4w();9T(u(){z.d3(z.5a,z.59)},13)}P{if(!z.1O||z.1O==\'fT\'){if(!k.G||!k.G[z.G]){9V=((-18.5H(p*18.2Q)/2)+0.5)*(z.5a-z.4b)+z.4b}P{9V=k.G[z.G](p,n,z.4b,(z.5a-z.4b),z.o.1m)}}P{9V=z.4b}if(!z.1O||z.1O==\'gd\'){if(!k.G||!k.G[z.G]){9W=((-18.5H(p*18.2Q)/2)+0.5)*(z.59-z.4k)+z.4k}P{9W=k.G[z.G](p,n,z.4k,(z.59-z.4k),z.o.1m)}}P{9W=z.4k}z.d3(9V,9W)}};z.d3=u(t,l){1X.j4(l,t)};z.2I=6V(u(){z.2D()},13)};k.fn.cY=u(3V,J){E q.1w(\'1n\',u(){if(!k.4K(q)){k.2H(q,\'1n\');E I}D e=12 k.fx.cY(q,3V,J);e.cG()})};k.fx.cY=u(e,3V,J){D z=q;z.el=k(e);z.el.1Y();z.3V=T(3V)||3;z.J=J;z.5y=1;z.V={};z.V.Y=z.el.B(\'Y\');z.V.Q=T(z.el.B(\'Q\'))||0;z.V.O=T(z.el.B(\'O\'))||0;if(z.V.Y!=\'2s\'&&z.V.Y!=\'1P\'){z.el.B(\'Y\',\'2s\')}z.cG=u(){z.5y++;z.e=12 k.fx(z.el.K(0),{1m:60,21:u(){z.e=12 k.fx(z.el.K(0),{1m:60,21:u(){z.e=12 k.fx(e,{1m:60,21:u(){if(z.5y<=z.3V)z.cG();P{z.el.B(\'Y\',z.V.Y).B(\'Q\',z.V.Q+\'U\').B(\'O\',z.V.O+\'U\');k.2H(z.el.K(0),\'1n\');if(z.J&&z.J.1K==2A){z.J.1D(z.el.K(0))}}}},\'O\');z.e.1L(z.V.O-20,z.V.O)}},\'O\');z.e.1L(z.V.O+20,z.V.O-20)}},\'O\');z.e.1L(z.V.O,z.V.O+20)}};k.fn.23({fo:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.1z(q,H,J,\'4F\',\'in\',G)})},fq:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.1z(q,H,J,\'4F\',\'4l\',G)})},iY:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.1z(q,H,J,\'4F\',\'3R\',G)})},iX:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.1z(q,H,J,\'4r\',\'in\',G)})},jr:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.1z(q,H,J,\'4r\',\'4l\',G)})},jq:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.1z(q,H,J,\'4r\',\'3R\',G)})},jp:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.1z(q,H,J,\'O\',\'in\',G)})},jn:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.1z(q,H,J,\'O\',\'4l\',G)})},jm:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.1z(q,H,J,\'O\',\'3R\',G)})},iP:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.1z(q,H,J,\'2L\',\'in\',G)})},ic:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.1z(q,H,J,\'2L\',\'4l\',G)})},ib:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.1z(q,H,J,\'2L\',\'3R\',G)})}});k.fx.1z=u(e,H,J,2S,1u,G){if(!k.4K(e)){k.2H(e,\'1n\');E I}D z=q;z.el=k(e);z.G=2g J==\'4V\'?J:G||S;z.J=2g J==\'u\'?J:S;if(1u==\'3R\'){1u=z.el.B(\'19\')==\'1o\'?\'in\':\'4l\'}if(!e.4s)e.4s=z.el.B(\'19\');z.el.1Y();z.H=H;z.fx=k.fx.9P(e);z.1u=1u;z.2S=2S;z.21=u(){if(z.1u==\'4l\')z.el.B(\'3n\',\'2K\');k.fx.a0(z.fx.3p.K(0),z.fx.V);if(z.1u==\'in\'){z.el.B(\'19\',z.el.K(0).4s==\'1o\'?\'2B\':z.el.K(0).4s)}P{z.el.B(\'19\',\'1o\');z.el.B(\'3n\',\'dd\')}if(z.J&&z.J.1K==2A){z.J.1D(z.el.K(0))}k.2H(z.el.K(0),\'1n\')};3m(z.2S){1e\'4F\':z.ef=12 k.fx(z.el.K(0),k.H(z.H,z.G,z.21),\'Q\');z.7v=12 k.fx(z.fx.3p.K(0),k.H(z.H,z.G),\'W\');if(z.1u==\'in\'){z.ef.1L(-z.fx.V.1q.hb,0);z.7v.1L(0,z.fx.V.1q.hb)}P{z.ef.1L(0,-z.fx.V.1q.hb);z.7v.1L(z.fx.V.1q.hb,0)}1r;1e\'4r\':z.ef=12 k.fx(z.el.K(0),k.H(z.H,z.G,z.21),\'Q\');if(z.1u==\'in\'){z.ef.1L(z.fx.V.1q.hb,0)}P{z.ef.1L(0,z.fx.V.1q.hb)}1r;1e\'O\':z.ef=12 k.fx(z.el.K(0),k.H(z.H,z.G,z.21),\'O\');z.7v=12 k.fx(z.fx.3p.K(0),k.H(z.H,z.G),\'Z\');if(z.1u==\'in\'){z.ef.1L(-z.fx.V.1q.1C,0);z.7v.1L(0,z.fx.V.1q.1C)}P{z.ef.1L(0,-z.fx.V.1q.1C);z.7v.1L(z.fx.V.1q.1C,0)}1r;1e\'2L\':z.ef=12 k.fx(z.el.K(0),k.H(z.H,z.G,z.21),\'O\');if(z.1u==\'in\'){z.ef.1L(z.fx.V.1q.1C,0)}P{z.ef.1L(0,z.fx.V.1q.1C)}1r}};k.3f=S;k.fn.ig=u(o){E q.1w(\'1n\',u(){12 k.fx.dG(q,o)})};k.fx.dG=u(e,o){if(k.3f==S){k(\'2e\',1h).1S(\'<22 id="3f"></22>\');k.3f=k(\'#3f\')}k.3f.B(\'19\',\'2B\').B(\'Y\',\'1P\');D z=q;z.el=k(e);if(!o||!o.30){E}if(o.30.1K==b0&&1h.9e(o.30)){o.30=1h.9e(o.30)}P if(!o.30.dq){E}if(!o.1m){o.1m=g5}z.1m=o.1m;z.30=o.30;z.8r=o.3l;z.21=o.21;if(z.8r){k.3f.2R(z.8r)}z.a3=0;z.a2=0;if(k.dF){z.a3=(T(k.3f.B(\'5b\'))||0)+(T(k.3f.B(\'5O\'))||0)+(T(k.3f.B(\'4X\'))||0)+(T(k.3f.B(\'5U\'))||0);z.a2=(T(k.3f.B(\'4S\'))||0)+(T(k.3f.B(\'5Q\'))||0)+(T(k.3f.B(\'5M\'))||0)+(T(k.3f.B(\'5n\'))||0)}z.26=k.23(k.1a.3w(z.el.K(0)),k.1a.2o(z.el.K(0)));z.2T=k.23(k.1a.3w(z.30),k.1a.2o(z.30));z.26.1C-=z.a3;z.26.hb-=z.a2;z.2T.1C-=z.a3;z.2T.hb-=z.a2;z.J=o.21;k.3f.B(\'Z\',z.26.1C+\'U\').B(\'W\',z.26.hb+\'U\').B(\'Q\',z.26.y+\'U\').B(\'O\',z.26.x+\'U\').5w({Q:z.2T.y,O:z.2T.x,Z:z.2T.1C,W:z.2T.hb},z.1m,u(){if(z.8r)k.3f.4i(z.8r);k.3f.B(\'19\',\'1o\');if(z.21&&z.21.1K==2A){z.21.1D(z.el.K(0),[z.30])}k.2H(z.el.K(0),\'1n\')})};k.1v={M:{2E:10,ec:\'1Q/iJ.eZ\',e3:\'<1T 2J="1Q/6g.da" />\',eW:0.8,d8:\'iN a6\',dc:\'57\',3W:8J},jQ:I,jW:I,6j:S,8m:I,8k:I,d1:u(2k){if(!k.1v.8k||k.1v.8m)E;D 3K=2k.7L||2k.7K||-1;3m(3K){1e 35:if(k.1v.6j)k.1v.26(S,k(\'a[@4I=\'+k.1v.6j+\']:jJ\').K(0));1r;1e 36:if(k.1v.6j)k.1v.26(S,k(\'a[@4I=\'+k.1v.6j+\']:jL\').K(0));1r;1e 37:1e 8:1e 33:1e 80:1e kb:D 9p=k(\'#87\');if(9p.K(0).53!=S){9p.K(0).53.1D(9p.K(0))}1r;1e 38:1r;1e 39:1e 34:1e 32:1e gl:1e 78:D 9k=k(\'#88\');if(9k.K(0).53!=S){9k.K(0).53.1D(9k.K(0))}1r;1e 40:1r;1e 27:k.1v.au();1r}},7q:u(M){if(M)k.23(k.1v.M,M);if(1X.2k){k(\'2e\',1h).1J(\'6y\',k.1v.d1)}P{k(1h).1J(\'6y\',k.1v.d1)}k(\'a\').1E(u(){el=k(q);en=el.1p(\'4I\')||\'\';e9=el.1p(\'3h\')||\'\';ev=/\\.da|\\.gw|\\.8X|\\.eZ|\\.gn/g;if(e9.6c().d5(ev)!=S&&en.6c().3J(\'eU\')==0){el.1J(\'5h\',k.1v.26)}});if(k.3a.4t){3A=1h.3F(\'3A\');k(3A).1p({id:\'cN\',2J:\'ek:I;\',ej:\'cD\',ep:\'cD\'}).B({19:\'1o\',Y:\'1P\',Q:\'0\',O:\'0\',5E:\'9n:9w.9y.cC(1G=0)\'});k(\'2e\').1S(3A)}8n=1h.3F(\'22\');k(8n).1p(\'id\',\'cP\').B({Y:\'1P\',19:\'1o\',Q:\'0\',O:\'0\',1G:0}).1S(1h.8M(\' \')).1J(\'5h\',k.1v.au);6A=1h.3F(\'22\');k(6A).1p(\'id\',\'eK\').B({4X:k.1v.M.2E+\'U\'}).1S(1h.8M(\' \'));cE=1h.3F(\'22\');k(cE).1p(\'id\',\'dg\').B({4X:k.1v.M.2E+\'U\',5n:k.1v.M.2E+\'U\'}).1S(1h.8M(\' \'));cF=1h.3F(\'a\');k(cF).1p({id:\'gg\',3h:\'#\'}).B({Y:\'1P\',2L:k.1v.M.2E+\'U\',Q:\'0\'}).1S(k.1v.M.e3).1J(\'5h\',k.1v.au);7m=1h.3F(\'22\');k(7m).1p(\'id\',\'cM\').B({Y:\'2s\',cA:\'O\',6w:\'0 9F\',3I:1}).1S(6A).1S(cE).1S(cF);2b=1h.3F(\'1T\');2b.2J=k.1v.M.ec;k(2b).1p(\'id\',\'eM\').B({Y:\'1P\'});4G=1h.3F(\'a\');k(4G).1p({id:\'87\',3h:\'#\'}).B({Y:\'1P\',19:\'1o\',2U:\'2K\',ey:\'1o\'}).1S(1h.8M(\' \'));4M=1h.3F(\'a\');k(4M).1p({id:\'88\',3h:\'#\'}).B({Y:\'1P\',2U:\'2K\',ey:\'1o\'}).1S(1h.8M(\' \'));1Z=1h.3F(\'22\');k(1Z).1p(\'id\',\'eE\').B({19:\'1o\',Y:\'2s\',2U:\'2K\',cA:\'O\',6w:\'0 9F\',Q:\'0\',O:\'0\',3I:2}).1S([2b,4G,4M]);6F=1h.3F(\'22\');k(6F).1p(\'id\',\'ao\').B({19:\'1o\',Y:\'1P\',2U:\'2K\',Q:\'0\',O:\'0\',cA:\'cv\',7i:\'cu\',hC:\'0\'}).1S([1Z,7m]);k(\'2e\').1S(8n).1S(6F)},26:u(e,C){el=C?k(C):k(q);9t=el.1p(\'4I\');D 6B,4u,4G,4M;if(9t!=\'eU\'){k.1v.6j=9t;8Y=k(\'a[@4I=\'+9t+\']\');6B=8Y.1N();4u=8Y.cZ(C?C:q);4G=8Y.K(4u-1);4M=8Y.K(4u+1)}89=el.1p(\'3h\');6A=el.1p(\'4g\');3O=k.1a.6z();8n=k(\'#cP\');if(!k.1v.8k){k.1v.8k=1b;if(k.3a.4t){k(\'#cN\').B(\'W\',18.3r(3O.ih,3O.h)+\'U\').B(\'Z\',18.3r(3O.iw,3O.w)+\'U\').1Y()}8n.B(\'W\',18.3r(3O.ih,3O.h)+\'U\').B(\'Z\',18.3r(3O.iw,3O.w)+\'U\').1Y().fX(cO,k.1v.M.eW,u(){k.1v.cw(89,6A,3O,6B,4u,4G,4M)});k(\'#ao\').B(\'Z\',18.3r(3O.iw,3O.w)+\'U\')}P{k(\'#87\').K(0).53=S;k(\'#88\').K(0).53=S;k.1v.cw(89,6A,3O,6B,4u,4G,4M)}E I},cw:u(89,gP,3O,6B,4u,4G,4M){k(\'#cW\').bk();aX=k(\'#87\');aX.2G();aO=k(\'#88\');aO.2G();2b=k(\'#eM\');1Z=k(\'#eE\');6F=k(\'#ao\');7m=k(\'#cM\').B(\'3n\',\'2K\');k(\'#eK\').3x(6A);k.1v.8m=1b;if(6B)k(\'#dg\').3x(k.1v.M.d8+\' \'+(4u+1)+\' \'+k.1v.M.dc+\' \'+6B);if(4G){aX.K(0).53=u(){q.5B();k.1v.26(S,4G);E I}}if(4M){aO.K(0).53=u(){q.5B();k.1v.26(S,4M);E I}}2b.1Y();82=k.1a.2o(1Z.K(0));56=18.3r(82.1C,2b.K(0).Z+k.1v.M.2E*2);6f=18.3r(82.hb,2b.K(0).W+k.1v.M.2E*2);2b.B({O:(56-2b.K(0).Z)/2+\'U\',Q:(6f-2b.K(0).W)/2+\'U\'});1Z.B({Z:56+\'U\',W:6f+\'U\'}).1Y();dw=k.1a.bm();6F.B(\'Q\',3O.t+(dw.h/15)+\'U\');if(6F.B(\'19\')==\'1o\'){6F.1Y().7f(k.1v.M.3W)}6k=12 9s;k(6k).1p(\'id\',\'cW\').1J(\'hJ\',u(){56=6k.Z+k.1v.M.2E*2;6f=6k.W+k.1v.M.2E*2;2b.2G();1Z.5w({W:6f},82.hb!=6f?k.1v.M.3W:1,u(){1Z.5w({Z:56},82.1C!=56?k.1v.M.3W:1,u(){1Z.bG(6k);k(6k).B({Y:\'1P\',O:k.1v.M.2E+\'U\',Q:k.1v.M.2E+\'U\'}).7f(k.1v.M.3W,u(){db=k.1a.2o(7m.K(0));if(4G){aX.B({O:k.1v.M.2E+\'U\',Q:k.1v.M.2E+\'U\',Z:56/2-k.1v.M.2E*3+\'U\',W:6f-k.1v.M.2E*2+\'U\'}).1Y()}if(4M){aO.B({O:56/2+k.1v.M.2E*2+\'U\',Q:k.1v.M.2E+\'U\',Z:56/2-k.1v.M.2E*3+\'U\',W:6f-k.1v.M.2E*2+\'U\'}).1Y()}7m.B({Z:56+\'U\',Q:-db.hb+\'U\',3n:\'dd\'}).5w({Q:-1},k.1v.M.3W,u(){k.1v.8m=I})})})})});6k.2J=89},au:u(){k(\'#cW\').bk();k(\'#ao\').2G();k(\'#cM\').B(\'3n\',\'2K\');k(\'#cP\').fX(cO,0,u(){k(q).2G();if(k.3a.4t){k(\'#cN\').2G()}});k(\'#87\').K(0).53=S;k(\'#88\').K(0).53=S;k.1v.6j=S;k.1v.8k=I;k.1v.8m=I;E I}};k.R={1A:S,41:S,F:S,1s:S,1q:S,Y:S,9a:u(e){k.R.F=(q.d0)?q.d0:q;k.R.1s=k.1a.4a(e);k.R.1q={Z:T(k(k.R.F).B(\'Z\'))||0,W:T(k(k.R.F).B(\'W\'))||0};k.R.Y={Q:T(k(k.R.F).B(\'Q\'))||0,O:T(k(k.R.F).B(\'O\'))||0};k(1h).1J(\'3D\',k.R.cR).1J(\'5P\',k.R.cK);if(2g k.R.F.1k.g2===\'u\'){k.R.F.1k.g2.1D(k.R.F)}E I},cK:u(e){k(1h).3q(\'3D\',k.R.cR).3q(\'5P\',k.R.cK);if(2g k.R.F.1k.fN===\'u\'){k.R.F.1k.fN.1D(k.R.F)}k.R.F=S},cR:u(e){if(!k.R.F){E}1s=k.1a.4a(e);7p=k.R.Y.Q-k.R.1s.y+1s.y;7r=k.R.Y.O-k.R.1s.x+1s.x;7p=18.3r(18.3L(7p,k.R.F.1k.8g-k.R.1q.W),k.R.F.1k.7h);7r=18.3r(18.3L(7r,k.R.F.1k.8h-k.R.1q.Z),k.R.F.1k.70);if(2g k.R.F.1k.4m===\'u\'){D 8a=k.R.F.1k.4m.1D(k.R.F,[7r,7p]);if(2g 8a==\'hh\'&&8a.1g==2){7r=8a[0];7p=8a[1]}}k.R.F.14.Q=7p+\'U\';k.R.F.14.O=7r+\'U\';E I},26:u(e){k(1h).1J(\'3D\',k.R.8j).1J(\'5P\',k.R.8o);k.R.1A=q.1A;k.R.41=q.41;k.R.1s=k.1a.4a(e);k.R.1q={Z:T(k(q.1A).B(\'Z\'))||0,W:T(k(q.1A).B(\'W\'))||0};k.R.Y={Q:T(k(q.1A).B(\'Q\'))||0,O:T(k(q.1A).B(\'O\'))||0};if(k.R.1A.1k.4o){k.R.1A.1k.4o.1D(k.R.1A,[q])}E I},8o:u(){k(1h).3q(\'3D\',k.R.8j).3q(\'5P\',k.R.8o);if(k.R.1A.1k.3T){k.R.1A.1k.3T.1D(k.R.1A,[k.R.41])}k.R.1A=S;k.R.41=S},6i:u(dx,az){E 18.3L(18.3r(k.R.1q.Z+dx*az,k.R.1A.1k.av),k.R.1A.1k.6x)},6m:u(dy,az){E 18.3L(18.3r(k.R.1q.W+dy*az,k.R.1A.1k.8c),k.R.1A.1k.8b)},fb:u(W){E 18.3L(18.3r(W,k.R.1A.1k.8c),k.R.1A.1k.8b)},8j:u(e){if(k.R.1A==S){E}1s=k.1a.4a(e);dx=1s.x-k.R.1s.x;dy=1s.y-k.R.1s.y;1I={Z:k.R.1q.Z,W:k.R.1q.W};2z={Q:k.R.Y.Q,O:k.R.Y.O};3m(k.R.41){1e\'e\':1I.Z=k.R.6i(dx,1);1r;1e\'fj\':1I.Z=k.R.6i(dx,1);1I.W=k.R.6m(dy,1);1r;1e\'w\':1I.Z=k.R.6i(dx,-1);2z.O=k.R.Y.O-1I.Z+k.R.1q.Z;1r;1e\'5F\':1I.Z=k.R.6i(dx,-1);2z.O=k.R.Y.O-1I.Z+k.R.1q.Z;1I.W=k.R.6m(dy,1);1r;1e\'76\':1I.W=k.R.6m(dy,-1);2z.Q=k.R.Y.Q-1I.W+k.R.1q.W;1I.Z=k.R.6i(dx,-1);2z.O=k.R.Y.O-1I.Z+k.R.1q.Z;1r;1e\'n\':1I.W=k.R.6m(dy,-1);2z.Q=k.R.Y.Q-1I.W+k.R.1q.W;1r;1e\'at\':1I.W=k.R.6m(dy,-1);2z.Q=k.R.Y.Q-1I.W+k.R.1q.W;1I.Z=k.R.6i(dx,1);1r;1e\'s\':1I.W=k.R.6m(dy,1);1r}if(k.R.1A.1k.4v){if(k.R.41==\'n\'||k.R.41==\'s\')4p=1I.W*k.R.1A.1k.4v;P 4p=1I.Z;4W=k.R.fb(4p*k.R.1A.1k.4v);4p=4W/k.R.1A.1k.4v;3m(k.R.41){1e\'n\':1e\'76\':1e\'at\':2z.Q+=1I.W-4W;1r}3m(k.R.41){1e\'76\':1e\'w\':1e\'5F\':2z.O+=1I.Z-4p;1r}1I.W=4W;1I.Z=4p}if(2z.Q<k.R.1A.1k.7h){4W=1I.W+2z.Q-k.R.1A.1k.7h;2z.Q=k.R.1A.1k.7h;if(k.R.1A.1k.4v){4p=4W/k.R.1A.1k.4v;3m(k.R.41){1e\'76\':1e\'w\':1e\'5F\':2z.O+=1I.Z-4p;1r}1I.Z=4p}1I.W=4W}if(2z.O<k.R.1A.1k.70){4p=1I.Z+2z.O-k.R.1A.1k.70;2z.O=k.R.1A.1k.70;if(k.R.1A.1k.4v){4W=4p*k.R.1A.1k.4v;3m(k.R.41){1e\'n\':1e\'76\':1e\'at\':2z.Q+=1I.W-4W;1r}1I.W=4W}1I.Z=4p}if(2z.Q+1I.W>k.R.1A.1k.8g){1I.W=k.R.1A.1k.8g-2z.Q;if(k.R.1A.1k.4v){1I.Z=1I.W/k.R.1A.1k.4v}}if(2z.O+1I.Z>k.R.1A.1k.8h){1I.Z=k.R.1A.1k.8h-2z.O;if(k.R.1A.1k.4v){1I.W=1I.Z*k.R.1A.1k.4v}}D 6p=I;if(k.R.1A.1k.f7){6p=k.R.1A.1k.f7.1D(k.R.1A,[1I,2z]);if(6p){if(6p.1q){k.23(1I,6p.1q)}if(6p.Y){k.23(2z,6p.Y)}}}8d=k.R.1A.14;8d.O=2z.O+\'U\';8d.Q=2z.Q+\'U\';8d.Z=1I.Z+\'U\';8d.W=1I.W+\'U\';E I},2r:u(M){if(!M||!M.3Z||M.3Z.1K!=7M){E}E q.1E(u(){D el=q;el.1k=M;el.1k.av=M.av||10;el.1k.8c=M.8c||10;el.1k.6x=M.6x||6P;el.1k.8b=M.8b||6P;el.1k.7h=M.7h||-aC;el.1k.70=M.70||-aC;el.1k.8h=M.8h||6P;el.1k.8g=M.8g||6P;d6=k(el).B(\'Y\');if(!(d6==\'2s\'||d6==\'1P\')){el.14.Y=\'2s\'}fS=/n|at|e|fj|s|5F|w|76/g;24(i in el.1k.3Z){if(i.6c().d5(fS)!=S){if(el.1k.3Z[i].1K==b0){3v=k(el.1k.3Z[i]);if(3v.1N()>0){el.1k.3Z[i]=3v.K(0)}}if(el.1k.3Z[i].4Y){el.1k.3Z[i].1A=el;el.1k.3Z[i].41=i;k(el.1k.3Z[i]).1J(\'5v\',k.R.26)}}}if(el.1k.5S){if(2g el.1k.5S===\'4V\'){aV=k(el.1k.5S);if(aV.1N()>0){aV.1E(u(){q.d0=el});aV.1J(\'5v\',k.R.9a)}}P if(el.1k.5S==1b){k(q).1J(\'5v\',k.R.9a)}}})},4U:u(){E q.1E(u(){D el=q;24(i in el.1k.3Z){el.1k.3Z[i].1A=S;el.1k.3Z[i].41=S;k(el.1k.3Z[i]).3q(\'5v\',k.R.26)}if(el.1k.5S){if(2g el.1k.5S===\'4V\'){3v=k(el.1k.5S);if(3v.1N()>0){3v.3q(\'5v\',k.R.9a)}}P if(el.1k.5S==1b){k(q).3q(\'5v\',k.R.9a)}}el.1k=S})}};k.fn.23({hz:k.R.2r,hs:k.R.4U});k.2C=S;k.7n=I;k.3k=S;k.7o=[];k.9v=u(e){D 3K=e.7L||e.7K||-1;if(3K==17||3K==16){k.7n=1b}};k.9u=u(e){k.7n=I};k.dL=u(e){q.f.1s=k.1a.4a(e);q.f.1M=k.23(k.1a.3w(q),k.1a.2o(q));q.f.3e=k.1a.6z(q);q.f.1s.x-=q.f.1M.x;q.f.1s.y-=q.f.1M.y;k(q).1S(k.2C.K(0));if(q.f.hc)k.2C.2R(q.f.hc).B(\'19\',\'2B\');k.2C.B({19:\'2B\',Z:\'2P\',W:\'2P\'});if(q.f.o){k.2C.B(\'1G\',q.f.o)}k.3k=q;k.96=I;k.7o=[];q.f.el.1E(u(){q.1M={x:q.8t+(q.4Z&&!k.3a.7I?T(q.4Z.5b)||0:0)+(k.3k.3c||0),y:q.8G+(q.4Z&&!k.3a.7I?T(q.4Z.4S)||0:0)+(k.3k.3d||0),1C:q.4c,hb:q.5W};if(q.s==1b){if(k.7n==I){q.s=I;k(q).4i(k.3k.f.7j)}P{k.96=1b;k.7o[k.7o.1g]=k.1p(q,\'id\')}}});k.am.1D(q,[e]);k(1h).1J(\'3D\',k.am).1J(\'5P\',k.cX);E I};k.am=u(e){if(!k.3k)E;k.fd.1D(k.3k,[e])};k.fd=u(e){if(!k.3k)E;D 1s=k.1a.4a(e);D 3e=k.1a.6z(k.3k);1s.x+=3e.l-q.f.3e.l-q.f.1M.x;1s.y+=3e.t-q.f.3e.t-q.f.1M.y;D 93=18.3L(1s.x,q.f.1s.x);D 5F=18.3L(18.3S(1s.x-q.f.1s.x),18.3S(q.f.3e.w-93));D 99=18.3L(1s.y,q.f.1s.y);D 9g=18.3L(18.3S(1s.y-q.f.1s.y),18.3S(q.f.3e.h-99));if(q.3d>0&&1s.y-20<q.3d){D 3X=18.3L(3e.t,10);99-=3X;9g+=3X;q.3d-=3X}P if(q.3d+q.f.1M.h<q.f.3e.h&&1s.y+20>q.3d+q.f.1M.h){D 3X=18.3L(q.f.3e.h-q.3d,10);q.3d+=3X;if(q.3d!=3e.t)9g+=3X}if(q.3c>0&&1s.x-20<q.3c){D 3X=18.3L(3e.l,10);93-=3X;5F+=3X;q.3c-=3X}P if(q.3c+q.f.1M.w<q.f.3e.w&&1s.x+20>q.3c+q.f.1M.w){D 3X=18.3L(q.f.3e.w-q.3c,10);q.3c+=3X;if(q.3c!=3e.l)5F+=3X}k.2C.B({O:93+\'U\',Q:99+\'U\',Z:5F+\'U\',W:9g+\'U\'});k.2C.l=93+q.f.3e.l;k.2C.t=99+q.f.3e.t;k.2C.r=k.2C.l+5F;k.2C.b=k.2C.t+9g;k.96=I;q.f.el.1E(u(){aw=k.7o.3J(k.1p(q,\'id\'));if(!(q.1M.x>k.2C.r||(q.1M.x+q.1M.1C)<k.2C.l||q.1M.y>k.2C.b||(q.1M.y+q.1M.hb)<k.2C.t)){k.96=1b;if(q.s!=1b){q.s=1b;k(q).2R(k.3k.f.7j)}if(aw!=-1){q.s=I;k(q).4i(k.3k.f.7j)}}P if((q.s==1b)&&(aw==-1)){q.s=I;k(q).4i(k.3k.f.7j)}P if((!q.s)&&(k.7n==1b)&&(aw!=-1)){q.s=1b;k(q).2R(k.3k.f.7j)}});E I};k.cX=u(e){if(!k.3k)E;k.g0.1D(k.3k,[e])};k.g0=u(e){k(1h).3q(\'3D\',k.am).3q(\'5P\',k.cX);if(!k.3k)E;k.2C.B(\'19\',\'1o\');if(q.f.hc)k.2C.4i(q.f.hc);k.3k=I;k(\'2e\').1S(k.2C.K(0));if(k.96==1b){if(q.f.98)q.f.98(k.cJ(k.1p(q,\'id\')))}P{if(q.f.9d)q.f.9d(k.cJ(k.1p(q,\'id\')))}k.7o=[]};k.cJ=u(s){D h=\'\';D o=[];if(a=k(\'#\'+s)){a.K(0).f.el.1E(u(){if(q.s==1b){if(h.1g>0){h+=\'&\'}h+=s+\'[]=\'+k.1p(q,\'id\');o[o.1g]=k.1p(q,\'id\')}})}E{7l:h,o:o}};k.fn.gZ=u(o){if(!k.2C){k(\'2e\',1h).1S(\'<22 id="2C"></22>\').1J(\'7B\',k.9v).1J(\'6y\',k.9u);k.2C=k(\'#2C\');k.2C.B({Y:\'1P\',19:\'1o\'});if(1X.2k){k(\'2e\',1h).1J(\'7B\',k.9v).1J(\'6y\',k.9u)}P{k(1h).1J(\'7B\',k.9v).1J(\'6y\',k.9u)}}if(!o){o={}}E q.1E(u(){if(q.eP)E;q.eP=1b;q.f={a:o.3C,o:o.1G?2m(o.1G):I,7j:o.eS?o.eS:I,hc:o.58?o.58:I,98:o.98?o.98:I,9d:o.9d?o.9d:I};q.f.el=k(\'.\'+o.3C);k(q).1J(\'5v\',k.dL).B(\'Y\',\'2s\')})};k.3b={bM:1,eH:u(3t){D 3t=3t;E q.1E(u(){q.4z.6s.1E(u(ab){k.3b.5c(q,3t[ab])})})},K:u(){D 3t=[];q.1E(u(cL){if(q.bI){3t[cL]=[];D C=q;D 1q=k.1a.2o(q);q.4z.6s.1E(u(ab){D x=q.8t;D y=q.8G;92=T(x*2a/(1q.w-q.4c));91=T(y*2a/(1q.h-q.5W));3t[cL][ab]=[92||0,91||0,x||0,y||0]})}});E 3t},ct:u(C){C.A.fu=C.A.28.w-C.A.1B.1C;C.A.fw=C.A.28.h-C.A.1B.hb;if(C.9r.4z.bC){9Z=C.9r.4z.6s.K(C.bF+1);if(9Z){C.A.28.w=(T(k(9Z).B(\'O\'))||0)+C.A.1B.1C;C.A.28.h=(T(k(9Z).B(\'Q\'))||0)+C.A.1B.hb}9Q=C.9r.4z.6s.K(C.bF-1);if(9Q){D cU=T(k(9Q).B(\'O\'))||0;D cH=T(k(9Q).B(\'O\'))||0;C.A.28.x+=cU;C.A.28.y+=cH;C.A.28.w-=cU;C.A.28.h-=cH}}C.A.g7=C.A.28.w-C.A.1B.1C;C.A.eC=C.A.28.h-C.A.1B.hb;if(C.A.2O){C.A.gx=((C.A.28.w-C.A.1B.1C)/C.A.2O)||1;C.A.gy=((C.A.28.h-C.A.1B.hb)/C.A.2O)||1;C.A.fU=C.A.g7/C.A.2O;C.A.fH=C.A.eC/C.A.2O}C.A.28.dx=C.A.28.x-C.A.2c.x;C.A.28.dy=C.A.28.y-C.A.2c.y;k.11.1c.B(\'9b\',\'ad\')},3H:u(C,x,y){if(C.A.2O){fE=T(x/C.A.fU);92=fE*2a/C.A.2O;ft=T(y/C.A.fH);91=ft*2a/C.A.2O}P{92=T(x*2a/C.A.fu);91=T(y*2a/C.A.fw)}C.A.b3=[92||0,91||0,x||0,y||0];if(C.A.3H)C.A.3H.1D(C,C.A.b3)},eI:u(2k){3K=2k.7L||2k.7K||-1;3m(3K){1e 35:k.3b.5c(q.3U,[ae,ae]);1r;1e 36:k.3b.5c(q.3U,[-ae,-ae]);1r;1e 37:k.3b.5c(q.3U,[-q.3U.A.gx||-1,0]);1r;1e 38:k.3b.5c(q.3U,[0,-q.3U.A.gy||-1]);1r;1e 39:k.3b.5c(q.3U,[q.3U.A.gx||1,0]);1r;1e 40:k.11.5c(q.3U,[0,q.3U.A.gy||1]);1r}},5c:u(C,Y){if(!C.A){E}C.A.1B=k.23(k.1a.3w(C),k.1a.2o(C));C.A.2c={x:T(k.B(C,\'O\'))||0,y:T(k.B(C,\'Q\'))||0};C.A.4n=k.B(C,\'Y\');if(C.A.4n!=\'2s\'&&C.A.4n!=\'1P\'){C.14.Y=\'2s\'}k.11.c5(C);k.3b.ct(C);dx=T(Y[0])||0;dy=T(Y[1])||0;2v=C.A.2c.x+dx;2q=C.A.2c.y+dy;if(C.A.2O){3y=k.11.c7.1D(C,[2v,2q,dx,dy]);if(3y.1K==7M){dx=3y.dx;dy=3y.dy}2v=C.A.2c.x+dx;2q=C.A.2c.y+dy}3y=k.11.ce.1D(C,[2v,2q,dx,dy]);if(3y&&3y.1K==7M){dx=3y.dx;dy=3y.dy}2v=C.A.2c.x+dx;2q=C.A.2c.y+dy;if(C.A.5i&&(C.A.3H||C.A.2Z)){k.3b.3H(C,2v,2q)}2v=!C.A.1O||C.A.1O==\'4j\'?2v:C.A.2c.x||0;2q=!C.A.1O||C.A.1O==\'49\'?2q:C.A.2c.y||0;C.14.O=2v+\'U\';C.14.Q=2q+\'U\'},2r:u(o){E q.1E(u(){if(q.bI==1b||!o.3C||!k.1a||!k.11||!k.1x){E}5x=k(o.3C,q);if(5x.1N()==0){E}D 4N={2p:\'94\',5i:1b,3H:o.3H&&o.3H.1K==2A?o.3H:S,2Z:o.2Z&&o.2Z.1K==2A?o.2Z:S,3v:q,1G:o.1G||I};if(o.2O&&T(o.2O)){4N.2O=T(o.2O)||1;4N.2O=4N.2O>0?4N.2O:1}if(5x.1N()==1)5x.7t(4N);P{k(5x.K(0)).7t(4N);4N.3v=S;5x.7t(4N)}5x.7B(k.3b.eI);5x.1p(\'bM\',k.3b.bM++);q.bI=1b;q.4z={};q.4z.er=4N.er;q.4z.2O=4N.2O;q.4z.6s=5x;q.4z.bC=o.bC?1b:I;bZ=q;bZ.4z.6s.1E(u(2N){q.bF=2N;q.9r=bZ});if(o.3t&&o.3t.1K==7F){24(i=o.3t.1g-1;i>=0;i--){if(o.3t[i].1K==7F&&o.3t[i].1g==2){el=q.4z.6s.K(i);if(el.4Y){k.3b.5c(el,o.3t[i])}}}}})}};k.fn.23({hN:k.3b.2r,hS:k.3b.eH,hG:k.3b.K});k.2u={5I:[],eg:u(){q.5B();X=q.31;id=k.1p(X,\'id\');if(k.2u.5I[id]!=S){1X.5T(k.2u.5I[id])}1z=X.L.3u+1;if(X.L.1Q.1g<1z){1z=1}1Q=k(\'1T\',X.L.5u);X.L.3u=1z;if(1Q.1N()>0){1Q.7a(X.L.3W,k.2u.95)}},dp:u(){q.5B();X=q.31;id=k.1p(X,\'id\');if(k.2u.5I[id]!=S){1X.5T(k.2u.5I[id])}1z=X.L.3u-1;1Q=k(\'1T\',X.L.5u);if(1z<1){1z=X.L.1Q.1g}X.L.3u=1z;if(1Q.1N()>0){1Q.7a(X.L.3W,k.2u.95)}},2I:u(c){X=1h.9e(c);if(X.L.6o){1z=X.L.3u;7d(1z==X.L.3u){1z=1+T(18.6o()*X.L.1Q.1g)}}P{1z=X.L.3u+1;if(X.L.1Q.1g<1z){1z=1}}1Q=k(\'1T\',X.L.5u);X.L.3u=1z;if(1Q.1N()>0){1Q.7a(X.L.3W,k.2u.95)}},go:u(o){D X;if(o&&o.1K==7M){if(o.2b){X=1h.9e(o.2b.X);5N=1X.hn.3h.7C("#");o.2b.6S=S;if(5N.1g==2){1z=T(5N[1]);1Y=5N[1].4E(1z,\'\');if(k.1p(X,\'id\')!=1Y){1z=1}}P{1z=1}}if(o.90){o.90.5B();X=o.90.31.31;id=k.1p(X,\'id\');if(k.2u.5I[id]!=S){1X.5T(k.2u.5I[id])}5N=o.90.3h.7C("#");1z=T(5N[1]);1Y=5N[1].4E(1z,\'\');if(k.1p(X,\'id\')!=1Y){1z=1}}if(X.L.1Q.1g<1z||1z<1){1z=1}X.L.3u=1z;52=k.1a.2o(X);dt=k.1a.aT(X);d9=k.1a.6U(X);if(X.L.3z){X.L.3z.o.B(\'19\',\'1o\')}if(X.L.3s){X.L.3s.o.B(\'19\',\'1o\')}if(X.L.2b){y=T(dt.t)+T(d9.t);if(X.L.1U){if(X.L.1U.5A==\'Q\'){y+=X.L.1U.4C.hb}P{52.h-=X.L.1U.4C.hb}}if(X.L.2x){if(X.L.2x&&X.L.2x.6Q==\'Q\'){y+=X.L.2x.4C.hb}P{52.h-=X.L.2x.4C.hb}}if(!X.L.c1){X.L.df=o.2b?o.2b.W:(T(X.L.2b.B(\'W\'))||0);X.L.c1=o.2b?o.2b.Z:(T(X.L.2b.B(\'Z\'))||0)}X.L.2b.B(\'Q\',y+(52.h-X.L.df)/2+\'U\');X.L.2b.B(\'O\',(52.1C-X.L.c1)/2+\'U\');X.L.2b.B(\'19\',\'2B\')}1Q=k(\'1T\',X.L.5u);if(1Q.1N()>0){1Q.7a(X.L.3W,k.2u.95)}P{aj=k(\'a\',X.L.1U.o).K(1z-1);k(aj).2R(X.L.1U.5R);D 1T=12 9s();1T.X=k.1p(X,\'id\');1T.1z=1z-1;1T.2J=X.L.1Q[X.L.3u-1].2J;if(1T.21){1T.6S=S;k.2u.19.1D(1T)}P{1T.6S=k.2u.19}if(X.L.2x){X.L.2x.o.3x(X.L.1Q[1z-1].6L)}}}},95:u(){X=q.31.31;X.L.5u.B(\'19\',\'1o\');if(X.L.1U.5R){aj=k(\'a\',X.L.1U.o).4i(X.L.1U.5R).K(X.L.3u-1);k(aj).2R(X.L.1U.5R)}D 1T=12 9s();1T.X=k.1p(X,\'id\');1T.1z=X.L.3u-1;1T.2J=X.L.1Q[X.L.3u-1].2J;if(1T.21){1T.6S=S;k.2u.19.1D(1T)}P{1T.6S=k.2u.19}if(X.L.2x){X.L.2x.o.3x(X.L.1Q[X.L.3u-1].6L)}},19:u(){X=1h.9e(q.X);if(X.L.3z){X.L.3z.o.B(\'19\',\'1o\')}if(X.L.3s){X.L.3s.o.B(\'19\',\'1o\')}52=k.1a.2o(X);y=0;if(X.L.1U){if(X.L.1U.5A==\'Q\'){y+=X.L.1U.4C.hb}P{52.h-=X.L.1U.4C.hb}}if(X.L.2x){if(X.L.2x&&X.L.2x.6Q==\'Q\'){y+=X.L.2x.4C.hb}P{52.h-=X.L.2x.4C.hb}}hg=k(\'.ca\',X);y=y+(52.h-q.W)/2;x=(52.1C-q.Z)/2;X.L.5u.B(\'Q\',y+\'U\').B(\'O\',x+\'U\').3x(\'<1T 2J="\'+q.2J+\'" />\');X.L.5u.7f(X.L.3W);3s=X.L.3u+1;if(3s>X.L.1Q.1g){3s=1}3z=X.L.3u-1;if(3z<1){3z=X.L.1Q.1g}X.L.3s.o.B(\'19\',\'2B\').B(\'Q\',y+\'U\').B(\'O\',x+2*q.Z/3+\'U\').B(\'Z\',q.Z/3+\'U\').B(\'W\',q.W+\'U\').1p(\'4g\',X.L.1Q[3s-1].6L);X.L.3s.o.K(0).3h=\'#\'+3s+k.1p(X,\'id\');X.L.3z.o.B(\'19\',\'2B\').B(\'Q\',y+\'U\').B(\'O\',x+\'U\').B(\'Z\',q.Z/3+\'U\').B(\'W\',q.W+\'U\').1p(\'4g\',X.L.1Q[3z-1].6L);X.L.3z.o.K(0).3h=\'#\'+3z+k.1p(X,\'id\')},2r:u(o){if(!o||!o.1Z||k.2u.5I[o.1Z])E;D 1Z=k(\'#\'+o.1Z);D el=1Z.K(0);if(el.14.Y!=\'1P\'&&el.14.Y!=\'2s\'){el.14.Y=\'2s\'}el.14.2U=\'2K\';if(1Z.1N()==0)E;el.L={};el.L.1Q=o.1Q?o.1Q:[];el.L.6o=o.6o&&o.6o==1b||I;97=el.f3(\'hL\');24(i=0;i<97.1g;i++){7Z=el.L.1Q.1g;el.L.1Q[7Z]={2J:97[i].2J,6L:97[i].4g||97[i].hD||\'\'}}if(el.L.1Q.1g==0){E}el.L.4n=k.23(k.1a.3w(el),k.1a.2o(el));el.L.b5=k.1a.aT(el);el.L.bu=k.1a.6U(el);t=T(el.L.b5.t)+T(el.L.bu.t);b=T(el.L.b5.b)+T(el.L.bu.b);k(\'1T\',el).bk();el.L.3W=o.3W?o.3W:g5;if(o.5A||o.9f||o.5R){el.L.1U={};1Z.1S(\'<22 6T="g1"></22>\');el.L.1U.o=k(\'.g1\',el);if(o.9f){el.L.1U.9f=o.9f;el.L.1U.o.2R(o.9f)}if(o.5R){el.L.1U.5R=o.5R}el.L.1U.o.B(\'Y\',\'1P\').B(\'Z\',el.L.4n.w+\'U\');if(o.5A&&o.5A==\'Q\'){el.L.1U.5A=\'Q\';el.L.1U.o.B(\'Q\',t+\'U\')}P{el.L.1U.5A=\'4D\';el.L.1U.o.B(\'4D\',b+\'U\')}el.L.1U.aE=o.aE?o.aE:\' \';24(D i=0;i<el.L.1Q.1g;i++){7Z=T(i)+1;el.L.1U.o.1S(\'<a 3h="#\'+7Z+o.1Z+\'" 6T="gR" 4g="\'+el.L.1Q[i].6L+\'">\'+7Z+\'</a>\'+(7Z!=el.L.1Q.1g?el.L.1U.aE:\'\'))}k(\'a\',el.L.1U.o).1J(\'5h\',u(){k.2u.go({90:q})});el.L.1U.4C=k.1a.2o(el.L.1U.o.K(0))}if(o.6Q||o.9c){el.L.2x={};1Z.1S(\'<22 6T="dn">&7k;</22>\');el.L.2x.o=k(\'.dn\',el);if(o.9c){el.L.2x.9c=o.9c;el.L.2x.o.2R(o.9c)}el.L.2x.o.B(\'Y\',\'1P\').B(\'Z\',el.L.4n.w+\'U\');if(o.6Q&&o.6Q==\'Q\'){el.L.2x.6Q=\'Q\';el.L.2x.o.B(\'Q\',(el.L.1U&&el.L.1U.5A==\'Q\'?el.L.1U.4C.hb+t:t)+\'U\')}P{el.L.2x.6Q=\'4D\';el.L.2x.o.B(\'4D\',(el.L.1U&&el.L.1U.5A==\'4D\'?el.L.1U.4C.hb+b:b)+\'U\')}el.L.2x.4C=k.1a.2o(el.L.2x.o.K(0))}if(o.9D){el.L.3s={9D:o.9D};1Z.1S(\'<a 3h="#2\'+o.1Z+\'" 6T="eY">&7k;</a>\');el.L.3s.o=k(\'.eY\',el);el.L.3s.o.B(\'Y\',\'1P\').B(\'19\',\'1o\').B(\'2U\',\'2K\').B(\'4A\',\'eR\').2R(el.L.3s.9D);el.L.3s.o.1J(\'5h\',k.2u.eg)}if(o.9o){el.L.3z={9o:o.9o};1Z.1S(\'<a 3h="#0\'+o.1Z+\'" 6T="ee">&7k;</a>\');el.L.3z.o=k(\'.ee\',el);el.L.3z.o.B(\'Y\',\'1P\').B(\'19\',\'1o\').B(\'2U\',\'2K\').B(\'4A\',\'eR\').2R(el.L.3z.9o);el.L.3z.o.1J(\'5h\',k.2u.dp)}1Z.bG(\'<22 6T="ca"></22>\');el.L.5u=k(\'.ca\',el);el.L.5u.B(\'Y\',\'1P\').B(\'Q\',\'2P\').B(\'O\',\'2P\').B(\'19\',\'1o\');if(o.2b){1Z.bG(\'<22 6T="dW" 14="19: 1o;"><1T 2J="\'+o.2b+\'" /></22>\');el.L.2b=k(\'.dW\',el);el.L.2b.B(\'Y\',\'1P\');D 1T=12 9s();1T.X=o.1Z;1T.2J=o.2b;if(1T.21){1T.6S=S;k.2u.go({2b:1T})}P{1T.6S=u(){k.2u.go({2b:q})}}}P{k.2u.go({1Z:el})}if(o.cS){fi=T(o.cS)*aC}k.2u.5I[o.1Z]=o.cS?1X.6V(\'k.2u.2I(\\\'\'+o.1Z+\'\\\')\',fi):S}};k.X=k.2u.2r;k.1t={7s:[],5L:{},1c:I,7u:S,26:u(){if(k.11.F==S){E}D 4O,3G,c,cs;k.1t.1c.K(0).3l=k.11.F.A.6R;4O=k.1t.1c.K(0).14;4O.19=\'2B\';k.1t.1c.1B=k.23(k.1a.3w(k.1t.1c.K(0)),k.1a.2o(k.1t.1c.K(0)));4O.Z=k.11.F.A.1B.1C+\'U\';4O.W=k.11.F.A.1B.hb+\'U\';3G=k.1a.cy(k.11.F);4O.5K=3G.t;4O.5z=3G.r;4O.5k=3G.b;4O.5j=3G.l;if(k.11.F.A.46==1b){c=k.11.F.fI(1b);cs=c.14;cs.5K=\'2P\';cs.5z=\'2P\';cs.5k=\'2P\';cs.5j=\'2P\';cs.19=\'2B\';k.1t.1c.5o().1S(c)}k(k.11.F).f5(k.1t.1c.K(0));k.11.F.14.19=\'1o\'},fC:u(e){if(!e.A.44&&k.1x.5r.cQ){if(e.A.3T)e.A.3T.1D(F);k(e).B(\'Y\',e.A.cz||e.A.4n);k(e).aS();k(k.1x.5r).f6(e)}k.1t.1c.4i(e.A.6R).3x(\'&7k;\');k.1t.7u=S;D 4O=k.1t.1c.K(0).14;4O.19=\'1o\';k.1t.1c.f5(e);if(e.A.fx>0){k(e).7f(e.A.fx)}k(\'2e\').1S(k.1t.1c.K(0));D 86=[];D 8q=I;24(D i=0;i<k.1t.7s.1g;i++){D 1j=k.1x.3P[k.1t.7s[i]].K(0);D id=k.1p(1j,\'id\');D 8i=k.1t.8x(id);if(1j.1i.ay!=8i.7l){1j.1i.ay=8i.7l;if(8q==I&&1j.1i.2Z){8q=1j.1i.2Z}8i.id=id;86[86.1g]=8i}}k.1t.7s=[];if(8q!=I&&86.1g>0){8q(86)}},al:u(e,o){if(!k.11.F)E;D 6e=I;D i=0;if(e.1i.el.1N()>0){24(i=e.1i.el.1N();i>0;i--){if(e.1i.el.K(i-1)!=k.11.F){if(!e.5V.b2){if((e.1i.el.K(i-1).1M.y+e.1i.el.K(i-1).1M.hb/2)>k.11.F.A.2q){6e=e.1i.el.K(i-1)}P{1r}}P{if((e.1i.el.K(i-1).1M.x+e.1i.el.K(i-1).1M.1C/2)>k.11.F.A.2v&&(e.1i.el.K(i-1).1M.y+e.1i.el.K(i-1).1M.hb/2)>k.11.F.A.2q){6e=e.1i.el.K(i-1)}}}}}if(6e&&k.1t.7u!=6e){k.1t.7u=6e;k(6e).h5(k.1t.1c.K(0))}P if(!6e&&(k.1t.7u!=S||k.1t.1c.K(0).31!=e)){k.1t.7u=S;k(e).1S(k.1t.1c.K(0))}k.1t.1c.K(0).14.19=\'2B\'},cT:u(e){if(k.11.F==S){E}e.1i.el.1E(u(){q.1M=k.23(k.1a.74(q),k.1a.7G(q))})},8x:u(s){D i;D h=\'\';D o={};if(s){if(k.1t.5L[s]){o[s]=[];k(\'#\'+s+\' .\'+k.1t.5L[s]).1E(u(){if(h.1g>0){h+=\'&\'}h+=s+\'[]=\'+k.1p(q,\'id\');o[s][o[s].1g]=k.1p(q,\'id\')})}P{24(a in s){if(k.1t.5L[s[a]]){o[s[a]]=[];k(\'#\'+s[a]+\' .\'+k.1t.5L[s[a]]).1E(u(){if(h.1g>0){h+=\'&\'}h+=s[a]+\'[]=\'+k.1p(q,\'id\');o[s[a]][o[s[a]].1g]=k.1p(q,\'id\')})}}}}P{24(i in k.1t.5L){o[i]=[];k(\'#\'+i+\' .\'+k.1t.5L[i]).1E(u(){if(h.1g>0){h+=\'&\'}h+=i+\'[]=\'+k.1p(q,\'id\');o[i][o[i].1g]=k.1p(q,\'id\')})}}E{7l:h,o:o}},fF:u(e){if(!e.dq){E}E q.1E(u(){if(!q.5V||!k(e).is(\'.\'+q.5V.3C))k(e).2R(q.5V.3C);k(e).7t(q.5V.A)})},4U:u(){E q.1E(u(){k(\'.\'+q.5V.3C).aS();k(q).dR();q.5V=S;q.fm=S})},2r:u(o){if(o.3C&&k.1a&&k.11&&k.1x){if(!k.1t.1c){k(\'2e\',1h).1S(\'<22 id="e5">&7k;</22>\');k.1t.1c=k(\'#e5\');k.1t.1c.K(0).14.19=\'1o\'}q.do({3C:o.3C,9J:o.9J?o.9J:I,a5:o.a5?o.a5:I,58:o.58?o.58:I,7x:o.7x||o.dC,7y:o.7y||o.fO,cQ:1b,2Z:o.2Z||o.ia,fx:o.fx?o.fx:I,46:o.46?1b:I,6I:o.6I?o.6I:\'cV\'});E q.1E(u(){D A={6N:o.6N?1b:I,ff:6P,1G:o.1G?2m(o.1G):I,6R:o.58?o.58:I,fx:o.fx?o.fx:I,44:1b,46:o.46?1b:I,3v:o.3v?o.3v:S,2p:o.2p?o.2p:S,4o:o.4o&&o.4o.1K==2A?o.4o:I,4m:o.4m&&o.4m.1K==2A?o.4m:I,3T:o.3T&&o.3T.1K==2A?o.3T:I,1O:/49|4j/.48(o.1O)?o.1O:I,6M:o.6M?T(o.6M)||0:I,2V:o.2V?o.2V:I};k(\'.\'+o.3C,q).7t(A);q.fm=1b;q.5V={3C:o.3C,6N:o.6N?1b:I,ff:6P,1G:o.1G?2m(o.1G):I,6R:o.58?o.58:I,fx:o.fx?o.fx:I,44:1b,46:o.46?1b:I,3v:o.3v?o.3v:S,2p:o.2p?o.2p:S,b2:o.b2?1b:I,A:A}})}}};k.fn.23({j3:k.1t.2r,f6:k.1t.fF,iS:k.1t.4U});k.iZ=k.1t.8x;k.2t={6O:S,7b:I,9m:S,6K:u(e){k.2t.7b=1b;k.2t.1Y(e,q,1b)},cq:u(e){if(k.2t.6O!=q)E;k.2t.7b=I;k.2t.2G(e,q)},1Y:u(e,el,7b){if(k.2t.6O!=S)E;if(!el){el=q}k.2t.6O=el;1M=k.23(k.1a.3w(el),k.1a.2o(el));8u=k(el);4g=8u.1p(\'4g\');3h=8u.1p(\'3h\');if(4g){k.2t.9m=4g;8u.1p(\'4g\',\'\');k(\'#eT\').3x(4g);if(3h)k(\'#bL\').3x(3h.4E(\'jh://\',\'\'));P k(\'#bL\').3x(\'\');1c=k(\'#8z\');if(el.4H.3l){1c.K(0).3l=el.4H.3l}P{1c.K(0).3l=\'\'}bo=k.1a.2o(1c.K(0));ga=7b&&el.4H.Y==\'bO\'?\'4D\':el.4H.Y;3m(ga){1e\'Q\':2q=1M.y-bo.hb;2v=1M.x;1r;1e\'O\':2q=1M.y;2v=1M.x-bo.1C;1r;1e\'2L\':2q=1M.y;2v=1M.x+1M.1C;1r;1e\'bO\':k(\'2e\').1J(\'3D\',k.2t.3D);1s=k.1a.4a(e);2q=1s.y+15;2v=1s.x+15;1r;ad:2q=1M.y+1M.hb;2v=1M.x;1r}1c.B({Q:2q+\'U\',O:2v+\'U\'});if(el.4H.54==I){1c.1Y()}P{1c.7f(el.4H.54)}if(el.4H.2Y)el.4H.2Y.1D(el);8u.1J(\'8B\',k.2t.2G).1J(\'5B\',k.2t.cq)}},3D:u(e){if(k.2t.6O==S){k(\'2e\').3q(\'3D\',k.2t.3D);E}1s=k.1a.4a(e);k(\'#8z\').B({Q:1s.y+15+\'U\',O:1s.x+15+\'U\'})},2G:u(e,el){if(!el){el=q}if(k.2t.7b!=1b&&k.2t.6O==el){k.2t.6O=S;k(\'#8z\').7a(1);k(el).1p(\'4g\',k.2t.9m).3q(\'8B\',k.2t.2G).3q(\'5B\',k.2t.cq);if(el.4H.3i)el.4H.3i.1D(el);k.2t.9m=S}},2r:u(M){if(!k.2t.1c){k(\'2e\').1S(\'<22 id="8z"><22 id="eT"></22><22 id="bL"></22></22>\');k(\'#8z\').B({Y:\'1P\',3I:6P,19:\'1o\'});k.2t.1c=1b}E q.1E(u(){if(k.1p(q,\'4g\')){q.4H={Y:/Q|4D|O|2L|bO/.48(M.Y)?M.Y:\'4D\',3l:M.3l?M.3l:I,54:M.54?M.54:I,2Y:M.2Y&&M.2Y.1K==2A?M.2Y:I,3i:M.3i&&M.3i.1K==2A?M.3i:I};D el=k(q);el.1J(\'9z\',k.2t.1Y);el.1J(\'6K\',k.2t.6K)}})}};k.fn.hO=k.2t.2r;k.84={bq:u(e){3K=e.7L||e.7K||-1;if(3K==9){if(1X.2k){1X.2k.bT=1b;1X.2k.c0=I}P{e.aP();e.aW()}if(q.b1){1h.6J.dZ().3g="\\t";q.dV=u(){q.6K();q.dV=S}}P if(q.aF){26=q.5q;2T=q.dN;q.2y=q.2y.hd(0,26)+"\\t"+q.2y.h8(2T);q.aF(26+1,26+1);q.6K()}E I}},4U:u(){E q.1E(u(){if(q.7P&&q.7P==1b){k(q).3q(\'7B\',k.84.bq);q.7P=I}})},2r:u(){E q.1E(u(){if(q.4Y==\'cf\'&&(!q.7P||q.7P==I)){k(q).1J(\'7B\',k.84.bq);q.7P=1b}})}};k.fn.23({j5:k.84.2r,hH:k.84.4U});k.1a={3w:u(e){D x=0;D y=0;D es=e.14;D bP=I;if(k(e).B(\'19\')==\'1o\'){D 5Y=es.3n;D 9q=es.Y;bP=1b;es.3n=\'2K\';es.19=\'2B\';es.Y=\'1P\'}D el=e;7d(el){x+=el.8t+(el.4Z&&!k.3a.7I?T(el.4Z.5b)||0:0);y+=el.8G+(el.4Z&&!k.3a.7I?T(el.4Z.4S)||0:0);el=el.dJ}el=e;7d(el&&el.4Y&&el.4Y.6c()!=\'2e\'){x-=el.3c||0;y-=el.3d||0;el=el.31}if(bP==1b){es.19=\'1o\';es.Y=9q;es.3n=5Y}E{x:x,y:y}},7G:u(el){D x=0,y=0;7d(el){x+=el.8t||0;y+=el.8G||0;el=el.dJ}E{x:x,y:y}},2o:u(e){D w=k.B(e,\'Z\');D h=k.B(e,\'W\');D 1C=0;D hb=0;D es=e.14;if(k(e).B(\'19\')!=\'1o\'){1C=e.4c;hb=e.5W}P{D 5Y=es.3n;D 9q=es.Y;es.3n=\'2K\';es.19=\'2B\';es.Y=\'1P\';1C=e.4c;hb=e.5W;es.19=\'1o\';es.Y=9q;es.3n=5Y}E{w:w,h:h,1C:1C,hb:hb}},74:u(el){E{1C:el.4c||0,hb:el.5W||0}},bm:u(e){D h,w,de;if(e){w=e.8W;h=e.8O}P{de=1h.5d;w=1X.d4||aa.d4||(de&&de.8W)||1h.2e.8W;h=1X.cB||aa.cB||(de&&de.8O)||1h.2e.8O}E{w:w,h:h}},6z:u(e){D t=0,l=0,w=0,h=0,iw=0,ih=0;if(e&&e.9N.6c()!=\'2e\'){t=e.3d;l=e.3c;w=e.d7;h=e.d2;iw=0;ih=0}P{if(1h.5d){t=1h.5d.3d;l=1h.5d.3c;w=1h.5d.d7;h=1h.5d.d2}P if(1h.2e){t=1h.2e.3d;l=1h.2e.3c;w=1h.2e.d7;h=1h.2e.d2}iw=aa.d4||1h.5d.8W||1h.2e.8W||0;ih=aa.cB||1h.5d.8O||1h.2e.8O||0}E{t:t,l:l,w:w,h:h,iw:iw,ih:ih}},cy:u(e,7N){D el=k(e);D t=el.B(\'5K\')||\'\';D r=el.B(\'5z\')||\'\';D b=el.B(\'5k\')||\'\';D l=el.B(\'5j\')||\'\';if(7N)E{t:T(t)||0,r:T(r)||0,b:T(b)||0,l:T(l)};P E{t:t,r:r,b:b,l:l}},aT:u(e,7N){D el=k(e);D t=el.B(\'5M\')||\'\';D r=el.B(\'5U\')||\'\';D b=el.B(\'5n\')||\'\';D l=el.B(\'4X\')||\'\';if(7N)E{t:T(t)||0,r:T(r)||0,b:T(b)||0,l:T(l)};P E{t:t,r:r,b:b,l:l}},6U:u(e,7N){D el=k(e);D t=el.B(\'4S\')||\'\';D r=el.B(\'5O\')||\'\';D b=el.B(\'5Q\')||\'\';D l=el.B(\'5b\')||\'\';if(7N)E{t:T(t)||0,r:T(r)||0,b:T(b)||0,l:T(l)||0};P E{t:t,r:r,b:b,l:l}},4a:u(2k){D x=2k.hT||(2k.gM+(1h.5d.3c||1h.2e.3c))||0;D y=2k.ki||(2k.iQ+(1h.5d.3d||1h.2e.3d))||0;E{x:x,y:y}},cI:u(4R,cx){cx(4R);4R=4R.7c;7d(4R){k.1a.cI(4R,cx);4R=4R.hQ}},h7:u(4R){k.1a.cI(4R,u(el){24(D 1p in el){if(2g el[1p]===\'u\'){el[1p]=S}}})},hV:u(el,1O){D 5l=k.1a.6z();D b6=k.1a.2o(el);if(!1O||1O==\'49\')k(el).B({Q:5l.t+((18.3r(5l.h,5l.ih)-5l.t-b6.hb)/2)+\'U\'});if(!1O||1O==\'4j\')k(el).B({O:5l.l+((18.3r(5l.w,5l.iw)-5l.l-b6.1C)/2)+\'U\'})},hW:u(el,dk){D 1Q=k(\'1T[@2J*="8X"]\',el||1h),8X;1Q.1E(u(){8X=q.2J;q.2J=dk;q.14.5E="9n:9w.9y.hE(2J=\'"+8X+"\')"})}};[].3J||(7F.hF.3J=u(v,n){n=(n==S)?0:n;D m=q.1g;24(D i=n;i<m;i++)if(q[i]==v)E i;E-1});',62,1293,'||||||||||||||||||||jQuery||||||this||||function||||||dragCfg|css|elm|var|return|dragged|easing|speed|false|callback|get|ss|options|iAuto|left|else|top|iResize|null|parseInt|px|oldStyle|height|slideshow|position|width||iDrag|new||style||||Math|display|iUtil|true|helper|subject|case|autoCFG|length|document|dropCfg|iEL|resizeOptions|carouselCfg|duration|interfaceFX|none|attr|sizes|break|pointer|iSort|type|ImageBox|queue|iDrop|iAutoscroller|slide|resizeElement|oC|wb|apply|each|fisheyeCfg|opacity|delta|newSizes|bind|constructor|custom|pos|size|axis|absolute|images|items|append|img|slideslinks|255|firstNum|window|show|container||complete|div|extend|for||start||cont|elsToScroll|100|loader|oR||body|elem|typeof|selectedItem|oldP|props|event|accordionCfg|parseFloat|field|getSize|containment|ny|build|relative|iTooltip|islideshow|nx|tp|slideCaption|value|newPosition|Function|block|selectHelper|step|border|itemWidth|hide|dequeue|timer|src|hidden|right|limit|nr|fractions|0px|PI|addClass|direction|end|overflow|cursorAt|result|parentData|onShow|onChange|to|parentNode|||||||||browser|iSlider|scrollLeft|scrollTop|scr|transferHelper|text|href|onHide|pre|selectdrug|className|switch|visibility|item|wrapper|unbind|max|nextslide|values|currentslide|handle|getPosition|html|newCoords|prevslide|iframe|iExpander|accept|mousemove|canvas|createElement|margins|onSlide|zIndex|indexOf|pressedKey|min|valueToAdd|multipleSeparator|pageSize|zones|highlighted|toggle|abs|onStop|dragElem|times|fadeDuration|diff|dhs|handlers||resizeDirection||vp|so|distance|ghosting||test|vertically|getPointer|startTop|offsetWidth|subjectValue|lastSuggestion|DropOutDirectiont|title|wrs|removeClass|horizontally|startLeft|out|onDrag|oP|onStart|nWidth|percent|down|ifxFirstDisplay|msie|iteration|ratio|clear|color|lastValue|slideCfg|fontSize|currentPointer|dimm|bottom|replace|up|prevImage|tooltipCFG|rel|els|fxCheckTag|context|nextImage|params|shs|fieldData|elToScroll|nodeEl|borderTopWidth|chunks|destroy|string|nHeight|paddingLeft|tagName|currentStyle||halign|slidePos|onclick|delay||containerW|from|helperclass|endLeft|endTop|borderLeftWidth|dragmoveBy|documentElement|dhe|newStyles|clonedEl|click|si|marginLeft|marginBottom|clientScroll|OpenClose|paddingBottom|empty|toWrite|selectionStart|overzone|toAdd|onDragModifier|holder|mousedown|animate|toDrag|cnt|marginRight|linksPosition|blur|getAttribute|hight|filter|sw|zoney|cos|slideshows|zonex|marginTop|collected|paddingTop|url|borderRightWidth|mouseup|borderBottomWidth|activeLinkClass|dragHandle|clearInterval|paddingRight|sortCfg|offsetHeight|prop|oldVisibility|styles||BlindDirection|point|fxh|nmp|old|post|currentPanel|onSelect|elementData|grid|pow|toLowerCase|animationHandler|cur|containerH|close|puff|getWidth|currentRel|imageEl|Expander|getHeight|iFisheye|random|newDimensions|itemHeight|reflections|sliders|selRange|wr|orig|margin|maxWidth|keyup|getScroll|captionText|totalImages|128|parseColor|curCSS|outerContainer|Scale|restore|tolerance|selection|focus|caption|snapDistance|revert|current|3000|captionPosition|hpc|onload|class|getBorder|setInterval|oldStyleAttr|rule|rgb|open|minLeft|ActiveXObject|oldDisplay|restoreStyle|getSizeLite||nw|0x||F0|fadeOut|focused|firstChild|while|cssRules|fadeIn|Date|minTop|backgroundColor|sc|nbsp|hash|captionEl|selectKeyHelper|selectCurrent|newTop|init|newLeft|changed|Draggable|inFrontOf|efx|139|onHover|onOut|getTime|np|keydown|split|radiusY|increment|Array|getPositionLite|selectClass|opera|onHighlight|keyCode|charCode|Object|toInteger|frameClass|hasTabsEnabled|zonew|user|zoneh|positionItems|onClick|oD|scrollIntoView|accordionPos|proximity|indic||data|containerSize|sin|iTTabs||ts|ImageBoxPrevImage|ImageBoxNextImage|imageSrc|newPos|maxHeight|minHeight|elS|activeClass|panels|maxBottom|maxRight|ser|move|opened|bounceout|animationInProgress|overlay|stop|reflectionSize|fnc|classname|insideParent|offsetLeft|jEl|nRy|pr|serialize|nRx|tooltipHelper|cssSides|mouseout|select|count|namedColors|padding|offsetTop|directionIncrement|parentEl|400|dir|expand|createTextNode|finishedPre|clientHeight|li|applyOn|content|contBorders|object|parentBorders|alpha|clientWidth|png|gallery|fontWeight|link|yproc|xproc|sx|parent|showImage|selectedone|imgs|onselect|sy|startDrag|cursor|captionClass|onselectstop|getElementById|linksClass|sh|ul|onActivate|isDroppable|nextEl|onDrop|oldTitle|progid|prevslideClass|prevEl|oldPosition|SliderContainer|Image|linkRel|selectKeyUp|selectKeyDown|DXImageTransform|inCache|Microsoft|mouseover|dragstop|diffX|211|nextslideClass|prot|auto|dEs|hidehelper|isDraggable|activeclass|unit|DoFold|unfold|nodeName|startTime|buildWrapper|prev|1px|oldColor|setTimeout|ScrollTo|st|sl|cssText|9999|next|destroyWrapper|opt|diffHeight|diffWidth|exec|hoverclass|image|blind|borderColor|sideEnd|self|key||default|2000|styleSheets|getValues|192|diffY|lnk|reflexions|checkhover|selectcheck|maxRotation|ImageBoxOuterContainer|gradient|panelHeight|childs|headers|ne|hideImage|minWidth|iIndex|itemsText|os|side|iCarousel|5625|1000|itemMinWidth|linksSeparator|setSelectionRange|protectRotation|positionContainer|posx|hoverClass|valToAdd|minchars|helperClass|source|nextImageEl|preventDefault|multiple|headerSelector|DraggableDestroy|getPadding|autofill|handleEl|stopPropagation|prevImageEl|getFieldValues|panelSelector|String|createTextRange|floats|lastSi|shrink|oPad|windowSize|paddingLeftSize|angle|paddingY|paddingX|RegExp|borderRightSize|floatVal|firstStep|pulse|Pulsate|Color|rotationSpeed|paddingBottomSize|remove|parseStyle|getClient|Number|helperSize|bounce|doTab||zoom|borderLeftSize|oBor|paddingRightSize|borderTopSize|paddingTopSize|stopAnim|pValue|borderBottomSize|extraWidth|restricted|autoSize|unselectable|SliderIteration|prepend|clearTimeout|isSlider|oneIsSortable|applyOnHover|tooltipURL|tabindex|draginit|mouse|restoreStyles|sliderSize|sliderPos|parentPos|cancelBubble|autocomplete|inputWidth|oldBorder|dragmove|clnt|sliderEl|returnValue|loaderWidth|idsa|letterSpacing|pause|getContainment|fade|snapToGrid|linear|10000|slideshowHolder|asin|cssSidesEnd|borderWidth|fitToContainer|TEXTAREA|entities|INPUT|spacer|writeItems|character|currentValue|paddings|169|oldFloat|borders|hidefocused|bouncein||modifyContainer|transparent|center|loadImage|func|getMargins|initialPosition|textAlign|innerHeight|Alpha|no|captionImages|closeEl|shake|prevTop|traverseDOM|Selectserialize|stopDrag|slider|ImageBoxCaption|ImageBoxIframe|300|ImageBoxOverlay|sortable|moveDrag|autoplay|measure|prevLeft|intersect|ImageBoxCurrentImage|selectstop|Shake|index|dragEl|keyPressed|scrollHeight|scroll|innerWidth|match|elPosition|scrollWidth|textImage|slideBor|jpg|captionSize|textImageFrom|visible||loaderHeight|ImageBoxCaptionImages||hoverItem|clickItem|emptyGIF||notColor|slideshowCaption|Droppable|goprev|childNodes|autocompleteHelper|autocompleteIframe|slidePad|fit|165|clientSize|||fontFamily|colorCssProps|elType|onhover|cssProps|expanderHelper|boxModel|itransferTo|keypress|moveStart|offsetParent|Width|selectstart|fxe|selectionEnd|checkCache|fontStyle|update|DroppableDestroy|remeasure|fontStretch|fontVariant|onblur|slideshowLoader|htmlEntities|wordSpacing|createRange|224|KhtmlUserSelect||closeHTML|on|sortHelper|245|userSelect|dragHelper|hrefAttr|dragstart|107|loaderSRC|highlight|slideshowPrevslide||gonext||styleFloat|frameborder|javascript|||relAttr|wid|scrolling||onslide|||listStyle|imageTypes|insertBefore|999|textDecoration|sqrt|140|230|maxy|240|ImageBoxContainer|doScroll|interval|set|dragmoveByKey|protect|ImageBoxCaptionText|144|ImageBoxLoader|off|checkdrop|isSelectable|hlt|30px|selectedclass|tooltipTitle|imagebox|shc|overlayOpacity|selRange2|slideshowNextSlide|gif|getSelectionStart|360|iAccordion|getElementsByTagName|iBounce|after|SortableAddItem|onResize|150|itemZIndex|grow|getHeightMinMax|borderTopUnit|selectcheckApply|borderRightUnit|zindex|fontUnit|togglehor|time|se|parte|easeout|isSortable||SlideInUp|fold|SlideOutUp|rgba|addColorStop|yfrac|containerMaxx|interfaceColorFX|containerMaxy||leftUnit|mousex||radiusX|check|getContext|xfrac|addItem|topUnit|fracH|cloneNode|togglever|paddingLeftUnit|borderBottomUnit|finish|onDragStop|onout|posy|isFunction|oldOverflow|directions|vertical|fracW|fakeAccordionClass|parts|fadeTo|inputValue|xml|selectstopApply|slideshowLinks|onDragStart|BlindUp|paddingTopUnit|500|trim|maxx|borderLeftUnit|paddingRightUnit|filteredPosition|BlindDown|paddingBottomUnit|horizontal|valign|find|ImageBoxClose|onselectstart|mozUserSelect|ondragstart|scale|110|globalCompositeOperation|bmp||drawImage|ondrop|password|quot||save|starty|jpeg|||number|startx|finishOpacity|hover|recallDroppables|flipv|finishx|destination|khtml|moz|lt|amp|pW|clientX|Accordion|translate|captiontext|elasticin|slideshowLink|fix|elasticout|resize|elasticboth|bounceboth|984375|9375|Selectable|30002|list|625|30001|nodeValue|before|100000|purgeEvents|substr|duplicate|moveEnd|||substring|success|param|par|array|Fisheye|name|POST|ajax|easeboth|location|fromHandler|collapse|MozUserSelect||ResizableDestroy|rotationTimer|fillRect|fill|WebKit|fillStyle|createLinearGradient|Resizable|navigator|appVersion|lineHeigt|alt|AlphaImageLoader|prototype|SliderGetValues|DisableTabs|Carousel|load|easein|IMG|200|Slider|ToolTip|wh|nextSibling|Autocomplete|SliderSetValues|pageX|float|centerEl|fixPNG|isNaN|dotted|dashed|stopAll|Left|outlineColor|Top|Right|Bottom|solid|double|selectorText|rules|onchange|SlideToggleRight|SlideOutRight||borderStyle||TransferTo||groove|ridge|inset|outset|borderTopColor||borderRightColor|olive|navy|orange||pink|203|maroon||magenta|182|193|lightyellow|lime|purple|red|outlineOffset|outlineWidth|borderBottomColor|borderLeftColor|lineHeight|loading|silver|white|yellow|Showing|100000000|SlideInRight|clientY|Highlight|SortableDestroy|CloseVertically|CloseHorizontally|FoldToggle|UnFold|SlideInDown|SlideToggleUp|SortSerialize|Fold|SwitchHorizontally|SwitchVertically|Sortable|scrollTo|EnableTabs|ScrollToAnchors|pt|Puff|OpenVertically|OpenHorizontally|Grow|Shrink|DropToggleRight|DropInRight|BlindToggleHorizontally|BlindRight|http|Bounce|120|BlindLeft|BlindToggleVertically|SlideToggleLeft|SlideOutLeft|toUpperCase|SlideInLeft|SlideToggleDown|SlideOutDown|DropOutLeft|DropInLeft|DropToggleLeft|DropOutRight|DropToggleUp|DropInUp|DropOutDown|DropInDown|DropToggleDown|DropOutUp|lightpink|textIndent|aqua|appendChild|azure|beige|220|last|cssFloat|first|ol|wrapEl|fxWrapper|black|imageLoaded|darkkhaki|darkgreen|189|183|darkmagenta|firstResize|darkgrey|brown|cyan|darkblue|darkcyan|table|form|col|tfoot|colgroup|th|header|thead|tbody|112|Autoexpand|tr|td|script|frame|input|pageY|textarea|button|w_|removeChild|frameset|option|optgroup|meta|darkolivegreen|blue|122|233|green|lightcyan|204|darkviolet|lightgreen|indigo|216|khaki|darksalmon|130|darkred|lightblue|148|173|215|238|fuchsia|gold|darkorchid|153|darkorange|lightgrey'.split('|'),0,{}))
 
bp-forums/bbpress/bb-login.php CHANGED
@@ -1,148 +1,104 @@
1
  <?php
 
 
2
 
3
- // Load bbPress
4
- require( './bb-load.php' );
5
-
6
- // SSL redirect if required
7
  bb_ssl_redirect();
8
 
9
- // Don't cache this page at all
10
- nocache_headers();
11
-
12
- /** Look for redirection ******************************************************/
13
-
14
- // Look for 'redirect_to'
15
- if ( isset( $_REQUEST['redirect_to'] ) )
16
- $re = $_REQUEST['redirect_to'];
17
-
18
- // Look for 're'
19
- if ( empty( $re ) && isset( $_REQUEST['re'] ) )
20
- $re = $_REQUEST['re'];
21
 
22
- // Use referer
23
- if ( empty( $re ) )
24
- $re = wp_get_referer();
25
 
26
- // Don't redirect to register or password reset pages
27
- if ( empty( $re ) ) {
28
- // Grab home path and URL for comparison
29
- $home_url = parse_url( bb_get_uri( null, null, BB_URI_CONTEXT_TEXT ) );
30
- $home_path = $home_url['path'];
31
 
32
- if ( false !== strpos( $re, $home_path . 'register.php' ) || false !== strpos( $re, $home_path . 'bb-reset-password.php' ) )
33
- $re = bb_get_uri( null, null, BB_URI_CONTEXT_HEADER );
34
- }
35
 
36
- /**
37
- * If this page was accessed using SSL, make sure the redirect is a full URL so
38
- * that we don't end up on an SSL page again (unless the whole site is under SSL)
39
- */
40
- if ( is_ssl() && 0 === strpos( $re, '/' ) )
41
  $re = bb_get_uri( $re , null, BB_URI_CONTEXT_HEADER );
42
-
43
- // Clean the redirection destination
44
- if ( !empty( $re ) ) {
45
- $re = esc_url( $re );
46
- $re = esc_attr( $re );
47
- $redirect_to = $re;
48
  }
49
 
50
- // Fallback to site root
51
- if ( empty( $re ) )
52
- $re = bb_get_uri();
53
-
54
- /** Handle logout *************************************************************/
 
55
 
56
- // User is logged in
57
  if ( bb_is_user_logged_in() ) {
58
-
59
- // Logout requested
60
- if ( isset( $_GET['logout'] ) )
61
- $_GET['action'] = 'logout';
62
-
63
- // Check logout action
64
- if ( isset( $_GET['action'] ) && 'logout' === $_GET['action'] )
65
- bb_logout();
66
-
67
  bb_safe_redirect( $re );
68
  exit;
69
  }
70
 
71
- /** Handle login **************************************************************/
72
-
73
- // Do we allow login by email address
74
- $email_login = bb_get_option( 'email_login' );
75
-
76
- // Get the user from the login details
77
- if ( empty( $_POST['log'] ) )
78
- $_POST['log'] = !empty( $_POST['user_login'] ) ? $_POST['user_login'] : '';
79
-
80
- if ( empty( $_POST['pwd'] ) )
81
- $_POST['pwd'] = !empty( $_POST['password'] ) ? $_POST['password'] : '';
82
 
83
- if ( empty( $_POST['rememberme'] ) )
84
- $_POST['rememberme'] = !empty( $_POST['remember'] ) ? 1 : '';
85
-
86
- // Attempt to log the user in
87
- if ( $user = bb_login( @$_POST['log'], @$_POST['pwd'], @$_POST['rememberme'] ) ) {
88
- if ( !is_wp_error( $user ) ) {
89
- bb_safe_redirect( $re );
90
- exit;
91
- } else {
92
- $bb_login_error =& $user;
93
- }
94
 
95
- // No login so prepare the error
 
 
96
  } else {
97
  $bb_login_error = new WP_Error;
98
  }
99
 
100
- /** Handle errors *************************************************************/
 
101
 
102
- // Get error data so we can provide feedback
103
  $error_data = $bb_login_error->get_error_data();
104
-
105
- // Does user actually exist
106
- if ( isset( $error_data['unique'] ) && false === $error_data['unique'] )
107
  $user_exists = true;
108
- else
109
- $user_exists = !empty( $_POST['log'] ) && (bool) bb_get_user( $_POST['log'], array( 'by' => 'login' ) );
 
 
110
 
111
- // Check for errors on post method
112
  if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) ) {
113
-
114
- // If the user doesn't exist then add that error
115
- if ( empty( $user_exists ) ) {
116
- if ( !empty( $_POST['log'] ) ) {
117
  $bb_login_error->add( 'user_login', __( 'User does not exist.' ) );
118
  } else {
119
  $bb_login_error->add( 'user_login', $email_login ? __( 'Enter a username or email address.' ) : __( 'Enter a username.' ) );
120
  }
121
  }
122
 
123
- // If the password was wrong then add that error
124
  if ( !$bb_login_error->get_error_code() ) {
125
  $bb_login_error->add( 'password', __( 'Incorrect password.' ) );
126
  }
127
  }
128
 
129
- /**
130
- * If trying to log in with email address, don't leak whether or not email
131
- * address exists in the db. is_email() is not perfect. Usernames can be
132
- * valid email addresses potentially.
133
- */
134
- if ( !empty( $email_login ) && $bb_login_error->get_error_codes() && false !== is_email( @$_POST['log'] ) )
135
  $bb_login_error = new WP_Error( 'user_login', __( 'Username and Password do not match.' ) );
 
136
 
137
- /** Prepare for display *******************************************************/
138
-
139
- // Sanitze variables for display
140
- $remember_checked = @$_POST['rememberme'] ? ' checked="checked"' : '';
141
- $user_login = esc_attr( sanitize_user( @$_POST['log'], true ) );
142
 
143
- // Load the template
144
  bb_load_template( 'login.php', array( 'user_exists', 'user_login', 'remember_checked', 'redirect_to', 're', 'bb_login_error' ) );
145
-
146
  exit;
147
-
148
- ?>
1
  <?php
2
+ // Load bbPress.
3
+ require('./bb-load.php');
4
 
5
+ // Redirect to an SSL page if required.
 
 
 
6
  bb_ssl_redirect();
7
 
8
+ // Get the referer.
9
+ $ref = wp_get_referer();
10
+ if ( !$re = $_POST['re'] ? $_POST['re'] : $_GET['re'] ) {
11
+ $re = $ref;
12
+ }
 
 
 
 
 
 
 
13
 
14
+ // Grab the URL for comparison.
15
+ $home_url = parse_url( bb_get_uri( null, null, BB_URI_CONTEXT_TEXT ) );
16
+ $home_path = $home_url['path'];
17
 
18
+ // Don't ever redirect to the register page or the password reset page.
19
+ if ( !$re || false !== strpos( $re, $home_path . 'register.php' ) || false !== strpos( $re, $home_path . 'bb-reset-password.php' ) ) {
20
+ $re = bb_get_uri( null, null, BB_URI_CONTEXT_HEADER );
21
+ }
 
22
 
23
+ // Don't cache this page at all.
24
+ nocache_headers();
 
25
 
26
+ // If this page was accessed using SSL, make sure the redirect is a full URL
27
+ // so that we don't end up on an SSL page again (unless the whole site is
28
+ // under SSL).
29
+ if ( is_ssl() && 0 === strpos( $re, '/' ) ) {
 
30
  $re = bb_get_uri( $re , null, BB_URI_CONTEXT_HEADER );
 
 
 
 
 
 
31
  }
32
 
33
+ // Logout requested.
34
+ if ( isset( $_GET['logout'] ) ) {
35
+ bb_logout();
36
+ bb_safe_redirect( $re );
37
+ exit;
38
+ }
39
 
40
+ // User is already logged in.
41
  if ( bb_is_user_logged_in() ) {
 
 
 
 
 
 
 
 
 
42
  bb_safe_redirect( $re );
43
  exit;
44
  }
45
 
46
+ // Get the user from the login details.
47
+ $user = bb_login( @$_POST['user_login'], @$_POST['password'], @$_POST['remember'] );
 
 
 
 
 
 
 
 
 
48
 
49
+ // User logged in successfully.
50
+ if ( $user && !is_wp_error( $user ) ) {
51
+ bb_safe_redirect( $re );
52
+ exit;
53
+ }
 
 
 
 
 
 
54
 
55
+ // Grab the error returned if there is one.
56
+ if ( is_wp_error( $user ) ) {
57
+ $bb_login_error =& $user;
58
  } else {
59
  $bb_login_error = new WP_Error;
60
  }
61
 
62
+ // Whether we allow login by email address or not.
63
+ $email_login = bb_get_option( 'email_login' );
64
 
65
+ // Find out if the user actually exists.
66
  $error_data = $bb_login_error->get_error_data();
67
+ if ( isset( $error_data['unique'] ) && false === $error_data['unique'] ) {
 
 
68
  $user_exists = true;
69
+ } else {
70
+ $user_exists = isset( $_POST['user_login'] ) && $_POST['user_login'] && (bool) bb_get_user( $_POST['user_login'], array( 'by' => 'login' ) );
71
+ }
72
+ unset( $error_data );
73
 
 
74
  if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) ) {
75
+ // If the user doesn't exist then add that error.
76
+ if ( !$user_exists ) {
77
+ if ( isset( $_POST['user_login'] ) && $_POST['user_login'] ) {
 
78
  $bb_login_error->add( 'user_login', __( 'User does not exist.' ) );
79
  } else {
80
  $bb_login_error->add( 'user_login', $email_login ? __( 'Enter a username or email address.' ) : __( 'Enter a username.' ) );
81
  }
82
  }
83
 
84
+ // If the password was wrong then add that error.
85
  if ( !$bb_login_error->get_error_code() ) {
86
  $bb_login_error->add( 'password', __( 'Incorrect password.' ) );
87
  }
88
  }
89
 
90
+ // If trying to log in with email address, don't leak whether or not email address exists in the db.
91
+ // is_email() is not perfect, usernames can be valid email addresses potentially.
92
+ if ( $email_login && $bb_login_error->get_error_codes() && false !== is_email( $_POST['user_login'] ) ) {
 
 
 
93
  $bb_login_error = new WP_Error( 'user_login', __( 'Username and Password do not match.' ) );
94
+ }
95
 
96
+ // Sanitze variables for display.
97
+ $user_login = esc_attr( sanitize_user( @$_POST['user_login'], true ) );
98
+ $remember_checked = @$_POST['remember'] ? ' checked="checked"' : '';
99
+ $re = esc_url( $re );
100
+ $re = $redirect_to = esc_attr( $re );
101
 
102
+ // Load the template.
103
  bb_load_template( 'login.php', array( 'user_exists', 'user_login', 'remember_checked', 'redirect_to', 're', 'bb_login_error' ) );
 
104
  exit;
 
 
bp-forums/bbpress/bb-templates/kakumei-blue/style.css CHANGED
@@ -22,8 +22,6 @@ input#tagformsub:active { border-color: #001364; }
22
  .sticky { background: #adb9e1; }
23
  #thread li.pingback { background-color: #d8dcf2; border-color: #d8dcf2; }
24
  #thread li.pingback .threadpost { background-color: #d8dcf2; }
25
- #topic-move input { color: #32689b; }
26
- #topic-move input:hover { color: #001364; }
27
  #latest tr:hover, #forumlist tr:hover, #favorites tr:hover { background: #d8dcf2; }
28
  #profile-menu li a:hover { background: #d8dcf2; }
29
  a.prev.page-numbers:hover, a.next.page-numbers:hover { color: #001364; }
22
  .sticky { background: #adb9e1; }
23
  #thread li.pingback { background-color: #d8dcf2; border-color: #d8dcf2; }
24
  #thread li.pingback .threadpost { background-color: #d8dcf2; }
 
 
25
  #latest tr:hover, #forumlist tr:hover, #favorites tr:hover { background: #d8dcf2; }
26
  #profile-menu li a:hover { background: #d8dcf2; }
27
  a.prev.page-numbers:hover, a.next.page-numbers:hover { color: #001364; }
bp-forums/bbpress/bb-templates/kakumei/favorites.php CHANGED
@@ -29,7 +29,7 @@
29
  <td class="num"><?php topic_posts(); ?></td>
30
  <!-- <td class="num"><?php bb_topic_voices(); ?></td> -->
31
  <td class="num"><?php topic_last_poster(); ?></td>
32
- <td class="num"><a href="<?php topic_last_post_link(); ?>" title="<?php topic_time(array('format'=>'datetime')); ?>"><?php topic_time(); ?></a></td>
33
  <?php if ( bb_current_user_can( 'edit_favorites_of', $user_id ) ) : ?>
34
  <td class="num">[<?php user_favorites_link('', array('mid'=>'&times;'), $user_id); ?>]</td>
35
  <?php endif; ?>
29
  <td class="num"><?php topic_posts(); ?></td>
30
  <!-- <td class="num"><?php bb_topic_voices(); ?></td> -->
31
  <td class="num"><?php topic_last_poster(); ?></td>
32
+ <td class="num"><a href="<?php topic_last_post_link(); ?>"><?php topic_time(); ?></a></td>
33
  <?php if ( bb_current_user_can( 'edit_favorites_of', $user_id ) ) : ?>
34
  <td class="num">[<?php user_favorites_link('', array('mid'=>'&times;'), $user_id); ?>]</td>
35
  <?php endif; ?>
bp-forums/bbpress/bb-templates/kakumei/forum.php CHANGED
@@ -19,7 +19,7 @@
19
  <td class="num"><?php topic_posts(); ?></td>
20
  <!-- <td class="num"><?php bb_topic_voices(); ?></td> -->
21
  <td class="num"><?php topic_last_poster(); ?></td>
22
- <td class="num"><a href="<?php topic_last_post_link(); ?>" title="<?php topic_time(array('format'=>'datetime')); ?>"><?php topic_time(); ?></a></td>
23
  </tr>
24
  <?php endforeach; endif; ?>
25
 
@@ -29,7 +29,7 @@
29
  <td class="num"><?php topic_posts(); ?></td>
30
  <!-- <td class="num"><?php bb_topic_voices(); ?></td> -->
31
  <td class="num"><?php topic_last_poster(); ?></td>
32
- <td class="num"><a href="<?php topic_last_post_link(); ?>" title="<?php topic_time(array('format'=>'datetime')); ?>"><?php topic_time(); ?></a></td>
33
  </tr>
34
  <?php endforeach; endif; ?>
35
  </table>
19
  <td class="num"><?php topic_posts(); ?></td>
20
  <!-- <td class="num"><?php bb_topic_voices(); ?></td> -->
21
  <td class="num"><?php topic_last_poster(); ?></td>
22
+ <td class="num"><a href="<?php topic_last_post_link(); ?>"><?php topic_time(); ?></a></td>
23
  </tr>
24
  <?php endforeach; endif; ?>
25
 
29
  <td class="num"><?php topic_posts(); ?></td>
30
  <!-- <td class="num"><?php bb_topic_voices(); ?></td> -->
31
  <td class="num"><?php topic_last_poster(); ?></td>
32
+ <td class="num"><a href="<?php topic_last_post_link(); ?>"><?php topic_time(); ?></a></td>
33
  </tr>
34
  <?php endforeach; endif; ?>
35
  </table>
bp-forums/bbpress/bb-templates/kakumei/front-page.php CHANGED
@@ -27,7 +27,7 @@
27
  <td class="num"><?php topic_posts(); ?></td>
28
  <!-- <td class="num"><?php bb_topic_voices(); ?></td> -->
29
  <td class="num"><?php topic_last_poster(); ?></td>
30
- <td class="num"><a href="<?php topic_last_post_link(); ?>" title="<?php topic_time(array('format'=>'datetime')); ?>"><?php topic_time(); ?></a></td>
31
  </tr>
32
  <?php endforeach; endif; // $super_stickies ?>
33
 
@@ -37,7 +37,7 @@
37
  <td class="num"><?php topic_posts(); ?></td>
38
  <!-- <td class="num"><?php bb_topic_voices(); ?></td> -->
39
  <td class="num"><?php topic_last_poster(); ?></td>
40
- <td class="num"><a href="<?php topic_last_post_link(); ?>" title="<?php topic_time(array('format'=>'datetime')); ?>"><?php topic_time(); ?></a></td>
41
  </tr>
42
  <?php endforeach; endif; // $topics ?>
43
  </table>
27
  <td class="num"><?php topic_posts(); ?></td>
28
  <!-- <td class="num"><?php bb_topic_voices(); ?></td> -->
29
  <td class="num"><?php topic_last_poster(); ?></td>
30
+ <td class="num"><a href="<?php topic_last_post_link(); ?>"><?php topic_time(); ?></a></td>
31
  </tr>
32
  <?php endforeach; endif; // $super_stickies ?>
33
 
37
  <td class="num"><?php topic_posts(); ?></td>
38
  <!-- <td class="num"><?php bb_topic_voices(); ?></td> -->
39
  <td class="num"><?php topic_last_poster(); ?></td>
40
+ <td class="num"><a href="<?php topic_last_post_link(); ?>"><?php topic_time(); ?></a></td>
41
  </tr>
42
  <?php endforeach; endif; // $topics ?>
43
  </table>
bp-forums/bbpress/bb-templates/kakumei/post-form.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php if ( !bb_is_topic() ) : ?>
2
  <p id="post-form-title-container">
3
  <label for="topic"><?php _e('Title'); ?>
4
- <input name="topic" type="text" id="topic" size="50" maxlength="100" tabindex="1" />
5
  </label>
6
  </p>
7
  <?php endif; do_action( 'post_form_pre_post' ); ?>
@@ -11,7 +11,7 @@
11
  </label>
12
  </p>
13
  <p id="post-form-tags-container">
14
- <label for="tags-input"><?php printf(__('Tags (comma separated)'), bb_get_tag_page_link()) ?>
15
  <input id="tags-input" name="tags" type="text" size="50" maxlength="100" value="<?php bb_tag_name(); ?>" tabindex="4" />
16
  </label>
17
  </p>
1
  <?php if ( !bb_is_topic() ) : ?>
2
  <p id="post-form-title-container">
3
  <label for="topic"><?php _e('Title'); ?>
4
+ <input name="topic" type="text" id="topic" size="50" maxlength="80" tabindex="1" />
5
  </label>
6
  </p>
7
  <?php endif; do_action( 'post_form_pre_post' ); ?>
11
  </label>
12
  </p>
13
  <p id="post-form-tags-container">
14
+ <label for="tags-input"><?php printf(__('Tags (comma seperated)'), bb_get_tag_page_link()) ?>
15
  <input id="tags-input" name="tags" type="text" size="50" maxlength="100" value="<?php bb_tag_name(); ?>" tabindex="4" />
16
  </label>
17
  </p>
bp-forums/bbpress/bb-templates/kakumei/style.css CHANGED
@@ -644,22 +644,7 @@ a.rss-link {
644
  background-position: 0 50%;
645
  }
646
 
647
- #topic-move,
648
- #topic-move fieldset,
649
- #topic-move fieldset div {
650
- display: inline;
651
- }
652
-
653
- #topic-move input {
654
- font-family: inherit;
655
- background: none;
656
- border: none;
657
- cursor: pointer;
658
- color: #2e6e15;
659
- font-size: 1em;
660
- }
661
-
662
- #topic-move input:hover { color: #006400; }
663
 
664
  /* Other
665
  =================================== */
644
  background-position: 0 50%;
645
  }
646
 
647
+ #topic-move { margin-top: 1em; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
648
 
649
  /* Other
650
  =================================== */
bp-forums/bbpress/bb-templates/kakumei/tag-single.php CHANGED
@@ -21,7 +21,7 @@
21
  <td class="num"><?php topic_posts(); ?></td>
22
  <!-- <td class="num"><?php bb_topic_voices(); ?></td> -->
23
  <td class="num"><?php topic_last_poster(); ?></td>
24
- <td class="num"><a href="<?php topic_last_post_link(); ?>" title="<?php topic_time(array('format'=>'datetime')); ?>"><?php topic_time(); ?></a></td>
25
  </tr>
26
  <?php endforeach; ?>
27
  </table>
21
  <td class="num"><?php topic_posts(); ?></td>
22
  <!-- <td class="num"><?php bb_topic_voices(); ?></td> -->
23
  <td class="num"><?php topic_last_poster(); ?></td>
24
+ <td class="num"><a href="<?php topic_last_post_link(); ?>"><?php topic_time(); ?></a></td>
25
  </tr>
26
  <?php endforeach; ?>
27
  </table>
bp-forums/bbpress/bb-templates/kakumei/view.php CHANGED
@@ -19,7 +19,7 @@
19
  <td class="num"><?php topic_posts(); ?></td>
20
  <!-- <td class="num"><?php bb_topic_voices(); ?></td> -->
21
  <td class="num"><?php topic_last_poster(); ?></td>
22
- <td class="num"><a href="<?php topic_last_post_link(); ?>" title="<?php topic_time(array('format'=>'datetime')); ?>"><?php topic_time(); ?></a></td>
23
  </tr>
24
  <?php endforeach; endif; ?>
25
 
@@ -29,7 +29,7 @@
29
  <td class="num"><?php topic_posts(); ?></td>
30
  <!-- <td class="num"><?php bb_topic_voices(); ?></td> -->
31
  <td class="num"><?php topic_last_poster(); ?></td>
32
- <td class="num"><a href="<?php topic_last_post_link(); ?>" title="<?php topic_time(array('format'=>'datetime')); ?>"><?php topic_time(); ?></a></td>
33
  </tr>
34
  <?php endforeach; endif; ?>
35
  </table>
19
  <td class="num"><?php topic_posts(); ?></td>
20
  <!-- <td class="num"><?php bb_topic_voices(); ?></td> -->
21
  <td class="num"><?php topic_last_poster(); ?></td>
22
+ <td class="num"><a href="<?php topic_last_post_link(); ?>"><?php topic_time(); ?></a></td>
23
  </tr>
24
  <?php endforeach; endif; ?>
25
 
29
  <td class="num"><?php topic_posts(); ?></td>
30
  <!-- <td class="num"><?php bb_topic_voices(); ?></td> -->
31
  <td class="num"><?php topic_last_poster(); ?></td>
32
+ <td class="num"><a href="<?php topic_last_post_link(); ?>"><?php topic_time(); ?></a></td>
33
  </tr>
34
  <?php endforeach; endif; ?>
35
  </table>
bp-forums/bbpress/rss.php CHANGED
@@ -108,7 +108,7 @@ if ( !$bb_db_override ) {
108
  if ( !$posts = get_user_favorites( $user->ID ) ) {
109
  die();
110
  }
111
- $title = esc_html( sprintf( __( '%1$s &raquo; User Favorites: %2$s' ), bb_get_option( 'name' ), $user->user_nicename ) );
112
  $link = bb_get_profile_link($feed_id);
113
  $link_self = get_favorites_rss_link($feed_id);
114
  break;
108
  if ( !$posts = get_user_favorites( $user->ID ) ) {
109
  die();
110
  }
111
+ $title = esc_html( sprintf( __( '%1$s &raquo; User Favorites: %2$s' ), bb_get_option( 'name' ), $user->user_login ) );
112
  $link = bb_get_profile_link($feed_id);
113
  $link_self = get_favorites_rss_link($feed_id);
114
  break;
bp-forums/bp-forums-admin.php CHANGED
@@ -1,12 +1,12 @@
1
  <?php
2
 
3
- function bp_forums_bbpress_admin() {
4
  global $bp;
5
  ?>
6
  <div class="wrap">
7
 
8
  <h2><?php _e( 'Forums Setup', 'buddypress' ) ?></h2>
9
-
10
  <?php if ( isset( $_POST['submit'] ) ) : ?>
11
  <div id="message" class="updated fade">
12
  <p><?php _e( 'Settings Saved.', 'buddypress' ) ?></p>
@@ -14,24 +14,24 @@ function bp_forums_bbpress_admin() {
14
  <?php endif; ?>
15
 
16
  <?php
17
-
18
  if ( isset( $_REQUEST['reinstall'] ) || !bp_forums_is_installed_correctly() ) {
19
  update_site_option( 'bb-config-location', false );
20
  bp_forums_bbpress_install_wizard();
21
  } else { ?>
22
  <p><?php printf( __( 'bbPress forum integration in BuddyPress has been set up correctly. If you are having problems you can <a href="%s" title="Reinstall bbPress">re-install</a>', 'buddypress' ), site_url( 'wp-admin/admin.php?page=bb-forums-setup&reinstall=1' ) ); ?>
23
  <p><?php _e( 'NOTE: The forums directory will only work if your bbPress tables are in the same database as your WordPress tables. If you are not using an existing bbPress install you can ignore this message.', 'buddypress' ) ?></p>
24
- <?php
25
  }
26
  ?>
27
  </div>
28
  <?php
29
  }
30
 
31
- function bp_forums_bbpress_install_wizard() {
32
  $post_url = site_url( 'wp-admin/admin.php?page=bb-forums-setup' );
33
 
34
- switch( $_REQUEST['step'] ) {
35
  case 'existing':
36
  if ( 1 == (int)$_REQUEST['doinstall'] ) {
37
  if ( !bp_forums_configure_existing_install() ) {
@@ -52,17 +52,17 @@ function bp_forums_bbpress_install_wizard() {
52
  <input type="hidden" name="doinstall" value="1" />
53
  <?php wp_nonce_field( 'bp_forums_existing_install_init' ) ?>
54
  </form>
55
- <?php
56
  }
57
  break;
58
-
59
  case 'new':
60
  if ( 1 == (int)$_REQUEST['doinstall'] ) {
61
  $result = bp_forums_bbpress_install();
62
-
63
  switch ( $result ) {
64
  case 1:
65
- _e( 'All done! Configuration settings have been saved to the file <code>bb-config.php</code> in the root of your WordPress install.' );
66
  break;
67
  default:
68
  // Just write the contents to screen
@@ -79,36 +79,36 @@ function bp_forums_bbpress_install_wizard() {
79
  <?php
80
  }
81
  break;
82
-
83
- default:
84
  if ( !file_exists( BP_PLUGIN_DIR . '/bp-forums/bbpress/' ) ) { ?>
85
  <div id="message" class="error">
86
  <p><?php printf( __( 'bbPress files were not found. To install the forums component you must download a copy of bbPress and make sure it is in the folder: "%s"', 'buddypress' ), 'wp-content/plugins/buddypress/bp-forums/bbpress/' ) ?></p>
87
  </div>
88
  <?php } else { ?>
89
-
90
  <p><?php _e( 'Forums in BuddyPress make use of a bbPress installation to function. You can choose to either let BuddyPress set up a new bbPress install, or use an already existing bbPress install. Please choose one of the options below.', 'buddypress' ) ?></p>
91
-
92
  <a class="button" href="<?php echo $post_url . '&step=new' ?>"><?php _e( 'Set up a new bbPress installation', 'buddypress' ) ?></a> &nbsp;
93
  <a class="button" href="<?php echo $post_url . '&step=existing' ?>"><?php _e( 'Use an existing bbPress installation', 'buddypress' ) ?></a>
94
 
95
- <?php }
96
  break;
97
  }
98
  }
99
 
100
  function bp_forums_configure_existing_install() {
101
  global $wpdb, $bbdb;
102
-
103
  check_admin_referer( 'bp_forums_existing_install_init' );
104
-
105
  /* Sanitize $_REQUEST['bbconfigloc'] */
106
  $_REQUEST['bbconfigloc'] = apply_filters( 'bp_forums_bbconfig_location', $_REQUEST['bbconfigloc'] );
107
-
108
  if ( false === strpos( $_REQUEST['bbconfigloc'], 'bb-config.php' ) ) {
109
  if ( '/' != substr( $_REQUEST['bbconfigloc'], -1, 1 ) )
110
  $_REQUEST['bbconfigloc'] .= '/';
111
-
112
  $_REQUEST['bbconfigloc'] .= 'bb-config.php';
113
  }
114
 
@@ -116,13 +116,13 @@ function bp_forums_configure_existing_install() {
116
  return false;
117
 
118
  update_site_option( 'bb-config-location', $_REQUEST['bbconfigloc'] );
119
-
120
  return true;
121
  }
122
 
123
  function bp_forums_bbpress_install() {
124
  global $wpdb, $bbdb;
125
-
126
  check_admin_referer( 'bp_forums_new_install_init' );
127
 
128
  /* Create the bb-config.php file */
@@ -144,7 +144,7 @@ function bp_forums_bbpress_install() {
144
  "define( 'BB_LANG', '" => array( "''", "'" . WPLANG . "'" )
145
  )
146
  );
147
-
148
  /* Add the custom user and usermeta entries to the config file */
149
  if ( $initial_write == 1 ) {
150
  $file = file_get_contents( ABSPATH . 'bb-config.php' );
@@ -153,17 +153,17 @@ function bp_forums_bbpress_install() {
153
  }
154
 
155
  $file = substr( $file, 0, -2 );
156
- $file .= "\n" . '$bb->custom_user_table = "' . $wpdb->users . '";';
157
  $file .= "\n" . '$bb->custom_user_meta_table = "' . $wpdb->usermeta . '";';
158
  $file .= "\n\n" . '$bb->uri = "' . BP_PLUGIN_URL . '/bp-forums/bbpress/";';
159
  $file .= "\n" . '$bb->name = "' . get_blog_option( BP_ROOT_BLOG, 'name' ) . ' ' . __( 'Forums', 'buddypress' ) . '";';
160
  $file .= "\n" . '$bb->wordpress_mu_primary_blog_id = ' . BP_ROOT_BLOG . ';';
161
- $file .= "\n\n" . 'define(\'BB_AUTH_SALT\', "' . AUTH_SALT . '");';
162
- $file .= "\n" . 'define(\'BB_LOGGED_IN_SALT\', "' . LOGGED_IN_SALT . '");';
163
- $file .= "\n" . 'define(\'BB_SECURE_AUTH_SALT\', "' . SECURE_AUTH_SALT . '");';
164
- $file .= "\n\n" . 'define(\'WP_AUTH_COOKIE_VERSION\', 2);';
165
  $file .= "\n\n" . '?>';
166
-
167
  if ( $initial_write == 1 ) {
168
  $file_handle = fopen( ABSPATH . 'bb-config.php', 'w' );
169
  fwrite( $file_handle, $file );
@@ -188,7 +188,7 @@ function bp_forums_bbpress_write( $file_source, $file_target, $alterations ) {
188
  if ( !$alterations || !is_array( $alterations ) ) {
189
  return -2;
190
  }
191
-
192
  // Get the existing lines in the file
193
  $lines = file( $file_source );
194
 
@@ -204,7 +204,7 @@ function bp_forums_bbpress_write( $file_source, $file_target, $alterations ) {
204
  $modified_lines[] = $line;
205
  }
206
  }
207
-
208
  $writable = true;
209
  if ( file_exists( $file_target ) ) {
210
  if ( !is_writable( $file_target ) ) {
1
  <?php
2
 
3
+ function bp_forums_bbpress_admin() {
4
  global $bp;
5
  ?>
6
  <div class="wrap">
7
 
8
  <h2><?php _e( 'Forums Setup', 'buddypress' ) ?></h2>
9
+
10
  <?php if ( isset( $_POST['submit'] ) ) : ?>
11
  <div id="message" class="updated fade">
12
  <p><?php _e( 'Settings Saved.', 'buddypress' ) ?></p>
14
  <?php endif; ?>
15
 
16
  <?php
17
+
18
  if ( isset( $_REQUEST['reinstall'] ) || !bp_forums_is_installed_correctly() ) {
19
  update_site_option( 'bb-config-location', false );
20
  bp_forums_bbpress_install_wizard();
21
  } else { ?>
22
  <p><?php printf( __( 'bbPress forum integration in BuddyPress has been set up correctly. If you are having problems you can <a href="%s" title="Reinstall bbPress">re-install</a>', 'buddypress' ), site_url( 'wp-admin/admin.php?page=bb-forums-setup&reinstall=1' ) ); ?>
23
  <p><?php _e( 'NOTE: The forums directory will only work if your bbPress tables are in the same database as your WordPress tables. If you are not using an existing bbPress install you can ignore this message.', 'buddypress' ) ?></p>
24
+ <?php
25
  }
26
  ?>
27
  </div>
28
  <?php
29
  }
30
 
31
+ function bp_forums_bbpress_install_wizard() {
32
  $post_url = site_url( 'wp-admin/admin.php?page=bb-forums-setup' );
33
 
34
+ switch( $_REQUEST['step'] ) {
35
  case 'existing':
36
  if ( 1 == (int)$_REQUEST['doinstall'] ) {
37
  if ( !bp_forums_configure_existing_install() ) {
52
  <input type="hidden" name="doinstall" value="1" />
53
  <?php wp_nonce_field( 'bp_forums_existing_install_init' ) ?>
54
  </form>
55
+ <?php
56
  }
57
  break;
58
+
59
  case 'new':
60
  if ( 1 == (int)$_REQUEST['doinstall'] ) {
61
  $result = bp_forums_bbpress_install();
62
+
63
  switch ( $result ) {
64
  case 1:
65
+ _e( 'All done! Configuration settings have been saved to the file <code>bb-config.php</code> in the root of your WordPress install.', 'buddypress' );
66
  break;
67
  default:
68
  // Just write the contents to screen
79
  <?php
80
  }
81
  break;
82
+
83
+ default:
84
  if ( !file_exists( BP_PLUGIN_DIR . '/bp-forums/bbpress/' ) ) { ?>
85
  <div id="message" class="error">
86
  <p><?php printf( __( 'bbPress files were not found. To install the forums component you must download a copy of bbPress and make sure it is in the folder: "%s"', 'buddypress' ), 'wp-content/plugins/buddypress/bp-forums/bbpress/' ) ?></p>
87
  </div>
88
  <?php } else { ?>
89
+
90
  <p><?php _e( 'Forums in BuddyPress make use of a bbPress installation to function. You can choose to either let BuddyPress set up a new bbPress install, or use an already existing bbPress install. Please choose one of the options below.', 'buddypress' ) ?></p>
91
+
92
  <a class="button" href="<?php echo $post_url . '&step=new' ?>"><?php _e( 'Set up a new bbPress installation', 'buddypress' ) ?></a> &nbsp;
93
  <a class="button" href="<?php echo $post_url . '&step=existing' ?>"><?php _e( 'Use an existing bbPress installation', 'buddypress' ) ?></a>
94
 
95
+ <?php }
96
  break;
97
  }
98
  }
99
 
100
  function bp_forums_configure_existing_install() {
101
  global $wpdb, $bbdb;
102
+
103
  check_admin_referer( 'bp_forums_existing_install_init' );
104
+
105
  /* Sanitize $_REQUEST['bbconfigloc'] */
106
  $_REQUEST['bbconfigloc'] = apply_filters( 'bp_forums_bbconfig_location', $_REQUEST['bbconfigloc'] );
107
+
108
  if ( false === strpos( $_REQUEST['bbconfigloc'], 'bb-config.php' ) ) {
109
  if ( '/' != substr( $_REQUEST['bbconfigloc'], -1, 1 ) )
110
  $_REQUEST['bbconfigloc'] .= '/';
111
+
112
  $_REQUEST['bbconfigloc'] .= 'bb-config.php';
113
  }
114
 
116
  return false;
117
 
118
  update_site_option( 'bb-config-location', $_REQUEST['bbconfigloc'] );
119
+
120
  return true;
121
  }
122
 
123
  function bp_forums_bbpress_install() {
124
  global $wpdb, $bbdb;
125
+
126
  check_admin_referer( 'bp_forums_new_install_init' );
127
 
128
  /* Create the bb-config.php file */
144
  "define( 'BB_LANG', '" => array( "''", "'" . WPLANG . "'" )
145
  )
146
  );
147
+
148
  /* Add the custom user and usermeta entries to the config file */
149
  if ( $initial_write == 1 ) {
150
  $file = file_get_contents( ABSPATH . 'bb-config.php' );
153
  }
154
 
155
  $file = substr( $file, 0, -2 );
156
+ $file .= "\n" . '$bb->custom_user_table = "' . $wpdb->users . '";';
157
  $file .= "\n" . '$bb->custom_user_meta_table = "' . $wpdb->usermeta . '";';
158
  $file .= "\n\n" . '$bb->uri = "' . BP_PLUGIN_URL . '/bp-forums/bbpress/";';
159
  $file .= "\n" . '$bb->name = "' . get_blog_option( BP_ROOT_BLOG, 'name' ) . ' ' . __( 'Forums', 'buddypress' ) . '";';
160
  $file .= "\n" . '$bb->wordpress_mu_primary_blog_id = ' . BP_ROOT_BLOG . ';';
161
+ $file .= "\n\n" . 'define(\'BB_AUTH_SALT\', "' . AUTH_SALT . '");';
162
+ $file .= "\n" . 'define(\'BB_LOGGED_IN_SALT\', "' . LOGGED_IN_SALT . '");';
163
+ $file .= "\n" . 'define(\'BB_SECURE_AUTH_SALT\', "' . SECURE_AUTH_SALT . '");';
164
+ $file .= "\n\n" . 'define(\'WP_AUTH_COOKIE_VERSION\', 2);';
165
  $file .= "\n\n" . '?>';
166
+
167
  if ( $initial_write == 1 ) {
168
  $file_handle = fopen( ABSPATH . 'bb-config.php', 'w' );
169
  fwrite( $file_handle, $file );
188
  if ( !$alterations || !is_array( $alterations ) ) {
189
  return -2;
190
  }
191
+
192
  // Get the existing lines in the file
193
  $lines = file( $file_source );
194
 
204
  $modified_lines[] = $line;
205
  }
206
  }
207
+
208
  $writable = true;
209
  if ( file_exists( $file_target ) ) {
210
  if ( !is_writable( $file_target ) ) {
bp-forums/bp-forums-bbpress.php CHANGED
@@ -4,14 +4,14 @@ function bp_forums_load_bbpress() {
4
  global $bp, $wpdb, $wp_roles, $current_user, $wp_users_object;
5
  global $bb, $bbdb, $bb_table_prefix, $bb_current_user;
6
  global $bb_roles, $wp_taxonomy_object;
7
-
8
  /* Return if we've already run this function. */
9
  if ( is_object( $bbdb ) && is_object( $bb_roles ) )
10
  return;
11
-
12
  if ( !bp_forums_is_installed_correctly() )
13
  return false;
14
-
15
  define( 'BB_PATH', BP_PLUGIN_DIR . '/bp-forums/bbpress/' );
16
  define( 'BACKPRESS_PATH', BP_PLUGIN_DIR . '/bp-forums/bbpress/bb-includes/backpress/' );
17
  define( 'BB_URL', BP_PLUGIN_URL . '/bp-forums/bbpress/' );
@@ -19,7 +19,7 @@ function bp_forums_load_bbpress() {
19
 
20
  require_once( BB_PATH . BB_INC . 'class.bb-query.php' );
21
  require_once( BB_PATH . BB_INC . 'class.bb-walker.php' );
22
-
23
  require_once( BB_PATH . BB_INC . 'functions.bb-core.php' );
24
  require_once( BB_PATH . BB_INC . 'functions.bb-forums.php' );
25
  require_once( BB_PATH . BB_INC . 'functions.bb-topics.php' );
@@ -30,16 +30,16 @@ function bp_forums_load_bbpress() {
30
  require_once( BB_PATH . BB_INC . 'functions.bb-pluggable.php' );
31
  require_once( BB_PATH . BB_INC . 'functions.bb-formatting.php' );
32
  require_once( BB_PATH . BB_INC . 'functions.bb-template.php' );
33
-
34
  require_once( BACKPRESS_PATH . 'class.wp-taxonomy.php' );
35
  require_once( BB_PATH . BB_INC . 'class.bb-taxonomy.php' );
36
-
37
  $bb = new stdClass();
38
  require_once( $bp->forums->bbconfig );
39
 
40
  // Setup the global database connection
41
  $bbdb = new BPDB ( BBDB_USER, BBDB_PASSWORD, BBDB_NAME, BBDB_HOST );
42
-
43
  /* Set the table names */
44
  $bbdb->forums = $bb_table_prefix . 'forums';
45
  $bbdb->meta = $bb_table_prefix . 'meta';
@@ -48,17 +48,17 @@ function bp_forums_load_bbpress() {
48
  $bbdb->term_relationships = $bb_table_prefix . 'term_relationships';
49
  $bbdb->term_taxonomy = $bb_table_prefix . 'term_taxonomy';
50
  $bbdb->topics = $bb_table_prefix . 'topics';
51
-
52
  if ( isset( $bb->custom_user_table ) )
53
  $bbdb->users = $bb->custom_user_table;
54
  else
55
  $bbdb->users = $wpdb->users;
56
-
57
  if ( isset( $bb->custom_user_meta_table ) )
58
  $bbdb->usermeta = $bb->custom_user_meta_table;
59
  else
60
  $bbdb->usermeta = $wpdb->usermeta;
61
-
62
  $bbdb->prefix = $bb_table_prefix;
63
 
64
  define( 'BB_INSTALLING', false );
@@ -66,9 +66,9 @@ function bp_forums_load_bbpress() {
66
  /* This must be loaded before functionss.bb-admin.php otherwise we get a function conflict. */
67
  if ( !$tables_installed = (boolean) $bbdb->get_results( 'DESCRIBE `' . $bbdb->forums . '`;', ARRAY_A ) )
68
  require_once( ABSPATH . 'wp-admin/upgrade-functions.php' );
69
-
70
  require_once( BB_PATH . 'bb-admin/includes/functions.bb-admin.php' );
71
-
72
  if ( is_object( $wp_roles ) ) {
73
  $bb_roles =& $wp_roles;
74
  bb_init_roles( $bb_roles );
@@ -83,7 +83,7 @@ function bp_forums_load_bbpress() {
83
 
84
  if ( !isset( $wp_taxonomy_object ) )
85
  $wp_taxonomy_object = new BB_Taxonomy( $bbdb );
86
-
87
  $wp_taxonomy_object->register_taxonomy( 'bb_topic_tag', 'bb_topic' );
88
 
89
  // Set a site id if there isn't one already
@@ -95,10 +95,10 @@ function bp_forums_load_bbpress() {
95
  require_once( BB_PATH . 'bb-admin/includes/defaults.bb-schema.php' );
96
 
97
  dbDelta( $bb_queries );
98
-
99
  require_once( BB_PATH . 'bb-admin/includes/functions.bb-upgrade.php' );
100
  bb_update_db_version();
101
-
102
  /* Set the site admins as the keymasters */
103
  $site_admins = get_site_option( 'site_admins', array('admin') );
104
  foreach ( (array)$site_admins as $site_admin )
@@ -106,7 +106,7 @@ function bp_forums_load_bbpress() {
106
 
107
  // Create the first forum.
108
  bb_new_forum( array( 'forum_name' => 'Default Forum' ) );
109
-
110
  // Set the site URI
111
  bb_update_option( 'uri', BB_URL );
112
  }
@@ -128,7 +128,7 @@ class BP_Forums_BB_Auth {
128
  $defaults = array( 'id' => 0, 'meta_key' => null, 'meta_value' => null, 'meta_table' => 'usermeta', 'meta_field' => 'user_id', 'cache_group' => 'users' );
129
  $args = wp_parse_args( $args, $defaults );
130
  extract( $args, EXTR_SKIP );
131
-
132
  return update_usermeta( $id, $meta_key, $meta_value );
133
  }
134
  }
4
  global $bp, $wpdb, $wp_roles, $current_user, $wp_users_object;
5
  global $bb, $bbdb, $bb_table_prefix, $bb_current_user;
6
  global $bb_roles, $wp_taxonomy_object;
7
+
8
  /* Return if we've already run this function. */
9
  if ( is_object( $bbdb ) && is_object( $bb_roles ) )
10
  return;
11
+
12
  if ( !bp_forums_is_installed_correctly() )
13
  return false;
14
+
15
  define( 'BB_PATH', BP_PLUGIN_DIR . '/bp-forums/bbpress/' );
16
  define( 'BACKPRESS_PATH', BP_PLUGIN_DIR . '/bp-forums/bbpress/bb-includes/backpress/' );
17
  define( 'BB_URL', BP_PLUGIN_URL . '/bp-forums/bbpress/' );
19
 
20
  require_once( BB_PATH . BB_INC . 'class.bb-query.php' );
21
  require_once( BB_PATH . BB_INC . 'class.bb-walker.php' );
22
+
23
  require_once( BB_PATH . BB_INC . 'functions.bb-core.php' );
24
  require_once( BB_PATH . BB_INC . 'functions.bb-forums.php' );
25
  require_once( BB_PATH . BB_INC . 'functions.bb-topics.php' );
30
  require_once( BB_PATH . BB_INC . 'functions.bb-pluggable.php' );
31
  require_once( BB_PATH . BB_INC . 'functions.bb-formatting.php' );
32
  require_once( BB_PATH . BB_INC . 'functions.bb-template.php' );
33
+
34
  require_once( BACKPRESS_PATH . 'class.wp-taxonomy.php' );
35
  require_once( BB_PATH . BB_INC . 'class.bb-taxonomy.php' );
36
+
37
  $bb = new stdClass();
38
  require_once( $bp->forums->bbconfig );
39
 
40
  // Setup the global database connection
41
  $bbdb = new BPDB ( BBDB_USER, BBDB_PASSWORD, BBDB_NAME, BBDB_HOST );
42
+
43
  /* Set the table names */
44
  $bbdb->forums = $bb_table_prefix . 'forums';
45
  $bbdb->meta = $bb_table_prefix . 'meta';
48
  $bbdb->term_relationships = $bb_table_prefix . 'term_relationships';
49
  $bbdb->term_taxonomy = $bb_table_prefix . 'term_taxonomy';
50
  $bbdb->topics = $bb_table_prefix . 'topics';
51
+
52
  if ( isset( $bb->custom_user_table ) )
53
  $bbdb->users = $bb->custom_user_table;
54
  else
55
  $bbdb->users = $wpdb->users;
56
+
57
  if ( isset( $bb->custom_user_meta_table ) )
58
  $bbdb->usermeta = $bb->custom_user_meta_table;
59
  else
60
  $bbdb->usermeta = $wpdb->usermeta;
61
+
62
  $bbdb->prefix = $bb_table_prefix;
63
 
64
  define( 'BB_INSTALLING', false );
66
  /* This must be loaded before functionss.bb-admin.php otherwise we get a function conflict. */
67
  if ( !$tables_installed = (boolean) $bbdb->get_results( 'DESCRIBE `' . $bbdb->forums . '`;', ARRAY_A ) )
68
  require_once( ABSPATH . 'wp-admin/upgrade-functions.php' );
69
+
70
  require_once( BB_PATH . 'bb-admin/includes/functions.bb-admin.php' );
71
+
72
  if ( is_object( $wp_roles ) ) {
73
  $bb_roles =& $wp_roles;
74
  bb_init_roles( $bb_roles );
83
 
84
  if ( !isset( $wp_taxonomy_object ) )
85
  $wp_taxonomy_object = new BB_Taxonomy( $bbdb );
86
+
87
  $wp_taxonomy_object->register_taxonomy( 'bb_topic_tag', 'bb_topic' );
88
 
89
  // Set a site id if there isn't one already
95
  require_once( BB_PATH . 'bb-admin/includes/defaults.bb-schema.php' );
96
 
97
  dbDelta( $bb_queries );
98
+
99
  require_once( BB_PATH . 'bb-admin/includes/functions.bb-upgrade.php' );
100
  bb_update_db_version();
101
+
102
  /* Set the site admins as the keymasters */
103
  $site_admins = get_site_option( 'site_admins', array('admin') );
104
  foreach ( (array)$site_admins as $site_admin )
106
 
107
  // Create the first forum.
108
  bb_new_forum( array( 'forum_name' => 'Default Forum' ) );
109
+
110
  // Set the site URI
111
  bb_update_option( 'uri', BB_URL );
112
  }
128
  $defaults = array( 'id' => 0, 'meta_key' => null, 'meta_value' => null, 'meta_table' => 'usermeta', 'meta_field' => 'user_id', 'cache_group' => 'users' );
129
  $args = wp_parse_args( $args, $defaults );
130
  extract( $args, EXTR_SKIP );
131
+
132
  return update_usermeta( $id, $meta_key, $meta_value );
133
  }
134
  }
bp-forums/bp-forums-filters.php CHANGED
@@ -37,14 +37,14 @@ add_filter( 'bp_get_the_topic_post_content', 'make_clickable' );
37
  function bp_forums_add_allowed_tags( $allowedtags ) {
38
  $allowedtags['p'] = array();
39
  $allowedtags['br'] = array();
40
-
41
  return $allowedtags;
42
  }
43
  add_filter( 'edit_allowedtags', 'bp_forums_add_allowed_tags' );
44
 
45
  function bp_forums_filter_tag_link( $link, $tag, $page, $context ) {
46
  global $bp;
47
-
48
  return apply_filters( 'bp_forums_filter_tag_link', $bp->root_domain . '/' . $bp->forums->slug . '/tag/' . $tag . '/' );
49
  }
50
  add_filter( 'bb_get_tag_link', 'bp_forums_filter_tag_link', 10, 4);
37
  function bp_forums_add_allowed_tags( $allowedtags ) {
38
  $allowedtags['p'] = array();
39
  $allowedtags['br'] = array();
40
+
41
  return $allowedtags;
42
  }
43
  add_filter( 'edit_allowedtags', 'bp_forums_add_allowed_tags' );
44
 
45
  function bp_forums_filter_tag_link( $link, $tag, $page, $context ) {
46
  global $bp;
47
+
48
  return apply_filters( 'bp_forums_filter_tag_link', $bp->root_domain . '/' . $bp->forums->slug . '/tag/' . $tag . '/' );
49
  }
50
  add_filter( 'bb_get_tag_link', 'bp_forums_filter_tag_link', 10, 4);
bp-forums/bp-forums-templatetags.php CHANGED
@@ -5,25 +5,25 @@ class BP_Forums_Template_Forum {
5
  var $topic_count;
6
  var $topics;
7
  var $topic;
8
-
9
  var $in_the_loop;
10
-
11
  var $pag_page;
12
  var $pag_num;
13
  var $pag_links;
14
  var $total_topic_count;
15
-
16
  var $single_topic = false;
17
-
18
  var $sort_by;
19
  var $order;
20
-
21
  function BP_Forums_Template_Forum( $type, $forum_id, $per_page, $max, $no_stickies, $filter ) {
22
  global $bp;
23
 
24
  $this->pag_page = isset( $_REQUEST['p'] ) ? intval( $_REQUEST['p'] ) : 1;
25
  $this->pag_num = isset( $_REQUEST['n'] ) ? intval( $_REQUEST['n'] ) : $per_page;
26
-
27
  /* Only show stickies if we are viewing a single group forum, otherwise we could end up with hundreds globally */
28
  if ( $no_stickies )
29
  $show_stickies = 'no'; // bbPress needs str 'no'
@@ -32,26 +32,26 @@ class BP_Forums_Template_Forum {
32
  case 'newest': default:
33
  $this->topics = bp_forums_get_forum_topics( array( 'forum_id' => $forum_id, 'filter' => $filter, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $show_stickies ) );
34
  break;
35
-
36
  case 'popular':
37
  $this->topics = bp_forums_get_forum_topics( array( 'type' => 'popular', 'filter' => $filter, 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $show_stickies ) );
38
  break;
39
-
40
  case 'unreplied':
41
  $this->topics = bp_forums_get_forum_topics( array( 'type' => 'unreplied', 'filter' => $filter, 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $show_stickies ) );
42
  break;
43
-
44
  case 'personal':
45
  $this->topics = bp_forums_get_forum_topics( array( 'type' => 'personal', 'filter' => $filter, 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $show_stickies ) );
46
  break;
47
-
48
  case 'tag':
49
  $this->topics = bp_forums_get_forum_topics( array( 'type' => 'tag', 'filter' => $filter, 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $show_stickies ) );
50
- break;
51
  }
52
 
53
  $this->topics = apply_filters( 'bp_forums_template_topics', $this->topics, $type, $forum_id, $per_page, $max, $no_stickies );
54
-
55
  if ( !(int)$this->topics ) {
56
  $this->topic_count = 0;
57
  $this->total_topic_count = 0;
@@ -62,9 +62,9 @@ class BP_Forums_Template_Forum {
62
  } else if ( function_exists( 'groups_total_public_forum_topic_count' ) ) {
63
  $topic_count = (int)groups_total_public_forum_topic_count( $type );
64
  } else {
65
- $topic_count = count( $this->topics );
66
  }
67
-
68
  if ( !$max || $max >= $topic_count )
69
  $this->total_topic_count = $topic_count;
70
  else
@@ -77,7 +77,7 @@ class BP_Forums_Template_Forum {
77
  $this->topic_count = (int)$max;
78
  } else {
79
  $this->topic_count = count( $this->topics );
80
- }
81
  }
82
 
83
  $this->topic_count = apply_filters( 'bp_forums_template_topic_count', $this->topic_count, &$topics, $type, $forum_id, $per_page, $max, $no_stickies );
@@ -89,7 +89,7 @@ class BP_Forums_Template_Forum {
89
  if ( 1 == (int)$topic->topic_sticky )
90
  $stickies[] = $topic;
91
  else
92
- $standard[] = $topic;
93
  }
94
  $this->topics = array_merge( (array)$stickies, (array)$standard );
95
  }
@@ -104,29 +104,29 @@ class BP_Forums_Template_Forum {
104
  'mid_size' => 1
105
  ));
106
  }
107
-
108
  function has_topics() {
109
  if ( $this->topic_count )
110
  return true;
111
-
112
  return false;
113
  }
114
-
115
  function next_topic() {
116
  $this->current_topic++;
117
  $this->topic = $this->topics[$this->current_topic];
118
-
119
  return $this->topic;
120
  }
121
-
122
  function rewind_topics() {
123
  $this->current_topic = -1;
124
  if ( $this->topic_count > 0 ) {
125
  $this->topic = $this->topics[0];
126
  }
127
  }
128
-
129
- function user_topics() {
130
  if ( $this->current_topic + 1 < $this->topic_count ) {
131
  return true;
132
  } elseif ( $this->current_topic + 1 == $this->topic_count ) {
@@ -138,14 +138,14 @@ class BP_Forums_Template_Forum {
138
  $this->in_the_loop = false;
139
  return false;
140
  }
141
-
142
  function the_topic() {
143
  global $topic;
144
 
145
  $this->in_the_loop = true;
146
  $this->topic = $this->next_topic();
147
  $this->topic = (object)$this->topic;
148
-
149
  if ( $this->current_topic == 0 ) // loop has just started
150
  do_action('loop_start');
151
  }
@@ -153,7 +153,7 @@ class BP_Forums_Template_Forum {
153
 
154
  function bp_has_forum_topics( $args = '' ) {
155
  global $forum_template, $bp;
156
-
157
  $defaults = array(
158
  'type' => 'newest',
159
  'forum_id' => false,
@@ -174,7 +174,7 @@ function bp_has_forum_topics( $args = '' ) {
174
  if ( !$forum_id )
175
  return false;
176
  }
177
-
178
  /* If we're viewing a tag in the directory, let's auto set the filter to the tag name */
179
  if ( $bp->is_directory && 'tag' == $type && !empty( $bp->action_variables[0] ) )
180
  $filter = $bp->action_variables[0];
@@ -182,10 +182,10 @@ function bp_has_forum_topics( $args = '' ) {
182
  /* If $_GET['s'] is set, let's auto populate the filter var */
183
  if ( $bp->is_directory && !empty( $_GET['fs'] ) )
184
  $filter = $_GET['fs'];
185
-
186
  $forum_template = new BP_Forums_Template_Forum( $type, $forum_id, $per_page, $max, $no_stickies, $filter );
187
 
188
- return apply_filters( 'bp_has_topics', $forum_template->has_topics(), &$forum_template );
189
  }
190
  /* DEPRECATED use bp_has_forum_topics() */
191
  function bp_has_topics( $args = '' ) { return bp_has_forum_topics( $args ); }
@@ -212,7 +212,7 @@ function bp_the_topic_id() {
212
 
213
  return apply_filters( 'bp_get_the_topic_id', $forum_template->topic->topic_id );
214
  }
215
-
216
  function bp_the_topic_title() {
217
  echo bp_get_the_topic_title();
218
  }
@@ -255,7 +255,7 @@ function bp_the_topic_poster_avatar( $args = '' ) {
255
  }
256
  function bp_get_the_topic_poster_avatar( $args = '' ) {
257
  global $forum_template;
258
-
259
  $defaults = array(
260
  'type' => 'thumb',
261
  'width' => false,
@@ -265,7 +265,7 @@ function bp_the_topic_poster_avatar( $args = '' ) {
265
  $r = wp_parse_args( $args, $defaults );
266
  extract( $r, EXTR_SKIP );
267
 
268
- return apply_filters( 'bp_get_the_topic_poster_avatar', bp_core_fetch_avatar( array( 'item_id' => $forum_template->topic->topic_poster, 'type' => $type, 'width' => $width, 'height' => $height ) ) );
269
  }
270
 
271
  function bp_the_topic_poster_name() {
@@ -276,7 +276,7 @@ function bp_the_topic_poster_name() {
276
 
277
  return apply_filters( 'bp_get_the_topic_poster_name', bp_core_get_userlink( $forum_template->topic->topic_poster ) );
278
  }
279
-
280
  function bp_the_topic_object_id() {
281
  echo bp_get_the_topic_object_id();
282
  }
@@ -285,7 +285,7 @@ function bp_the_topic_object_id() {
285
 
286
  return apply_filters( 'bp_get_the_topic_object_id', $forum_template->topic->object_id );
287
  }
288
-
289
  function bp_the_topic_object_name() {
290
  echo bp_get_the_topic_object_name();
291
  }
@@ -294,7 +294,7 @@ function bp_the_topic_object_name() {
294
 
295
  return apply_filters( 'bp_get_the_topic_object_name', $forum_template->topic->object_name );
296
  }
297
-
298
  function bp_the_topic_object_slug() {
299
  echo bp_get_the_topic_object_slug();
300
  }
@@ -303,17 +303,17 @@ function bp_the_topic_object_slug() {
303
 
304
  return apply_filters( 'bp_get_the_topic_object_slug', $forum_template->topic->object_slug );
305
  }
306
-
307
  function bp_the_topic_object_permalink() {
308
  echo bp_get_the_topic_object_permalink();
309
  }
310
  function bp_get_the_topic_object_permalink() {
311
  global $bp, $forum_template;
312
-
313
  /* Currently this will only work with group forums, extended support in the future */
314
  return apply_filters( 'bp_get_the_topic_object_permalink', $bp->root_domain . '/' . BP_GROUPS_SLUG . '/' . $forum_template->topic->object_slug . '/forum/' );
315
  }
316
-
317
  function bp_the_topic_last_poster_name() {
318
  echo bp_get_the_topic_last_poster_name();
319
  }
@@ -322,7 +322,7 @@ function bp_the_topic_last_poster_name() {
322
 
323
  return apply_filters( 'bp_get_the_topic_last_poster_name', bp_core_get_userlink( $forum_template->topic->topic_last_poster ) );
324
  }
325
-
326
  function bp_the_topic_object_avatar( $args = '' ) {
327
  echo bp_get_the_topic_object_avatar( $args );
328
  }
@@ -338,9 +338,9 @@ function bp_the_topic_object_avatar( $args = '' ) {
338
  $r = wp_parse_args( $args, $defaults );
339
  extract( $r, EXTR_SKIP );
340
 
341
- return apply_filters( 'bp_get_the_topic_object_avatar', bp_core_fetch_avatar( array( 'item_id' => $forum_template->topic->object_id, 'type' => $type, 'object' => 'group', 'width' => $width, 'height' => $height ) ) );
342
  }
343
-
344
  function bp_the_topic_last_poster_avatar( $args = '' ) {
345
  echo bp_get_the_topic_last_poster_avatar( $args );
346
  }
@@ -356,7 +356,7 @@ function bp_the_topic_last_poster_avatar( $args = '' ) {
356
  $r = wp_parse_args( $args, $defaults );
357
  extract( $r, EXTR_SKIP );
358
 
359
- return apply_filters( 'bp_get_the_topic_last_poster_avatar', bp_core_fetch_avatar( array( 'item_id' => $forum_template->topic->topic_last_poster, 'type' => $type, 'width' => $width, 'height' => $height ) ) );
360
  }
361
 
362
  function bp_the_topic_start_time() {
@@ -367,7 +367,7 @@ function bp_the_topic_start_time() {
367
 
368
  return apply_filters( 'bp_get_the_topic_start_time', $forum_template->topic->topic_start_time );
369
  }
370
-
371
  function bp_the_topic_time() {
372
  echo bp_get_the_topic_time();
373
  }
@@ -431,18 +431,18 @@ function bp_the_topic_total_post_count() {
431
  if ( $forum_template->topic->topic_posts == 1 )
432
  return apply_filters( 'bp_get_the_topic_total_post_count', sprintf( __( '%d post', 'buddypress' ), $forum_template->topic->topic_posts ) );
433
  else
434
- return apply_filters( 'bp_get_the_topic_total_post_count', sprintf( __( '%d posts', 'buddypress' ), $forum_template->topic->topic_posts ) );
435
  }
436
-
437
  function bp_the_topic_total_posts() {
438
  echo bp_get_the_topic_total_posts();
439
  }
440
  function bp_get_the_topic_total_posts() {
441
  global $forum_template;
442
-
443
  return $forum_template->topic->topic_posts;
444
  }
445
-
446
  function bp_the_topic_tag_count() {
447
  echo bp_get_the_topic_tag_count();
448
  }
@@ -457,14 +457,14 @@ function bp_the_topic_permalink() {
457
  }
458
  function bp_get_the_topic_permalink() {
459
  global $forum_template, $bp;
460
-
461
  if ( $forum_template->topic->object_slug )
462
  $permalink = $bp->root_domain . '/' . BP_GROUPS_SLUG . '/' . $forum_template->topic->object_slug . '/';
463
  else if ( $bp->is_single_item )
464
  $permalink = $bp->root_domain . '/' . $bp->current_component . '/' . $bp->current_item . '/';
465
  else
466
  $permalink = $bp->root_domain . '/' . $bp->current_component . '/' . $bp->current_action . '/';
467
-
468
  return apply_filters( 'bp_get_the_topic_permalink', $permalink . 'forum/topic/' . $forum_template->topic->topic_slug . '/' );
469
  }
470
 
@@ -476,7 +476,7 @@ function bp_the_topic_time_since_created() {
476
 
477
  return apply_filters( 'bp_get_the_topic_time_since_created', bp_core_time_since( strtotime( $forum_template->topic->topic_start_time ) ) );
478
  }
479
-
480
  function bp_the_topic_latest_post_excerpt( $args = '' ) {
481
  echo bp_get_the_topic_latest_post_excerpt( $args );
482
  }
@@ -497,7 +497,7 @@ function bp_the_topic_latest_post_excerpt( $args = '' ) {
497
 
498
  function bp_the_topic_time_since_last_post( $deprecated = true ) {
499
  global $forum_template;
500
-
501
  if ( !$deprecated )
502
  return bp_get_the_topic_time_since_last_post();
503
  else
@@ -514,7 +514,7 @@ function bp_the_topic_is_mine() {
514
  }
515
  function bp_get_the_topic_is_mine() {
516
  global $bp, $forum_template;
517
-
518
  return $bp->loggedin_user->id == $forum_template->topic->topic_poster;
519
  }
520
 
@@ -522,8 +522,8 @@ function bp_the_topic_admin_links( $args = '' ) {
522
  echo bp_get_the_topic_admin_links( $args );
523
  }
524
  function bp_get_the_topic_admin_links( $args = '' ) {
525
- global $bp, $forum_template;
526
-
527
  $defaults = array(
528
  'seperator' => '|'
529
  );
@@ -532,7 +532,7 @@ function bp_the_topic_admin_links( $args = '' ) {
532
  extract( $r, EXTR_SKIP );
533
 
534
  $links[] = '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'edit', 'bp_forums_edit_topic' ) . '">' . __( 'Edit', 'buddypress' ) . '</a>';
535
-
536
  if ( $bp->is_item_admin || $bp->is_item_mod || is_site_admin() ) {
537
  if ( 0 == (int)$forum_template->topic->topic_sticky )
538
  $links[] = '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'stick', 'bp_forums_stick_topic' ) . '">' . __( 'Sticky', 'buddypress' ) . '</a>';
@@ -546,7 +546,7 @@ function bp_the_topic_admin_links( $args = '' ) {
546
 
547
  $links[] = '<a class="confirm" id="topic-delete-link" href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'delete', 'bp_forums_delete_topic' ) . '">' . __( 'Delete', 'buddypress' ) . '</a>';
548
  }
549
-
550
  return implode( ' ' . $seperator . ' ', (array) $links );
551
  }
552
 
@@ -556,18 +556,18 @@ function bp_the_topic_css_class() {
556
 
557
  function bp_get_the_topic_css_class() {
558
  global $forum_template;
559
-
560
  $class = false;
561
-
562
  if ( $forum_template->current_topic % 2 == 1 )
563
  $class .= 'alt';
564
-
565
  if ( 1 == (int)$forum_template->topic->topic_sticky )
566
  $class .= ' sticky';
567
-
568
  if ( 0 == (int)$forum_template->topic->topic_open )
569
  $class .= ' closed';
570
-
571
  return trim( $class );
572
  }
573
 
@@ -576,7 +576,7 @@ function bp_my_forum_topics_link() {
576
  }
577
  function bp_get_my_forum_topics_link() {
578
  global $bp;
579
-
580
  return apply_filters( 'bp_get_my_forum_topics_link', $bp->root_domain . '/' . $bp->forums->slug . '/personal/' );
581
  }
582
 
@@ -585,7 +585,7 @@ function bp_unreplied_forum_topics_link() {
585
  }
586
  function bp_get_unreplied_forum_topics_link() {
587
  global $bp;
588
-
589
  return apply_filters( 'bp_get_unreplied_forum_topics_link', $bp->root_domain . '/' . $bp->forums->slug . '/unreplied/' );
590
  }
591
 
@@ -595,7 +595,7 @@ function bp_popular_forum_topics_link() {
595
  }
596
  function bp_get_popular_forum_topics_link() {
597
  global $bp;
598
-
599
  return apply_filters( 'bp_get_popular_forum_topics_link', $bp->root_domain . '/' . $bp->forums->slug . '/popular/' );
600
  }
601
 
@@ -604,7 +604,7 @@ function bp_newest_forum_topics_link() {
604
  }
605
  function bp_get_newest_forum_topics_link() {
606
  global $bp;
607
-
608
  return apply_filters( 'bp_get_newest_forum_topics_link', $bp->root_domain . '/' . $bp->forums->slug . '/' );
609
  }
610
 
@@ -613,22 +613,22 @@ function bp_forum_topic_type() {
613
  }
614
  function bp_get_forum_topic_type() {
615
  global $bp;
616
-
617
  if ( !$bp->is_directory || !$bp->current_action )
618
  return 'newest';
619
-
620
 
621
  return apply_filters( 'bp_get_forum_topic_type', $bp->current_action );
622
  }
623
-
624
  function bp_forums_tag_name() {
625
  echo bp_get_forums_tag_name();
626
  }
627
  function bp_get_forums_tag_name() {
628
  global $bp;
629
-
630
  if ( $bp->is_directory && $bp->forums->slug == $bp->current_component )
631
- return apply_filters( 'bp_get_forums_tag_name', $bp->action_variables[0] );
632
  }
633
 
634
  function bp_forum_pagination() {
@@ -642,10 +642,10 @@ function bp_forum_pagination() {
642
 
643
  function bp_forum_pagination_count() {
644
  global $bp, $forum_template;
645
-
646
  $from_num = intval( ( $forum_template->pag_page - 1 ) * $forum_template->pag_num ) + 1;
647
- $to_num = ( $from_num + ( $forum_template->pag_num - 1 ) > $forum_template->total_topic_count ) ? $forum_template->total_topic_count : $from_num + ( $forum_template->pag_num - 1 );
648
-
649
  echo apply_filters( 'bp_forum_pagination_count', sprintf( __( 'Viewing topic %d to %d (%d total topics)', 'buddypress' ), $from_num, $to_num, $forum_template->total_topic_count ) );
650
  ?>
651
  <span class="ajax-loader"></span>
@@ -654,10 +654,10 @@ function bp_forum_pagination_count() {
654
 
655
  function bp_is_edit_topic() {
656
  global $bp;
657
-
658
  if ( in_array( 'post', (array)$bp->action_variables ) && in_array( 'edit', (array)$bp->action_variables ) )
659
  return false;
660
-
661
  return true;
662
  }
663
 
@@ -667,33 +667,33 @@ class BP_Forums_Template_Topic {
667
  var $post_count;
668
  var $posts;
669
  var $post;
670
-
671
  var $topic_id;
672
  var $topic;
673
-
674
  var $in_the_loop;
675
-
676
  var $pag_page;
677
  var $pag_num;
678
  var $pag_links;
679
  var $total_post_count;
680
-
681
  var $single_post = false;
682
-
683
  var $sort_by;
684
  var $order;
685
-
686
  function BP_Forums_Template_Topic( $topic_id, $per_page, $max ) {
687
  global $bp, $current_user, $forum_template;
688
-
689
  $this->pag_page = isset( $_REQUEST['topic_page'] ) ? intval( $_REQUEST['topic_page'] ) : 1;
690
  $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
691
-
692
  $this->topic_id = $topic_id;
693
  $forum_template->topic = (object) bp_forums_get_topic_details( $this->topic_id );
694
 
695
  $this->posts = bp_forums_get_topic_posts( array( 'topic_id' => $this->topic_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num ) );
696
-
697
  if ( !$this->posts ) {
698
  $this->post_count = 0;
699
  $this->total_post_count = 0;
@@ -723,29 +723,29 @@ class BP_Forums_Template_Topic {
723
  'mid_size' => 1
724
  ));
725
  }
726
-
727
  function has_posts() {
728
  if ( $this->post_count )
729
  return true;
730
-
731
  return false;
732
  }
733
-
734
  function next_post() {
735
  $this->current_post++;
736
  $this->post = $this->posts[$this->current_post];
737
-
738
  return $this->post;
739
  }
740
-
741
  function rewind_posts() {
742
  $this->current_post = -1;
743
  if ( $this->post_count > 0 ) {
744
  $this->post = $this->posts[0];
745
  }
746
  }
747
-
748
- function user_posts() {
749
  if ( $this->current_post + 1 < $this->post_count ) {
750
  return true;
751
  } elseif ( $this->current_post + 1 == $this->post_count ) {
@@ -757,14 +757,14 @@ class BP_Forums_Template_Topic {
757
  $this->in_the_loop = false;
758
  return false;
759
  }
760
-
761
  function the_post() {
762
  global $post;
763
 
764
  $this->in_the_loop = true;
765
  $this->post = $this->next_post();
766
  $this->post = (object)$this->post;
767
-
768
  if ( $this->current_post == 0 ) // loop has just started
769
  do_action('loop_start');
770
  }
@@ -772,7 +772,7 @@ class BP_Forums_Template_Topic {
772
 
773
  function bp_has_forum_topic_posts( $args = '' ) {
774
  global $topic_template, $bp;
775
-
776
  $defaults = array(
777
  'topic_id' => false,
778
  'per_page' => 15,
@@ -814,7 +814,7 @@ function bp_the_topic_post_id() {
814
  }
815
  function bp_get_the_topic_post_id() {
816
  global $topic_template;
817
-
818
  return apply_filters( 'bp_get_the_topic_post_id', $topic_template->post->post_id );
819
  }
820
 
@@ -842,7 +842,7 @@ function bp_the_topic_post_poster_avatar( $args = '' ) {
842
  $r = wp_parse_args( $args, $defaults );
843
  extract( $r, EXTR_SKIP );
844
 
845
- return apply_filters( 'bp_get_the_topic_post_poster_avatar', bp_core_fetch_avatar( array( 'item_id' => $topic_template->post->poster_id, 'type' => $type, 'width' => $width, 'height' => $height ) ) );
846
  }
847
 
848
  function bp_the_topic_post_poster_name( $deprecated = true ) {
@@ -854,7 +854,7 @@ function bp_the_topic_post_poster_name( $deprecated = true ) {
854
  function bp_get_the_topic_post_poster_name() {
855
  global $topic_template;
856
 
857
- return apply_filters( 'bp_get_the_topic_post_poster_name', bp_core_get_userlink( $topic_template->post->poster_id ) );
858
  }
859
 
860
  function bp_the_topic_post_time_since( $deprecated = true ) {
@@ -874,7 +874,7 @@ function bp_the_topic_post_is_mine() {
874
  }
875
  function bp_get_the_topic_post_is_mine() {
876
  global $bp, $topic_template;
877
-
878
  return $bp->loggedin_user->id == $topic_template->post->poster_id;
879
  }
880
 
@@ -882,12 +882,12 @@ function bp_the_topic_post_admin_links( $args = '' ) {
882
  echo bp_get_the_topic_post_admin_links( $args );
883
  }
884
  function bp_get_the_topic_post_admin_links( $args = '' ) {
885
- global $topic_template;
886
-
887
  /* Never show for the first post in a topic. */
888
  if ( 0 == $topic_template->current_post )
889
  return;
890
-
891
  $defaults = array(
892
  'seperator' => '|'
893
  );
@@ -906,7 +906,7 @@ function bp_the_topic_post_edit_text() {
906
  }
907
  function bp_get_the_topic_post_edit_text() {
908
  global $bp;
909
-
910
  $post = bp_forums_get_post( $bp->action_variables[4] );
911
  return attribute_escape( $post->post_text );
912
  }
@@ -922,10 +922,10 @@ function bp_the_topic_pagination() {
922
 
923
  function bp_the_topic_pagination_count() {
924
  global $bp, $topic_template;
925
-
926
  $from_num = intval( ( $topic_template->pag_page - 1 ) * $topic_template->pag_num ) + 1;
927
- $to_num = ( $from_num + ( $topic_template->pag_num - 1 ) > $topic_template->total_post_count ) ? $topic_template->total_post_count : $from_num + ( $topic_template->pag_num - 1 );
928
-
929
  echo apply_filters( 'bp_the_topic_pagination_count', sprintf( __( 'Viewing post %d to %d (%d total posts)', 'buddypress' ), $from_num, $to_num, $topic_template->total_post_count ) );
930
  ?>
931
  <span class="ajax-loader"></span>
@@ -946,7 +946,7 @@ function bp_forum_permalink() {
946
  }
947
  function bp_get_forum_permalink() {
948
  global $bp;
949
-
950
  if ( $bp->is_single_item )
951
  $permalink = $bp->root_domain . '/' . $bp->current_component . '/' . $bp->current_item . '/';
952
  else
@@ -960,11 +960,11 @@ function bp_forum_directory_permalink() {
960
  }
961
  function bp_get_forum_directory_permalink() {
962
  global $bp;
963
-
964
  return apply_filters( 'bp_get_forum_directory_permalink', $bp->root_domain . '/' . $bp->forums->slug );
965
  }
966
 
967
- function bp_forums_tag_heat_map( $args = '' ) {
968
  $defaults = array(
969
  'smallest' => '10',
970
  'largest' => '42',
@@ -984,7 +984,7 @@ function bp_forum_action() {
984
  function bp_get_forum_action() {
985
  global $topic_template;
986
 
987
- return apply_filters( 'bp_get_forum_action', $bp->root_domain . attribute_escape( $_SERVER['REQUEST_URI'] ) );
988
  }
989
 
990
  function bp_forum_topic_action() {
@@ -992,8 +992,8 @@ function bp_forum_topic_action() {
992
  }
993
  function bp_get_forum_topic_action() {
994
  global $bp;
995
-
996
- return apply_filters( 'bp_get_forum_topic_action', $bp->root_domain . attribute_escape( $_SERVER['REQUEST_URI'] ) );
997
  }
998
 
999
  ?>
5
  var $topic_count;
6
  var $topics;
7
  var $topic;
8
+
9
  var $in_the_loop;
10
+
11
  var $pag_page;
12
  var $pag_num;
13
  var $pag_links;
14
  var $total_topic_count;
15
+
16
  var $single_topic = false;
17
+
18
  var $sort_by;
19
  var $order;
20
+
21
  function BP_Forums_Template_Forum( $type, $forum_id, $per_page, $max, $no_stickies, $filter ) {
22
  global $bp;
23
 
24
  $this->pag_page = isset( $_REQUEST['p'] ) ? intval( $_REQUEST['p'] ) : 1;
25
  $this->pag_num = isset( $_REQUEST['n'] ) ? intval( $_REQUEST['n'] ) : $per_page;
26
+
27
  /* Only show stickies if we are viewing a single group forum, otherwise we could end up with hundreds globally */
28
  if ( $no_stickies )
29
  $show_stickies = 'no'; // bbPress needs str 'no'
32
  case 'newest': default:
33
  $this->topics = bp_forums_get_forum_topics( array( 'forum_id' => $forum_id, 'filter' => $filter, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $show_stickies ) );
34
  break;
35
+
36
  case 'popular':
37
  $this->topics = bp_forums_get_forum_topics( array( 'type' => 'popular', 'filter' => $filter, 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $show_stickies ) );
38
  break;
39
+
40
  case 'unreplied':
41
  $this->topics = bp_forums_get_forum_topics( array( 'type' => 'unreplied', 'filter' => $filter, 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $show_stickies ) );
42
  break;
43
+
44
  case 'personal':
45
  $this->topics = bp_forums_get_forum_topics( array( 'type' => 'personal', 'filter' => $filter, 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $show_stickies ) );
46
  break;
47
+
48
  case 'tag':
49
  $this->topics = bp_forums_get_forum_topics( array( 'type' => 'tag', 'filter' => $filter, 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $show_stickies ) );
50
+ break;
51
  }
52
 
53
  $this->topics = apply_filters( 'bp_forums_template_topics', $this->topics, $type, $forum_id, $per_page, $max, $no_stickies );
54
+
55
  if ( !(int)$this->topics ) {
56
  $this->topic_count = 0;
57
  $this->total_topic_count = 0;
62
  } else if ( function_exists( 'groups_total_public_forum_topic_count' ) ) {
63
  $topic_count = (int)groups_total_public_forum_topic_count( $type );
64
  } else {
65
+ $topic_count = count( $this->topics );
66
  }
67
+
68
  if ( !$max || $max >= $topic_count )
69
  $this->total_topic_count = $topic_count;
70
  else
77
  $this->topic_count = (int)$max;
78
  } else {
79
  $this->topic_count = count( $this->topics );
80
+ }
81
  }
82
 
83
  $this->topic_count = apply_filters( 'bp_forums_template_topic_count', $this->topic_count, &$topics, $type, $forum_id, $per_page, $max, $no_stickies );
89
  if ( 1 == (int)$topic->topic_sticky )
90
  $stickies[] = $topic;
91
  else
92
+ $standard[] = $topic;
93
  }
94
  $this->topics = array_merge( (array)$stickies, (array)$standard );
95
  }
104
  'mid_size' => 1
105
  ));
106
  }
107
+
108
  function has_topics() {
109
  if ( $this->topic_count )
110
  return true;
111
+
112
  return false;
113
  }
114
+
115
  function next_topic() {
116
  $this->current_topic++;
117
  $this->topic = $this->topics[$this->current_topic];
118
+
119
  return $this->topic;
120
  }
121
+
122
  function rewind_topics() {
123
  $this->current_topic = -1;
124
  if ( $this->topic_count > 0 ) {
125
  $this->topic = $this->topics[0];
126
  }
127
  }
128
+
129
+ function user_topics() {
130
  if ( $this->current_topic + 1 < $this->topic_count ) {
131
  return true;
132
  } elseif ( $this->current_topic + 1 == $this->topic_count ) {
138
  $this->in_the_loop = false;
139
  return false;
140
  }
141
+
142
  function the_topic() {
143
  global $topic;
144
 
145
  $this->in_the_loop = true;
146
  $this->topic = $this->next_topic();
147
  $this->topic = (object)$this->topic;
148
+
149
  if ( $this->current_topic == 0 ) // loop has just started
150
  do_action('loop_start');
151
  }
153
 
154
  function bp_has_forum_topics( $args = '' ) {
155
  global $forum_template, $bp;
156
+
157
  $defaults = array(
158
  'type' => 'newest',
159
  'forum_id' => false,
174
  if ( !$forum_id )
175
  return false;
176
  }
177
+
178
  /* If we're viewing a tag in the directory, let's auto set the filter to the tag name */
179
  if ( $bp->is_directory && 'tag' == $type && !empty( $bp->action_variables[0] ) )
180
  $filter = $bp->action_variables[0];
182
  /* If $_GET['s'] is set, let's auto populate the filter var */
183
  if ( $bp->is_directory && !empty( $_GET['fs'] ) )
184
  $filter = $_GET['fs'];
185
+
186
  $forum_template = new BP_Forums_Template_Forum( $type, $forum_id, $per_page, $max, $no_stickies, $filter );
187
 
188
+ return apply_filters( 'bp_has_topics', $forum_template->has_topics(), &$forum_template );
189
  }
190
  /* DEPRECATED use bp_has_forum_topics() */
191
  function bp_has_topics( $args = '' ) { return bp_has_forum_topics( $args ); }
212
 
213
  return apply_filters( 'bp_get_the_topic_id', $forum_template->topic->topic_id );
214
  }
215
+
216
  function bp_the_topic_title() {
217
  echo bp_get_the_topic_title();
218
  }
255
  }
256
  function bp_get_the_topic_poster_avatar( $args = '' ) {
257
  global $forum_template;
258
+
259
  $defaults = array(
260
  'type' => 'thumb',
261
  'width' => false,
265
  $r = wp_parse_args( $args, $defaults );
266
  extract( $r, EXTR_SKIP );
267
 
268
+ return apply_filters( 'bp_get_the_topic_poster_avatar', bp_core_fetch_avatar( array( 'item_id' => $forum_template->topic->topic_poster, 'type' => $type, 'width' => $width, 'height' => $height ) ) );
269
  }
270
 
271
  function bp_the_topic_poster_name() {
276
 
277
  return apply_filters( 'bp_get_the_topic_poster_name', bp_core_get_userlink( $forum_template->topic->topic_poster ) );
278
  }
279
+
280
  function bp_the_topic_object_id() {
281
  echo bp_get_the_topic_object_id();
282
  }
285
 
286
  return apply_filters( 'bp_get_the_topic_object_id', $forum_template->topic->object_id );
287
  }
288
+
289
  function bp_the_topic_object_name() {
290
  echo bp_get_the_topic_object_name();
291
  }
294
 
295
  return apply_filters( 'bp_get_the_topic_object_name', $forum_template->topic->object_name );
296
  }
297
+
298
  function bp_the_topic_object_slug() {
299
  echo bp_get_the_topic_object_slug();
300
  }
303
 
304
  return apply_filters( 'bp_get_the_topic_object_slug', $forum_template->topic->object_slug );
305
  }
306
+
307
  function bp_the_topic_object_permalink() {
308
  echo bp_get_the_topic_object_permalink();
309
  }
310
  function bp_get_the_topic_object_permalink() {
311
  global $bp, $forum_template;
312
+
313
  /* Currently this will only work with group forums, extended support in the future */
314
  return apply_filters( 'bp_get_the_topic_object_permalink', $bp->root_domain . '/' . BP_GROUPS_SLUG . '/' . $forum_template->topic->object_slug . '/forum/' );
315
  }
316
+
317
  function bp_the_topic_last_poster_name() {
318
  echo bp_get_the_topic_last_poster_name();
319
  }
322
 
323
  return apply_filters( 'bp_get_the_topic_last_poster_name', bp_core_get_userlink( $forum_template->topic->topic_last_poster ) );
324
  }
325
+
326
  function bp_the_topic_object_avatar( $args = '' ) {
327
  echo bp_get_the_topic_object_avatar( $args );
328
  }
338
  $r = wp_parse_args( $args, $defaults );
339
  extract( $r, EXTR_SKIP );
340
 
341
+ return apply_filters( 'bp_get_the_topic_object_avatar', bp_core_fetch_avatar( array( 'item_id' => $forum_template->topic->object_id, 'type' => $type, 'object' => 'group', 'width' => $width, 'height' => $height ) ) );
342
  }
343
+
344
  function bp_the_topic_last_poster_avatar( $args = '' ) {
345
  echo bp_get_the_topic_last_poster_avatar( $args );
346
  }
356
  $r = wp_parse_args( $args, $defaults );
357
  extract( $r, EXTR_SKIP );
358
 
359
+ return apply_filters( 'bp_get_the_topic_last_poster_avatar', bp_core_fetch_avatar( array( 'item_id' => $forum_template->topic->topic_last_poster, 'type' => $type, 'width' => $width, 'height' => $height ) ) );
360
  }
361
 
362
  function bp_the_topic_start_time() {
367
 
368
  return apply_filters( 'bp_get_the_topic_start_time', $forum_template->topic->topic_start_time );
369
  }
370
+
371
  function bp_the_topic_time() {
372
  echo bp_get_the_topic_time();
373
  }
431
  if ( $forum_template->topic->topic_posts == 1 )
432
  return apply_filters( 'bp_get_the_topic_total_post_count', sprintf( __( '%d post', 'buddypress' ), $forum_template->topic->topic_posts ) );
433
  else
434
+ return apply_filters( 'bp_get_the_topic_total_post_count', sprintf( __( '%d posts', 'buddypress' ), $forum_template->topic->topic_posts ) );
435
  }
436
+
437
  function bp_the_topic_total_posts() {
438
  echo bp_get_the_topic_total_posts();
439
  }
440
  function bp_get_the_topic_total_posts() {
441
  global $forum_template;
442
+
443
  return $forum_template->topic->topic_posts;
444
  }
445
+
446
  function bp_the_topic_tag_count() {
447
  echo bp_get_the_topic_tag_count();
448
  }
457
  }
458
  function bp_get_the_topic_permalink() {
459
  global $forum_template, $bp;
460
+
461
  if ( $forum_template->topic->object_slug )
462
  $permalink = $bp->root_domain . '/' . BP_GROUPS_SLUG . '/' . $forum_template->topic->object_slug . '/';
463
  else if ( $bp->is_single_item )
464
  $permalink = $bp->root_domain . '/' . $bp->current_component . '/' . $bp->current_item . '/';
465
  else
466
  $permalink = $bp->root_domain . '/' . $bp->current_component . '/' . $bp->current_action . '/';
467
+
468
  return apply_filters( 'bp_get_the_topic_permalink', $permalink . 'forum/topic/' . $forum_template->topic->topic_slug . '/' );
469
  }
470
 
476
 
477
  return apply_filters( 'bp_get_the_topic_time_since_created', bp_core_time_since( strtotime( $forum_template->topic->topic_start_time ) ) );
478
  }
479
+
480
  function bp_the_topic_latest_post_excerpt( $args = '' ) {
481
  echo bp_get_the_topic_latest_post_excerpt( $args );
482
  }
497
 
498
  function bp_the_topic_time_since_last_post( $deprecated = true ) {
499
  global $forum_template;
500
+
501
  if ( !$deprecated )
502
  return bp_get_the_topic_time_since_last_post();
503
  else
514
  }
515
  function bp_get_the_topic_is_mine() {
516
  global $bp, $forum_template;
517
+
518
  return $bp->loggedin_user->id == $forum_template->topic->topic_poster;
519
  }
520
 
522
  echo bp_get_the_topic_admin_links( $args );
523
  }
524
  function bp_get_the_topic_admin_links( $args = '' ) {
525
+ global $bp, $forum_template;
526
+
527
  $defaults = array(
528
  'seperator' => '|'
529
  );
532
  extract( $r, EXTR_SKIP );
533
 
534
  $links[] = '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'edit', 'bp_forums_edit_topic' ) . '">' . __( 'Edit', 'buddypress' ) . '</a>';
535
+
536
  if ( $bp->is_item_admin || $bp->is_item_mod || is_site_admin() ) {
537
  if ( 0 == (int)$forum_template->topic->topic_sticky )
538
  $links[] = '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'stick', 'bp_forums_stick_topic' ) . '">' . __( 'Sticky', 'buddypress' ) . '</a>';
546
 
547
  $links[] = '<a class="confirm" id="topic-delete-link" href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'delete', 'bp_forums_delete_topic' ) . '">' . __( 'Delete', 'buddypress' ) . '</a>';
548
  }
549
+
550
  return implode( ' ' . $seperator . ' ', (array) $links );
551
  }
552
 
556
 
557
  function bp_get_the_topic_css_class() {
558
  global $forum_template;
559
+
560
  $class = false;
561
+
562
  if ( $forum_template->current_topic % 2 == 1 )
563
  $class .= 'alt';
564
+
565
  if ( 1 == (int)$forum_template->topic->topic_sticky )
566
  $class .= ' sticky';
567
+
568
  if ( 0 == (int)$forum_template->topic->topic_open )
569
  $class .= ' closed';
570
+
571
  return trim( $class );
572
  }
573
 
576
  }
577
  function bp_get_my_forum_topics_link() {
578
  global $bp;
579
+
580
  return apply_filters( 'bp_get_my_forum_topics_link', $bp->root_domain . '/' . $bp->forums->slug . '/personal/' );
581
  }
582
 
585
  }
586
  function bp_get_unreplied_forum_topics_link() {
587
  global $bp;
588
+
589
  return apply_filters( 'bp_get_unreplied_forum_topics_link', $bp->root_domain . '/' . $bp->forums->slug . '/unreplied/' );
590
  }
591
 
595
  }
596
  function bp_get_popular_forum_topics_link() {
597
  global $bp;
598
+
599
  return apply_filters( 'bp_get_popular_forum_topics_link', $bp->root_domain . '/' . $bp->forums->slug . '/popular/' );
600
  }
601
 
604
  }
605
  function bp_get_newest_forum_topics_link() {
606
  global $bp;
607
+
608
  return apply_filters( 'bp_get_newest_forum_topics_link', $bp->root_domain . '/' . $bp->forums->slug . '/' );
609
  }
610
 
613
  }
614
  function bp_get_forum_topic_type() {
615
  global $bp;
616
+
617
  if ( !$bp->is_directory || !$bp->current_action )
618
  return 'newest';
619
+
620
 
621
  return apply_filters( 'bp_get_forum_topic_type', $bp->current_action );
622
  }
623
+
624
  function bp_forums_tag_name() {
625
  echo bp_get_forums_tag_name();
626
  }
627
  function bp_get_forums_tag_name() {
628
  global $bp;
629
+
630
  if ( $bp->is_directory && $bp->forums->slug == $bp->current_component )
631
+ return apply_filters( 'bp_get_forums_tag_name', $bp->action_variables[0] );
632
  }
633
 
634
  function bp_forum_pagination() {
642
 
643
  function bp_forum_pagination_count() {
644
  global $bp, $forum_template;
645
+
646
  $from_num = intval( ( $forum_template->pag_page - 1 ) * $forum_template->pag_num ) + 1;
647
+ $to_num = ( $from_num + ( $forum_template->pag_num - 1 ) > $forum_template->total_topic_count ) ? $forum_template->total_topic_count : $from_num + ( $forum_template->pag_num - 1 );
648
+
649
  echo apply_filters( 'bp_forum_pagination_count', sprintf( __( 'Viewing topic %d to %d (%d total topics)', 'buddypress' ), $from_num, $to_num, $forum_template->total_topic_count ) );
650
  ?>
651
  <span class="ajax-loader"></span>
654
 
655
  function bp_is_edit_topic() {
656
  global $bp;
657
+
658
  if ( in_array( 'post', (array)$bp->action_variables ) && in_array( 'edit', (array)$bp->action_variables ) )
659
  return false;
660
+
661
  return true;
662
  }
663
 
667
  var $post_count;
668
  var $posts;
669
  var $post;
670
+
671
  var $topic_id;
672
  var $topic;
673
+
674
  var $in_the_loop;
675
+
676
  var $pag_page;
677
  var $pag_num;
678
  var $pag_links;
679
  var $total_post_count;
680
+
681
  var $single_post = false;
682
+
683
  var $sort_by;
684
  var $order;
685
+
686
  function BP_Forums_Template_Topic( $topic_id, $per_page, $max ) {
687
  global $bp, $current_user, $forum_template;
688
+
689
  $this->pag_page = isset( $_REQUEST['topic_page'] ) ? intval( $_REQUEST['topic_page'] ) : 1;
690
  $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
691
+
692
  $this->topic_id = $topic_id;
693
  $forum_template->topic = (object) bp_forums_get_topic_details( $this->topic_id );
694
 
695
  $this->posts = bp_forums_get_topic_posts( array( 'topic_id' => $this->topic_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num ) );
696
+
697
  if ( !$this->posts ) {
698
  $this->post_count = 0;
699
  $this->total_post_count = 0;
723
  'mid_size' => 1
724
  ));
725
  }
726
+
727
  function has_posts() {
728
  if ( $this->post_count )
729
  return true;
730
+
731
  return false;
732
  }
733
+
734
  function next_post() {
735
  $this->current_post++;
736
  $this->post = $this->posts[$this->current_post];
737
+
738
  return $this->post;
739
  }
740
+
741
  function rewind_posts() {
742
  $this->current_post = -1;
743
  if ( $this->post_count > 0 ) {
744
  $this->post = $this->posts[0];
745
  }
746
  }
747
+
748
+ function user_posts() {
749
  if ( $this->current_post + 1 < $this->post_count ) {
750
  return true;
751
  } elseif ( $this->current_post + 1 == $this->post_count ) {
757
  $this->in_the_loop = false;
758
  return false;
759
  }
760
+
761
  function the_post() {
762
  global $post;
763
 
764
  $this->in_the_loop = true;
765
  $this->post = $this->next_post();
766
  $this->post = (object)$this->post;
767
+
768
  if ( $this->current_post == 0 ) // loop has just started
769
  do_action('loop_start');
770
  }
772
 
773
  function bp_has_forum_topic_posts( $args = '' ) {
774
  global $topic_template, $bp;
775
+
776
  $defaults = array(
777
  'topic_id' => false,
778
  'per_page' => 15,
814
  }
815
  function bp_get_the_topic_post_id() {
816
  global $topic_template;
817
+
818
  return apply_filters( 'bp_get_the_topic_post_id', $topic_template->post->post_id );
819
  }
820
 
842
  $r = wp_parse_args( $args, $defaults );
843
  extract( $r, EXTR_SKIP );
844
 
845
+ return apply_filters( 'bp_get_the_topic_post_poster_avatar', bp_core_fetch_avatar( array( 'item_id' => $topic_template->post->poster_id, 'type' => $type, 'width' => $width, 'height' => $height ) ) );
846
  }
847
 
848
  function bp_the_topic_post_poster_name( $deprecated = true ) {
854
  function bp_get_the_topic_post_poster_name() {
855
  global $topic_template;
856
 
857
+ return apply_filters( 'bp_get_the_topic_post_poster_name', bp_core_get_userlink( $topic_template->post->poster_id ) );
858
  }
859
 
860
  function bp_the_topic_post_time_since( $deprecated = true ) {
874
  }
875
  function bp_get_the_topic_post_is_mine() {
876
  global $bp, $topic_template;
877
+
878
  return $bp->loggedin_user->id == $topic_template->post->poster_id;
879
  }
880
 
882
  echo bp_get_the_topic_post_admin_links( $args );
883
  }
884
  function bp_get_the_topic_post_admin_links( $args = '' ) {
885
+ global $topic_template;
886
+
887
  /* Never show for the first post in a topic. */
888
  if ( 0 == $topic_template->current_post )
889
  return;
890
+
891
  $defaults = array(
892
  'seperator' => '|'
893
  );
906
  }
907
  function bp_get_the_topic_post_edit_text() {
908
  global $bp;
909
+
910
  $post = bp_forums_get_post( $bp->action_variables[4] );
911
  return attribute_escape( $post->post_text );
912
  }
922
 
923
  function bp_the_topic_pagination_count() {
924
  global $bp, $topic_template;
925
+
926
  $from_num = intval( ( $topic_template->pag_page - 1 ) * $topic_template->pag_num ) + 1;
927
+ $to_num = ( $from_num + ( $topic_template->pag_num - 1 ) > $topic_template->total_post_count ) ? $topic_template->total_post_count : $from_num + ( $topic_template->pag_num - 1 );
928
+
929
  echo apply_filters( 'bp_the_topic_pagination_count', sprintf( __( 'Viewing post %d to %d (%d total posts)', 'buddypress' ), $from_num, $to_num, $topic_template->total_post_count ) );
930
  ?>
931
  <span class="ajax-loader"></span>
946
  }
947
  function bp_get_forum_permalink() {
948
  global $bp;
949
+
950
  if ( $bp->is_single_item )
951
  $permalink = $bp->root_domain . '/' . $bp->current_component . '/' . $bp->current_item . '/';
952
  else
960
  }
961
  function bp_get_forum_directory_permalink() {
962
  global $bp;
963
+
964
  return apply_filters( 'bp_get_forum_directory_permalink', $bp->root_domain . '/' . $bp->forums->slug );
965
  }
966
 
967
+ function bp_forums_tag_heat_map( $args = '' ) {
968
  $defaults = array(
969
  'smallest' => '10',
970
  'largest' => '42',
984
  function bp_get_forum_action() {
985
  global $topic_template;
986
 
987
+ return apply_filters( 'bp_get_forum_action', $bp->root_domain . attribute_escape( $_SERVER['REQUEST_URI'] ) );
988
  }
989
 
990
  function bp_forum_topic_action() {
992
  }
993
  function bp_get_forum_topic_action() {
994
  global $bp;
995
+
996
+ return apply_filters( 'bp_get_forum_topic_action', $bp->root_domain . attribute_escape( $_SERVER['REQUEST_URI'] ) );
997
  }
998
 
999
  ?>
bp-forums/deprecated/images/closed.png CHANGED
File without changes
bp-friends.php CHANGED
@@ -15,10 +15,10 @@ if ( !defined( 'BP_IGNORE_DEPRECATED' ) )
15
 
16
  function friends_install() {
17
  global $wpdb, $bp;
18
-
19
  if ( !empty($wpdb->charset) )
20
  $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
21
-
22
  $sql[] = "CREATE TABLE {$bp->friends->table_name} (
23
  id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
24
  initiator_user_id bigint(20) NOT NULL,
@@ -32,7 +32,7 @@ function friends_install() {
32
 
33
  require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
34
  dbDelta($sql);
35
-
36
  update_site_option( 'bp-friends-db-version', BP_FRIENDS_DB_VERSION );
37
  }
38
 
@@ -41,25 +41,25 @@ function friends_setup_globals() {
41
 
42
  /* For internal identification */
43
  $bp->friends->id = 'friends';
44
-
45
  $bp->friends->table_name = $wpdb->base_prefix . 'bp_friends';
46
  $bp->friends->format_notification_function = 'friends_format_notifications';
47
  $bp->friends->slug = BP_FRIENDS_SLUG;
48
-
49
  /* Register this in the active components array */
50
  $bp->active_components[$bp->friends->slug] = $bp->friends->id;
51
 
52
  do_action( 'friends_setup_globals' );
53
  }
54
- add_action( 'plugins_loaded', 'friends_setup_globals', 5 );
55
  add_action( 'admin_menu', 'friends_setup_globals', 2 );
56
 
57
- function friends_check_installed() {
58
  global $wpdb, $bp;
59
 
60
  if ( !is_site_admin() )
61
  return false;
62
-
63
  /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
64
  if ( get_site_option('bp-friends-db-version') < BP_FRIENDS_DB_VERSION )
65
  friends_install();
@@ -68,25 +68,25 @@ add_action( 'admin_menu', 'friends_check_installed' );
68
 
69
  function friends_setup_nav() {
70
  global $bp;
71
-
72
  /* Add 'Friends' to the main navigation */
73
  bp_core_new_nav_item( array( 'name' => __('Friends', 'buddypress'), 'slug' => $bp->friends->slug, 'position' => 60, 'screen_function' => 'friends_screen_my_friends', 'default_subnav_slug' => 'my-friends', 'item_css_id' => $bp->friends->id ) );
74
-
75
  $friends_link = $bp->loggedin_user->domain . $bp->friends->slug . '/';
76
-
77
  /* Add the subnav items to the friends nav item */
78
  bp_core_new_subnav_item( array( 'name' => __( 'My Friends', 'buddypress' ), 'slug' => 'my-friends', 'parent_url' => $friends_link, 'parent_slug' => $bp->friends->slug, 'screen_function' => 'friends_screen_my_friends', 'position' => 10, 'item_css_id' => 'friends-my-friends' ) );
79
  bp_core_new_subnav_item( array( 'name' => __( 'Requests', 'buddypress' ), 'slug' => 'requests', 'parent_url' => $friends_link, 'parent_slug' => $bp->friends->slug, 'screen_function' => 'friends_screen_requests', 'position' => 20, 'user_has_access' => bp_is_home() ) );
80
-
81
  if ( $bp->current_component == $bp->friends->slug ) {
82
  if ( bp_is_home() ) {
83
  $bp->bp_options_title = __( 'My Friends', 'buddypress' );
84
  } else {
85
  $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) );
86
- $bp->bp_options_title = $bp->displayed_user->fullname;
87
  }
88
  }
89
-
90
  do_action( 'friends_setup_nav' );
91
  }
92
  add_action( 'wp', 'friends_setup_nav', 2 );
@@ -108,40 +108,39 @@ function friends_screen_my_friends() {
108
  bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, 'friends', 'friendship_accepted' );
109
 
110
  do_action( 'friends_screen_my_friends' );
111
-
112
- bp_core_load_template( apply_filters( 'friends_template_my_friends', 'friends/index' ) );
113
  }
114
 
115
  function friends_screen_requests() {
116
  global $bp;
117
-
118
  if ( isset($bp->action_variables) && 'accept' == $bp->action_variables[0] && is_numeric($bp->action_variables[1]) ) {
119
  /* Check the nonce */
120
- if ( !check_admin_referer( 'friends_accept_friendship' ) )
121
- return false;
122
-
123
  if ( friends_accept_friendship( $bp->action_variables[1] ) ) {
124
  bp_core_add_message( __( 'Friendship accepted', 'buddypress' ) );
125
  } else {
126
  bp_core_add_message( __( 'Friendship could not be accepted', 'buddypress' ), 'error' );
127
  }
128
  bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action );
129
-
130
  } else if ( isset($bp->action_variables) && 'reject' == $bp->action_variables[0] && is_numeric($bp->action_variables[1]) ) {
131
  /* Check the nonce */
132
- if ( !check_admin_referer( 'friends_reject_friendship' ) )
133
- return false;
134
-
135
  if ( friends_reject_friendship( $bp->action_variables[1] ) ) {
136
  bp_core_add_message( __( 'Friendship rejected', 'buddypress' ) );
137
  } else {
138
  bp_core_add_message( __( 'Friendship could not be rejected', 'buddypress' ), 'error' );
139
- }
140
  bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action );
141
  }
142
-
143
  do_action( 'friends_screen_requests' );
144
-
145
  bp_core_load_template( apply_filters( 'friends_template_requests', 'friends/requests' ) );
146
  }
147
 
@@ -150,7 +149,7 @@ function friends_screen_friend_finder() {
150
  bp_core_load_template( apply_filters( 'friends_template_friend_finder', 'friends/friend-finder' ) );
151
  }
152
 
153
- function friends_screen_notification_settings() {
154
  global $current_user; ?>
155
  <table class="notification-settings" id="friends-notification-settings">
156
  <tr>
@@ -171,10 +170,10 @@ function friends_screen_notification_settings() {
171
  <td class="yes"><input type="radio" name="notifications[notification_friends_friendship_accepted]" value="yes" <?php if ( !get_usermeta( $current_user->id,'notification_friends_friendship_accepted') || 'yes' == get_usermeta( $current_user->id,'notification_friends_friendship_accepted') ) { ?>checked="checked" <?php } ?>/></td>
172
  <td class="no"><input type="radio" name="notifications[notification_friends_friendship_accepted]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id,'notification_friends_friendship_accepted') ) { ?>checked="checked" <?php } ?>/></td>
173
  </tr>
174
-
175
  <?php do_action( 'friends_screen_notification_settings' ); ?>
176
  </table>
177
- <?php
178
  }
179
  add_action( 'bp_notification_settings', 'friends_screen_notification_settings' );
180
 
@@ -192,7 +191,7 @@ function friends_action_add_friend() {
192
 
193
  if ( $bp->current_component != $bp->friends->slug || $bp->current_action != 'add-friend' )
194
  return false;
195
-
196
  $potential_friend_id = $bp->action_variables[0];
197
 
198
  if ( !is_numeric( $potential_friend_id ) || !isset( $potential_friend_id ) )
@@ -200,37 +199,37 @@ function friends_action_add_friend() {
200
 
201
  if ( $potential_friend_id == $bp->loggedin_user->id )
202
  return false;
203
-
204
  $friendship_status = BP_Friends_Friendship::check_is_friend( $bp->loggedin_user->id, $potential_friend_id );
205
 
206
  if ( 'not_friends' == $friendship_status ) {
207
-
208
  if ( !check_admin_referer( 'friends_add_friend' ) )
209
  return false;
210
-
211
  if ( !friends_add_friend( $bp->loggedin_user->id, $potential_friend_id ) ) {
212
  bp_core_add_message( __( 'Friendship could not be requested.', 'buddypress' ), 'error' );
213
  } else {
214
  bp_core_add_message( __( 'Friendship requested', 'buddypress' ) );
215
  }
216
  } else if ( 'is_friend' == $friendship_status ) {
217
- bp_core_add_message( __( 'You are already friends with this user', 'buddypress' ), 'error' );
218
  } else {
219
- bp_core_add_message( __( 'You already have a pending friendship request with this user', 'buddypress' ), 'error' );
220
  }
221
-
222
  bp_core_redirect( wp_get_referer() );
223
-
224
  return false;
225
  }
226
  add_action( 'init', 'friends_action_add_friend' );
227
 
228
  function friends_action_remove_friend() {
229
  global $bp;
230
-
231
  if ( $bp->current_component != $bp->friends->slug || $bp->current_action != 'remove-friend' )
232
  return false;
233
-
234
  $potential_friend_id = $bp->action_variables[0];
235
 
236
  if ( !is_numeric( $potential_friend_id ) || !isset( $potential_friend_id ) )
@@ -238,27 +237,27 @@ function friends_action_remove_friend() {
238
 
239
  if ( $potential_friend_id == $bp->loggedin_user->id )
240
  return false;
241
-
242
  $friendship_status = BP_Friends_Friendship::check_is_friend( $bp->loggedin_user->id, $potential_friend_id );
243
-
244
  if ( 'is_friend' == $friendship_status ) {
245
-
246
  if ( !check_admin_referer( 'friends_remove_friend' ) )
247
  return false;
248
-
249
  if ( !friends_remove_friend( $bp->loggedin_user->id, $potential_friend_id ) ) {
250
  bp_core_add_message( __( 'Friendship could not be canceled.', 'buddypress' ), 'error' );
251
  } else {
252
  bp_core_add_message( __( 'Friendship canceled', 'buddypress' ) );
253
  }
254
  } else if ( 'is_friends' == $friendship_status ) {
255
- bp_core_add_message( __( 'You are not yet friends with this user', 'buddypress' ), 'error' );
256
  } else {
257
- bp_core_add_message( __( 'You have a pending friendship request with this user', 'buddypress' ), 'error' );
258
  }
259
-
260
  bp_core_redirect( wp_get_referer() );
261
-
262
  return false;
263
  }
264
  add_action( 'init', 'friends_action_remove_friend' );
@@ -273,7 +272,7 @@ add_action( 'init', 'friends_action_remove_friend' );
273
 
274
  function friends_record_activity( $args = '' ) {
275
  global $bp;
276
-
277
  if ( !function_exists( 'bp_activity_add' ) )
278
  return false;
279
 
@@ -290,7 +289,7 @@ function friends_record_activity( $args = '' ) {
290
  );
291
 
292
  $r = wp_parse_args( $args, $defaults );
293
- extract( $r, EXTR_SKIP );
294
 
295
  return bp_activity_add( array( 'user_id' => $user_id, 'content' => $content, 'primary_link' => $primary_link, 'component_name' => $component_name, 'component_action' => $component_action, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) );
296
  }
@@ -304,7 +303,7 @@ function friends_delete_activity( $args ) {
304
 
305
  function friends_register_activity_actions() {
306
  global $bp;
307
-
308
  if ( !function_exists( 'bp_activity_set_action' ) )
309
  return false;
310
 
@@ -316,31 +315,31 @@ add_action( 'plugins_loaded', 'friends_register_activity_actions' );
316
 
317
  function friends_format_notifications( $action, $item_id, $secondary_item_id, $total_items ) {
318
  global $bp;
319
-
320
  switch ( $action ) {
321
  case 'friendship_accepted':
322
  if ( (int)$total_items > 1 ) {
323
- return apply_filters( 'bp_friends_multiple_friendship_accepted_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/my-friends/newest" title="' . __( 'My Friends', 'buddypress' ) . '">' . sprintf( __('%d friends accepted your friendship requests', 'buddypress' ), (int)$total_items ) . '</a>', (int)$total_items );
324
  } else {
325
  $user_fullname = bp_core_get_user_displayname( $item_id );
326
  $user_url = bp_core_get_userurl( $item_id );
327
  return apply_filters( 'bp_friends_single_friendship_accepted_notification', '<a href="' . $user_url . '?new" title="' . $user_fullname .'\'s profile">' . sprintf( __( '%s accepted your friendship request', 'buddypress' ), $user_fullname ) . '</a>', $user_fullname );
328
- }
329
  break;
330
-
331
  case 'friendship_request':
332
  if ( (int)$total_items > 1 ) {
333
- return apply_filters( 'bp_friends_multiple_friendship_request_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/requests" title="' . __( 'Friendship requests', 'buddypress' ) . '">' . sprintf( __('You have %d pending friendship requests', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
334
  } else {
335
  $user_fullname = bp_core_get_user_displayname( $item_id );
336
  $user_url = bp_core_get_userurl( $item_id );
337
  return apply_filters( 'bp_friends_single_friendship_request_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/requests" title="' . __( 'Friendship requests', 'buddypress' ) . '">' . sprintf( __('You have a friendship request from %s', 'buddypress' ), $user_fullname ) . '</a>', $user_fullname );
338
- }
339
  break;
340
  }
341
 
342
  do_action( 'friends_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
343
-
344
  return false;
345
  }
346
 
@@ -359,10 +358,10 @@ function friends_check_user_has_friends( $user_id ) {
359
 
360
  if ( empty( $friend_count ) )
361
  return false;
362
-
363
  if ( !(int)$friend_count )
364
  return false;
365
-
366
  return true;
367
  }
368
 
@@ -380,7 +379,7 @@ function friends_search_friends( $search_terms, $user_id, $pag_num = 10, $pag_pa
380
 
381
  function friends_get_friendship_requests( $user_id ) {
382
  $fship_ids = friends_get_friendship_ids( $user_id, true );
383
-
384
  return array( 'requests' => $fship_ids, 'total' => count($fship_ids) );
385
  }
386
 
@@ -389,20 +388,20 @@ function friends_get_recently_active( $user_id, $pag_num = false, $pag_page = fa
389
  $friend_ids = friends_search_friends( $filter, $user_id, false );
390
  else
391
  $friend_ids = friends_get_friend_user_ids( $user_id );
392
-
393
  if ( !$friend_ids )
394
  return false;
395
-
396
  if ( $filter )
397
  $friend_ids = $friend_ids['friends'];
398
 
399
  $ids_and_activity = friends_get_bulk_last_active( implode( ',', (array)$friend_ids ) );
400
-
401
  if ( !$ids_and_activity )
402
  return false;
403
-
404
  $total_friends = count( $ids_and_activity );
405
-
406
  if ( $pag_num && $pag_page )
407
  return array( 'friends' => array_slice( $ids_and_activity, intval( ( $pag_page - 1 ) * $pag_num), intval( $pag_num ) ), 'total' => $total_friends );
408
  else
@@ -414,20 +413,20 @@ function friends_get_alphabetically( $user_id, $pag_num = false, $pag_page = fal
414
  $friend_ids = friends_search_friends( $filter, $user_id, false );
415
  else
416
  $friend_ids = friends_get_friend_user_ids( $user_id );
417
-
418
  if ( !$friend_ids )
419
  return false;
420
-
421
  if ( $filter )
422
  $friend_ids = $friend_ids['friends'];
423
-
424
  $sorted_ids = BP_Friends_Friendship::sort_by_name( implode( ',', $friend_ids ) );
425
-
426
  if ( !$sorted_ids )
427
  return false;
428
-
429
  $total_friends = count( $sorted_ids );
430
-
431
  if ( $pag_num && $pag_page )
432
  return array( 'friends' => array_slice( $sorted_ids, intval( ( $pag_page - 1 ) * $pag_num), intval( $pag_num ) ), 'total' => $total_friends );
433
  else
@@ -439,28 +438,28 @@ function friends_get_newest( $user_id, $pag_num = false, $pag_page = false, $fil
439
  $friend_ids = friends_search_friends( $filter, $user_id, false );
440
  else
441
  $friend_ids = friends_get_friend_user_ids( $user_id );
442
-
443
  if ( !$friend_ids )
444
- return false;
445
 
446
  if ( $filter )
447
  $friend_ids = $friend_ids['friends'];
448
 
449
  $total_friends = count( $friend_ids );
450
-
451
  if ( $pag_num && $pag_page )
452
- return array( 'friends' => array_slice( $friend_ids, intval( ( $pag_page - 1 ) * $pag_num), intval( $pag_num ) ), 'total' => $total_friends );
453
  else
454
- return array( 'friends' => $friend_ids, 'total' => $total_friends );
455
  }
456
-
457
  function friends_get_bulk_last_active( $friend_ids ) {
458
  return BP_Friends_Friendship::get_bulk_last_active( $friend_ids );
459
  }
460
 
461
  function friends_get_friends_list( $user_id ) {
462
  global $bp;
463
-
464
  $friend_ids = BP_Friends_Friendship::get_friend_user_ids( $user_id );
465
 
466
  if ( !$friend_ids )
@@ -469,7 +468,7 @@ function friends_get_friends_list( $user_id ) {
469
  for ( $i = 0; $i < count($friend_ids); $i++ ) {
470
  if ( function_exists('bp_user_fullname') )
471
  $display_name = bp_core_get_user_displayname( $friend_ids[$i] );
472
-
473
  if ( $display_name != ' ' ) {
474
  $friends[] = array(
475
  'id' => $friend_ids[$i],
@@ -477,7 +476,7 @@ function friends_get_friends_list( $user_id ) {
477
  );
478
  }
479
  }
480
-
481
  if ( $friends && is_array($friends) )
482
  usort($friends, 'friends_sort_by_name');
483
 
@@ -487,16 +486,16 @@ function friends_get_friends_list( $user_id ) {
487
  return $friends;
488
  }
489
 
490
- function friends_sort_by_name($a, $b) {
491
  return strcasecmp($a['full_name'], $b['full_name']);
492
  }
493
 
494
  function friends_get_friends_invite_list( $user_id = false, $group_id ) {
495
  global $bp;
496
-
497
  if ( !$user_id )
498
  $user_id = $bp->loggedin_user->id;
499
-
500
  $friend_ids = friends_get_alphabetically( $user_id );
501
 
502
  if ( (int) $friend_ids['total'] < 1 )
@@ -505,9 +504,9 @@ function friends_get_friends_invite_list( $user_id = false, $group_id ) {
505
  for ( $i = 0; $i < count($friend_ids['friends']); $i++ ) {
506
  if ( groups_check_user_has_invite( $friend_ids['friends'][$i]->user_id, $group_id ) || groups_is_user_member( $friend_ids['friends'][$i]->user_id, $group_id ) )
507
  continue;
508
-
509
  $display_name = bp_core_get_user_displayname( $friend_ids['friends'][$i]->user_id );
510
-
511
  if ( $display_name != ' ' ) {
512
  $friends[] = array(
513
  'id' => $friend_ids['friends'][$i]->user_id,
@@ -534,14 +533,14 @@ function friends_search_users( $search_terms, $user_id, $pag_num = false, $pag_p
534
  global $bp;
535
 
536
  $user_ids = BP_Friends_Friendship::search_users( $search_terms, $user_id, $pag_num, $pag_page );
537
-
538
  if ( !$user_ids )
539
  return false;
540
 
541
  for ( $i = 0; $i < count($user_ids); $i++ ) {
542
  $users[] = new BP_Core_User($user_ids[$i]);
543
  }
544
-
545
  return array( 'users' => $users, 'count' => BP_Friends_Friendship::search_users_count($search_terms) );
546
  }
547
 
@@ -550,89 +549,89 @@ function friends_check_friendship( $user_id, $possible_friend_id ) {
550
 
551
  if ( 'is_friend' == BP_Friends_Friendship::check_is_friend( $user_id, $possible_friend_id ) )
552
  return true;
553
-
554
  return false;
555
  }
556
 
557
  function friends_add_friend( $initiator_userid, $friend_userid, $force_accept = false ) {
558
  global $bp;
559
-
560
  $friendship = new BP_Friends_Friendship;
561
-
562
  if ( (int)$friendship->is_confirmed )
563
  return true;
564
-
565
  $friendship->initiator_user_id = $initiator_userid;
566
  $friendship->friend_user_id = $friend_userid;
567
  $friendship->is_confirmed = 0;
568
  $friendship->is_limited = 0;
569
  $friendship->date_created = time();
570
-
571
  if ( $force_accept )
572
  $friendship->is_confirmed = 1;
573
-
574
  if ( $friendship->save() ) {
575
-
576
  if ( !$force_accept ) {
577
  // Add the on screen notification
578
- bp_core_add_notification( $friendship->initiator_user_id, $friendship->friend_user_id, 'friends', 'friendship_request' );
579
 
580
  // Send the email notification
581
  require_once( BP_PLUGIN_DIR . '/bp-friends/bp-friends-notifications.php' );
582
  friends_notification_new_request( $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id );
583
-
584
- do_action( 'friends_friendship_requested', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id );
585
  } else {
586
  do_action( 'friends_friendship_accepted', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id );
587
  }
588
-
589
  return true;
590
  }
591
-
592
  return false;
593
  }
594
 
595
  function friends_remove_friend( $initiator_userid, $friend_userid ) {
596
  global $bp;
597
-
598
  $friendship_id = BP_Friends_Friendship::get_friendship_id( $initiator_userid, $friend_userid );
599
  $friendship = new BP_Friends_Friendship( $friendship_id );
600
-
601
  // Remove the activity stream item for the user who canceled the friendship
602
  friends_delete_activity( array( 'item_id' => $friendship_id, 'component_action' => 'friendship_accepted', 'user_id' => $bp->displayed_user->id ) );
603
-
604
  do_action( 'friends_friendship_deleted', $friendship_id, $initiator_userid, $friend_userid );
605
-
606
  if ( $friendship->delete() ) {
607
  friends_update_friend_totals( $initiator_userid, $friend_userid, 'remove' );
608
-
609
  return true;
610
  }
611
-
612
  return false;
613
  }
614
 
615
  function friends_accept_friendship( $friendship_id ) {
616
  global $bp;
617
-
618
  $friendship = new BP_Friends_Friendship( $friendship_id, true, false );
619
 
620
  if ( !$friendship->is_confirmed && BP_Friends_Friendship::accept( $friendship_id ) ) {
621
  friends_update_friend_totals( $friendship->initiator_user_id, $friendship->friend_user_id );
622
-
623
  /* Remove the friend request notice */
624
- bp_core_delete_notifications_for_user_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, 'friends', 'friendship_request' );
625
-
626
  /* Add a friend accepted notice for the initiating user */
627
  bp_core_add_notification( $friendship->friend_user_id, $friendship->initiator_user_id, 'friends', 'friendship_accepted' );
628
-
629
  $initiator_link = bp_core_get_userlink( $friendship->initiator_user_id );
630
  $friend_link = bp_core_get_userlink( $friendship->friend_user_id );
631
-
632
- $primary_link = apply_filters( 'friends_activity_friendship_accepted_primary_link', bp_core_get_userlink( $friendship->initiator_user_id ), &$friendship );
633
-
634
  /* Record in activity streams for the initiator */
635
- friends_record_activity( array(
636
  'user_id' => $friendship->initiator_user_id,
637
  'component_action' => 'friendship_created',
638
  'content' => apply_filters( 'friends_activity_friendship_accepted', sprintf( __( '%s and %s are now friends', 'buddypress' ), $initiator_link, $friend_link ), &$friendship ),
@@ -641,7 +640,7 @@ function friends_accept_friendship( $friendship_id ) {
641
  ) );
642
 
643
  /* Record in activity streams for the friend */
644
- friends_record_activity( array(
645
  'user_id' => $friendship->friend_user_id,
646
  'component_action' => 'friendship_created',
647
  'content' => apply_filters( 'friends_activity_friendship_accepted', sprintf( __( '%s and %s are now friends', 'buddypress' ), $friend_link, $initiator_link ), &$friendship ),
@@ -649,30 +648,30 @@ function friends_accept_friendship( $friendship_id ) {
649
  'item_id' => $friendship_id,
650
  'hide_sitewide' => true /* We've already got the first entry site wide */
651
  ) );
652
-
653
  /* Send the email notification */
654
  require_once( BP_PLUGIN_DIR . '/bp-friends/bp-friends-notifications.php' );
655
  friends_notification_accepted_request( $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id );
656
 
657
  do_action( 'friends_friendship_accepted', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id );
658
-
659
  return true;
660
  }
661
-
662
  return false;
663
  }
664
 
665
- function friends_reject_friendship( $friendship_id ) {
666
  $friendship = new BP_Friends_Friendship( $friendship_id, true, false );
667
 
668
  if ( !$friendship->is_confirmed && BP_Friends_Friendship::reject( $friendship_id ) ) {
669
  // Remove the friend request notice
670
- bp_core_delete_notifications_for_user_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, 'friends', 'friendship_request' );
671
-
672
  do_action( 'friends_friendship_rejected', $friendship_id, &$friendship );
673
  return true;
674
  }
675
-
676
  return false;
677
  }
678
 
@@ -687,16 +686,16 @@ function friends_update_friend_totals( $initiator_user_id, $friend_user_id, $sta
687
  update_usermeta( $friend_user_id, 'total_friend_count', (int)get_usermeta( $friend_user_id, 'total_friend_count' ) + 1 );
688
  } else {
689
  update_usermeta( $initiator_user_id, 'total_friend_count', (int)get_usermeta( $initiator_user_id, 'total_friend_count' ) - 1 );
690
- update_usermeta( $friend_user_id, 'total_friend_count', (int)get_usermeta( $friend_user_id, 'total_friend_count' ) - 1 );
691
  }
692
  }
693
 
694
  function friends_remove_data( $user_id ) {
695
  BP_Friends_Friendship::delete_all_for_user($user_id);
696
-
697
  /* Remove usermeta */
698
  delete_usermeta( $user_id, 'total_friend_count' );
699
-
700
  /* Remove friendship requests FROM user */
701
  bp_core_delete_notifications_from_user( $user_id, $bp->friends->slug, 'friendship_request' );
702
 
15
 
16
  function friends_install() {
17
  global $wpdb, $bp;
18
+
19
  if ( !empty($wpdb->charset) )
20
  $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
21
+
22
  $sql[] = "CREATE TABLE {$bp->friends->table_name} (
23
  id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
24
  initiator_user_id bigint(20) NOT NULL,
32
 
33
  require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
34
  dbDelta($sql);
35
+
36
  update_site_option( 'bp-friends-db-version', BP_FRIENDS_DB_VERSION );
37
  }
38
 
41
 
42
  /* For internal identification */
43
  $bp->friends->id = 'friends';
44
+
45
  $bp->friends->table_name = $wpdb->base_prefix . 'bp_friends';
46
  $bp->friends->format_notification_function = 'friends_format_notifications';
47
  $bp->friends->slug = BP_FRIENDS_SLUG;
48
+
49
  /* Register this in the active components array */
50
  $bp->active_components[$bp->friends->slug] = $bp->friends->id;
51
 
52
  do_action( 'friends_setup_globals' );
53
  }
54
+ add_action( 'plugins_loaded', 'friends_setup_globals', 5 );
55
  add_action( 'admin_menu', 'friends_setup_globals', 2 );
56
 
57
+ function friends_check_installed() {
58
  global $wpdb, $bp;
59
 
60
  if ( !is_site_admin() )
61
  return false;
62
+
63
  /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
64
  if ( get_site_option('bp-friends-db-version') < BP_FRIENDS_DB_VERSION )
65
  friends_install();
68
 
69
  function friends_setup_nav() {
70
  global $bp;
71
+
72
  /* Add 'Friends' to the main navigation */
73
  bp_core_new_nav_item( array( 'name' => __('Friends', 'buddypress'), 'slug' => $bp->friends->slug, 'position' => 60, 'screen_function' => 'friends_screen_my_friends', 'default_subnav_slug' => 'my-friends', 'item_css_id' => $bp->friends->id ) );
74
+
75
  $friends_link = $bp->loggedin_user->domain . $bp->friends->slug . '/';
76
+
77
  /* Add the subnav items to the friends nav item */
78
  bp_core_new_subnav_item( array( 'name' => __( 'My Friends', 'buddypress' ), 'slug' => 'my-friends', 'parent_url' => $friends_link, 'parent_slug' => $bp->friends->slug, 'screen_function' => 'friends_screen_my_friends', 'position' => 10, 'item_css_id' => 'friends-my-friends' ) );
79
  bp_core_new_subnav_item( array( 'name' => __( 'Requests', 'buddypress' ), 'slug' => 'requests', 'parent_url' => $friends_link, 'parent_slug' => $bp->friends->slug, 'screen_function' => 'friends_screen_requests', 'position' => 20, 'user_has_access' => bp_is_home() ) );
80
+
81
  if ( $bp->current_component == $bp->friends->slug ) {
82
  if ( bp_is_home() ) {
83
  $bp->bp_options_title = __( 'My Friends', 'buddypress' );
84
  } else {
85
  $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) );
86
+ $bp->bp_options_title = $bp->displayed_user->fullname;
87
  }
88
  }
89
+
90
  do_action( 'friends_setup_nav' );
91
  }
92
  add_action( 'wp', 'friends_setup_nav', 2 );
108
  bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, 'friends', 'friendship_accepted' );
109
 
110
  do_action( 'friends_screen_my_friends' );
111
+
112
+ bp_core_load_template( apply_filters( 'friends_template_my_friends', 'friends/index' ) );
113
  }
114
 
115
  function friends_screen_requests() {
116
  global $bp;
117
+
118
  if ( isset($bp->action_variables) && 'accept' == $bp->action_variables[0] && is_numeric($bp->action_variables[1]) ) {
119
  /* Check the nonce */
120
+ check_admin_referer( 'friends_accept_friendship' );
121
+
 
122
  if ( friends_accept_friendship( $bp->action_variables[1] ) ) {
123
  bp_core_add_message( __( 'Friendship accepted', 'buddypress' ) );
124
  } else {
125
  bp_core_add_message( __( 'Friendship could not be accepted', 'buddypress' ), 'error' );
126
  }
127
  bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action );
128
+
129
  } else if ( isset($bp->action_variables) && 'reject' == $bp->action_variables[0] && is_numeric($bp->action_variables[1]) ) {
130
  /* Check the nonce */
131
+ check_admin_referer( 'friends_reject_friendship' );
132
+
133
+
134
  if ( friends_reject_friendship( $bp->action_variables[1] ) ) {
135
  bp_core_add_message( __( 'Friendship rejected', 'buddypress' ) );
136
  } else {
137
  bp_core_add_message( __( 'Friendship could not be rejected', 'buddypress' ), 'error' );
138
+ }
139
  bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action );
140
  }
141
+
142
  do_action( 'friends_screen_requests' );
143
+
144
  bp_core_load_template( apply_filters( 'friends_template_requests', 'friends/requests' ) );
145
  }
146
 
149
  bp_core_load_template( apply_filters( 'friends_template_friend_finder', 'friends/friend-finder' ) );
150
  }
151
 
152
+ function friends_screen_notification_settings() {
153
  global $current_user; ?>
154
  <table class="notification-settings" id="friends-notification-settings">
155
  <tr>
170
  <td class="yes"><input type="radio" name="notifications[notification_friends_friendship_accepted]" value="yes" <?php if ( !get_usermeta( $current_user->id,'notification_friends_friendship_accepted') || 'yes' == get_usermeta( $current_user->id,'notification_friends_friendship_accepted') ) { ?>checked="checked" <?php } ?>/></td>
171
  <td class="no"><input type="radio" name="notifications[notification_friends_friendship_accepted]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id,'notification_friends_friendship_accepted') ) { ?>checked="checked" <?php } ?>/></td>
172
  </tr>
173
+
174
  <?php do_action( 'friends_screen_notification_settings' ); ?>
175
  </table>
176
+ <?php
177
  }
178
  add_action( 'bp_notification_settings', 'friends_screen_notification_settings' );
179
 
191
 
192
  if ( $bp->current_component != $bp->friends->slug || $bp->current_action != 'add-friend' )
193
  return false;
194
+
195
  $potential_friend_id = $bp->action_variables[0];
196
 
197
  if ( !is_numeric( $potential_friend_id ) || !isset( $potential_friend_id ) )
199
 
200
  if ( $potential_friend_id == $bp->loggedin_user->id )
201
  return false;
202
+
203
  $friendship_status = BP_Friends_Friendship::check_is_friend( $bp->loggedin_user->id, $potential_friend_id );
204
 
205
  if ( 'not_friends' == $friendship_status ) {
206
+
207
  if ( !check_admin_referer( 'friends_add_friend' ) )
208
  return false;
209
+
210
  if ( !friends_add_friend( $bp->loggedin_user->id, $potential_friend_id ) ) {
211
  bp_core_add_message( __( 'Friendship could not be requested.', 'buddypress' ), 'error' );
212
  } else {
213
  bp_core_add_message( __( 'Friendship requested', 'buddypress' ) );
214
  }
215
  } else if ( 'is_friend' == $friendship_status ) {
216
+ bp_core_add_message( __( 'You are already friends with this user', 'buddypress' ), 'error' );
217
  } else {
218
+ bp_core_add_message( __( 'You already have a pending friendship request with this user', 'buddypress' ), 'error' );
219
  }
220
+
221
  bp_core_redirect( wp_get_referer() );
222
+
223
  return false;
224
  }
225
  add_action( 'init', 'friends_action_add_friend' );
226
 
227
  function friends_action_remove_friend() {
228
  global $bp;
229
+
230
  if ( $bp->current_component != $bp->friends->slug || $bp->current_action != 'remove-friend' )
231
  return false;
232
+
233
  $potential_friend_id = $bp->action_variables[0];
234
 
235
  if ( !is_numeric( $potential_friend_id ) || !isset( $potential_friend_id ) )
237
 
238
  if ( $potential_friend_id == $bp->loggedin_user->id )
239
  return false;
240
+
241
  $friendship_status = BP_Friends_Friendship::check_is_friend( $bp->loggedin_user->id, $potential_friend_id );
242
+
243
  if ( 'is_friend' == $friendship_status ) {
244
+
245
  if ( !check_admin_referer( 'friends_remove_friend' ) )
246
  return false;
247
+
248
  if ( !friends_remove_friend( $bp->loggedin_user->id, $potential_friend_id ) ) {
249
  bp_core_add_message( __( 'Friendship could not be canceled.', 'buddypress' ), 'error' );
250
  } else {
251
  bp_core_add_message( __( 'Friendship canceled', 'buddypress' ) );
252
  }
253
  } else if ( 'is_friends' == $friendship_status ) {
254
+ bp_core_add_message( __( 'You are not yet friends with this user', 'buddypress' ), 'error' );
255
  } else {
256
+ bp_core_add_message( __( 'You have a pending friendship request with this user', 'buddypress' ), 'error' );
257
  }
258
+
259
  bp_core_redirect( wp_get_referer() );
260
+
261
  return false;
262
  }
263
  add_action( 'init', 'friends_action_remove_friend' );
272
 
273
  function friends_record_activity( $args = '' ) {
274
  global $bp;
275
+
276
  if ( !function_exists( 'bp_activity_add' ) )
277
  return false;
278
 
289
  );
290
 
291
  $r = wp_parse_args( $args, $defaults );
292
+ extract( $r, EXTR_SKIP );
293
 
294
  return bp_activity_add( array( 'user_id' => $user_id, 'content' => $content, 'primary_link' => $primary_link, 'component_name' => $component_name, 'component_action' => $component_action, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) );
295
  }
303
 
304
  function friends_register_activity_actions() {
305
  global $bp;
306
+
307
  if ( !function_exists( 'bp_activity_set_action' ) )
308
  return false;
309
 
315
 
316
  function friends_format_notifications( $action, $item_id, $secondary_item_id, $total_items ) {
317
  global $bp;
318
+
319
  switch ( $action ) {
320
  case 'friendship_accepted':
321
  if ( (int)$total_items > 1 ) {
322
+ return apply_filters( 'bp_friends_multiple_friendship_accepted_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/my-friends/newest" title="' . __( 'My Friends', 'buddypress' ) . '">' . sprintf( __('%d friends accepted your friendship requests', 'buddypress' ), (int)$total_items ) . '</a>', (int)$total_items );
323
  } else {
324
  $user_fullname = bp_core_get_user_displayname( $item_id );
325
  $user_url = bp_core_get_userurl( $item_id );
326
  return apply_filters( 'bp_friends_single_friendship_accepted_notification', '<a href="' . $user_url . '?new" title="' . $user_fullname .'\'s profile">' . sprintf( __( '%s accepted your friendship request', 'buddypress' ), $user_fullname ) . '</a>', $user_fullname );
327
+ }
328
  break;
329
+
330
  case 'friendship_request':
331
  if ( (int)$total_items > 1 ) {
332
+ return apply_filters( 'bp_friends_multiple_friendship_request_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/requests" title="' . __( 'Friendship requests', 'buddypress' ) . '">' . sprintf( __('You have %d pending friendship requests', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
333
  } else {
334
  $user_fullname = bp_core_get_user_displayname( $item_id );
335
  $user_url = bp_core_get_userurl( $item_id );
336
  return apply_filters( 'bp_friends_single_friendship_request_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/requests" title="' . __( 'Friendship requests', 'buddypress' ) . '">' . sprintf( __('You have a friendship request from %s', 'buddypress' ), $user_fullname ) . '</a>', $user_fullname );
337
+ }
338
  break;
339
  }
340
 
341
  do_action( 'friends_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
342
+
343
  return false;
344
  }
345
 
358
 
359
  if ( empty( $friend_count ) )
360
  return false;
361
+
362
  if ( !(int)$friend_count )
363
  return false;
364
+
365
  return true;
366
  }
367
 
379
 
380
  function friends_get_friendship_requests( $user_id ) {
381
  $fship_ids = friends_get_friendship_ids( $user_id, true );
382
+
383
  return array( 'requests' => $fship_ids, 'total' => count($fship_ids) );
384
  }
385
 
388
  $friend_ids = friends_search_friends( $filter, $user_id, false );
389
  else
390
  $friend_ids = friends_get_friend_user_ids( $user_id );
391
+
392
  if ( !$friend_ids )
393
  return false;
394
+
395
  if ( $filter )
396
  $friend_ids = $friend_ids['friends'];
397
 
398
  $ids_and_activity = friends_get_bulk_last_active( implode( ',', (array)$friend_ids ) );
399
+
400
  if ( !$ids_and_activity )
401
  return false;
402
+
403
  $total_friends = count( $ids_and_activity );
404
+
405
  if ( $pag_num && $pag_page )
406
  return array( 'friends' => array_slice( $ids_and_activity, intval( ( $pag_page - 1 ) * $pag_num), intval( $pag_num ) ), 'total' => $total_friends );
407
  else
413
  $friend_ids = friends_search_friends( $filter, $user_id, false );
414
  else
415
  $friend_ids = friends_get_friend_user_ids( $user_id );
416
+
417
  if ( !$friend_ids )
418
  return false;
419
+
420
  if ( $filter )
421
  $friend_ids = $friend_ids['friends'];
422
+
423
  $sorted_ids = BP_Friends_Friendship::sort_by_name( implode( ',', $friend_ids ) );
424
+
425
  if ( !$sorted_ids )
426
  return false;
427
+
428
  $total_friends = count( $sorted_ids );
429
+
430
  if ( $pag_num && $pag_page )
431
  return array( 'friends' => array_slice( $sorted_ids, intval( ( $pag_page - 1 ) * $pag_num), intval( $pag_num ) ), 'total' => $total_friends );
432
  else
438
  $friend_ids = friends_search_friends( $filter, $user_id, false );
439
  else
440
  $friend_ids = friends_get_friend_user_ids( $user_id );
441
+
442
  if ( !$friend_ids )
443
+ return false;
444
 
445
  if ( $filter )
446
  $friend_ids = $friend_ids['friends'];
447
 
448
  $total_friends = count( $friend_ids );
449
+
450
  if ( $pag_num && $pag_page )
451
+ return array( 'friends' => array_slice( $friend_ids, intval( ( $pag_page - 1 ) * $pag_num), intval( $pag_num ) ), 'total' => $total_friends );
452
  else
453
+ return array( 'friends' => $friend_ids, 'total' => $total_friends );
454
  }
455
+
456
  function friends_get_bulk_last_active( $friend_ids ) {
457
  return BP_Friends_Friendship::get_bulk_last_active( $friend_ids );
458
  }
459
 
460
  function friends_get_friends_list( $user_id ) {
461
  global $bp;
462
+
463
  $friend_ids = BP_Friends_Friendship::get_friend_user_ids( $user_id );
464
 
465
  if ( !$friend_ids )
468
  for ( $i = 0; $i < count($friend_ids); $i++ ) {
469
  if ( function_exists('bp_user_fullname') )
470
  $display_name = bp_core_get_user_displayname( $friend_ids[$i] );
471
+
472
  if ( $display_name != ' ' ) {
473
  $friends[] = array(
474
  'id' => $friend_ids[$i],
476
  );
477
  }
478
  }
479
+
480
  if ( $friends && is_array($friends) )
481
  usort($friends, 'friends_sort_by_name');
482
 
486
  return $friends;
487
  }
488
 
489
+ function friends_sort_by_name($a, $b) {
490
  return strcasecmp($a['full_name'], $b['full_name']);
491
  }
492
 
493
  function friends_get_friends_invite_list( $user_id = false, $group_id ) {
494
  global $bp;
495
+
496
  if ( !$user_id )
497
  $user_id = $bp->loggedin_user->id;
498
+
499
  $friend_ids = friends_get_alphabetically( $user_id );
500
 
501
  if ( (int) $friend_ids['total'] < 1 )
504
  for ( $i = 0; $i < count($friend_ids['friends']); $i++ ) {
505
  if ( groups_check_user_has_invite( $friend_ids['friends'][$i]->user_id, $group_id ) || groups_is_user_member( $friend_ids['friends'][$i]->user_id, $group_id ) )
506
  continue;
507
+
508
  $display_name = bp_core_get_user_displayname( $friend_ids['friends'][$i]->user_id );
509
+
510
  if ( $display_name != ' ' ) {
511
  $friends[] = array(
512
  'id' => $friend_ids['friends'][$i]->user_id,
533
  global $bp;
534
 
535
  $user_ids = BP_Friends_Friendship::search_users( $search_terms, $user_id, $pag_num, $pag_page );
536
+
537
  if ( !$user_ids )
538
  return false;
539
 
540
  for ( $i = 0; $i < count($user_ids); $i++ ) {
541
  $users[] = new BP_Core_User($user_ids[$i]);
542
  }
543
+
544
  return array( 'users' => $users, 'count' => BP_Friends_Friendship::search_users_count($search_terms) );
545
  }
546
 
549
 
550
  if ( 'is_friend' == BP_Friends_Friendship::check_is_friend( $user_id, $possible_friend_id ) )
551
  return true;
552
+
553
  return false;
554
  }
555
 
556
  function friends_add_friend( $initiator_userid, $friend_userid, $force_accept = false ) {
557
  global $bp;
558
+
559
  $friendship = new BP_Friends_Friendship;
560
+
561
  if ( (int)$friendship->is_confirmed )
562
  return true;
563
+
564
  $friendship->initiator_user_id = $initiator_userid;
565
  $friendship->friend_user_id = $friend_userid;
566
  $friendship->is_confirmed = 0;
567
  $friendship->is_limited = 0;
568
  $friendship->date_created = time();
569
+
570
  if ( $force_accept )
571
  $friendship->is_confirmed = 1;
572
+
573
  if ( $friendship->save() ) {
574
+
575
  if ( !$force_accept ) {
576
  // Add the on screen notification
577
+ bp_core_add_notification( $friendship->initiator_user_id, $friendship->friend_user_id, 'friends', 'friendship_request' );
578
 
579
  // Send the email notification
580
  require_once( BP_PLUGIN_DIR . '/bp-friends/bp-friends-notifications.php' );
581
  friends_notification_new_request( $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id );
582
+
583
+ do_action( 'friends_friendship_requested', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id );
584
  } else {
585
  do_action( 'friends_friendship_accepted', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id );
586
  }
587
+
588
  return true;
589
  }
590
+
591
  return false;
592
  }
593
 
594
  function friends_remove_friend( $initiator_userid, $friend_userid ) {
595
  global $bp;
596
+
597
  $friendship_id = BP_Friends_Friendship::get_friendship_id( $initiator_userid, $friend_userid );
598
  $friendship = new BP_Friends_Friendship( $friendship_id );
599
+
600
  // Remove the activity stream item for the user who canceled the friendship
601
  friends_delete_activity( array( 'item_id' => $friendship_id, 'component_action' => 'friendship_accepted', 'user_id' => $bp->displayed_user->id ) );
602
+
603
  do_action( 'friends_friendship_deleted', $friendship_id, $initiator_userid, $friend_userid );
604
+
605
  if ( $friendship->delete() ) {
606
  friends_update_friend_totals( $initiator_userid, $friend_userid, 'remove' );
607
+
608
  return true;
609
  }
610
+
611
  return false;
612
  }
613
 
614
  function friends_accept_friendship( $friendship_id ) {
615
  global $bp;
616
+
617
  $friendship = new BP_Friends_Friendship( $friendship_id, true, false );
618
 
619
  if ( !$friendship->is_confirmed && BP_Friends_Friendship::accept( $friendship_id ) ) {
620
  friends_update_friend_totals( $friendship->initiator_user_id, $friendship->friend_user_id );
621
+
622
  /* Remove the friend request notice */
623
+ bp_core_delete_notifications_for_user_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, 'friends', 'friendship_request' );
624
+
625
  /* Add a friend accepted notice for the initiating user */
626
  bp_core_add_notification( $friendship->friend_user_id, $friendship->initiator_user_id, 'friends', 'friendship_accepted' );
627
+
628
  $initiator_link = bp_core_get_userlink( $friendship->initiator_user_id );
629
  $friend_link = bp_core_get_userlink( $friendship->friend_user_id );
630
+
631
+ $primary_link = apply_filters( 'friends_activity_friendship_accepted_primary_link', bp_core_get_userurl( $friendship->initiator_user_id ), &$friendship );
632
+
633
  /* Record in activity streams for the initiator */
634
+ friends_record_activity( array(
635
  'user_id' => $friendship->initiator_user_id,
636
  'component_action' => 'friendship_created',
637
  'content' => apply_filters( 'friends_activity_friendship_accepted', sprintf( __( '%s and %s are now friends', 'buddypress' ), $initiator_link, $friend_link ), &$friendship ),
640
  ) );
641
 
642
  /* Record in activity streams for the friend */
643
+ friends_record_activity( array(
644
  'user_id' => $friendship->friend_user_id,
645
  'component_action' => 'friendship_created',
646
  'content' => apply_filters( 'friends_activity_friendship_accepted', sprintf( __( '%s and %s are now friends', 'buddypress' ), $friend_link, $initiator_link ), &$friendship ),
648
  'item_id' => $friendship_id,
649
  'hide_sitewide' => true /* We've already got the first entry site wide */
650
  ) );
651
+
652
  /* Send the email notification */
653
  require_once( BP_PLUGIN_DIR . '/bp-friends/bp-friends-notifications.php' );
654
  friends_notification_accepted_request( $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id );
655
 
656
  do_action( 'friends_friendship_accepted', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id );
657
+
658
  return true;
659
  }
660
+
661
  return false;
662
  }
663
 
664
+ function friends_reject_friendship( $friendship_id ) {
665
  $friendship = new BP_Friends_Friendship( $friendship_id, true, false );
666
 
667
  if ( !$friendship->is_confirmed && BP_Friends_Friendship::reject( $friendship_id ) ) {
668
  // Remove the friend request notice
669
+ bp_core_delete_notifications_for_user_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, 'friends', 'friendship_request' );
670
+
671
  do_action( 'friends_friendship_rejected', $friendship_id, &$friendship );
672
  return true;
673
  }
674
+
675
  return false;
676
  }
677
 
686
  update_usermeta( $friend_user_id, 'total_friend_count', (int)get_usermeta( $friend_user_id, 'total_friend_count' ) + 1 );
687
  } else {
688
  update_usermeta( $initiator_user_id, 'total_friend_count', (int)get_usermeta( $initiator_user_id, 'total_friend_count' ) - 1 );
689
+ update_usermeta( $friend_user_id, 'total_friend_count', (int)get_usermeta( $friend_user_id, 'total_friend_count' ) - 1 );
690
  }
691
  }
692
 
693
  function friends_remove_data( $user_id ) {
694
  BP_Friends_Friendship::delete_all_for_user($user_id);
695
+
696
  /* Remove usermeta */
697
  delete_usermeta( $user_id, 'total_friend_count' );
698
+
699
  /* Remove friendship requests FROM user */
700
  bp_core_delete_notifications_from_user( $user_id, $bp->friends->slug, 'friendship_request' );
701
 
bp-friends/bp-friends-classes.php CHANGED
@@ -7,15 +7,15 @@ class BP_Friends_Friendship {
7
  var $is_confirmed;
8
  var $is_limited;
9
  var $date_created;
10
-
11
  var $is_request;
12
  var $populate_friend_details;
13
-
14
  var $friend;
15
-
16
  function bp_friends_friendship( $id = null, $is_request = false, $populate_friend_details = true ) {
17
  $this->is_request = $is_request;
18
-
19
  if ( $id ) {
20
  $this->id = $id;
21
  $this->populate_friend_details = $populate_friend_details;
@@ -25,7 +25,7 @@ class BP_Friends_Friendship {
25
 
26
  function populate() {
27
  global $wpdb, $bp, $creds;
28
-
29
  if ( $friendship = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->friends->table_name} WHERE id = %d", $this->id ) ) ) {
30
  $this->initiator_user_id = $friendship->initiator_user_id;
31
  $this->friend_user_id = $friendship->friend_user_id;
@@ -33,11 +33,11 @@ class BP_Friends_Friendship {
33
  $this->is_limited = $friendship->is_limited;
34
  $this->date_created = $friendship->date_created;
35
  }
36
-
37
  // if running from ajax.
38
  if ( !$bp->displayed_user->id )
39
  $bp->displayed_user->id = $creds['current_userid'];
40
-
41
  if ( $this->populate_friend_details ) {
42
  if ( $this->friend_user_id == $bp->displayed_user->id ) {
43
  $this->friend = new BP_Core_User( $this->initiator_user_id );
@@ -46,7 +46,7 @@ class BP_Friends_Friendship {
46
  }
47
  }
48
  }
49
-
50
  function save() {
51
  global $wpdb, $bp;
52
 
@@ -56,8 +56,8 @@ class BP_Friends_Friendship {
56
  $this->is_limited = apply_filters( 'friends_friendship_is_limited_before_save', $this->is_limited, $this->id );
57
  $this->date_created = apply_filters( 'friends_friendship_date_created_before_save', $this->date_created, $this->id );
58
 
59
- do_action( 'friends_friendship_before_save', $this );
60
-
61
  if ( $this->id ) {
62
  // Update
63
  $result = $wpdb->query( $wpdb->prepare( "UPDATE {$bp->friends->table_name} SET initiator_user_id = %d, friend_user_id = %d, is_confirmed = %d, is_limited = %d, date_created = FROM_UNIXTIME(%d) ) WHERE id = %d", $this->initiator_user_id, $this->friend_user_id, $this->is_confirmed, $this->is_limited, $this->date_created, $this->id ) );
@@ -67,22 +67,22 @@ class BP_Friends_Friendship {
67
  $this->id = $wpdb->insert_id;
68
  }
69
 
70
- do_action( 'friends_friendship_after_save', $this );
71
-
72
  return $result;
73
  }
74
-
75
  function delete() {
76
  global $wpdb, $bp;
77
-
78
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->friends->table_name} WHERE id = %d", $this->id ) );
79
  }
80
-
81
  /* Static Functions */
82
-
83
  function get_friend_user_ids( $user_id, $friend_requests_only = false, $assoc_arr = false ) {
84
  global $wpdb, $bp;
85
-
86
  if ( $friend_requests_only ) {
87
  $oc_sql = $wpdb->prepare( "AND is_confirmed = 0" );
88
  $friend_sql = $wpdb->prepare ( " WHERE friend_user_id = %d", $user_id );
@@ -92,17 +92,17 @@ class BP_Friends_Friendship {
92
  }
93
 
94
  $friends = $wpdb->get_results( $wpdb->prepare( "SELECT friend_user_id, initiator_user_id FROM {$bp->friends->table_name} $friend_sql $oc_sql ORDER BY date_created DESC" ) );
95
-
96
  for ( $i = 0; $i < count($friends); $i++ ) {
97
  if ( $assoc_arr )
98
  $fids[] = array( 'user_id' => ( $friends[$i]->friend_user_id == $user_id ) ? $friends[$i]->initiator_user_id : $friends[$i]->friend_user_id );
99
  else
100
  $fids[] = ( $friends[$i]->friend_user_id == $user_id ) ? $friends[$i]->initiator_user_id : $friends[$i]->friend_user_id;
101
  }
102
-
103
  return $fids;
104
  }
105
-
106
  function get_friendship_ids( $user_id, $friend_requests_only = false ) {
107
  global $wpdb, $bp;
108
 
@@ -113,82 +113,82 @@ class BP_Friends_Friendship {
113
  $oc_sql = $wpdb->prepare( "AND is_confirmed = 1" );
114
  $friend_sql = $wpdb->prepare ( " WHERE (initiator_user_id = %d OR friend_user_id = %d)", $user_id, $user_id );
115
  }
116
-
117
  return $wpdb->get_col( $wpdb->prepare( "SELECT id FROM {$bp->friends->table_name} $friend_sql $oc_sql" ) );
118
  }
119
-
120
  function get_friendship_id( $user_id, $friend_id ) {
121
  global $wpdb, $bp;
122
-
123
  return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->friends->table_name} WHERE ( initiator_user_id = %d AND friend_user_id = %d ) OR ( initiator_user_id = %d AND friend_user_id = %d ) AND is_confirmed = 1", $user_id, $friend_id, $friend_id, $user_id ) );
124
  }
125
-
126
  function total_friend_count( $user_id = false) {
127
  global $wpdb, $bp;
128
-
129
  if ( !$user_id )
130
  $user_id = $bp->displayed_user->id;
131
-
132
- /* This is stored in 'total_friend_count' usermeta.
133
  This function will recalculate, update and return. */
134
-
135
- $count = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->friends->table_name} WHERE (initiator_user_id = %d OR friend_user_id = %d) AND is_confirmed = 1", $user_id, $user_id ) );
136
 
137
  if ( !$count )
138
  return 0;
139
-
140
  update_usermeta( $user_id, 'total_friend_count', $count );
141
  return $count;
142
  }
143
-
144
  function search_friends( $filter, $user_id, $limit = null, $page = null ) {
145
  global $wpdb, $bp;
146
-
147
  // TODO: Optimize this function.
148
-
149
  if ( !$user_id )
150
  $user_id = $bp->loggedin_user->id;
151
-
152
  $filter = like_escape( $wpdb->escape( $filter ) );
153
-
154
  if ( $limit && $page )
155
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
156
-
157
  if ( !$friend_ids = BP_Friends_Friendship::get_friend_user_ids( $user_id ) )
158
  return false;
159
 
160
  // Get all the user ids for the current user's friends.
161
  $fids = implode( ',', $friend_ids );
162
-
163
  if ( empty($fids) )
164
  return false;
165
 
166
  // filter the user_ids based on the search criteria.
167
  if ( function_exists('xprofile_install') ) {
168
  $sql = $wpdb->prepare( "SELECT DISTINCT user_id FROM {$bp->profile->table_name_data} WHERE user_id IN ($fids) AND value LIKE '$filter%%' {$pag_sql}" );
169
- $total_sql = $wpdb->prepare( "SELECT DISTINCT count(user_id) FROM {$bp->profile->table_name_data} WHERE user_id IN ($fids) AND value LIKE '$filter%%'" );
170
  } else {
171
  $sql = $wpdb->prepare( "SELECT DISTINCT user_id FROM " . CUSTOM_USER_META_TABLE . " WHERE user_id IN ($fids) AND meta_key = 'nickname' AND meta_value LIKE '$filter%%' {$pag_sql}" );
172
- $total_sql = $wpdb->prepare( "SELECT DISTINCT count(user_id) FROM " . CUSTOM_USER_META_TABLE . " WHERE user_id IN ($fids) AND meta_key = 'nickname' AND meta_value LIKE '$filter%%'" );
173
  }
174
 
175
- $filtered_friend_ids = $wpdb->get_col($sql);
176
- $total_friend_ids = $wpdb->get_var($total_sql);
177
-
178
  if ( !$filtered_friend_ids )
179
  return false;
180
 
181
  return array( 'friends' => $filtered_friend_ids, 'total' => (int)$total_friend_ids );
182
  }
183
-
184
  function check_is_friend( $loggedin_userid, $possible_friend_userid ) {
185
  global $wpdb, $bp;
186
-
187
  if ( !$loggedin_userid || !$possible_friend_userid )
188
  return false;
189
-
190
  $result = $wpdb->get_results( $wpdb->prepare( "SELECT id, is_confirmed FROM {$bp->friends->table_name} WHERE (initiator_user_id = %d AND friend_user_id = %d) OR (initiator_user_id = %d AND friend_user_id = %d)", $loggedin_userid, $possible_friend_userid, $possible_friend_userid, $loggedin_userid ) );
191
-
192
  if ( $result ) {
193
  if ( 0 == (int)$result[0]->is_confirmed ) {
194
  return 'pending';
@@ -199,81 +199,81 @@ class BP_Friends_Friendship {
199
  return 'not_friends';
200
  }
201
  }
202
-
203
  function get_bulk_last_active( $user_ids ) {
204
  global $wpdb, $bp;
205
 
206
  return $wpdb->get_results( $wpdb->prepare( "SELECT meta_value as last_activity, user_id FROM " . CUSTOM_USER_META_TABLE . " WHERE meta_key = 'last_activity' AND user_id IN ( {$user_ids} ) ORDER BY meta_value DESC" ) );
207
  }
208
-
209
  function accept($friendship_id) {
210
  global $wpdb, $bp;
211
 
212
  return $wpdb->query( $wpdb->prepare( "UPDATE {$bp->friends->table_name} SET is_confirmed = 1, date_created = FROM_UNIXTIME(%d) WHERE id = %d AND friend_user_id = %d", time(), $friendship_id, $bp->loggedin_user->id ) );
213
  }
214
-
215
  function reject($friendship_id) {
216
  global $wpdb, $bp;
217
-
218
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->friends->table_name} WHERE id = %d AND friend_user_id = %d", $friendship_id, $bp->loggedin_user->id ) );
219
  }
220
-
221
  function search_users( $filter, $user_id, $limit = null, $page = null ) {
222
  global $wpdb, $bp;
223
-
224
  $filter = like_escape( $wpdb->escape( $filter ) );
225
  $usermeta_table = $wpdb->base_prefix . 'usermeta';
226
  $users_table = $wpdb->base_prefix . 'users';
227
 
228
  if ( $limit && $page )
229
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
230
-
231
  // filter the user_ids based on the search criteria.
232
  if ( function_exists('xprofile_install') ) {
233
  $sql = $wpdb->prepare( "SELECT DISTINCT d.user_id as id FROM {$bp->profile->table_name_data} d, $users_table u WHERE d.user_id = u.id AND d.value LIKE '$filter%%' ORDER BY d.value DESC $pag_sql" );
234
  } else {
235
  $sql = $wpdb->prepare( "SELECT DISTINCT user_id as id FROM $usermeta_table WHERE meta_value LIKE '$filter%%' ORDER BY d.value DESC $pag_sql" );
236
  }
237
-
238
- $filtered_fids = $wpdb->get_col($sql);
239
-
240
  if ( !$filtered_fids )
241
  return false;
242
 
243
  return $filtered_fids;
244
  }
245
-
246
  function search_users_count( $filter ) {
247
  global $wpdb, $bp;
248
-
249
  $filter = like_escape( $wpdb->escape( $filter ) );
250
  $usermeta_table = $wpdb->prefix . 'usermeta';
251
  $users_table = $wpdb->base_prefix . 'users';
252
-
253
  // filter the user_ids based on the search criteria.
254
  if ( function_exists('xprofile_install') ) {
255
- $sql = $wpdb->prepare( "SELECT DISTINCT count(d.user_id) FROM {$bp->profile->table_name_data} d, $users_table u WHERE d.user_id = u.id AND d.value LIKE '$filter%%'" );
256
  } else {
257
- $sql = $wpdb->prepare( "SELECT DISTINCT count(user_id) FROM $usermeta_table WHERE meta_value LIKE '$filter%%'" );
258
  }
259
 
260
- $user_count = $wpdb->get_col($sql);
261
-
262
  if ( !$user_count )
263
  return false;
264
 
265
  return $user_count[0];
266
  }
267
-
268
  function sort_by_name( $user_ids ) {
269
  global $wpdb, $bp;
270
-
271
  if ( !function_exists( 'xprofile_install') )
272
  return false;
273
-
274
  return $wpdb->get_results( $wpdb->prepare( "SELECT user_id FROM {$bp->profile->table_name_data} pd, {$bp->profile->table_name_fields} pf WHERE pf.id = pd.field_id AND pf.name = %s AND pd.user_id IN ( {$user_ids} ) ORDER BY pd.value ASC", BP_XPROFILE_FULLNAME_FIELD_NAME ) );
275
  }
276
-
277
  function get_random_friends( $user_id, $total_friends = 5 ) {
278
  global $wpdb, $bp;
279
 
@@ -283,50 +283,50 @@ class BP_Friends_Friendship {
283
  for ( $i = 0; $i < count($results); $i++ ) {
284
  $fids[] = ( $results[$i]->friend_user_id == $user_id ) ? $results[$i]->initiator_user_id : $results[$i]->friend_user_id;
285
  }
286
-
287
  // remove duplicates
288
  if ( count($fids) > 0 )
289
  return array_flip(array_flip($fids));
290
  else
291
  return false;
292
  }
293
-
294
  function get_invitable_friend_count( $user_id, $group_id ) {
295
  global $wpdb, $bp;
296
 
297
  $friend_ids = BP_Friends_Friendship::get_friend_user_ids( $user_id );
298
-
299
  $invitable_count = 0;
300
  for ( $i = 0; $i < count($friend_ids); $i++ ) {
301
-
302
  if ( BP_Groups_Member::check_is_member( (int)$friend_ids[$i], $group_id ) )
303
  continue;
304
-
305
  if ( BP_Groups_Member::check_has_invite( (int)$friend_ids[$i], $group_id ) )
306
  continue;
307
-
308
  $invitable_count++;
309
  }
310
 
311
  return $invitable_count;
312
  }
313
-
314
  function get_user_ids_for_friendship( $friendship_id ) {
315
  global $wpdb, $bp;
316
 
317
  return $wpdb->get_row( $wpdb->prepare( "SELECT friend_user_id, initiator_user_id FROM {$bp->friends->table_name} WHERE id = %d", $friendship_id ) );
318
  }
319
-
320
  function delete_all_for_user( $user_id ) {
321
  global $wpdb, $bp;
322
 
323
- $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->friends->table_name} WHERE friend_user_id = %d OR initiator_user_id = %d", $user_id, $user_id ) );
324
-
325
- // Delete friend request notifications for members who have a notification from this user.
326
  $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE component_name = 'friends' AND ( component_action = 'friendship_request' OR component_action = 'friendship_accepted' ) AND item_id = %d", $user_id ) );
327
  }
328
  }
329
-
330
 
331
 
332
  ?>
7
  var $is_confirmed;
8
  var $is_limited;
9
  var $date_created;
10
+
11
  var $is_request;
12
  var $populate_friend_details;
13
+
14
  var $friend;
15
+
16
  function bp_friends_friendship( $id = null, $is_request = false, $populate_friend_details = true ) {
17
  $this->is_request = $is_request;
18
+
19
  if ( $id ) {
20
  $this->id = $id;
21
  $this->populate_friend_details = $populate_friend_details;
25
 
26
  function populate() {
27
  global $wpdb, $bp, $creds;
28
+
29
  if ( $friendship = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->friends->table_name} WHERE id = %d", $this->id ) ) ) {
30
  $this->initiator_user_id = $friendship->initiator_user_id;
31
  $this->friend_user_id = $friendship->friend_user_id;
33
  $this->is_limited = $friendship->is_limited;
34
  $this->date_created = $friendship->date_created;
35
  }
36
+
37
  // if running from ajax.
38
  if ( !$bp->displayed_user->id )
39
  $bp->displayed_user->id = $creds['current_userid'];
40
+
41
  if ( $this->populate_friend_details ) {
42
  if ( $this->friend_user_id == $bp->displayed_user->id ) {
43
  $this->friend = new BP_Core_User( $this->initiator_user_id );
46
  }
47
  }
48
  }
49
+
50
  function save() {
51
  global $wpdb, $bp;
52
 
56
  $this->is_limited = apply_filters( 'friends_friendship_is_limited_before_save', $this->is_limited, $this->id );
57
  $this->date_created = apply_filters( 'friends_friendship_date_created_before_save', $this->date_created, $this->id );
58
 
59
+ do_action( 'friends_friendship_before_save', $this );
60
+
61
  if ( $this->id ) {
62
  // Update
63
  $result = $wpdb->query( $wpdb->prepare( "UPDATE {$bp->friends->table_name} SET initiator_user_id = %d, friend_user_id = %d, is_confirmed = %d, is_limited = %d, date_created = FROM_UNIXTIME(%d) ) WHERE id = %d", $this->initiator_user_id, $this->friend_user_id, $this->is_confirmed, $this->is_limited, $this->date_created, $this->id ) );
67
  $this->id = $wpdb->insert_id;
68
  }
69
 
70
+ do_action( 'friends_friendship_after_save', $this );
71
+
72
  return $result;
73
  }
74
+
75
  function delete() {
76
  global $wpdb, $bp;
77
+
78
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->friends->table_name} WHERE id = %d", $this->id ) );
79
  }
80
+
81
  /* Static Functions */
82
+
83
  function get_friend_user_ids( $user_id, $friend_requests_only = false, $assoc_arr = false ) {
84
  global $wpdb, $bp;
85
+
86
  if ( $friend_requests_only ) {
87
  $oc_sql = $wpdb->prepare( "AND is_confirmed = 0" );
88
  $friend_sql = $wpdb->prepare ( " WHERE friend_user_id = %d", $user_id );
92
  }
93
 
94
  $friends = $wpdb->get_results( $wpdb->prepare( "SELECT friend_user_id, initiator_user_id FROM {$bp->friends->table_name} $friend_sql $oc_sql ORDER BY date_created DESC" ) );
95
+
96
  for ( $i = 0; $i < count($friends); $i++ ) {
97
  if ( $assoc_arr )
98
  $fids[] = array( 'user_id' => ( $friends[$i]->friend_user_id == $user_id ) ? $friends[$i]->initiator_user_id : $friends[$i]->friend_user_id );
99
  else
100
  $fids[] = ( $friends[$i]->friend_user_id == $user_id ) ? $friends[$i]->initiator_user_id : $friends[$i]->friend_user_id;
101
  }
102
+
103
  return $fids;
104
  }
105
+
106
  function get_friendship_ids( $user_id, $friend_requests_only = false ) {
107
  global $wpdb, $bp;
108
 
113
  $oc_sql = $wpdb->prepare( "AND is_confirmed = 1" );
114
  $friend_sql = $wpdb->prepare ( " WHERE (initiator_user_id = %d OR friend_user_id = %d)", $user_id, $user_id );
115
  }
116
+
117
  return $wpdb->get_col( $wpdb->prepare( "SELECT id FROM {$bp->friends->table_name} $friend_sql $oc_sql" ) );
118
  }
119
+
120
  function get_friendship_id( $user_id, $friend_id ) {
121
  global $wpdb, $bp;
122
+
123
  return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->friends->table_name} WHERE ( initiator_user_id = %d AND friend_user_id = %d ) OR ( initiator_user_id = %d AND friend_user_id = %d ) AND is_confirmed = 1", $user_id, $friend_id, $friend_id, $user_id ) );
124
  }
125
+
126
  function total_friend_count( $user_id = false) {
127
  global $wpdb, $bp;
128
+
129
  if ( !$user_id )
130
  $user_id = $bp->displayed_user->id;
131
+
132
+ /* This is stored in 'total_friend_count' usermeta.
133
  This function will recalculate, update and return. */
134
+
135
+ $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->friends->table_name} WHERE (initiator_user_id = %d OR friend_user_id = %d) AND is_confirmed = 1", $user_id, $user_id ) );
136
 
137
  if ( !$count )
138
  return 0;
139
+
140
  update_usermeta( $user_id, 'total_friend_count', $count );
141
  return $count;
142
  }
143
+
144
  function search_friends( $filter, $user_id, $limit = null, $page = null ) {
145
  global $wpdb, $bp;
146
+
147
  // TODO: Optimize this function.
148
+
149
  if ( !$user_id )
150
  $user_id = $bp->loggedin_user->id;
151
+
152
  $filter = like_escape( $wpdb->escape( $filter ) );
153
+
154
  if ( $limit && $page )
155
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
156
+
157
  if ( !$friend_ids = BP_Friends_Friendship::get_friend_user_ids( $user_id ) )
158
  return false;
159
 
160
  // Get all the user ids for the current user's friends.
161
  $fids = implode( ',', $friend_ids );
162
+
163
  if ( empty($fids) )
164
  return false;
165
 
166
  // filter the user_ids based on the search criteria.
167
  if ( function_exists('xprofile_install') ) {
168
  $sql = $wpdb->prepare( "SELECT DISTINCT user_id FROM {$bp->profile->table_name_data} WHERE user_id IN ($fids) AND value LIKE '$filter%%' {$pag_sql}" );
169
+ $total_sql = $wpdb->prepare( "SELECT COUNT(DISTINCT user_id) FROM {$bp->profile->table_name_data} WHERE user_id IN ($fids) AND value LIKE '$filter%%'" );
170
  } else {
171
  $sql = $wpdb->prepare( "SELECT DISTINCT user_id FROM " . CUSTOM_USER_META_TABLE . " WHERE user_id IN ($fids) AND meta_key = 'nickname' AND meta_value LIKE '$filter%%' {$pag_sql}" );
172
+ $total_sql = $wpdb->prepare( "SELECT COUNT(DISTINCT user_id) FROM " . CUSTOM_USER_META_TABLE . " WHERE user_id IN ($fids) AND meta_key = 'nickname' AND meta_value LIKE '$filter%%'" );
173
  }
174
 
175
+ $filtered_friend_ids = $wpdb->get_col($sql);
176
+ $total_friend_ids = $wpdb->get_var($total_sql);
177
+
178
  if ( !$filtered_friend_ids )
179
  return false;
180
 
181
  return array( 'friends' => $filtered_friend_ids, 'total' => (int)$total_friend_ids );
182
  }
183
+
184
  function check_is_friend( $loggedin_userid, $possible_friend_userid ) {
185
  global $wpdb, $bp;
186
+
187
  if ( !$loggedin_userid || !$possible_friend_userid )
188
  return false;
189
+
190
  $result = $wpdb->get_results( $wpdb->prepare( "SELECT id, is_confirmed FROM {$bp->friends->table_name} WHERE (initiator_user_id = %d AND friend_user_id = %d) OR (initiator_user_id = %d AND friend_user_id = %d)", $loggedin_userid, $possible_friend_userid, $possible_friend_userid, $loggedin_userid ) );
191
+
192
  if ( $result ) {
193
  if ( 0 == (int)$result[0]->is_confirmed ) {
194
  return 'pending';
199
  return 'not_friends';
200
  }
201
  }
202
+
203
  function get_bulk_last_active( $user_ids ) {
204
  global $wpdb, $bp;
205
 
206
  return $wpdb->get_results( $wpdb->prepare( "SELECT meta_value as last_activity, user_id FROM " . CUSTOM_USER_META_TABLE . " WHERE meta_key = 'last_activity' AND user_id IN ( {$user_ids} ) ORDER BY meta_value DESC" ) );
207
  }
208
+
209
  function accept($friendship_id) {
210
  global $wpdb, $bp;
211
 
212
  return $wpdb->query( $wpdb->prepare( "UPDATE {$bp->friends->table_name} SET is_confirmed = 1, date_created = FROM_UNIXTIME(%d) WHERE id = %d AND friend_user_id = %d", time(), $friendship_id, $bp->loggedin_user->id ) );
213
  }
214
+
215
  function reject($friendship_id) {
216
  global $wpdb, $bp;
217
+
218
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->friends->table_name} WHERE id = %d AND friend_user_id = %d", $friendship_id, $bp->loggedin_user->id ) );
219
  }
220
+
221
  function search_users( $filter, $user_id, $limit = null, $page = null ) {
222
  global $wpdb, $bp;
223
+
224
  $filter = like_escape( $wpdb->escape( $filter ) );
225
  $usermeta_table = $wpdb->base_prefix . 'usermeta';
226
  $users_table = $wpdb->base_prefix . 'users';
227
 
228
  if ( $limit && $page )
229
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
230
+
231
  // filter the user_ids based on the search criteria.
232
  if ( function_exists('xprofile_install') ) {
233
  $sql = $wpdb->prepare( "SELECT DISTINCT d.user_id as id FROM {$bp->profile->table_name_data} d, $users_table u WHERE d.user_id = u.id AND d.value LIKE '$filter%%' ORDER BY d.value DESC $pag_sql" );
234
  } else {
235
  $sql = $wpdb->prepare( "SELECT DISTINCT user_id as id FROM $usermeta_table WHERE meta_value LIKE '$filter%%' ORDER BY d.value DESC $pag_sql" );
236
  }
237
+
238
+ $filtered_fids = $wpdb->get_col($sql);
239
+
240
  if ( !$filtered_fids )
241
  return false;
242
 
243
  return $filtered_fids;
244
  }
245
+
246
  function search_users_count( $filter ) {
247
  global $wpdb, $bp;
248
+
249
  $filter = like_escape( $wpdb->escape( $filter ) );
250
  $usermeta_table = $wpdb->prefix . 'usermeta';
251
  $users_table = $wpdb->base_prefix . 'users';
252
+
253
  // filter the user_ids based on the search criteria.
254
  if ( function_exists('xprofile_install') ) {
255
+ $sql = $wpdb->prepare( "SELECT COUNT(DISTINCT d.user_id) FROM {$bp->profile->table_name_data} d, $users_table u WHERE d.user_id = u.id AND d.value LIKE '$filter%%'" );
256
  } else {
257
+ $sql = $wpdb->prepare( "SELECT COUNT(DISTINCT user_id) FROM $usermeta_table WHERE meta_value LIKE '$filter%%'" );
258
  }
259
 
260
+ $user_count = $wpdb->get_col($sql);
261
+
262
  if ( !$user_count )
263
  return false;
264
 
265
  return $user_count[0];
266
  }
267
+
268
  function sort_by_name( $user_ids ) {
269
  global $wpdb, $bp;
270
+
271
  if ( !function_exists( 'xprofile_install') )
272
  return false;
273
+
274
  return $wpdb->get_results( $wpdb->prepare( "SELECT user_id FROM {$bp->profile->table_name_data} pd, {$bp->profile->table_name_fields} pf WHERE pf.id = pd.field_id AND pf.name = %s AND pd.user_id IN ( {$user_ids} ) ORDER BY pd.value ASC", BP_XPROFILE_FULLNAME_FIELD_NAME ) );
275
  }
276
+
277
  function get_random_friends( $user_id, $total_friends = 5 ) {
278
  global $wpdb, $bp;
279
 
283
  for ( $i = 0; $i < count($results); $i++ ) {
284
  $fids[] = ( $results[$i]->friend_user_id == $user_id ) ? $results[$i]->initiator_user_id : $results[$i]->friend_user_id;
285
  }
286
+
287
  // remove duplicates
288
  if ( count($fids) > 0 )
289
  return array_flip(array_flip($fids));
290
  else
291
  return false;
292
  }
293
+
294
  function get_invitable_friend_count( $user_id, $group_id ) {
295
  global $wpdb, $bp;
296
 
297
  $friend_ids = BP_Friends_Friendship::get_friend_user_ids( $user_id );
298
+
299
  $invitable_count = 0;
300
  for ( $i = 0; $i < count($friend_ids); $i++ ) {
301
+
302
  if ( BP_Groups_Member::check_is_member( (int)$friend_ids[$i], $group_id ) )
303
  continue;
304
+
305
  if ( BP_Groups_Member::check_has_invite( (int)$friend_ids[$i], $group_id ) )
306
  continue;
307
+
308
  $invitable_count++;
309
  }
310
 
311
  return $invitable_count;
312
  }
313
+
314
  function get_user_ids_for_friendship( $friendship_id ) {
315
  global $wpdb, $bp;
316
 
317
  return $wpdb->get_row( $wpdb->prepare( "SELECT friend_user_id, initiator_user_id FROM {$bp->friends->table_name} WHERE id = %d", $friendship_id ) );
318
  }
319
+
320
  function delete_all_for_user( $user_id ) {
321
  global $wpdb, $bp;
322
 
323
+ $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->friends->table_name} WHERE friend_user_id = %d OR initiator_user_id = %d", $user_id, $user_id ) );
324
+
325
+ // Delete friend request notifications for members who have a notification from this user.
326
  $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE component_name = 'friends' AND ( component_action = 'friendship_request' OR component_action = 'friendship_accepted' ) AND item_id = %d", $user_id ) );
327
  }
328
  }
329
+
330
 
331
 
332
  ?>
bp-friends/bp-friends-notifications.php CHANGED
@@ -2,25 +2,25 @@
2
 
3
  function friends_notification_new_request( $friendship_id, $initiator_id, $friend_id ) {
4
  global $bp;
5
-
6
  $initiator_name = bp_core_get_user_displayname( $initiator_id );
7
 
8
  if ( 'no' == get_usermeta( (int)$friend_id, 'notification_friends_friendship_request' ) )
9
  return false;
10
-
11
  $ud = get_userdata( $friend_id );
12
  $initiator_ud = get_userdata( $initiator_id );
13
-
14
  $all_requests_link = bp_core_get_user_domain( $friend_id ) . 'friends/requests/';
15
- $settings_link = bp_core_get_user_domain( $friend_id ) . 'settings/notifications';
16
-
17
  $initiator_link = bp_core_get_user_domain( $initiator_id );
18
 
19
  // Set up and send the message
20
  $to = $ud->user_email;
21
  $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'New friendship request from %s', 'buddypress' ), $initiator_name );
22
 
23
- $message = sprintf( __(
24
  "%s wants to add you as a friend.
25
 
26
  To view all of your pending friendship requests: %s
@@ -39,24 +39,24 @@ To view %s's profile: %s
39
 
40
  function friends_notification_accepted_request( $friendship_id, $initiator_id, $friend_id ) {
41
  global $bp;
42
-
43
  $friendship = new BP_Friends_Friendship( $friendship_id, false, false );
44
-
45
  $friend_name = bp_core_get_user_displayname( $friend_id );
46
 
47
  if ( 'no' == get_usermeta( (int)$initiator_id, 'notification_friends_friendship_accepted' ) )
48
  return false;
49
-
50
  $ud = get_userdata( $initiator_id );
51
-
52
  $friend_link = bp_core_get_user_domain( $friend_id );
53
- $settings_link = bp_core_get_user_domain( $initiator_id ) . 'settings/notifications';
54
-
55
  // Set up and send the message
56
  $to = $ud->user_email;
57
  $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( '%s accepted your friendship request', 'buddypress' ), $friend_name );
58
 
59
- $message = sprintf( __(
60
  '%s accepted your friend request.
61
 
62
  To view %s\'s profile: %s
2
 
3
  function friends_notification_new_request( $friendship_id, $initiator_id, $friend_id ) {
4
  global $bp;
5
+
6
  $initiator_name = bp_core_get_user_displayname( $initiator_id );
7
 
8
  if ( 'no' == get_usermeta( (int)$friend_id, 'notification_friends_friendship_request' ) )
9
  return false;
10
+
11
  $ud = get_userdata( $friend_id );
12
  $initiator_ud = get_userdata( $initiator_id );
13
+
14
  $all_requests_link = bp_core_get_user_domain( $friend_id ) . 'friends/requests/';
15
+ $settings_link = bp_core_get_user_domain( $friend_id ) . $bp->settings->slug . '/notifications';
16
+
17
  $initiator_link = bp_core_get_user_domain( $initiator_id );
18
 
19
  // Set up and send the message
20
  $to = $ud->user_email;
21
  $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'New friendship request from %s', 'buddypress' ), $initiator_name );
22
 
23
+ $message = sprintf( __(
24
  "%s wants to add you as a friend.
25
 
26
  To view all of your pending friendship requests: %s
39
 
40
  function friends_notification_accepted_request( $friendship_id, $initiator_id, $friend_id ) {
41
  global $bp;
42
+
43
  $friendship = new BP_Friends_Friendship( $friendship_id, false, false );
44
+
45
  $friend_name = bp_core_get_user_displayname( $friend_id );
46
 
47
  if ( 'no' == get_usermeta( (int)$initiator_id, 'notification_friends_friendship_accepted' ) )
48
  return false;
49
+
50
  $ud = get_userdata( $initiator_id );
51
+
52
  $friend_link = bp_core_get_user_domain( $friend_id );
53
+ $settings_link = bp_core_get_user_domain( $initiator_id ) . $bp->settings->slug . '/notifications';
54
+
55
  // Set up and send the message
56
  $to = $ud->user_email;
57
  $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( '%s accepted your friendship request', 'buddypress' ), $friend_name );
58
 
59
+ $message = sprintf( __(
60
  '%s accepted your friend request.
61
 
62
  To view %s\'s profile: %s
bp-friends/bp-friends-templatetags.php CHANGED
@@ -5,20 +5,20 @@ class BP_Friendship_Template {
5
  var $friendship_count;
6
  var $friendships;
7
  var $friendship;
8
-
9
  var $in_the_loop;
10
-
11
  var $pag_page;
12
  var $pag_num;
13
  var $pag_links;
14
  var $total_friend_count;
15
-
16
  function bp_friendship_template( $user_id, $type, $per_page, $max, $filter ) {
17
  global $bp;
18
 
19
  if ( !$user_id )
20
  $user_id = $bp->displayed_user->id;
21
-
22
  $this->pag_page = isset( $_REQUEST['frpage'] ) ? intval( $_REQUEST['frpage'] ) : 1;
23
  $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
24
  $this->type = $type;
@@ -27,9 +27,9 @@ class BP_Friendship_Template {
27
  case 'newest':
28
  $this->friendships = friends_get_newest( $user_id, $this->pag_num, $this->pag_page, $filter );
29
  break;
30
-
31
  case 'alphabetical':
32
- $this->friendships = friends_get_alphabetically( $user_id, $this->pag_num, $this->pag_page, $filter );
33
  break;
34
 
35
  case 'requests':
@@ -37,7 +37,7 @@ class BP_Friendship_Template {
37
  break;
38
 
39
  case 'active': default:
40
- $this->friendships = friends_get_recently_active( $user_id, $this->pag_num, $this->pag_page, $filter );
41
  break;
42
  }
43
 
@@ -73,29 +73,29 @@ class BP_Friendship_Template {
73
  'mid_size' => 1
74
  ));
75
  }
76
-
77
  function has_friendships() {
78
  if ( $this->friendship_count )
79
  return true;
80
-
81
  return false;
82
  }
83
-
84
  function next_friendship() {
85
  $this->current_friendship++;
86
  $this->friendship = $this->friendships[$this->current_friendship];
87
-
88
  return $this->friendship;
89
  }
90
-
91
  function rewind_friendships() {
92
  $this->current_friendship = -1;
93
  if ( $this->friendship_count > 0 ) {
94
  $this->friendship = $this->friendships[0];
95
  }
96
  }
97
-
98
- function user_friendships() {
99
  if ( $this->current_friendship + 1 < $this->friendship_count ) {
100
  return true;
101
  } elseif ( $this->current_friendship + 1 == $this->friendship_count ) {
@@ -107,7 +107,7 @@ class BP_Friendship_Template {
107
  $this->in_the_loop = false;
108
  return false;
109
  }
110
-
111
  function the_friendship() {
112
  global $friendship, $bp;
113
 
@@ -122,14 +122,14 @@ class BP_Friendship_Template {
122
  $user_id = $this->friendship;
123
  else
124
  $user_id = $this->friendship->user_id;
125
-
126
  $this->friendship = new stdClass;
127
-
128
  if ( !$this->friendship->friend = wp_cache_get( 'bp_user_' . $user_id, 'bp' ) ) {
129
  $this->friendship->friend = new BP_Core_User( $user_id );
130
  wp_cache_set( 'bp_user_' . $user_id, $this->friendship->friend, 'bp' );
131
  }
132
-
133
  /* Make sure the user_id is available in the friend object. */
134
  $this->friendship->friend->user_id = $user_id;
135
  }
@@ -152,7 +152,7 @@ function bp_has_friendships( $args = '' ) {
152
 
153
  $r = wp_parse_args( $args, $defaults );
154
  extract( $r, EXTR_SKIP );
155
-
156
  /* The following code will auto set parameters based on the page being viewed.
157
  * for example on example.com/members/andy/friends/my-friends/newest/
158
  * $type = 'newest'
@@ -166,7 +166,7 @@ function bp_has_friendships( $args = '' ) {
166
  } else if ( 'requests' == $bp->current_action ) {
167
  $type = 'requests';
168
  }
169
-
170
  if ( isset( $_REQUEST['friend-search-box'] ) )
171
  $filter = $_REQUEST['friend-search-box'];
172
 
@@ -189,8 +189,8 @@ function bp_friend_id() {
189
  }
190
  function bp_get_friend_id() {
191
  global $friends_template;
192
-
193
- return apply_filters( 'bp_get_friend_id', $friends_template->friendship->friend->user_id );
194
  }
195
 
196
  function bp_friend_avatar_thumb() {
@@ -207,10 +207,10 @@ function bp_friend_name() {
207
  }
208
  function bp_get_friend_name() {
209
  global $friends_template;
210
-
211
- return apply_filters( 'bp_get_friend_name', strip_tags( $friends_template->friendship->friend->user_link ) );
212
  }
213
-
214
  function bp_friend_link() {
215
  echo bp_get_friend_link();
216
  }
@@ -237,7 +237,7 @@ function bp_friend_last_active() {
237
 
238
  return apply_filters( 'bp_get_friend_last_active', $friends_template->friendship->friend->last_active );
239
  }
240
-
241
  function bp_friend_time_since_requested() {
242
  echo bp_get_friend_time_since_requested();
243
  }
@@ -247,7 +247,7 @@ function bp_friend_time_since_requested() {
247
  if ( $friends_template->friendship->date_created != "0000-00-00 00:00:00" ) {
248
  return apply_filters( 'bp_friend_time_since_requested', sprintf( __( 'requested %s ago', 'buddypress' ), bp_core_time_since( strtotime( $friends_template->friendship->date_created ) ) ) );
249
  }
250
-
251
  return false;
252
  }
253
 
@@ -266,7 +266,7 @@ function bp_friend_reject_request_link() {
266
  function bp_get_friend_reject_request_link() {
267
  global $friends_template, $bp;
268
 
269
- return apply_filters( 'bp_get_friend_reject_request_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/requests/reject/' . $friends_template->friendship->id, 'friends_reject_friendship' ) );
270
  }
271
 
272
  function bp_friend_pagination() {
@@ -274,7 +274,7 @@ function bp_friend_pagination() {
274
  }
275
  function bp_get_friend_pagination() {
276
  global $friends_template;
277
-
278
  return apply_filters( 'bp_friend_pagination', $friends_template->pag_links );
279
  }
280
 
@@ -285,7 +285,7 @@ function bp_friend_pagination_count() {
285
  $to_num = ( $from_num + ( $friends_template->pag_num - 1 ) > $friends_template->total_friend_count ) ? $friends_template->total_friend_count : $from_num + ( $friends_template->pag_num - 1) ;
286
 
287
  echo sprintf( __( 'Viewing friend %d to %d (of %d friends)', 'buddypress' ), $from_num, $to_num, $friends_template->total_friend_count ); ?> &nbsp;
288
- <span class="ajax-loader"></span><?php
289
  }
290
 
291
  function bp_friend_total_for_member() {
@@ -294,7 +294,7 @@ function bp_friend_total_for_member() {
294
  function bp_get_friend_total_for_member() {
295
  return apply_filters( 'bp_get_friend_total_for_member', BP_Friends_Friendship::total_friend_count() );
296
  }
297
-
298
  function bp_friend_search_form() {
299
  global $friends_template, $bp;
300
 
@@ -305,10 +305,10 @@ function bp_friend_search_form() {
305
 
306
  <label for="friend-search-box" id="friend-search-label"><?php echo $label ?></label>
307
  <input type="search" name="friend-search-box" id="friend-search-box" value="<?php echo $value ?>"<?php echo $disabled ?> />
308
-
309
  <?php wp_nonce_field( 'friends_search', '_wpnonce_friend_search' ) ?>
310
  <input type="hidden" name="initiator" id="initiator" value="<?php echo attribute_escape( $bp->displayed_user->id ) ?>" />
311
-
312
  </form>
313
  <?php
314
  }
@@ -316,7 +316,7 @@ function bp_friend_search_form() {
316
  function bp_friends_is_filtered() {
317
  if ( isset( $_POST['friend-search-box'] ) )
318
  return true;
319
-
320
  return false;
321
  }
322
 
@@ -327,17 +327,17 @@ function bp_friend_all_friends_link() {
327
 
328
  function bp_friend_latest_update_link() {
329
  global $bp;
330
- echo apply_filters( 'bp_friend_latest_update_link', $bp->displayed_user->domain . 'my-friends/last-updated' );
331
  }
332
 
333
  function bp_friend_recent_activity_link() {
334
  global $bp;
335
- echo apply_filters( 'bp_friend_recent_activity_link', $bp->displayed_user->domain . 'my-friends/recently-active' );
336
  }
337
 
338
  function bp_friend_recent_status_link() {
339
  global $bp;
340
- echo apply_filters( 'bp_friend_recent_status_link', $bp->displayed_user->domain . 'my-friends/status-updates' );
341
  }
342
 
343
  function bp_add_friend_button( $potential_friend_id = false ) {
@@ -345,11 +345,11 @@ function bp_add_friend_button( $potential_friend_id = false ) {
345
  }
346
  function bp_get_add_friend_button( $potential_friend_id = false ) {
347
  global $bp, $friends_template;
348
-
349
  $button = false;
350
-
351
  if ( is_user_logged_in() ) {
352
-
353
  if ( !$potential_friend_id && $friends_template->friendship->friend )
354
  $potential_friend_id = $friends_template->friendship->friend->id;
355
  else if ( !$potential_friend_id && !$friends_template->friendship->friend )
@@ -370,7 +370,7 @@ function bp_add_friend_button( $potential_friend_id = false ) {
370
  }
371
  $button .= '</div>';
372
  }
373
-
374
  return apply_filters( 'bp_get_add_friend_button', $button );
375
  }
376
 
@@ -386,9 +386,9 @@ function bp_friends_header_tabs() {
386
 
387
  function bp_friends_filter_title() {
388
  global $bp;
389
-
390
  $current_filter = $bp->action_variables[0];
391
-
392
  switch ( $current_filter ) {
393
  case 'recently-active': default:
394
  _e( 'Recently Active', 'buddypress' );
@@ -404,15 +404,15 @@ function bp_friends_filter_title() {
404
 
405
  function bp_friends_random_friends() {
406
  global $bp;
407
-
408
  if ( !$friend_ids = wp_cache_get( 'friends_friend_ids_' . $bp->displayed_user->id, 'bp' ) ) {
409
  $friend_ids = BP_Friends_Friendship::get_random_friends( $bp->displayed_user->id );
410
  wp_cache_set( 'friends_friend_ids_' . $bp->displayed_user->id, $friend_ids, 'bp' );
411
  }
412
- ?>
413
  <div class="info-group">
414
  <h4><?php bp_word_or_name( __( "My Friends", 'buddypress' ), __( "%s's Friends", 'buddypress' ) ) ?> (<?php echo BP_Friends_Friendship::total_friend_count( $bp->displayed_user->id ) ?>) <span><a href="<?php echo $bp->displayed_user->domain . $bp->friends->slug ?>"><?php _e('See All', 'buddypress') ?> &raquo;</a></span></h4>
415
-
416
  <?php if ( $friend_ids ) { ?>
417
  <ul class="horiz-gallery">
418
  <?php for ( $i = 0; $i < count( $friend_ids ); $i++ ) { ?>
@@ -434,12 +434,12 @@ function bp_friends_random_friends() {
434
 
435
  function bp_friends_random_members( $total_members = 5 ) {
436
  global $bp;
437
-
438
  if ( !$user_ids = wp_cache_get( 'friends_random_users', 'bp' ) ) {
439
  $user_ids = BP_Core_User::get_random_users( $total_members );
440
  wp_cache_set( 'friends_random_users', $user_ids, 'bp' );
441
  }
442
- ?>
443
  <?php if ( $user_ids['users'] ) { ?>
444
  <ul class="item-list" id="random-members-list">
445
  <?php for ( $i = 0; $i < count( $user_ids['users'] ); $i++ ) { ?>
@@ -453,7 +453,7 @@ function bp_friends_random_members( $total_members = 5 ) {
453
  <?php echo $random_data[0]->value ?>
454
  </div>
455
  <?php } ?>
456
-
457
  <div class="action">
458
  <?php if ( function_exists( 'bp_add_friend_button' ) ) { ?>
459
  <?php bp_add_friend_button( $user_ids['users'][$i]->user_id ) ?>
@@ -465,7 +465,7 @@ function bp_friends_random_members( $total_members = 5 ) {
465
  <?php } else { ?>
466
  <div id="message" class="info">
467
  <p><?php _e( "There aren't enough site members to show a random sample just yet.", 'buddypress' ) ?></p>
468
- </div>
469
  <?php } ?>
470
  <?php
471
  }
5
  var $friendship_count;
6
  var $friendships;
7
  var $friendship;
8
+
9
  var $in_the_loop;
10
+
11
  var $pag_page;
12
  var $pag_num;
13
  var $pag_links;
14
  var $total_friend_count;
15
+
16
  function bp_friendship_template( $user_id, $type, $per_page, $max, $filter ) {
17
  global $bp;
18
 
19
  if ( !$user_id )
20
  $user_id = $bp->displayed_user->id;
21
+
22
  $this->pag_page = isset( $_REQUEST['frpage'] ) ? intval( $_REQUEST['frpage'] ) : 1;
23
  $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
24
  $this->type = $type;
27
  case 'newest':
28
  $this->friendships = friends_get_newest( $user_id, $this->pag_num, $this->pag_page, $filter );
29
  break;
30
+
31
  case 'alphabetical':
32
+ $this->friendships = friends_get_alphabetically( $user_id, $this->pag_num, $this->pag_page, $filter );
33
  break;
34
 
35
  case 'requests':
37
  break;
38
 
39
  case 'active': default:
40
+ $this->friendships = friends_get_recently_active( $user_id, $this->pag_num, $this->pag_page, $filter );
41
  break;
42
  }
43
 
73
  'mid_size' => 1
74
  ));
75
  }
76
+
77
  function has_friendships() {
78
  if ( $this->friendship_count )
79
  return true;
80
+
81
  return false;
82
  }
83
+
84
  function next_friendship() {
85
  $this->current_friendship++;
86
  $this->friendship = $this->friendships[$this->current_friendship];
87
+
88
  return $this->friendship;
89
  }
90
+
91
  function rewind_friendships() {
92
  $this->current_friendship = -1;
93
  if ( $this->friendship_count > 0 ) {
94
  $this->friendship = $this->friendships[0];
95
  }
96
  }
97
+
98
+ function user_friendships() {
99
  if ( $this->current_friendship + 1 < $this->friendship_count ) {
100
  return true;
101
  } elseif ( $this->current_friendship + 1 == $this->friendship_count ) {
107
  $this->in_the_loop = false;
108
  return false;
109
  }
110
+
111
  function the_friendship() {
112
  global $friendship, $bp;
113
 
122
  $user_id = $this->friendship;
123
  else
124
  $user_id = $this->friendship->user_id;
125
+
126
  $this->friendship = new stdClass;
127
+
128
  if ( !$this->friendship->friend = wp_cache_get( 'bp_user_' . $user_id, 'bp' ) ) {
129
  $this->friendship->friend = new BP_Core_User( $user_id );
130
  wp_cache_set( 'bp_user_' . $user_id, $this->friendship->friend, 'bp' );
131
  }
132
+
133
  /* Make sure the user_id is available in the friend object. */
134
  $this->friendship->friend->user_id = $user_id;
135
  }
152
 
153
  $r = wp_parse_args( $args, $defaults );
154
  extract( $r, EXTR_SKIP );
155
+
156
  /* The following code will auto set parameters based on the page being viewed.
157
  * for example on example.com/members/andy/friends/my-friends/newest/
158
  * $type = 'newest'
166
  } else if ( 'requests' == $bp->current_action ) {
167
  $type = 'requests';
168
  }
169
+
170
  if ( isset( $_REQUEST['friend-search-box'] ) )
171
  $filter = $_REQUEST['friend-search-box'];
172
 
189
  }
190
  function bp_get_friend_id() {
191
  global $friends_template;
192
+
193
+ return apply_filters( 'bp_get_friend_id', $friends_template->friendship->friend->user_id );
194
  }
195
 
196
  function bp_friend_avatar_thumb() {
207
  }
208
  function bp_get_friend_name() {
209
  global $friends_template;
210
+
211
+ return apply_filters( 'bp_get_friend_name', strip_tags( $friends_template->friendship->friend->user_link ) );
212
  }
213
+
214
  function bp_friend_link() {
215
  echo bp_get_friend_link();
216
  }
237
 
238
  return apply_filters( 'bp_get_friend_last_active', $friends_template->friendship->friend->last_active );
239
  }
240
+
241
  function bp_friend_time_since_requested() {
242
  echo bp_get_friend_time_since_requested();
243
  }
247
  if ( $friends_template->friendship->date_created != "0000-00-00 00:00:00" ) {
248
  return apply_filters( 'bp_friend_time_since_requested', sprintf( __( 'requested %s ago', 'buddypress' ), bp_core_time_since( strtotime( $friends_template->friendship->date_created ) ) ) );
249
  }
250
+
251
  return false;
252
  }
253
 
266
  function bp_get_friend_reject_request_link() {
267
  global $friends_template, $bp;
268
 
269
+ return apply_filters( 'bp_get_friend_reject_request_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/requests/reject/' . $friends_template->friendship->id, 'friends_reject_friendship' ) );
270
  }
271
 
272
  function bp_friend_pagination() {
274
  }
275
  function bp_get_friend_pagination() {
276
  global $friends_template;
277
+
278
  return apply_filters( 'bp_friend_pagination', $friends_template->pag_links );
279
  }
280
 
285
  $to_num = ( $from_num + ( $friends_template->pag_num - 1 ) > $friends_template->total_friend_count ) ? $friends_template->total_friend_count : $from_num + ( $friends_template->pag_num - 1) ;
286
 
287
  echo sprintf( __( 'Viewing friend %d to %d (of %d friends)', 'buddypress' ), $from_num, $to_num, $friends_template->total_friend_count ); ?> &nbsp;
288
+ <span class="ajax-loader"></span><?php
289
  }
290
 
291
  function bp_friend_total_for_member() {
294
  function bp_get_friend_total_for_member() {
295
  return apply_filters( 'bp_get_friend_total_for_member', BP_Friends_Friendship::total_friend_count() );
296
  }
297
+
298
  function bp_friend_search_form() {
299
  global $friends_template, $bp;
300
 
305
 
306
  <label for="friend-search-box" id="friend-search-label"><?php echo $label ?></label>
307
  <input type="search" name="friend-search-box" id="friend-search-box" value="<?php echo $value ?>"<?php echo $disabled ?> />
308
+
309
  <?php wp_nonce_field( 'friends_search', '_wpnonce_friend_search' ) ?>
310
  <input type="hidden" name="initiator" id="initiator" value="<?php echo attribute_escape( $bp->displayed_user->id ) ?>" />
311
+
312
  </form>
313
  <?php
314
  }
316
  function bp_friends_is_filtered() {
317
  if ( isset( $_POST['friend-search-box'] ) )
318
  return true;
319
+
320
  return false;
321
  }
322
 
327
 
328
  function bp_friend_latest_update_link() {
329
  global $bp;
330
+ echo apply_filters( 'bp_friend_latest_update_link', $bp->displayed_user->domain . 'my-friends/last-updated' );
331
  }
332
 
333
  function bp_friend_recent_activity_link() {
334
  global $bp;
335
+ echo apply_filters( 'bp_friend_recent_activity_link', $bp->displayed_user->domain . 'my-friends/recently-active' );
336
  }
337
 
338
  function bp_friend_recent_status_link() {
339
  global $bp;
340
+ echo apply_filters( 'bp_friend_recent_status_link', $bp->displayed_user->domain . 'my-friends/status-updates' );
341
  }
342
 
343
  function bp_add_friend_button( $potential_friend_id = false ) {
345
  }
346
  function bp_get_add_friend_button( $potential_friend_id = false ) {
347
  global $bp, $friends_template;
348
+
349
  $button = false;
350
+
351
  if ( is_user_logged_in() ) {
352
+
353
  if ( !$potential_friend_id && $friends_template->friendship->friend )
354
  $potential_friend_id = $friends_template->friendship->friend->id;
355
  else if ( !$potential_friend_id && !$friends_template->friendship->friend )
370
  }
371
  $button .= '</div>';
372
  }
373
+
374
  return apply_filters( 'bp_get_add_friend_button', $button );
375
  }
376
 
386
 
387
  function bp_friends_filter_title() {
388
  global $bp;
389
+
390
  $current_filter = $bp->action_variables[0];
391
+
392
  switch ( $current_filter ) {
393
  case 'recently-active': default:
394
  _e( 'Recently Active', 'buddypress' );
404
 
405
  function bp_friends_random_friends() {
406
  global $bp;
407
+
408
  if ( !$friend_ids = wp_cache_get( 'friends_friend_ids_' . $bp->displayed_user->id, 'bp' ) ) {
409
  $friend_ids = BP_Friends_Friendship::get_random_friends( $bp->displayed_user->id );
410
  wp_cache_set( 'friends_friend_ids_' . $bp->displayed_user->id, $friend_ids, 'bp' );
411
  }
412
+ ?>
413
  <div class="info-group">
414
  <h4><?php bp_word_or_name( __( "My Friends", 'buddypress' ), __( "%s's Friends", 'buddypress' ) ) ?> (<?php echo BP_Friends_Friendship::total_friend_count( $bp->displayed_user->id ) ?>) <span><a href="<?php echo $bp->displayed_user->domain . $bp->friends->slug ?>"><?php _e('See All', 'buddypress') ?> &raquo;</a></span></h4>
415
+
416
  <?php if ( $friend_ids ) { ?>
417
  <ul class="horiz-gallery">
418
  <?php for ( $i = 0; $i < count( $friend_ids ); $i++ ) { ?>
434
 
435
  function bp_friends_random_members( $total_members = 5 ) {
436
  global $bp;
437
+
438
  if ( !$user_ids = wp_cache_get( 'friends_random_users', 'bp' ) ) {
439
  $user_ids = BP_Core_User::get_random_users( $total_members );
440
  wp_cache_set( 'friends_random_users', $user_ids, 'bp' );
441
  }
442
+ ?>
443
  <?php if ( $user_ids['users'] ) { ?>
444
  <ul class="item-list" id="random-members-list">
445
  <?php for ( $i = 0; $i < count( $user_ids['users'] ); $i++ ) { ?>
453
  <?php echo $random_data[0]->value ?>
454
  </div>
455
  <?php } ?>
456
+
457
  <div class="action">
458
  <?php if ( function_exists( 'bp_add_friend_button' ) ) { ?>
459
  <?php bp_add_friend_button( $user_ids['users'][$i]->user_id ) ?>
465
  <?php } else { ?>
466
  <div id="message" class="info">
467
  <p><?php _e( "There aren't enough site members to show a random sample just yet.", 'buddypress' ) ?></p>
468
+ </div>
469
  <?php } ?>
470
  <?php
471
  }
bp-friends/deprecated/bp-friends-deprecated.php CHANGED
File without changes
bp-friends/deprecated/css/structure.css CHANGED
File without changes
bp-friends/deprecated/images/ajax-loader.gif CHANGED
File without changes
bp-friends/deprecated/js/general.js CHANGED
File without changes
bp-groups.php CHANGED
@@ -13,14 +13,14 @@ require ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-filters.php' );
13
 
14
  /* Include deprecated functions if settings allow */
15
  if ( !defined( 'BP_IGNORE_DEPRECATED' ) )
16
- require ( BP_PLUGIN_DIR . '/bp-groups/deprecated/bp-groups-deprecated.php' );
17
 
18
  function groups_install() {
19
  global $wpdb, $bp;
20
-
21
  if ( !empty($wpdb->charset) )
22
  $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
23
-
24
  $sql[] = "CREATE TABLE {$bp->groups->table_name} (
25
  id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
26
  creator_id bigint(20) NOT NULL,
@@ -35,7 +35,7 @@ function groups_install() {
35
  KEY creator_id (creator_id),
36
  KEY status (status)
37
  ) {$charset_collate};";
38
-
39
  $sql[] = "CREATE TABLE {$bp->groups->table_name_members} (
40
  id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
41
  group_id bigint(20) NOT NULL,
@@ -65,13 +65,13 @@ function groups_install() {
65
  KEY group_id (group_id),
66
  KEY meta_key (meta_key)
67
  ) {$charset_collate};";
68
-
69
  require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
70
  dbDelta($sql);
71
-
72
  /* On upgrade, handle moving of old group avatars */
73
  $groups = groups_get_all();
74
-
75
  foreach ( $groups as $group ) {
76
  /* Don't fetch and move gravs, default images or empties */
77
  if ( empty($group->avatar_thumb) || strpos( $group->avatar_thumb, 'gravatar.com' ) || strpos( $group->avatar_thumb, 'identicon' ) || strpos( $group->avatar_thumb, 'none-thumbnail' ) )
@@ -85,26 +85,26 @@ function groups_install() {
85
 
86
  if ( !file_exists( $avatar_thumb ) || !file_exists( $avatar_full ) )
87
  continue;
88
-
89
  $upload_dir = groups_avatar_upload_dir( $group->id );
90
 
91
  copy( $avatar_thumb, $upload_dir['path'] . '/' . basename($avatar_thumb) );
92
  copy( $avatar_full, $upload_dir['path'] . '/' . basename($avatar_full) );
93
  }
94
  }
95
-
96
  if ( function_exists('bp_wire_install') )
97
  groups_wire_install();
98
-
99
  update_site_option( 'bp-groups-db-version', BP_GROUPS_DB_VERSION );
100
  }
101
 
102
  function groups_wire_install() {
103
  global $wpdb, $bp;
104
-
105
  if ( !empty($wpdb->charset) )
106
  $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
107
-
108
  $sql[] = "CREATE TABLE {$bp->groups->table_name_wire} (
109
  id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
110
  item_id bigint(20) NOT NULL,
@@ -124,7 +124,7 @@ function groups_setup_globals() {
124
 
125
  /* For internal identification */
126
  $bp->groups->id = 'groups';
127
-
128
  $bp->groups->table_name = $wpdb->base_prefix . 'bp_groups';
129
  $bp->groups->table_name_members = $wpdb->base_prefix . 'bp_groups_members';
130
  $bp->groups->table_name_groupmeta = $wpdb->base_prefix . 'bp_groups_groupmeta';
@@ -133,24 +133,24 @@ function groups_setup_globals() {
133
 
134
  /* Register this in the active components array */
135
  $bp->active_components[$bp->groups->slug] = $bp->groups->id;
136
-
137
  if ( function_exists('bp_wire_install') )
138
  $bp->groups->table_name_wire = $wpdb->base_prefix . 'bp_groups_wire';
139
-
140
  $bp->groups->forbidden_names = apply_filters( 'groups_forbidden_names', array( 'my-groups', 'group-finder', 'create', 'invites', 'delete', 'add', 'admin', 'request-membership' ) );
141
-
142
- $bp->groups->group_creation_steps = apply_filters( 'groups_create_group_steps', array(
143
- 'group-details' => array( 'name' => __( 'Group Details', 'buddypress' ), 'position' => 0 ),
144
  'group-settings' => array( 'name' => __( 'Group Settings', 'buddypress' ), 'position' => 10 ),
145
  'group-avatar' => array( 'name' => __( 'Group Avatar', 'buddypress' ), 'position' => 20 ),
146
  'group-invites' => array( 'name' => __( 'Group Invites', 'buddypress' ), 'position' => 30 )
147
  ) );
148
-
149
  $bp->groups->valid_status = apply_filters( 'groups_valid_status', array( 'public', 'private', 'hidden' ) );
150
 
151
  do_action( 'groups_setup_globals' );
152
  }
153
- add_action( 'plugins_loaded', 'groups_setup_globals', 5 );
154
  add_action( 'admin_menu', 'groups_setup_globals', 2 );
155
 
156
  function groups_setup_root_component() {
@@ -159,9 +159,9 @@ function groups_setup_root_component() {
159
  }
160
  add_action( 'plugins_loaded', 'groups_setup_root_component', 2 );
161
 
162
- function groups_check_installed() {
163
  global $wpdb, $bp;
164
-
165
  require ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-admin.php' );
166
 
167
  /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
@@ -172,10 +172,10 @@ add_action( 'admin_menu', 'groups_check_installed' );
172
 
173
  function groups_add_admin_menu() {
174
  global $wpdb, $bp;
175
-
176
  if ( !is_site_admin() )
177
  return false;
178
-
179
  /* Add the administration tab under the "Site Admin" tab for site administrators */
180
  add_submenu_page( 'wpmu-admin.php', __("Groups", 'buddypress'), __("Groups", 'buddypress'), 1, "groups_admin_settings", "groups_admin_settings" );
181
  }
@@ -183,71 +183,71 @@ add_action( 'admin_menu', 'groups_add_admin_menu' );
183
 
184
  function groups_setup_nav() {
185
  global $bp, $current_blog, $group_obj;
186
-
187
  if ( $group_id = BP_Groups_Group::group_exists($bp->current_action) ) {
188
-
189
  /* This is a single group page. */
190
  $bp->is_single_item = true;
191
  $bp->groups->current_group = &new BP_Groups_Group( $group_id );
192
-
193
  /* Using "item" not "group" for generic support in other components. */
194
  if ( is_site_admin() )
195
  $bp->is_item_admin = 1;
196
  else
197
  $bp->is_item_admin = groups_is_user_admin( $bp->loggedin_user->id, $bp->groups->current_group->id );
198
-
199
  /* If the user is not an admin, check if they are a moderator */
200
  if ( !$bp->is_item_admin )
201
  $bp->is_item_mod = groups_is_user_mod( $bp->loggedin_user->id, $bp->groups->current_group->id );
202
-
203
  /* Is the logged in user a member of the group? */
204
  $bp->groups->current_group->is_user_member = ( is_user_logged_in() && groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) ? true : false;
205
-
206
  /* Should this group be visible to the logged in user? */
207
  $bp->groups->current_group->is_group_visible_to_member = ( 'public' == $bp->groups->current_group->status || $is_member ) ? true : false;
208
-
209
  /* Pre 1.1 backwards compatibility - use $bp->groups->current_group instead */
210
  $group_obj = &$bp->groups->current_group;
211
  }
212
 
213
  /* Add 'Groups' to the main navigation */
214
  bp_core_new_nav_item( array( 'name' => __('Groups', 'buddypress'), 'slug' => $bp->groups->slug, 'position' => 70, 'screen_function' => 'groups_screen_my_groups', 'default_subnav_slug' => 'my-groups', 'item_css_id' => $bp->groups->id ) );
215
-
216
  $groups_link = $bp->loggedin_user->domain . $bp->groups->slug . '/';
217
-
218
  /* Add the subnav items to the groups nav item */
219
  bp_core_new_subnav_item( array( 'name' => __( 'My Groups', 'buddypress' ), 'slug' => 'my-groups', 'parent_url' => $groups_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_my_groups', 'position' => 10, 'item_css_id' => 'groups-my-groups' ) );
220
  bp_core_new_subnav_item( array( 'name' => __( 'Create a Group', 'buddypress' ), 'slug' => 'create', 'parent_url' => $groups_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_create_group', 'position' => 20, 'user_has_access' => bp_is_home() ) );
221
  bp_core_new_subnav_item( array( 'name' => __( 'Invites', 'buddypress' ), 'slug' => 'invites', 'parent_url' => $groups_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_invites', 'position' => 30, 'user_has_access' => bp_is_home() ) );
222
 
223
  if ( $bp->current_component == $bp->groups->slug ) {
224
-
225
  if ( bp_is_home() && !$bp->is_single_item ) {
226
-
227
  $bp->bp_options_title = __( 'My Groups', 'buddypress' );
228
-
229
  } else if ( !bp_is_home() && !$bp->is_single_item ) {
230
 
231
  $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) );
232
  $bp->bp_options_title = $bp->displayed_user->fullname;
233
-
234
  } else if ( $bp->is_single_item ) {
235
  // We are viewing a single group, so set up the
236
  // group navigation menu using the $bp->groups->current_group global.
237
-
238
  /* When in a single group, the first action is bumped down one because of the
239
  group name, so we need to adjust this and set the group name to current_item. */
240
  $bp->current_item = $bp->current_action;
241
  $bp->current_action = $bp->action_variables[0];
242
  array_shift($bp->action_variables);
243
-
244
  $bp->bp_options_title = $bp->groups->current_group->name;
245
-
246
  if ( !$bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->groups->current_group->id, 'object' => 'group', 'type' => 'thumb', 'avatar_dir' => 'group-avatars', 'alt' => __( 'Group Avatar', 'buddypress' ) ) ) )
247
  $bp->bp_options_avatar = '<img src="' . attribute_escape( $group->avatar_full ) . '" class="avatar" alt="' . attribute_escape( $group->name ) . '" />';
248
-
249
  $group_link = $bp->root_domain . '/' . $bp->groups->slug . '/' . $bp->groups->current_group->slug . '/';
250
-
251
  // If this is a private or hidden group, does the user have access?
252
  if ( 'private' == $bp->groups->current_group->status || 'hidden' == $bp->groups->current_group->status ) {
253
  if ( $bp->groups->current_group->is_user_member && is_user_logged_in() )
@@ -260,13 +260,13 @@ function groups_setup_nav() {
260
 
261
  /* Reset the existing subnav items */
262
  bp_core_reset_subnav_items($bp->groups->slug);
263
-
264
  /* Add a new default subnav item for when the groups nav is selected. */
265
  bp_core_new_nav_default( array( 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_home', 'subnav_slug' => 'home' ) );
266
-
267
  /* Add the "Home" subnav item, as this will always be present */
268
  bp_core_new_subnav_item( array( 'name' => __( 'Home', 'buddypress' ), 'slug' => 'home', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_home', 'position' => 10, 'item_css_id' => 'group-home' ) );
269
-
270
  /* If the user is a group mod or more, then show the group admin nav item */
271
  if ( $bp->is_item_mod || $bp->is_item_admin )
272
  bp_core_new_subnav_item( array( 'name' => __( 'Admin', 'buddypress' ), 'slug' => 'admin', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_admin', 'position' => 20, 'user_has_access' => ( $bp->is_item_admin + (int)$bp->is_item_mod ), 'item_css_id' => 'group-admin' ) );
@@ -282,7 +282,7 @@ function groups_setup_nav() {
282
  bp_core_new_subnav_item( array( 'name' => __( 'Wire', 'buddypress' ), 'slug' => BP_WIRE_SLUG, 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_wire', 'position' => 50, 'user_has_access' => $bp->groups->current_group->user_has_access, 'item_css_id' => 'group-wire' ) );
283
 
284
  bp_core_new_subnav_item( array( 'name' => __( 'Members', 'buddypress' ), 'slug' => 'members', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_members', 'position' => 60, 'user_has_access' => $bp->groups->current_group->user_has_access, 'item_css_id' => 'group-members' ) );
285
-
286
  if ( is_user_logged_in() && groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) {
287
  if ( function_exists('friends_install') )
288
  bp_core_new_subnav_item( array( 'name' => __( 'Send Invites', 'buddypress' ), 'slug' => 'send-invites', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_invite', 'item_css_id' => 'group-invite', 'position' => 70, 'user_has_access' => $bp->groups->current_group->user_has_access ) );
@@ -291,7 +291,7 @@ function groups_setup_nav() {
291
  }
292
  }
293
  }
294
-
295
  do_action( 'groups_setup_nav', $bp->groups->current_group->user_has_access );
296
  }
297
  add_action( 'plugins_loaded', 'groups_setup_nav' );
@@ -311,7 +311,7 @@ add_action( 'wp', 'groups_directory_groups_setup', 2 );
311
 
312
  function groups_setup_adminbar_menu() {
313
  global $bp;
314
-
315
  if ( !$bp->groups->current_group )
316
  return false;
317
 
@@ -321,10 +321,10 @@ function groups_setup_adminbar_menu() {
321
  ?>
322
  <li id="bp-adminbar-adminoptions-menu">
323
  <a href=""><?php _e( 'Admin Options', 'buddypress' ) ?></a>
324
-
325
  <ul>
326
  <li><a class="confirm" href="<?php echo wp_nonce_url( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/delete-group/', 'groups_delete_group' ) ?>&amp;delete-group-button=1&amp;delete-group-understand=1"><?php _e( "Delete Group", 'buddypress' ) ?></a></li>
327
-
328
  <?php do_action( 'groups_adminbar_menu_items' ) ?>
329
  </ul>
330
  </li>
@@ -343,35 +343,35 @@ add_action( 'bp_adminbar_menus', 'groups_setup_adminbar_menu', 20 );
343
 
344
  function groups_screen_my_groups() {
345
  global $bp;
346
-
347
  bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'member_promoted_to_mod' );
348
  bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'member_promoted_to_admin' );
349
 
350
  do_action( 'groups_screen_my_groups' );
351
-
352
  bp_core_load_template( apply_filters( 'groups_template_my_groups', 'groups/index' ) );
353
  }
354
 
355
  function groups_screen_group_invites() {
356
  global $bp;
357
-
358
  $group_id = $bp->action_variables[1];
359
-
360
  if ( isset($bp->action_variables) && in_array( 'accept', (array)$bp->action_variables ) && is_numeric($group_id) ) {
361
  /* Check the nonce */
362
  if ( !check_admin_referer( 'groups_accept_invite' ) )
363
  return false;
364
-
365
  if ( !groups_accept_invite( $bp->loggedin_user->id, $group_id ) ) {
366
- bp_core_add_message( __('Group invite could not be accepted', 'buddypress'), 'error' );
367
  } else {
368
  bp_core_add_message( __('Group invite accepted', 'buddypress') );
369
-
370
  /* Record this in activity streams */
371
  $group = new BP_Groups_Group( $group_id, false, false );
372
 
373
  groups_record_activity( array(
374
- 'content' => apply_filters( 'groups_activity_accepted_invite', sprintf( __( '%s joined the group %s', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . attribute_escape( $group->name ) . '</a>' ), $bp->loggedin_user->id, &$group ),
375
  'primary_link' => apply_filters( 'groups_activity_accepted_invite_primary_link', bp_get_group_permalink( $group ), &$group ),
376
  'component_action' => 'joined_group',
377
  'item_id' => $group->id
@@ -379,48 +379,52 @@ function groups_screen_group_invites() {
379
  }
380
 
381
  bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action );
382
-
383
  } else if ( isset($bp->action_variables) && in_array( 'reject', (array)$bp->action_variables ) && is_numeric($group_id) ) {
384
  /* Check the nonce */
385
  if ( !check_admin_referer( 'groups_reject_invite' ) )
386
  return false;
387
-
388
  if ( !groups_reject_invite( $bp->loggedin_user->id, $group_id ) ) {
389
- bp_core_add_message( __('Group invite could not be rejected', 'buddypress'), 'error' );
390
- } else {
391
- bp_core_add_message( __('Group invite rejected', 'buddypress') );
392
  }
393
 
394
  bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action );
395
  }
396
-
397
  // Remove notifications
398
  bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'group_invite' );
399
 
400
  do_action( 'groups_screen_group_invites', $group_id );
401
-
402
  if ( '' != locate_template( array( 'groups/invites.php' ), false ) )
403
  bp_core_load_template( apply_filters( 'groups_template_group_invites', 'groups/invites' ) );
404
  else
405
- bp_core_load_template( apply_filters( 'groups_template_group_invites', 'groups/list-invites' ) );
406
  }
407
 
408
  function groups_screen_create_group() {
409
  global $bp;
410
 
 
 
 
 
411
  /* If no current step is set, reset everything so we can start a fresh group creation */
412
  if ( !$bp->groups->current_create_step = $bp->action_variables[1] ) {
413
 
414
  unset( $bp->groups->current_create_step );
415
  unset( $bp->groups->completed_create_steps );
416
-
417
  setcookie( 'bp_new_group_id', false, time() - 1000, COOKIEPATH );
418
  setcookie( 'bp_completed_create_steps', false, time() - 1000, COOKIEPATH );
419
-
420
  $reset_steps = true;
421
  bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . array_shift( array_keys( $bp->groups->group_creation_steps ) ) );
422
  }
423
-
424
  /* If this is a creation step that is not recognized, just redirect them back to the first screen */
425
  if ( $bp->action_variables[1] && !$bp->groups->group_creation_steps[$bp->action_variables[1]] ) {
426
  bp_core_add_message( __('There was an error saving group details. Please try again.', 'buddypress'), 'error' );
@@ -439,35 +443,35 @@ function groups_screen_create_group() {
439
 
440
  /* If the save, upload or skip button is hit, lets calculate what we need to save */
441
  if ( isset( $_POST['save'] ) ) {
442
-
443
  /* Check the nonce */
444
  check_admin_referer( 'groups_create_save_' . $bp->groups->current_create_step );
445
-
446
  if ( 'group-details' == $bp->groups->current_create_step ) {
447
  if ( empty( $_POST['group-name'] ) || empty( $_POST['group-desc'] ) ) {
448
  bp_core_add_message( __( 'Please fill in all of the required fields', 'buddypress' ), 'error' );
449
  bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $bp->groups->current_create_step );
450
  }
451
-
452
  if ( !$bp->groups->new_group_id = groups_create_group( array( 'group_id' => $bp->groups->new_group_id, 'name' => $_POST['group-name'], 'description' => $_POST['group-desc'], 'news' => $_POST['group-news'], 'slug' => groups_check_slug( sanitize_title($_POST['group-name']) ), 'date_created' => time() ) ) ) {
453
  bp_core_add_message( __( 'There was an error saving group details, please try again.', 'buddypress' ), 'error' );
454
- bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $bp->groups->current_create_step );
455
  }
456
-
457
  groups_update_groupmeta( $bp->groups->new_group_id, 'total_member_count', 1 );
458
  groups_update_groupmeta( $bp->groups->new_group_id, 'last_activity', time() );
459
  groups_update_groupmeta( $bp->groups->new_group_id, 'theme', 'buddypress' );
460
  groups_update_groupmeta( $bp->groups->new_group_id, 'stylesheet', 'buddypress' );
461
  }
462
-
463
  if ( 'group-settings' == $bp->groups->current_create_step ) {
464
  $group_status = 'public';
465
  $group_enable_wire = 1;
466
  $group_enable_forum = 1;
467
-
468
  if ( !isset($_POST['group-show-wire']) )
469
  $group_enable_wire = 0;
470
-
471
  if ( !isset($_POST['group-show-forum']) ) {
472
  $group_enable_forum = 0;
473
  } else {
@@ -476,15 +480,15 @@ function groups_screen_create_group() {
476
  groups_new_group_forum();
477
  }
478
  }
479
-
480
  if ( 'private' == $_POST['group-status'] )
481
  $group_status = 'private';
482
  else if ( 'hidden' == $_POST['group-status'] )
483
  $group_status = 'hidden';
484
-
485
  if ( !$bp->groups->new_group_id = groups_create_group( array( 'group_id' => $bp->groups->new_group_id, 'status' => $group_status, 'enable_wire' => $group_enable_wire, 'enable_forum' => $group_enable_forum ) ) ) {
486
  bp_core_add_message( __( 'There was an error saving group details, please try again.', 'buddypress' ), 'error' );
487
- bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $bp->groups->current_create_step );
488
  }
489
  }
490
 
@@ -494,7 +498,7 @@ function groups_screen_create_group() {
494
 
495
  do_action( 'groups_create_group_step_save_' . $bp->groups->current_create_step );
496
  do_action( 'groups_create_group_step_complete' ); // Mostly for clearing cache on a generic action name
497
-
498
  /**
499
  * Once we have successfully saved the details for this step of the creation process
500
  * we need to add the current step to the array of completed steps, then update the cookies
@@ -502,26 +506,26 @@ function groups_screen_create_group() {
502
  */
503
  if ( !in_array( $bp->groups->current_create_step, (array)$bp->groups->completed_create_steps ) )
504
  $bp->groups->completed_create_steps[] = $bp->groups->current_create_step;
505
-
506
  /* Reset cookie info */
507
  setcookie( 'bp_new_group_id', $bp->groups->new_group_id, time()+60*60*24, COOKIEPATH );
508
- setcookie( 'bp_completed_create_steps', serialize( $bp->groups->completed_create_steps ), time()+60*60*24, COOKIEPATH );
509
 
510
  /* If we have completed all steps and hit done on the final step we can redirect to the completed group */
511
  if ( count( $bp->groups->completed_create_steps ) == count( $bp->groups->group_creation_steps ) && $bp->groups->current_create_step == array_pop( array_keys( $bp->groups->group_creation_steps ) ) ) {
512
  unset( $bp->groups->current_create_step );
513
  unset( $bp->groups->completed_create_steps );
514
-
515
  /* Once we compelete all steps, record the group creation in the activity stream. */
516
  groups_record_activity( array(
517
- 'content' => apply_filters( 'groups_activity_created_group', sprintf( __( '%s created the group %s', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' ) ),
518
  'primary_link' => apply_filters( 'groups_activity_created_group_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ),
519
  'component_action' => 'created_group',
520
  'item_id' => $bp->groups->new_group_id
521
  ) );
522
-
523
  do_action( 'groups_group_create_complete', $bp->groups->new_group_id );
524
-
525
  bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
526
  } else {
527
  /**
@@ -530,12 +534,12 @@ function groups_screen_create_group() {
530
  */
531
  foreach ( $bp->groups->group_creation_steps as $key => $value ) {
532
  if ( $key == $bp->groups->current_create_step ) {
533
- $next = 1;
534
  continue;
535
  }
536
-
537
  if ( $next ) {
538
- $next_step = $key;
539
  break;
540
  }
541
  }
@@ -543,14 +547,14 @@ function groups_screen_create_group() {
543
  bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $next_step );
544
  }
545
  }
546
-
547
- /* Group avatar is handled seperately */
548
  if ( 'group-avatar' == $bp->groups->current_create_step && isset( $_POST['upload'] ) ) {
549
  if ( !empty( $_FILES ) && isset( $_POST['upload'] ) ) {
550
  /* Normally we would check a nonce here, but the group save nonce is used instead */
551
 
552
  /* Pass the file to the avatar upload handler */
553
- if ( bp_core_avatar_handle_upload( $_FILES, 'groups_avatar_upload_dir' ) ) {
554
  $bp->avatar_admin->step = 'crop-image';
555
 
556
  /* Make sure we include the jQuery jCrop file for image cropping */
@@ -561,7 +565,7 @@ function groups_screen_create_group() {
561
  /* If the image cropping is done, crop the image and save a full/thumb version */
562
  if ( isset( $_POST['avatar-crop-submit'] ) && isset( $_POST['upload'] ) ) {
563
  /* Normally we would check a nonce here, but the group save nonce is used instead */
564
-
565
  if ( !bp_core_avatar_handle_crop( array( 'object' => 'group', 'avatar_dir' => 'group-avatars', 'item_id' => $bp->groups->current_group->id, 'original_file' => $_POST['image_src'], 'crop_x' => $_POST['x'], 'crop_y' => $_POST['y'], 'crop_w' => $_POST['w'], 'crop_h' => $_POST['h'] ) ) )
566
  bp_core_add_message( __( 'There was an error saving the group avatar, please try uploading again.', 'buddypress' ), 'error' );
567
  else
@@ -575,19 +579,19 @@ function groups_screen_create_group() {
575
 
576
  function groups_screen_group_home() {
577
  global $bp;
578
-
579
  if ( $bp->is_single_item ) {
580
-
581
  if ( isset($_GET['new']) ) {
582
  // Delete group request notifications for the user
583
  bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'membership_request_accepted' );
584
  bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'membership_request_rejected' );
585
  bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'member_promoted_to_mod' );
586
  bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'member_promoted_to_admin' );
587
- }
 
 
588
 
589
- do_action( 'groups_screen_group_home' );
590
-
591
  if ( '' != locate_template( array( 'groups/single/home.php' ), false ) )
592
  bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) );
593
  else
@@ -597,9 +601,9 @@ function groups_screen_group_home() {
597
 
598
  function groups_screen_group_forum() {
599
  global $bp;
600
-
601
  if ( $bp->is_single_item && $bp->groups->current_group->user_has_access ) {
602
-
603
  /* Fetch the details we need */
604
  $topic_slug = $bp->action_variables[1];
605
  $topic_id = bp_forums_get_topic_id_from_slug( $topic_slug );
@@ -611,22 +615,22 @@ function groups_screen_group_forum() {
611
  if ( !$bp->action_variables[2] && isset( $_POST['submit_reply'] ) ) {
612
  /* Check the nonce */
613
  check_admin_referer( 'bp_forums_new_reply' );
614
-
615
  /* Auto join this user if they are not yet a member of this group */
616
  if ( !is_site_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) )
617
  groups_join_group( $bp->groups->current_group->id, $bp->loggedin_user->id );
618
-
619
  if ( !groups_new_group_forum_post( $_POST['reply_text'], $topic_id ) )
620
  bp_core_add_message( __( 'There was an error when replying to that topic', 'buddypress'), 'error' );
621
  else
622
  bp_core_add_message( __( 'Your reply was posted successfully', 'buddypress') );
623
-
624
  if ( $_SERVER['QUERY_STRING'] )
625
- $query_vars = '?' . $_SERVER['QUERY_STRING'];
626
-
627
  bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic_slug . '/' . $query_vars );
628
  }
629
-
630
  /* Sticky a topic */
631
  else if ( 'stick' == $bp->action_variables[2] && ( $bp->is_item_admin || $bp->is_item_mod ) ) {
632
  /* Check the nonce */
@@ -636,35 +640,35 @@ function groups_screen_group_forum() {
636
  bp_core_add_message( __( 'There was an error when making that topic a sticky', 'buddypress' ), 'error' );
637
  else
638
  bp_core_add_message( __( 'The topic was made sticky successfully', 'buddypress' ) );
639
-
640
  do_action( 'groups_stick_forum_topic', $topic_id );
641
  bp_core_redirect( wp_get_referer() );
642
  }
643
-
644
  /* Un-Sticky a topic */
645
  else if ( 'unstick' == $bp->action_variables[2] && ( $bp->is_item_admin || $bp->is_item_mod ) ) {
646
  /* Check the nonce */
647
  check_admin_referer( 'bp_forums_unstick_topic' );
648
-
649
  if ( !bp_forums_sticky_topic( array( 'topic_id' => $topic_id, 'mode' => 'unstick' ) ) )
650
  bp_core_add_message( __( 'There was an error when unsticking that topic', 'buddypress'), 'error' );
651
  else
652
  bp_core_add_message( __( 'The topic was unstuck successfully', 'buddypress') );
653
-
654
  do_action( 'groups_unstick_forum_topic', $topic_id );
655
  bp_core_redirect( wp_get_referer() );
656
  }
657
-
658
  /* Close a topic */
659
  else if ( 'close' == $bp->action_variables[2] && ( $bp->is_item_admin || $bp->is_item_mod ) ) {
660
  /* Check the nonce */
661
  check_admin_referer( 'bp_forums_close_topic' );
662
-
663
  if ( !bp_forums_openclose_topic( array( 'topic_id' => $topic_id ) ) )
664
  bp_core_add_message( __( 'There was an error when closing that topic', 'buddypress'), 'error' );
665
  else
666
  bp_core_add_message( __( 'The topic was closed successfully', 'buddypress') );
667
-
668
  do_action( 'groups_close_forum_topic', $topic_id );
669
  bp_core_redirect( wp_get_referer() );
670
  }
@@ -673,12 +677,12 @@ function groups_screen_group_forum() {
673
  else if ( 'open' == $bp->action_variables[2] && ( $bp->is_item_admin || $bp->is_item_mod ) ) {
674
  /* Check the nonce */
675
  check_admin_referer( 'bp_forums_open_topic' );
676
-
677
  if ( !bp_forums_openclose_topic( array( 'topic_id' => $topic_id, 'mode' => 'open' ) ) )
678
  bp_core_add_message( __( 'There was an error when opening that topic', 'buddypress'), 'error' );
679
  else
680
  bp_core_add_message( __( 'The topic was opened successfully', 'buddypress') );
681
-
682
  do_action( 'groups_open_forum_topic', $topic_id );
683
  bp_core_redirect( wp_get_referer() );
684
  }
@@ -691,19 +695,19 @@ function groups_screen_group_forum() {
691
  /* Check the logged in user can delete this topic */
692
  if ( !$bp->is_item_admin && !$bp->is_item_mod && (int)$bp->loggedin_user->id != (int)$topic->topic_poster )
693
  bp_core_redirect( wp_get_referer() );
694
-
695
  /* Check the nonce */
696
  check_admin_referer( 'bp_forums_delete_topic' );
697
-
698
  if ( !groups_delete_group_forum_topic( $topic_id ) )
699
  bp_core_add_message( __( 'There was an error deleting the topic', 'buddypress'), 'error' );
700
  else
701
  bp_core_add_message( __( 'The topic was deleted successfully', 'buddypress') );
702
-
703
  do_action( 'groups_delete_forum_topic', $topic_id );
704
  bp_core_redirect( wp_get_referer() );
705
  }
706
-
707
  /* Editing a topic */
708
  else if ( 'edit' == $bp->action_variables[2] && empty( $bp->action_variables[3] ) ) {
709
  /* Fetch the topic */
@@ -716,19 +720,19 @@ function groups_screen_group_forum() {
716
  if ( isset( $_POST['save_changes'] ) ) {
717
  /* Check the nonce */
718
  check_admin_referer( 'bp_forums_edit_topic' );
719
-
720
  if ( !groups_update_group_forum_topic( $topic_id, $_POST['topic_title'], $_POST['topic_text'] ) )
721
  bp_core_add_message( __( 'There was an error when editing that topic', 'buddypress'), 'error' );
722
  else
723
  bp_core_add_message( __( 'The topic was edited successfully', 'buddypress') );
724
-
725
  do_action( 'groups_edit_forum_topic', $topic_id );
726
  bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic_slug . '/' );
727
  }
728
-
729
  bp_core_load_template( apply_filters( 'groups_template_group_forum_topic_edit', 'groups/single/forum/edit' ) );
730
  }
731
-
732
  /* Delete a post */
733
  else if ( 'delete' == $bp->action_variables[2] && $post_id = $bp->action_variables[4] ) {
734
  /* Fetch the post */
@@ -745,11 +749,11 @@ function groups_screen_group_forum() {
745
  bp_core_add_message( __( 'There was an error deleting that post', 'buddypress'), 'error' );
746
  else
747
  bp_core_add_message( __( 'The post was deleted successfully', 'buddypress') );
748
-
749
  do_action( 'groups_delete_forum_post', $post_id );
750
  bp_core_redirect( wp_get_referer() );
751
  }
752
-
753
  /* Editing a post */
754
  else if ( 'edit' == $bp->action_variables[2] && $post_id = $bp->action_variables[4] ) {
755
  /* Fetch the post */
@@ -762,16 +766,16 @@ function groups_screen_group_forum() {
762
  if ( isset( $_POST['save_changes'] ) ) {
763
  /* Check the nonce */
764
  check_admin_referer( 'bp_forums_edit_post' );
765
-
766
  if ( !groups_update_group_forum_post( $post_id, $_POST['post_text'], $topic_id ) )
767
  bp_core_add_message( __( 'There was an error when editing that post', 'buddypress'), 'error' );
768
  else
769
  bp_core_add_message( __( 'The post was edited successfully', 'buddypress') );
770
-
771
  do_action( 'groups_edit_forum_post', $post_id );
772
  bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic_slug . '/' );
773
  }
774
-
775
  bp_core_load_template( apply_filters( 'groups_template_group_forum_topic_edit', 'groups/single/forum/edit' ) );
776
  }
777
 
@@ -782,14 +786,14 @@ function groups_screen_group_forum() {
782
  else
783
  bp_core_load_template( apply_filters( 'groups_template_group_forum_topic', 'groups/forum/topic' ) );
784
  }
785
-
786
  } else {
787
 
788
  /* Posting a topic */
789
  if ( isset( $_POST['submit_topic'] ) && function_exists( 'bp_forums_new_topic') ) {
790
- /* Check the nonce */
791
  check_admin_referer( 'bp_forums_new_topic' );
792
-
793
  /* Auto join this user if they are not yet a member of this group */
794
  if ( !is_site_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) )
795
  groups_join_group( $bp->groups->current_group->id, $bp->loggedin_user->id );
@@ -798,31 +802,31 @@ function groups_screen_group_forum() {
798
  bp_core_add_message( __( 'There was an error when creating the topic', 'buddypress'), 'error' );
799
  else
800
  bp_core_add_message( __( 'The topic was created successfully', 'buddypress') );
801
-
802
  bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic->topic_slug . '/' );
803
  }
804
-
805
  do_action( 'groups_screen_group_forum', $topic_id, $forum_id );
806
-
807
  if ( '' != locate_template( array( 'groups/single/forum/index.php' ), false ) )
808
  bp_core_load_template( apply_filters( 'groups_template_group_forum', 'groups/single/forum/index' ) );
809
  else
810
- bp_core_load_template( apply_filters( 'groups_template_group_forum', 'groups/forum/index' ) );
811
  }
812
  }
813
  }
814
 
815
  function groups_screen_group_wire() {
816
  global $bp;
817
-
818
  $wire_action = $bp->action_variables[0];
819
-
820
  if ( $bp->is_single_item ) {
821
- if ( 'post' == $wire_action && groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) {
822
  /* Check the nonce first. */
823
- if ( !check_admin_referer( 'bp_wire_post' ) )
824
  return false;
825
-
826
  if ( !groups_new_wire_post( $bp->groups->current_group->id, $_POST['wire-post-textarea'] ) )
827
  bp_core_add_message( __('Wire message could not be posted.', 'buddypress'), 'error' );
828
  else
@@ -832,33 +836,33 @@ function groups_screen_group_wire() {
832
  bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
833
  else
834
  bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/' . $bp->wire->slug );
835
-
836
- } else if ( 'delete' == $wire_action && groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) {
837
  $wire_message_id = $bp->action_variables[1];
838
 
839
  /* Check the nonce first. */
840
  if ( !check_admin_referer( 'bp_wire_delete_link' ) )
841
  return false;
842
-
843
  if ( !groups_delete_wire_post( $wire_message_id, $bp->groups->table_name_wire ) )
844
  bp_core_add_message( __('There was an error deleting the wire message.', 'buddypress'), 'error' );
845
  else
846
  bp_core_add_message( __('Wire message successfully deleted.', 'buddypress') );
847
-
848
  if ( !strpos( wp_get_referer(), $bp->wire->slug ) )
849
  bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
850
  else
851
  bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/' . $bp->wire->slug );
852
-
853
  } else if ( ( !$wire_action || 'latest' == $bp->action_variables[1] ) ) {
854
  if ( '' != locate_template( array( 'groups/single/wire.php' ), false ) )
855
  bp_core_load_template( apply_filters( 'groups_template_group_wire', 'groups/single/wire' ) );
856
- else
857
  bp_core_load_template( apply_filters( 'groups_template_group_wire', 'groups/wire' ) );
858
  } else {
859
  if ( '' != locate_template( array( 'groups/single/home.php' ), false ) )
860
  bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) );
861
- else
862
  bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/group-home' ) );
863
  }
864
  }
@@ -866,29 +870,29 @@ function groups_screen_group_wire() {
866
 
867
  function groups_screen_group_members() {
868
  global $bp;
869
-
870
  if ( $bp->is_single_item ) {
871
  do_action( 'groups_screen_group_members', $bp->groups->current_group->id );
872
 
873
  if ( '' != locate_template( array( 'groups/single/members.php' ), false ) )
874
  bp_core_load_template( apply_filters( 'groups_template_group_forum', 'groups/single/members' ) );
875
  else
876
- bp_core_load_template( apply_filters( 'groups_template_group_forum', 'groups/list-members' ) );
877
  }
878
  }
879
 
880
  function groups_screen_group_invite() {
881
  global $bp;
882
-
883
  if ( $bp->is_single_item ) {
884
  if ( isset($bp->action_variables) && 'send' == $bp->action_variables[0] ) {
885
-
886
  if ( !check_admin_referer( 'groups_send_invites', '_wpnonce_send_invites' ) )
887
  return false;
888
-
889
  // Send the invites.
890
  groups_send_invites( $bp->loggedin_user->id, $bp->groups->current_group->id );
891
-
892
  bp_core_add_message( __('Group invites sent.', 'buddypress') );
893
 
894
  do_action( 'groups_screen_group_invite', $bp->groups->current_group->id );
@@ -897,25 +901,26 @@ function groups_screen_group_invite() {
897
  } else {
898
  // Show send invite page
899
  if ( '' != locate_template( array( 'groups/single/send-invite.php' ), false ) )
900
- bp_core_load_template( apply_filters( 'groups_template_group_invite', 'groups/single/send-invite' ) );
901
  else
902
- bp_core_load_template( apply_filters( 'groups_template_group_invite', 'groups/send-invite' ) );
903
  }
904
  }
905
  }
906
 
907
  function groups_screen_group_leave() {
908
  global $bp;
909
-
910
  if ( $bp->is_single_item ) {
911
  if ( isset($bp->action_variables) && 'yes' == $bp->action_variables[0] ) {
912
-
913
  // Check if the user is the group admin first.
914
- if ( groups_is_user_admin( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) {
915
- bp_core_add_message( __('As the only group administrator, you cannot leave this group.', 'buddypress'), 'error' );
916
- bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
 
 
917
  }
918
-
919
  // remove the user from the group.
920
  if ( !groups_leave_group( $bp->groups->current_group->id ) ) {
921
  bp_core_add_message( __('There was an error leaving the group. Please try again.', 'buddypress'), 'error' );
@@ -924,37 +929,37 @@ function groups_screen_group_leave() {
924
  bp_core_add_message( __('You left the group successfully.', 'buddypress') );
925
  bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug );
926
  }
927
-
928
  } else if ( isset($bp->action_variables) && 'no' == $bp->action_variables[0] ) {
929
-
930
  bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
931
-
932
  } else {
933
-
934
  do_action( 'groups_screen_group_leave', $bp->groups->current_group->id );
935
-
936
  // Show leave group page
937
  if ( '' != locate_template( array( 'groups/single/leave-confirm.php' ), false ) )
938
  bp_core_load_template( apply_filters( 'groups_template_group_leave', 'groups/single/leave-confirm' ) );
939
  else
940
- bp_core_load_template( apply_filters( 'groups_template_group_leave', 'groups/leave-group-confirm' ) );
941
  }
942
  }
943
  }
944
 
945
  function groups_screen_group_request_membership() {
946
  global $bp;
947
-
948
  if ( !is_user_logged_in() )
949
  return false;
950
-
951
  if ( 'private' == $bp->groups->current_group->status ) {
952
  // If the user has submitted a request, send it.
953
  if ( isset( $_POST['group-request-send']) ) {
954
  /* Check the nonce first. */
955
  if ( !check_admin_referer( 'groups_request_membership' ) )
956
  return false;
957
-
958
  if ( !groups_send_membership_request( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) {
959
  bp_core_add_message( __( 'There was an error sending your group membership request, please try again.', 'buddypress' ), 'error' );
960
  } else {
@@ -962,58 +967,58 @@ function groups_screen_group_request_membership() {
962
  }
963
  bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
964
  }
965
-
966
  do_action( 'groups_screen_group_request_membership', $bp->groups->current_group->id );
967
-
968
  if ( '' != locate_template( array( 'groups/single/request-membership.php' ), false ) )
969
  bp_core_load_template( apply_filters( 'groups_template_group_request_membership', 'groups/single/request-membership' ) );
970
  else
971
- bp_core_load_template( apply_filters( 'groups_template_group_request_membership', 'groups/request-membership' ) );
972
  }
973
  }
974
 
975
  function groups_screen_group_admin() {
976
  global $bp;
977
-
978
  if ( $bp->current_component != BP_GROUPS_SLUG || 'admin' != $bp->current_action )
979
  return false;
980
-
981
  if ( !empty( $bp->action_variables[0] ) )
982
  return false;
983
-
984
  bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/edit-details' );
985
  }
986
 
987
  function groups_screen_group_admin_edit_details() {
988
  global $bp;
989
-
990
  if ( $bp->current_component == $bp->groups->slug && 'edit-details' == $bp->action_variables[0] ) {
991
-
992
  if ( $bp->is_item_admin || $bp->is_item_mod ) {
993
-
994
  // If the edit form has been submitted, save the edited details
995
  if ( isset( $_POST['save'] ) ) {
996
  /* Check the nonce first. */
997
  if ( !check_admin_referer( 'groups_edit_group_details' ) )
998
  return false;
999
-
1000
  if ( !groups_edit_base_group_details( $_POST['group-id'], $_POST['group-name'], $_POST['group-desc'], $_POST['group-news'], (int)$_POST['group-notify-members'] ) ) {
1001
  bp_core_add_message( __( 'There was an error updating group details, please try again.', 'buddypress' ), 'error' );
1002
  } else {
1003
  bp_core_add_message( __( 'Group details were successfully updated.', 'buddypress' ) );
1004
  }
1005
-
1006
  do_action( 'groups_group_details_edited', $bp->groups->current_group->id );
1007
-
1008
  bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/edit-details' );
1009
  }
1010
 
1011
  do_action( 'groups_screen_group_admin_edit_details', $bp->groups->current_group->id );
1012
 
1013
  if ( '' != locate_template( array( 'groups/single/admin.php' ), false ) )
1014
- bp_core_load_template( apply_filters( 'groups_template_group_admin', 'groups/single/admin' ) );
1015
  else
1016
- bp_core_load_template( apply_filters( 'groups_template_group_admin', 'groups/admin/edit-details' ) );
1017
  }
1018
  }
1019
  }
@@ -1021,26 +1026,26 @@ add_action( 'wp', 'groups_screen_group_admin_edit_details', 4 );
1021
 
1022
  function groups_screen_group_admin_settings() {
1023
  global $bp;
1024
-
1025
  if ( $bp->current_component == $bp->groups->slug && 'group-settings' == $bp->action_variables[0] ) {
1026
-
1027
  if ( !$bp->is_item_admin )
1028
  return false;
1029
-
1030
  // If the edit form has been submitted, save the edited details
1031
  if ( isset( $_POST['save'] ) ) {
1032
  $enable_wire = ( isset($_POST['group-show-wire'] ) ) ? 1 : 0;
1033
  $enable_forum = ( isset($_POST['group-show-forum'] ) ) ? 1 : 0;
1034
  $enable_photos = ( isset($_POST['group-show-photos'] ) ) ? 1 : 0;
1035
  $photos_admin_only = ( $_POST['group-photos-status'] != 'all' ) ? 1 : 0;
1036
-
1037
  $allowed_status = apply_filters( 'groups_allowed_status', array( 'public', 'private', 'hidden' ) );
1038
  $status = ( in_array( $_POST['group-status'], (array)$allowed_status ) ) ? $_POST['group-status'] : 'public';
1039
-
1040
  /* Check the nonce first. */
1041
  if ( !check_admin_referer( 'groups_edit_group_settings' ) )
1042
  return false;
1043
-
1044
  if ( !groups_edit_group_settings( $_POST['group-id'], $enable_wire, $enable_forum, $enable_photos, $photos_admin_only, $status ) ) {
1045
  bp_core_add_message( __( 'There was an error updating group settings, please try again.', 'buddypress' ), 'error' );
1046
  } else {
@@ -1048,14 +1053,14 @@ function groups_screen_group_admin_settings() {
1048
  }
1049
 
1050
  do_action( 'groups_group_settings_edited', $bp->groups->current_group->id );
1051
-
1052
  bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/group-settings' );
1053
  }
1054
 
1055
  do_action( 'groups_screen_group_admin_settings', $bp->groups->current_group->id );
1056
-
1057
  if ( '' != locate_template( array( 'groups/single/admin.php' ), false ) )
1058
- bp_core_load_template( apply_filters( 'groups_template_group_admin_settings', 'groups/single/admin' ) );
1059
  else
1060
  bp_core_load_template( apply_filters( 'groups_template_group_admin_settings', 'groups/admin/group-settings' ) );
1061
  }
@@ -1064,25 +1069,25 @@ add_action( 'wp', 'groups_screen_group_admin_settings', 4 );
1064
 
1065
  function groups_screen_group_admin_avatar() {
1066
  global $bp;
1067
-
1068
  if ( $bp->current_component == $bp->groups->slug && 'group-avatar' == $bp->action_variables[0] ) {
1069
-
1070
  if ( !$bp->is_item_admin )
1071
  return false;
1072
-
1073
  /* If the group admin has deleted the admin avatar */
1074
  if ( 'delete' == $bp->action_variables[1] ) {
1075
-
1076
  /* Check the nonce */
1077
  check_admin_referer( 'bp_group_avatar_delete' );
1078
-
1079
  if ( bp_core_delete_existing_avatar( array( 'item_id' => $bp->groups->current_group->id, 'object' => 'group' ) ) )
1080
  bp_core_add_message( __( 'Your avatar was deleted successfully!', 'buddypress' ) );
1081
  else
1082
  bp_core_add_message( __( 'There was a problem deleting that avatar, please try again.', 'buddypress' ), 'error' );
1083
-
1084
- }
1085
-
1086
  $bp->avatar_admin->step = 'upload-image';
1087
 
1088
  if ( !empty( $_FILES ) ) {
@@ -1091,7 +1096,7 @@ function groups_screen_group_admin_avatar() {
1091
  check_admin_referer( 'bp_avatar_upload' );
1092
 
1093
  /* Pass the file to the avatar upload handler */
1094
- if ( bp_core_avatar_handle_upload( $_FILES, 'groups_avatar_upload_dir' ) ) {
1095
  $bp->avatar_admin->step = 'crop-image';
1096
 
1097
  /* Make sure we include the jQuery jCrop file for image cropping */
@@ -1113,12 +1118,12 @@ function groups_screen_group_admin_avatar() {
1113
 
1114
  }
1115
 
1116
- do_action( 'groups_screen_group_admin_avatar', $bp->groups->current_group->id );
1117
-
1118
  if ( '' != locate_template( array( 'groups/single/admin.php' ), false ) )
1119
- bp_core_load_template( apply_filters( 'groups_template_group_admin_avatar', 'groups/single/admin' ) );
1120
  else
1121
- bp_core_load_template( apply_filters( 'groups_template_group_admin_avatar', 'groups/admin/group-avatar' ) );
1122
  }
1123
  }
1124
  add_action( 'wp', 'groups_screen_group_admin_avatar', 4 );
@@ -1127,37 +1132,37 @@ function groups_screen_group_admin_manage_members() {
1127
  global $bp;
1128
 
1129
  if ( $bp->current_component == $bp->groups->slug && 'manage-members' == $bp->action_variables[0] ) {
1130
-
1131
  if ( !$bp->is_item_admin )
1132
  return false;
1133
-
1134
  if ( 'promote' == $bp->action_variables[1] && ( 'mod' == $bp->action_variables[2] || 'admin' == $bp->action_variables[2] ) && is_numeric( $bp->action_variables[3] ) ) {
1135
  $user_id = $bp->action_variables[3];
1136
  $status = $bp->action_variables[2];
1137
-
1138
  /* Check the nonce first. */
1139
  if ( !check_admin_referer( 'groups_promote_member' ) )
1140
  return false;
1141
-
1142
  // Promote a user.
1143
  if ( !groups_promote_member( $user_id, $bp->groups->current_group->id, $status ) ) {
1144
  bp_core_add_message( __( 'There was an error when promoting that user, please try again', 'buddypress' ), 'error' );
1145
  } else {
1146
  bp_core_add_message( __( 'User promoted successfully', 'buddypress' ) );
1147
  }
1148
-
1149
  do_action( 'groups_promoted_member', $user_id, $bp->groups->current_group->id );
1150
 
1151
  bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/manage-members' );
1152
  }
1153
-
1154
  if ( 'demote' == $bp->action_variables[1] && is_numeric( $bp->action_variables[2] ) ) {
1155
  $user_id = $bp->action_variables[2];
1156
 
1157
  /* Check the nonce first. */
1158
  if ( !check_admin_referer( 'groups_demote_member' ) )
1159
  return false;
1160
-
1161
  // Demote a user.
1162
  if ( !groups_demote_member( $user_id, $bp->groups->current_group->id ) ) {
1163
  bp_core_add_message( __( 'There was an error when demoting that user, please try again', 'buddypress' ), 'error' );
@@ -1169,14 +1174,14 @@ function groups_screen_group_admin_manage_members() {
1169
 
1170
  bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/manage-members' );
1171
  }
1172
-
1173
  if ( 'ban' == $bp->action_variables[1] && is_numeric( $bp->action_variables[2] ) ) {
1174
  $user_id = $bp->action_variables[2];
1175
 
1176
  /* Check the nonce first. */
1177
  if ( !check_admin_referer( 'groups_ban_member' ) )
1178
  return false;
1179
-
1180
  // Ban a user.
1181
  if ( !groups_ban_member( $user_id, $bp->groups->current_group->id ) ) {
1182
  bp_core_add_message( __( 'There was an error when banning that user, please try again', 'buddypress' ), 'error' );
@@ -1188,14 +1193,14 @@ function groups_screen_group_admin_manage_members() {
1188
 
1189
  bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/manage-members' );
1190
  }
1191
-
1192
  if ( 'unban' == $bp->action_variables[1] && is_numeric( $bp->action_variables[2] ) ) {
1193
  $user_id = $bp->action_variables[2];
1194
 
1195
  /* Check the nonce first. */
1196
  if ( !check_admin_referer( 'groups_unban_member' ) )
1197
  return false;
1198
-
1199
  // Remove a ban for user.
1200
  if ( !groups_unban_member( $user_id, $bp->groups->current_group->id ) ) {
1201
  bp_core_add_message( __( 'There was an error when unbanning that user, please try again', 'buddypress' ), 'error' );
@@ -1209,9 +1214,9 @@ function groups_screen_group_admin_manage_members() {
1209
  }
1210
 
1211
  do_action( 'groups_screen_group_admin_manage_members', $bp->groups->current_group->id );
1212
-
1213
  if ( '' != locate_template( array( 'groups/single/admin.php' ), false ) )
1214
- bp_core_load_template( apply_filters( 'groups_template_group_admin_manage_members', 'groups/single/admin' ) );
1215
  else
1216
  bp_core_load_template( apply_filters( 'groups_template_group_admin_manage_members', 'groups/admin/manage-members' ) );
1217
  }
@@ -1220,15 +1225,15 @@ add_action( 'wp', 'groups_screen_group_admin_manage_members', 4 );
1220
 
1221
  function groups_screen_group_admin_requests() {
1222
  global $bp;
1223
-
1224
  if ( $bp->current_component == $bp->groups->slug && 'membership-requests' == $bp->action_variables[0] ) {
1225
-
1226
  if ( !$bp->is_item_admin || 'public' == $bp->groups->current_group->status )
1227
  return false;
1228
-
1229
  // Remove any screen notifications
1230
  bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'new_membership_request' );
1231
-
1232
  $request_action = $bp->action_variables[1];
1233
  $membership_id = $bp->action_variables[2];
1234
 
@@ -1238,7 +1243,7 @@ function groups_screen_group_admin_requests() {
1238
  /* Check the nonce first. */
1239
  if ( !check_admin_referer( 'groups_accept_membership_request' ) )
1240
  return false;
1241
-
1242
  // Accept the membership request
1243
  if ( !groups_accept_membership_request( $membership_id ) ) {
1244
  bp_core_add_message( __( 'There was an error accepting the membership request, please try again.', 'buddypress' ), 'error' );
@@ -1250,16 +1255,16 @@ function groups_screen_group_admin_requests() {
1250
  /* Check the nonce first. */
1251
  if ( !check_admin_referer( 'groups_reject_membership_request' ) )
1252
  return false;
1253
-
1254
  // Reject the membership request
1255
  if ( !groups_reject_membership_request( $membership_id ) ) {
1256
  bp_core_add_message( __( 'There was an error rejecting the membership request, please try again.', 'buddypress' ), 'error' );
1257
  } else {
1258
  bp_core_add_message( __( 'Group membership request rejected', 'buddypress' ) );
1259
- }
1260
 
1261
  }
1262
-
1263
  do_action( 'groups_group_request_managed', $bp->groups->current_group->id, $request_action, $membership_id );
1264
 
1265
  bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/membership-requests' );
@@ -1268,26 +1273,26 @@ function groups_screen_group_admin_requests() {
1268
  do_action( 'groups_screen_group_admin_requests', $bp->groups->current_group->id );
1269
 
1270
  if ( '' != locate_template( array( 'groups/single/admin.php' ), false ) )
1271
- bp_core_load_template( apply_filters( 'groups_template_group_admin_requests', 'groups/single/admin' ) );
1272
  else
1273
- bp_core_load_template( apply_filters( 'groups_template_group_admin_requests', 'groups/admin/membership-requests' ) );
1274
  }
1275
  }
1276
  add_action( 'wp', 'groups_screen_group_admin_requests', 4 );
1277
 
1278
  function groups_screen_group_admin_delete_group() {
1279
  global $bp;
1280
-
1281
  if ( $bp->current_component == $bp->groups->slug && 'delete-group' == $bp->action_variables[0] ) {
1282
-
1283
  if ( !$bp->is_item_admin && !is_site_admin() )
1284
  return false;
1285
-
1286
  if ( isset( $_REQUEST['delete-group-button'] ) && isset( $_REQUEST['delete-group-understand'] ) ) {
1287
  /* Check the nonce first. */
1288
  if ( !check_admin_referer( 'groups_delete_group' ) )
1289
  return false;
1290
-
1291
  // Group admin has deleted the group, now do it.
1292
  if ( !groups_delete_group( $bp->groups->current_group->id ) ) {
1293
  bp_core_add_message( __( 'There was an error deleting the group, please try again.', 'buddypress' ), 'error' );
@@ -1305,14 +1310,14 @@ function groups_screen_group_admin_delete_group() {
1305
  do_action( 'groups_screen_group_admin_delete_group', $bp->groups->current_group->id );
1306
 
1307
  if ( '' != locate_template( array( 'groups/single/admin.php' ), false ) )
1308
- bp_core_load_template( apply_filters( 'groups_template_group_admin_delete_group', 'groups/single/admin' ) );
1309
  else
1310
- bp_core_load_template( apply_filters( 'groups_template_group_admin_delete_group', 'groups/admin/delete-group' ) );
1311
  }
1312
  }
1313
  add_action( 'wp', 'groups_screen_group_admin_delete_group', 4 );
1314
 
1315
- function groups_screen_notification_settings() {
1316
  global $current_user; ?>
1317
  <table class="notification-settings" id="groups-notification-settings">
1318
  <tr>
@@ -1353,10 +1358,10 @@ function groups_screen_notification_settings() {
1353
  <td class="yes"><input type="radio" name="notifications[notification_groups_membership_request]" value="yes" <?php if ( !get_usermeta( $current_user->id, 'notification_groups_membership_request') || 'yes' == get_usermeta( $current_user->id, 'notification_groups_membership_request') ) { ?>checked="checked" <?php } ?>/></td>
1354
  <td class="no"><input type="radio" name="notifications[notification_groups_membership_request]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id, 'notification_groups_membership_request') ) { ?>checked="checked" <?php } ?>/></td>
1355
  </tr>
1356
-
1357
  <?php do_action( 'groups_screen_notification_settings' ); ?>
1358
  </table>
1359
- <?php
1360
  }
1361
  add_action( 'bp_notification_settings', 'groups_screen_notification_settings' );
1362
 
@@ -1371,10 +1376,10 @@ add_action( 'bp_notification_settings', 'groups_screen_notification_settings' );
1371
 
1372
  function groups_action_join_group() {
1373
  global $bp;
1374
-
1375
  if ( !$bp->is_single_item || $bp->current_component != $bp->groups->slug || $bp->current_action != 'join' )
1376
  return false;
1377
-
1378
  // user wants to join a group
1379
  if ( !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) && !groups_is_user_banned( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) {
1380
  if ( !groups_join_group($bp->groups->current_group->id) ) {
@@ -1386,7 +1391,7 @@ function groups_action_join_group() {
1386
  }
1387
 
1388
  if ( '' != locate_template( array( 'groups/single/admin.php' ), false ) )
1389
- bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) );
1390
  else
1391
  bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/group-home' ) );
1392
  }
@@ -1394,20 +1399,20 @@ add_action( 'wp', 'groups_action_join_group', 3 );
1394
 
1395
  function groups_action_sort_creation_steps() {
1396
  global $bp;
1397
-
1398
  if ( $bp->current_component != BP_GROUPS_SLUG && $bp->current_action != 'create' )
1399
  return false;
1400
 
1401
  if ( !is_array( $bp->groups->group_creation_steps ) )
1402
  return false;
1403
-
1404
  foreach ( $bp->groups->group_creation_steps as $slug => $step )
1405
  $temp[$step['position']] = array( 'name' => $step['name'], 'slug' => $slug );
1406
 
1407
  /* Sort the steps by their position key */
1408
  ksort($temp);
1409
  unset($bp->groups->group_creation_steps);
1410
-
1411
  foreach( $temp as $position => $step )
1412
  $bp->groups->group_creation_steps[$step['slug']] = array( 'name' => $step['name'], 'position' => $position );
1413
  }
@@ -1415,7 +1420,7 @@ add_action( 'wp', 'groups_action_sort_creation_steps', 3 );
1415
 
1416
  function groups_aciton_redirect_to_random_group() {
1417
  global $bp, $wpdb;
1418
-
1419
  if ( $bp->current_component == $bp->groups->slug && isset( $_GET['random-group'] ) ) {
1420
  $group = groups_get_random_groups( 1, 1 );
1421
 
@@ -1434,7 +1439,7 @@ add_action( 'wp', 'groups_aciton_redirect_to_random_group', 6 );
1434
 
1435
  function groups_register_activity_actions() {
1436
  global $bp;
1437
-
1438
  if ( !function_exists( 'bp_activity_set_action' ) )
1439
  return false;
1440
 
@@ -1450,14 +1455,14 @@ add_action( 'plugins_loaded', 'groups_register_activity_actions' );
1450
 
1451
  function groups_record_activity( $args = '' ) {
1452
  global $bp;
1453
-
1454
  if ( !function_exists( 'bp_activity_add' ) )
1455
  return false;
1456
-
1457
  /* If the group is not public, no recording of activity please. */
1458
- if ( 'public' != $bp->groups->current_group->status )
1459
  return false;
1460
-
1461
  $defaults = array(
1462
  'user_id' => $bp->loggedin_user->id,
1463
  'content' => false,
@@ -1471,7 +1476,7 @@ function groups_record_activity( $args = '' ) {
1471
  );
1472
 
1473
  $r = wp_parse_args( $args, $defaults );
1474
- extract( $r, EXTR_SKIP );
1475
 
1476
  return bp_activity_add( array( 'user_id' => $user_id, 'content' => $content, 'primary_link' => $primary_link, 'component_name' => $component_name, 'component_action' => $component_action, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) );
1477
  }
@@ -1489,93 +1494,93 @@ add_action( 'groups_new_forum_topic_post', 'groups_update_last_activity' );
1489
 
1490
  function groups_format_notifications( $action, $item_id, $secondary_item_id, $total_items ) {
1491
  global $bp;
1492
-
1493
  switch ( $action ) {
1494
  case 'new_membership_request':
1495
  $group_id = $secondary_item_id;
1496
  $requesting_user_id = $item_id;
1497
 
1498
  $group = new BP_Groups_Group( $group_id, false, false );
1499
-
1500
  $group_link = bp_get_group_permalink( $group );
1501
 
1502
  if ( (int)$total_items > 1 ) {
1503
- return apply_filters( 'bp_groups_multiple_new_membership_requests_notification', '<a href="' . $group_link . '/admin/membership-requests/" title="' . __( 'Group Membership Requests', 'buddypress' ) . '">' . sprintf( __('%d new membership requests for the group "%s"', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $group_link, $total_items, $group->name );
1504
  } else {
1505
  $user_fullname = bp_core_get_user_displayname( $requesting_user_id );
1506
  return apply_filters( 'bp_groups_single_new_membership_request_notification', '<a href="' . $group_link . '/admin/membership-requests/" title="' . $user_fullname .' requests group membership">' . sprintf( __('%s requests membership for the group "%s"', 'buddypress' ), $user_fullname, $group->name ) . '</a>', $group_link, $user_fullname, $group->name );
1507
- }
1508
  break;
1509
-
1510
  case 'membership_request_accepted':
1511
  $group_id = $item_id;
1512
-
1513
  $group = new BP_Groups_Group( $group_id, false, false );
1514
  $group_link = bp_get_group_permalink( $group ) . '/?new';
1515
-
1516
  if ( (int)$total_items > 1 ) {
1517
- return apply_filters( 'bp_groups_multiple_membership_request_accepted_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('%d accepted group membership requests', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $total_items, $group_name );
1518
  } else {
1519
  return apply_filters( 'bp_groups_single_membership_request_accepted_notification', '<a href="' . $group_link . '">' . sprintf( __('Membership for group "%s" accepted'), $group->name ) . '</a>', $group_link, $group->name );
1520
- }
1521
  break;
1522
-
1523
  case 'membership_request_rejected':
1524
  $group_id = $item_id;
1525
-
1526
  $group = new BP_Groups_Group( $group_id, false, false );
1527
  $group_link = bp_get_group_permalink( $group ) . '/?new';
1528
-
1529
  if ( (int)$total_items > 1 ) {
1530
- return apply_filters( 'bp_groups_multiple_membership_request_rejected_notification', '<a href="' . site_url() . '/' . BP_MEMBERS_SLUG . '/' . $bp->groups->slug . '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('%d rejected group membership requests', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $total_items, $group->name );
1531
  } else {
1532
  return apply_filters( 'bp_groups_single_membership_request_rejected_notification', '<a href="' . $group_link . '">' . sprintf( __('Membership for group "%s" rejected'), $group->name ) . '</a>', $group_link, $group->name );
1533
- }
1534
-
1535
  break;
1536
-
1537
  case 'member_promoted_to_admin':
1538
  $group_id = $item_id;
1539
-
1540
  $group = new BP_Groups_Group( $group_id, false, false );
1541
  $group_link = bp_get_group_permalink( $group ) . '/?new';
1542
-
1543
  if ( (int)$total_items > 1 ) {
1544
- return apply_filters( 'bp_groups_multiple_member_promoted_to_admin_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('You were promoted to an admin in %d groups', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
1545
  } else {
1546
  return apply_filters( 'bp_groups_single_member_promoted_to_admin_notification', '<a href="' . $group_link . '">' . sprintf( __('You were promoted to an admin in the group %s'), $group->name ) . '</a>', $group_link, $group->name );
1547
- }
1548
  break;
1549
-
1550
  case 'member_promoted_to_mod':
1551
  $group_id = $item_id;
1552
-
1553
  $group = new BP_Groups_Group( $group_id, false, false );
1554
  $group_link = bp_get_group_permalink( $group ) . '/?new';
1555
-
1556
  if ( (int)$total_items > 1 ) {
1557
- return apply_filters( 'bp_groups_multiple_member_promoted_to_mod_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('You were promoted to a mod in %d groups', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
1558
  } else {
1559
  return apply_filters( 'bp_groups_single_member_promoted_to_mod_notification', '<a href="' . $group_link . '">' . sprintf( __('You were promoted to a mod in the group %s'), $group->name ) . '</a>', $group_link, $group->name );
1560
- }
1561
  break;
1562
-
1563
  case 'group_invite':
1564
  $group_id = $item_id;
1565
 
1566
  $group = new BP_Groups_Group( $group_id, false, false );
1567
  $user_url = bp_core_get_userurl( $user_id );
1568
-
1569
  if ( (int)$total_items > 1 ) {
1570
- return apply_filters( 'bp_groups_multiple_group_invite_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/invites" title="' . __( 'Group Invites', 'buddypress' ) . '">' . sprintf( __('You have %d new group invitations', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
1571
  } else {
1572
  return apply_filters( 'bp_groups_single_group_invite_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/invites" title="' . __( 'Group Invites', 'buddypress' ) . '">' . sprintf( __('You have an invitation to the group: %s', 'buddypress' ), $group->name ) . '</a>', $group->name );
1573
- }
1574
  break;
1575
  }
1576
 
1577
  do_action( 'groups_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
1578
-
1579
  return false;
1580
  }
1581
 
@@ -1593,9 +1598,9 @@ function groups_format_notifications( $action, $item_id, $secondary_item_id, $to
1593
 
1594
  function groups_create_group( $args = '' ) {
1595
  global $bp;
1596
-
1597
  extract( $args );
1598
-
1599
  /**
1600
  * Possible parameters (pass as assoc array):
1601
  * 'group_id'
@@ -1614,43 +1619,43 @@ function groups_create_group( $args = '' ) {
1614
  $group = new BP_Groups_Group( $group_id );
1615
  else
1616
  $group = new BP_Groups_Group;
1617
-
1618
  if ( $creator_id ) {
1619
  $group->creator_id = $creator_id;
1620
  } else {
1621
  $group->creator_id = $bp->loggedin_user->id;
1622
  }
1623
-
1624
  if ( isset( $name ) )
1625
  $group->name = $name;
1626
-
1627
  if ( isset( $description ) )
1628
  $group->description = $description;
1629
-
1630
  if ( isset( $news ) )
1631
  $group->news = $news;
1632
-
1633
  if ( isset( $slug ) && groups_check_slug( $slug ) )
1634
  $group->slug = $slug;
1635
-
1636
  if ( isset( $status ) ) {
1637
  if ( groups_is_valid_status( $status ) )
1638
  $group->status = $status;
1639
  }
1640
-
1641
  if ( isset( $enable_wire ) )
1642
  $group->enable_wire = $enable_wire;
1643
  else if ( !$group_id && !isset( $enable_wire ) )
1644
  $group->enable_wire = 1;
1645
-
1646
  if ( isset( $enable_forum ) )
1647
  $group->enable_forum = $enable_forum;
1648
  else if ( !$group_id && !isset( $enable_forum ) )
1649
  $group->enable_forum = 1;
1650
-
1651
  if ( isset( $date_created ) )
1652
  $group->date_created = $date_created;
1653
-
1654
  if ( !$group->save() )
1655
  return false;
1656
 
@@ -1662,7 +1667,7 @@ function groups_create_group( $args = '' ) {
1662
  $member->is_admin = 1;
1663
  $member->user_title = __( 'Group Admin', 'buddypress' );
1664
  $member->is_confirmed = 1;
1665
-
1666
  $member->save();
1667
  }
1668
 
@@ -1674,7 +1679,7 @@ function groups_edit_base_group_details( $group_id, $group_name, $group_desc, $g
1674
 
1675
  if ( empty( $group_name ) || empty( $group_desc ) )
1676
  return false;
1677
-
1678
  $group = new BP_Groups_Group( $group_id, false, false );
1679
  $group->name = $group_name;
1680
  $group->description = $group_desc;
@@ -1687,56 +1692,56 @@ function groups_edit_base_group_details( $group_id, $group_name, $group_desc, $g
1687
  require_once ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' );
1688
  groups_notification_group_updated( $group->id );
1689
  }
1690
-
1691
  do_action( 'groups_details_updated', $group->id );
1692
-
1693
  return true;
1694
  }
1695
 
1696
  function groups_edit_group_settings( $group_id, $enable_wire, $enable_forum, $enable_photos, $photos_admin_only, $status ) {
1697
  global $bp;
1698
-
1699
  $group = new BP_Groups_Group( $group_id, false, false );
1700
  $group->enable_wire = $enable_wire;
1701
  $group->enable_forum = $enable_forum;
1702
  $group->enable_photos = $enable_photos;
1703
  $group->photos_admin_only = $photos_admin_only;
1704
-
1705
- /***
1706
  * Before we potentially switch the group status, if it has been changed to public
1707
  * from private and there are outstanding membership requests, auto-accept those requests.
1708
  */
1709
  if ( 'private' == $group->status && 'public' == $status )
1710
  groups_accept_all_pending_membership_requests( $group->id );
1711
-
1712
  /* Now update the status */
1713
  $group->status = $status;
1714
-
1715
  if ( !$group->save() )
1716
  return false;
1717
-
1718
  /* If forums have been enabled, and a forum does not yet exist, we need to create one. */
1719
  if ( $group->enable_forum ) {
1720
  if ( function_exists( 'bp_forums_setup' ) && '' == groups_get_groupmeta( $group->id, 'forum_id' ) ) {
1721
  groups_new_group_forum( $group->id, $group->name, $group->description );
1722
  }
1723
  }
1724
-
1725
  do_action( 'groups_settings_updated', $group->id );
1726
-
1727
  return true;
1728
  }
1729
 
1730
  function groups_delete_group( $group_id ) {
1731
  global $bp;
1732
-
1733
  // Check the user is the group admin.
1734
  if ( !$bp->is_item_admin )
1735
  return false;
1736
-
1737
  // Get the group object
1738
  $group = new BP_Groups_Group( $group_id );
1739
-
1740
  if ( !$group->delete() )
1741
  return false;
1742
 
@@ -1744,21 +1749,21 @@ function groups_delete_group( $group_id ) {
1744
  if ( function_exists( 'bp_activity_delete_by_item_id' ) ) {
1745
  bp_activity_delete_by_item_id( array( 'item_id' => $group_id, 'component_name' => $bp->groups->id ) );
1746
  }
1747
-
1748
  // Remove all outstanding invites for this group
1749
  groups_delete_all_group_invites( $group_id );
1750
 
1751
  // Remove all notifications for any user belonging to this group
1752
  bp_core_delete_all_notifications_by_type( $group_id, $bp->groups->slug );
1753
-
1754
  do_action( 'groups_delete_group', $group_id );
1755
-
1756
  return true;
1757
  }
1758
 
1759
  function groups_is_valid_status( $status ) {
1760
  global $bp;
1761
-
1762
  return in_array( $status, (array)$bp->groups->valid_status );
1763
  }
1764
 
@@ -1767,18 +1772,18 @@ function groups_check_slug( $slug ) {
1767
 
1768
  if ( 'wp' == substr( $slug, 0, 2 ) )
1769
  $slug = substr( $slug, 2, strlen( $slug ) - 2 );
1770
-
1771
  if ( in_array( $slug, (array)$bp->groups->forbidden_names ) ) {
1772
  $slug = $slug . '-' . rand();
1773
  }
1774
-
1775
  if ( BP_Groups_Group::check_slug( $slug ) ) {
1776
  do {
1777
  $slug = $slug . '-' . rand();
1778
  }
1779
  while ( BP_Groups_Group::check_slug( $slug ) );
1780
  }
1781
-
1782
  return $slug;
1783
  }
1784
 
@@ -1794,11 +1799,7 @@ function groups_leave_group( $group_id, $user_id = false ) {
1794
 
1795
  if ( !$user_id )
1796
  $user_id = $bp->loggedin_user->id;
1797
-
1798
- // Admins cannot leave a group, that is until promotion to admin support is implemented.
1799
- if ( groups_is_user_admin( $user_id, $group_id ) )
1800
- return false;
1801
-
1802
  // This is exactly the same as deleting and invite, just is_confirmed = 1 NOT 0.
1803
  if ( !groups_uninvite_user( $user_id, $group_id, true ) )
1804
  return false;
@@ -1807,19 +1808,22 @@ function groups_leave_group( $group_id, $user_id = false ) {
1807
 
1808
  /* Modify group member count */
1809
  groups_update_groupmeta( $group_id, 'total_member_count', (int) groups_get_groupmeta( $group_id, 'total_member_count') - 1 );
1810
-
1811
  return true;
1812
  }
1813
 
1814
  function groups_join_group( $group_id, $user_id = false ) {
1815
  global $bp;
1816
-
1817
  if ( !$user_id )
1818
  $user_id = $bp->loggedin_user->id;
1819
 
1820
  if ( groups_check_user_has_invite( $user_id, $group_id ) )
1821
  groups_delete_invite( $user_id, $group_id );
1822
-
 
 
 
1823
  $new_member = new BP_Groups_Member;
1824
  $new_member->group_id = $group_id;
1825
  $new_member->user_id = $user_id;
@@ -1828,16 +1832,16 @@ function groups_join_group( $group_id, $user_id = false ) {
1828
  $new_member->user_title = '';
1829
  $new_member->date_modified = time();
1830
  $new_member->is_confirmed = 1;
1831
-
1832
  if ( !$new_member->save() )
1833
  return false;
1834
 
1835
  /* Record this in activity streams */
1836
  groups_record_activity( array(
1837
- 'content' => apply_filters( 'groups_activity_joined_group', sprintf( __( '%s joined the group %s', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' ) ),
1838
  'primary_link' => apply_filters( 'groups_activity_joined_group_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ),
1839
  'component_action' => 'joined_group',
1840
- 'item_id' => $bp->groups->current_group->id
1841
  ) );
1842
 
1843
  /* Modify group meta */
@@ -1890,7 +1894,7 @@ function groups_get_random_groups( $limit = null, $page = 1 ) {
1890
  }
1891
 
1892
  function groups_get_alphabetically( $limit = null, $page = 1 ) {
1893
- return BP_Groups_Group::get_alphabetically( $limit, $page );
1894
  }
1895
 
1896
  function groups_get_by_most_forum_topics( $limit = null, $page = 1 ) {
@@ -1903,10 +1907,10 @@ function groups_get_by_most_forum_posts( $limit = null, $page = 1 ) {
1903
 
1904
  function groups_get_user_groups( $user_id = false, $pag_num = false, $pag_page = false ) {
1905
  global $bp;
1906
-
1907
  if ( !$user_id )
1908
  $user_id = $bp->displayed_user->id;
1909
-
1910
  return BP_Groups_Member::get_group_ids( $user_id, $pag_num, $pag_page );
1911
  }
1912
 
@@ -1914,7 +1918,7 @@ function groups_get_user_groups( $user_id = false, $pag_num = false, $pag_page =
1914
 
1915
  function groups_get_recently_joined_for_user( $user_id = false, $pag_num = false, $pag_page = false, $filter = false ) {
1916
  global $bp;
1917
-
1918
  if ( !$user_id )
1919
  $user_id = $bp->displayed_user->id;
1920
 
@@ -1923,64 +1927,64 @@ function groups_get_recently_joined_for_user( $user_id = false, $pag_num = false
1923
 
1924
  function groups_get_most_popular_for_user( $user_id = false, $pag_num = false, $pag_page = false, $filter = false ) {
1925
  global $bp;
1926
-
1927
  if ( !$user_id )
1928
  $user_id = $bp->displayed_user->id;
1929
 
1930
- return BP_Groups_Member::get_most_popular( $user_id, $pag_num, $pag_page, $filter );
1931
  }
1932
 
1933
  function groups_get_recently_active_for_user( $user_id = false, $pag_num = false, $pag_page = false, $filter = false ) {
1934
  global $bp;
1935
-
1936
  if ( !$user_id )
1937
  $user_id = $bp->displayed_user->id;
1938
-
1939
  return BP_Groups_Member::get_recently_active( $user_id, $pag_num, $pag_page, $filter );
1940
  }
1941
 
1942
  function groups_get_alphabetically_for_user( $user_id = false, $pag_num = false, $pag_page = false, $filter = false ) {
1943
  global $bp;
1944
-
1945
  if ( !$user_id )
1946
  $user_id = $bp->displayed_user->id;
1947
 
1948
- return BP_Groups_Member::get_alphabetically( $user_id, $pag_num, $pag_page, $filter );
1949
  }
1950
 
1951
  function groups_get_user_is_admin_of( $user_id = false, $pag_num = false, $pag_page = false, $filter = false ) {
1952
  global $bp;
1953
-
1954
  if ( !$user_id )
1955
  $user_id = $bp->displayed_user->id;
1956
-
1957
- return BP_Groups_Member::get_is_admin_of( $user_id, $pag_num, $pag_page, $filter );
1958
  }
1959
 
1960
  function groups_get_user_is_mod_of( $user_id = false, $pag_num = false, $pag_page = false, $filter = false ) {
1961
  global $bp;
1962
-
1963
  if ( !$user_id )
1964
  $user_id = $bp->displayed_user->id;
1965
-
1966
- return BP_Groups_Member::get_is_mod_of( $user_id, $pag_num, $pag_page, $filter );
1967
  }
1968
 
1969
  function groups_total_groups_for_user( $user_id = false ) {
1970
  global $bp;
1971
-
1972
  if ( !$user_id )
1973
  $user_id = $bp->displayed_user->id;
1974
-
1975
  return BP_Groups_Member::total_group_count( $user_id );
1976
  }
1977
 
1978
  function groups_get_random_groups_for_user( $user_id = false, $total_groups = 5 ) {
1979
  global $bp;
1980
-
1981
  if ( !$user_id )
1982
  $user_id = $bp->displayed_user->id;
1983
-
1984
  return BP_Groups_Member::get_random_groups( $user_id, $total_groups );
1985
  }
1986
 
@@ -1999,13 +2003,13 @@ function groups_avatar_upload_dir( $group_id = false ) {
1999
 
2000
  if ( !$group_id )
2001
  $group_id = $bp->groups->current_group->id;
2002
-
2003
  $path = get_blog_option( BP_ROOT_BLOG, 'upload_path' );
2004
  $newdir = WP_CONTENT_DIR . str_replace( 'wp-content', '', $path );
2005
  $newdir .= '/group-avatars/' . $group_id;
2006
 
2007
  $newbdir = $newdir;
2008
-
2009
  if ( !file_exists( $newdir ) )
2010
  @wp_mkdir_p( $newdir );
2011
 
@@ -2013,7 +2017,7 @@ function groups_avatar_upload_dir( $group_id = false ) {
2013
  $newburl = $newurl;
2014
  $newsubdir = '/group-avatars/' . $group_id;
2015
 
2016
- return apply_filters( 'groups_avatar_upload_dir', array( 'path' => $newdir, 'url' => $newurl, 'subdir' => $newsubdir, 'basedir' => $newbdir, 'baseurl' => $newburl, 'error' => false ) );
2017
  }
2018
 
2019
  /*** Group Member Status Checks ************************************************/
@@ -2038,22 +2042,22 @@ function groups_is_user_banned( $user_id, $group_id ) {
2038
 
2039
  function groups_new_wire_post( $group_id, $content ) {
2040
  global $bp;
2041
-
2042
  if ( !function_exists( 'bp_wire_new_post' ) )
2043
  return false;
2044
-
2045
  if ( $wire_post = bp_wire_new_post( $group_id, $content, 'groups' ) ) {
2046
-
2047
  /* Post an email notification if settings allow */
2048
  require_once ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' );
2049
  groups_notification_new_wire_post( $group_id, $wire_post->id );
2050
-
2051
  /* Record this in activity streams */
2052
  $activity_content = sprintf( __( '%s wrote on the wire of the group %s:', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' );
2053
  $activity_content .= '<blockquote>' . bp_create_excerpt( attribute_escape( $content ) ) . '</blockquote>';
2054
-
2055
  groups_record_activity( array(
2056
- 'content' => apply_filters( 'groups_activity_new_wire_post', $activity_content ),
2057
  'primary_link' => apply_filters( 'groups_activity_new_wire_post_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ),
2058
  'component_action' => 'new_wire_post',
2059
  'item_id' => $bp->groups->current_group->id,
@@ -2061,10 +2065,10 @@ function groups_new_wire_post( $group_id, $content ) {
2061
  ) );
2062
 
2063
  do_action( 'groups_new_wire_post', $group_id, $wire_post->id );
2064
-
2065
  return true;
2066
  }
2067
-
2068
  return false;
2069
  }
2070
 
@@ -2074,11 +2078,11 @@ function groups_delete_wire_post( $wire_post_id, $table_name ) {
2074
  if ( function_exists( 'bp_activity_delete_by_item_id' ) ) {
2075
  bp_activity_delete_by_item_id( array( 'item_id' => $wire_post_id, 'component_name' => 'groups', 'component_action' => 'new_wire_post' ) );
2076
  }
2077
-
2078
  do_action( 'groups_deleted_wire_post', $wire_post_id );
2079
  return true;
2080
  }
2081
-
2082
  return false;
2083
  }
2084
 
@@ -2089,35 +2093,35 @@ function groups_new_group_forum( $group_id = false, $group_name = false, $group_
2089
 
2090
  if ( !$group_id )
2091
  $group_id = $bp->groups->current_group->id;
2092
-
2093
  if ( !$group_name )
2094
  $group_name = $bp->groups->current_group->name;
2095
-
2096
  if ( !$group_desc )
2097
  $group_desc = $bp->groups->current_group->description;
2098
-
2099
  $forum_id = bp_forums_new_forum( array( 'forum_name' => $group_name, 'forum_desc' => $group_desc ) );
2100
 
2101
  groups_update_groupmeta( $group_id, 'forum_id', $forum_id );
2102
-
2103
  do_action( 'groups_new_group_forum', $forum, $group_id );
2104
  }
2105
 
2106
  function groups_new_group_forum_post( $post_text, $topic_id ) {
2107
  global $bp;
2108
-
2109
  if ( empty( $post_text ) )
2110
  return false;
2111
-
2112
  if ( $forum_post = bp_forums_insert_post( array( 'post_text' => $post_text, 'topic_id' => $topic_id ) ) ) {
2113
  $topic = bp_forums_get_topic_details( $topic_id );
2114
-
2115
  $activity_content = sprintf( __( '%s posted on the forum topic %s in the group %s:', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic->topic_slug .'">' . attribute_escape( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' );
2116
  $activity_content .= '<blockquote>' . bp_create_excerpt( attribute_escape( $post_text ) ) . '</blockquote>';
2117
-
2118
  /* Record this in activity streams */
2119
  groups_record_activity( array(
2120
- 'content' => apply_filters( 'groups_activity_new_forum_post', $activity_content, $post_text, &$topic, &$forum_post ),
2121
  'primary_link' => apply_filters( 'groups_activity_new_forum_post_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ),
2122
  'component_action' => 'new_forum_post',
2123
  'item_id' => $bp->groups->current_group->id,
@@ -2125,56 +2129,56 @@ function groups_new_group_forum_post( $post_text, $topic_id ) {
2125
  ) );
2126
 
2127
  do_action( 'groups_new_forum_topic_post', $bp->groups->current_group->id, $forum_post );
2128
-
2129
  return $forum_post;
2130
  }
2131
-
2132
  return false;
2133
  }
2134
 
2135
  function groups_new_group_forum_topic( $topic_title, $topic_text, $topic_tags, $forum_id ) {
2136
  global $bp;
2137
-
2138
  if ( empty( $topic_title ) || empty( $topic_text ) )
2139
  return false;
2140
-
2141
  if ( $topic_id = bp_forums_new_topic( array( 'topic_title' => $topic_title, 'topic_text' => $topic_text, 'topic_tags' => $topic_tags, 'forum_id' => $forum_id ) ) ) {
2142
  $topic = bp_forums_get_topic_details( $topic_id );
2143
 
2144
  $activity_content = sprintf( __( '%s started the forum topic %s in the group %s:', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic->topic_slug .'">' . attribute_escape( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' );
2145
  $activity_content .= '<blockquote>' . bp_create_excerpt( attribute_escape( $topic_text ) ) . '</blockquote>';
2146
-
2147
  /* Record this in activity streams */
2148
  groups_record_activity( array(
2149
- 'content' => apply_filters( 'groups_activity_new_forum_topic', $activity_content, $topic_text, &$topic ),
2150
  'primary_link' => apply_filters( 'groups_activity_new_forum_topic_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ),
2151
  'component_action' => 'new_forum_topic',
2152
  'item_id' => $bp->groups->current_group->id,
2153
  'secondary_item_id' => $topic->topic_id
2154
  ) );
2155
-
2156
  do_action( 'groups_new_forum_topic', $bp->groups->current_group->id, &$topic );
2157
 
2158
  return $topic;
2159
  }
2160
-
2161
  return false;
2162
  }
2163
 
2164
  function groups_update_group_forum_topic( $topic_id, $topic_title, $topic_text ) {
2165
  global $bp;
2166
-
2167
  if ( $topic = bp_forums_update_topic( array( 'topic_title' => $topic_title, 'topic_text' => $topic_text, 'topic_id' => $topic_id ) ) ) {
2168
  /* Update the activity stream item */
2169
  if ( function_exists( 'bp_activity_delete_by_item_id' ) )
2170
  bp_activity_delete_by_item_id( array( 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $topic_id, 'component_name' => $bp->groups->id, 'component_action' => 'new_forum_topic' ) );
2171
-
2172
  $activity_content = sprintf( __( '%s started the forum topic %s in the group %s:', 'buddypress'), bp_core_get_userlink( $topic->topic_poster ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic->topic_slug .'">' . attribute_escape( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' );
2173
  $activity_content .= '<blockquote>' . bp_create_excerpt( attribute_escape( $topic_text ) ) . '</blockquote>';
2174
 
2175
  /* Record this in activity streams */
2176
  groups_record_activity( array(
2177
- 'content' => apply_filters( 'groups_activity_new_forum_topic', $activity_content, $topic_text, &$topic ),
2178
  'primary_link' => apply_filters( 'groups_activity_new_forum_topic_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ),
2179
  'component_action' => 'new_forum_topic',
2180
  'item_id' => (int)$bp->groups->current_group->id,
@@ -2184,31 +2188,31 @@ function groups_update_group_forum_topic( $topic_id, $topic_title, $topic_text )
2184
  ) );
2185
 
2186
  do_action( 'groups_update_group_forum_topic', &$topic );
2187
-
2188
  return true;
2189
  }
2190
-
2191
  return false;
2192
  }
2193
 
2194
  function groups_update_group_forum_post( $post_id, $post_text, $topic_id ) {
2195
  global $bp;
2196
-
2197
  $post = bp_forums_get_post( $post_id );
2198
-
2199
  if ( $post_id = bp_forums_insert_post( array( 'post_id' => $post_id, 'post_text' => $post_text, 'post_time' => $post->post_time, 'topic_id' => $topic_id, 'poster_id' => $post->poster_id ) ) ) {
2200
  $topic = bp_forums_get_topic_details( $topic_id );
2201
 
2202
  /* Update the activity stream item */
2203
  if ( function_exists( 'bp_activity_delete_by_item_id' ) )
2204
  bp_activity_delete_by_item_id( array( 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $post_id, 'component_name' => $bp->groups->id, 'component_action' => 'new_forum_post' ) );
2205
-
2206
  $activity_content = sprintf( __( '%s posted on the forum topic %s in the group %s:', 'buddypress'), bp_core_get_userlink( $post->poster_id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic->topic_slug .'">' . attribute_escape( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' );
2207
  $activity_content .= '<blockquote>' . bp_create_excerpt( attribute_escape( $post_text ) ) . '</blockquote>';
2208
-
2209
  /* Record this in activity streams */
2210
  groups_record_activity( array(
2211
- 'content' => apply_filters( 'groups_activity_new_forum_post', $activity_content, $post_text, &$topic, &$forum_post ),
2212
  'primary_link' => apply_filters( 'groups_activity_new_forum_post_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ),
2213
  'component_action' => 'new_forum_post',
2214
  'item_id' => (int)$bp->groups->current_group->id,
@@ -2218,16 +2222,16 @@ function groups_update_group_forum_post( $post_id, $post_text, $topic_id ) {
2218
  ) );
2219
 
2220
  do_action( 'groups_update_group_forum_post', &$post, &$topic );
2221
-
2222
  return true;
2223
  }
2224
-
2225
  return false;
2226
  }
2227
 
2228
  function groups_delete_group_forum_topic( $topic_id ) {
2229
  global $bp;
2230
-
2231
  if ( bp_forums_delete_topic( array( 'topic_id' => $topic_id ) ) ) {
2232
  /* Delete the activity stream item */
2233
  if ( function_exists( 'bp_activity_delete_by_item_id' ) ) {
@@ -2236,16 +2240,16 @@ function groups_delete_group_forum_topic( $topic_id ) {
2236
  }
2237
 
2238
  do_action( 'groups_delete_group_forum_topic', $topic_id );
2239
-
2240
  return true;
2241
  }
2242
-
2243
  return false;
2244
  }
2245
 
2246
  function groups_delete_group_forum_post( $post_id, $topic_id ) {
2247
  global $bp;
2248
-
2249
  if ( bp_forums_delete_post( array( 'post_id' => $post_id ) ) ) {
2250
  /* Delete the activity stream item */
2251
  if ( function_exists( 'bp_activity_delete_by_item_id' ) ) {
@@ -2253,10 +2257,10 @@ function groups_delete_group_forum_post( $post_id, $topic_id ) {
2253
  }
2254
 
2255
  do_action( 'groups_delete_group_forum_post', $post_id, $topic_id );
2256
-
2257
  return true;
2258
  }
2259
-
2260
  return false;
2261
  }
2262
 
@@ -2269,16 +2273,16 @@ function groups_total_public_forum_topic_count( $type = 'newest' ) {
2269
 
2270
  function groups_get_invites_for_user( $user_id = false ) {
2271
  global $bp;
2272
-
2273
  if ( !$user_id )
2274
  $user_id = $bp->loggedin_user->id;
2275
-
2276
  return BP_Groups_Member::get_invites( $user_id );
2277
  }
2278
 
2279
  function groups_invite_user( $args = '' ) {
2280
  global $bp;
2281
-
2282
  $defaults = array(
2283
  'user_id' => false,
2284
  'group_id' => false,
@@ -2288,32 +2292,32 @@ function groups_invite_user( $args = '' ) {
2288
  );
2289
 
2290
  $args = wp_parse_args( $args, $defaults );
2291
- extract( $args, EXTR_SKIP );
2292
 
2293
  if ( !$user_id || !$group_id )
2294
  return false;
2295
-
2296
  if ( groups_is_user_member( $user_id, $group_id ) )
2297
  return false;
2298
-
2299
  $invite = new BP_Groups_Member;
2300
  $invite->group_id = $group_id;
2301
  $invite->user_id = $user_id;
2302
  $invite->date_modified = $date_modified;
2303
  $invite->inviter_id = $inviter_id;
2304
  $invite->is_confirmed = $is_confirmed;
2305
-
2306
  if ( !$invite->save() )
2307
  return false;
2308
-
2309
  do_action( 'groups_invite_user', $args );
2310
-
2311
  return true;
2312
  }
2313
 
2314
  function groups_uninvite_user( $user_id, $group_id ) {
2315
  global $bp;
2316
-
2317
  if ( !BP_Groups_Member::delete( $user_id, $group_id ) )
2318
  return false;
2319
 
@@ -2325,13 +2329,13 @@ function groups_uninvite_user( $user_id, $group_id ) {
2325
  function groups_accept_invite( $user_id, $group_id ) {
2326
  if ( groups_is_user_member( $user_id, $group_id ) )
2327
  return false;
2328
-
2329
  $member = new BP_Groups_Member( $user_id, $group_id );
2330
  $member->accept_invite();
2331
 
2332
- if ( !$member->save() )
2333
  return false;
2334
-
2335
  do_action( 'groups_accept_invite', $user_id, $group_id );
2336
  return true;
2337
  }
@@ -2339,28 +2343,28 @@ function groups_accept_invite( $user_id, $group_id ) {
2339
  function groups_reject_invite( $user_id, $group_id ) {
2340
  if ( !BP_Groups_Member::delete( $user_id, $group_id ) )
2341
  return false;
2342
-
2343
  do_action( 'groups_reject_invite', $user_id, $group_id );
2344
-
2345
  return true;
2346
  }
2347
 
2348
  function groups_delete_invite( $user_id, $group_id ) {
2349
  global $bp;
2350
-
2351
  $delete = BP_Groups_Member::delete_invite( $user_id, $group_id );
2352
-
2353
  if ( $delete )
2354
  bp_core_delete_notifications_for_user_by_item_id( $user_id, $group_id, $bp->groups->slug, 'group_invite' );
2355
-
2356
  return $delete;
2357
  }
2358
 
2359
  function groups_send_invites( $user_id, $group_id ) {
2360
  global $bp;
2361
-
2362
  require_once ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' );
2363
-
2364
  if ( !$user_id )
2365
  $user_id = $bp->loggedin_user->id;
2366
 
@@ -2373,11 +2377,11 @@ function groups_send_invites( $user_id, $group_id ) {
2373
 
2374
  // Send the actual invite
2375
  groups_notification_group_invites( $group, $member, $user_id );
2376
-
2377
  $member->invite_sent = 1;
2378
  $member->save();
2379
  }
2380
-
2381
  do_action( 'groups_send_invites', $bp->groups->current_group->id, $invited_users );
2382
  }
2383
 
@@ -2397,14 +2401,14 @@ function groups_delete_all_group_invites( $group_id ) {
2397
 
2398
  function groups_promote_member( $user_id, $group_id, $status ) {
2399
  global $bp;
2400
-
2401
  if ( !$bp->is_item_admin )
2402
  return false;
2403
-
2404
  $member = new BP_Groups_Member( $user_id, $group_id );
2405
 
2406
  do_action( 'groups_premote_member', $user_id, $group_id, $status );
2407
-
2408
  return $member->promote( $status );
2409
  }
2410
 
@@ -2412,7 +2416,7 @@ function groups_demote_member( $user_id, $group_id ) {
2412
  global $bp;
2413
 
2414
  $member = new BP_Groups_Member( $user_id, $group_id );
2415
-
2416
  do_action( 'groups_demote_member', $user_id, $group_id );
2417
 
2418
  return $member->demote();
@@ -2423,24 +2427,24 @@ function groups_ban_member( $user_id, $group_id ) {
2423
 
2424
  if ( !$bp->is_item_admin )
2425
  return false;
2426
-
2427
  $member = new BP_Groups_Member( $user_id, $group_id );
2428
 
2429
  do_action( 'groups_ban_member', $user_id, $group_id );
2430
-
2431
  return $member->ban();
2432
  }
2433
 
2434
  function groups_unban_member( $user_id, $group_id ) {
2435
  global $bp;
2436
-
2437
  if ( !$bp->is_item_admin )
2438
  return false;
2439
-
2440
  $member = new BP_Groups_Member( $user_id, $group_id );
2441
-
2442
  do_action( 'groups_unban_member', $user_id, $group_id );
2443
-
2444
  return $member->unban();
2445
  }
2446
 
@@ -2458,7 +2462,7 @@ function groups_send_membership_request( $requesting_user_id, $group_id ) {
2458
  $requesting_user->date_modified = time();
2459
  $requesting_user->is_confirmed = 0;
2460
  $requesting_user->comments = $_POST['group-request-membership-comments'];
2461
-
2462
  if ( $requesting_user->save() ) {
2463
  $admins = groups_get_group_admins( $group_id );
2464
 
@@ -2468,36 +2472,36 @@ function groups_send_membership_request( $requesting_user_id, $group_id ) {
2468
  // Saved okay, now send the email notification
2469
  groups_notification_new_membership_request( $requesting_user_id, $admins[$i]->user_id, $group_id, $requesting_user->id );
2470
  }
2471
-
2472
  do_action( 'groups_membership_requested', $requesting_user_id, $admins, $group_id, $requesting_user->id );
2473
-
2474
  return true;
2475
  }
2476
-
2477
  return false;
2478
  }
2479
 
2480
  function groups_accept_membership_request( $membership_id, $user_id = false, $group_id = false ) {
2481
  global $bp;
2482
-
2483
  if ( $user_id && $group_id )
2484
  $membership = new BP_Groups_Member( $user_id, $group_id );
2485
  else
2486
  $membership = new BP_Groups_Member( false, false, $membership_id );
2487
 
2488
  $membership->accept_request();
2489
-
2490
  if ( !$membership->save() )
2491
  return false;
2492
-
2493
  /* Modify group member count */
2494
  groups_update_groupmeta( $membership->group_id, 'total_member_count', (int) groups_get_groupmeta( $membership->group_id, 'total_member_count') + 1 );
2495
-
2496
  /* Record this in activity streams */
2497
  $group = new BP_Groups_Group( $group_id, false, false );
2498
 
2499
  groups_record_activity( array(
2500
- 'content' => apply_filters( 'groups_activity_membership_accepted', sprintf( __( '%s joined the group %s', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . attribute_escape( $group->name ) . '</a>' ), $user_id, &$group ),
2501
  'primary_link' => apply_filters( 'groups_activity_membership_accepted_primary_link', bp_get_group_permalink( $group ), &$group ),
2502
  'component_action' => 'joined_group',
2503
  'item_id' => $group->id,
@@ -2507,27 +2511,27 @@ function groups_accept_membership_request( $membership_id, $user_id = false, $gr
2507
  /* Send a notification to the user. */
2508
  require_once ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' );
2509
  groups_notification_membership_request_completed( $membership->user_id, $membership->group_id, true );
2510
-
2511
  do_action( 'groups_membership_accepted', $membership->user_id, $membership->group_id );
2512
-
2513
  return true;
2514
  }
2515
 
2516
- function groups_reject_membership_request( $membership_id, $user_id = false, $group_id = false ) {
2517
  if ( $user_id && $group_id )
2518
  $membership = new BP_Groups_Member( $user_id, $group_id );
2519
  else
2520
  $membership = new BP_Groups_Member( false, false, $membership_id );
2521
-
2522
  if ( !BP_Groups_Member::delete( $membership->user_id, $membership->group_id ) )
2523
  return false;
2524
-
2525
  // Send a notification to the user.
2526
  require_once ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' );
2527
  groups_notification_membership_request_completed( $membership->user_id, $membership->group_id, false );
2528
-
2529
  do_action( 'groups_membership_rejected', $membership->user_id, $membership->group_id );
2530
-
2531
  return true;
2532
  }
2533
 
@@ -2540,13 +2544,13 @@ function groups_accept_all_pending_membership_requests( $group_id ) {
2540
 
2541
  if ( !$user_ids )
2542
  return false;
2543
-
2544
  foreach ( (array) $user_ids as $user_id ) {
2545
  groups_accept_membership_request( false, $user_id, $group_id );
2546
  }
2547
-
2548
  do_action( 'groups_accept_all_pending_membership_requests', $group_id );
2549
-
2550
  return true;
2551
  }
2552
 
@@ -2554,25 +2558,25 @@ function groups_accept_all_pending_membership_requests( $group_id ) {
2554
 
2555
  function groups_delete_groupmeta( $group_id, $meta_key = false, $meta_value = false ) {
2556
  global $wpdb, $bp;
2557
-
2558
  if ( !is_numeric( $group_id ) )
2559
  return false;
2560
-
2561
  $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
2562
 
2563
  if ( is_array($meta_value) || is_object($meta_value) )
2564
  $meta_value = serialize($meta_value);
2565
-
2566
  $meta_value = trim( $meta_value );
2567
 
2568
  if ( !$meta_key ) {
2569
- $wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d", $group_id ) );
2570
  } else if ( $meta_value ) {
2571
  $wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d AND meta_key = %s AND meta_value = %s", $group_id, $meta_key, $meta_value ) );
2572
  } else {
2573
  $wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d AND meta_key = %s", $group_id, $meta_key ) );
2574
  }
2575
-
2576
  // TODO need to look into using this.
2577
  // wp_cache_delete($group_id, 'groups');
2578
 
@@ -2581,7 +2585,7 @@ function groups_delete_groupmeta( $group_id, $meta_key = false, $meta_value = fa
2581
 
2582
  function groups_get_groupmeta( $group_id, $meta_key = '') {
2583
  global $wpdb, $bp;
2584
-
2585
  $group_id = (int) $group_id;
2586
 
2587
  if ( !$group_id )
@@ -2589,10 +2593,10 @@ function groups_get_groupmeta( $group_id, $meta_key = '') {
2589
 
2590
  if ( !empty($meta_key) ) {
2591
  $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
2592
-
2593
  // TODO need to look into using this.
2594
  //$user = wp_cache_get($user_id, 'users');
2595
-
2596
  // Check the cached user object
2597
  //if ( false !== $user && isset($user->$meta_key) )
2598
  // $metas = array($user->$meta_key);
@@ -2619,17 +2623,17 @@ function groups_get_groupmeta( $group_id, $meta_key = '') {
2619
 
2620
  function groups_update_groupmeta( $group_id, $meta_key, $meta_value ) {
2621
  global $wpdb, $bp;
2622
-
2623
  if ( !is_numeric( $group_id ) )
2624
  return false;
2625
-
2626
  $meta_key = preg_replace( '|[^a-z0-9_]|i', '', $meta_key );
2627
 
2628
  if ( is_string($meta_value) )
2629
  $meta_value = stripslashes($wpdb->escape($meta_value));
2630
-
2631
  $meta_value = maybe_serialize($meta_value);
2632
-
2633
  if (empty($meta_value)) {
2634
  return groups_delete_groupmeta( $group_id, $meta_key );
2635
  }
@@ -2654,7 +2658,7 @@ function groups_update_groupmeta( $group_id, $meta_key, $meta_value ) {
2654
 
2655
  function groups_remove_data_for_user( $user_id ) {
2656
  BP_Groups_Member::delete_all_for_user($user_id);
2657
-
2658
  do_action( 'groups_remove_data_for_user', $user_id );
2659
  }
2660
  add_action( 'wpmu_delete_user', 'groups_remove_data_for_user', 1 );
13
 
14
  /* Include deprecated functions if settings allow */
15
  if ( !defined( 'BP_IGNORE_DEPRECATED' ) )
16
+ require ( BP_PLUGIN_DIR . '/bp-groups/deprecated/bp-groups-deprecated.php' );
17
 
18
  function groups_install() {
19
  global $wpdb, $bp;
20
+
21
  if ( !empty($wpdb->charset) )
22
  $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
23
+
24
  $sql[] = "CREATE TABLE {$bp->groups->table_name} (
25
  id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
26
  creator_id bigint(20) NOT NULL,
35
  KEY creator_id (creator_id),
36
  KEY status (status)
37
  ) {$charset_collate};";
38
+
39
  $sql[] = "CREATE TABLE {$bp->groups->table_name_members} (
40
  id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
41
  group_id bigint(20) NOT NULL,
65
  KEY group_id (group_id),
66
  KEY meta_key (meta_key)
67
  ) {$charset_collate};";
68
+
69
  require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
70
  dbDelta($sql);
71
+
72
  /* On upgrade, handle moving of old group avatars */
73
  $groups = groups_get_all();
74
+
75
  foreach ( $groups as $group ) {
76
  /* Don't fetch and move gravs, default images or empties */
77
  if ( empty($group->avatar_thumb) || strpos( $group->avatar_thumb, 'gravatar.com' ) || strpos( $group->avatar_thumb, 'identicon' ) || strpos( $group->avatar_thumb, 'none-thumbnail' ) )
85
 
86
  if ( !file_exists( $avatar_thumb ) || !file_exists( $avatar_full ) )
87
  continue;
88
+
89
  $upload_dir = groups_avatar_upload_dir( $group->id );
90
 
91
  copy( $avatar_thumb, $upload_dir['path'] . '/' . basename($avatar_thumb) );
92
  copy( $avatar_full, $upload_dir['path'] . '/' . basename($avatar_full) );
93
  }
94
  }
95
+
96
  if ( function_exists('bp_wire_install') )
97
  groups_wire_install();
98
+
99
  update_site_option( 'bp-groups-db-version', BP_GROUPS_DB_VERSION );
100
  }
101
 
102
  function groups_wire_install() {
103
  global $wpdb, $bp;
104
+
105
  if ( !empty($wpdb->charset) )
106
  $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
107
+
108
  $sql[] = "CREATE TABLE {$bp->groups->table_name_wire} (
109
  id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
110
  item_id bigint(20) NOT NULL,
124
 
125
  /* For internal identification */
126
  $bp->groups->id = 'groups';
127
+
128
  $bp->groups->table_name = $wpdb->base_prefix . 'bp_groups';
129
  $bp->groups->table_name_members = $wpdb->base_prefix . 'bp_groups_members';
130
  $bp->groups->table_name_groupmeta = $wpdb->base_prefix . 'bp_groups_groupmeta';
133
 
134
  /* Register this in the active components array */
135
  $bp->active_components[$bp->groups->slug] = $bp->groups->id;
136
+
137
  if ( function_exists('bp_wire_install') )
138
  $bp->groups->table_name_wire = $wpdb->base_prefix . 'bp_groups_wire';
139
+
140
  $bp->groups->forbidden_names = apply_filters( 'groups_forbidden_names', array( 'my-groups', 'group-finder', 'create', 'invites', 'delete', 'add', 'admin', 'request-membership' ) );
141
+
142
+ $bp->groups->group_creation_steps = apply_filters( 'groups_create_group_steps', array(
143
+ 'group-details' => array( 'name' => __( 'Group Details', 'buddypress' ), 'position' => 0 ),
144
  'group-settings' => array( 'name' => __( 'Group Settings', 'buddypress' ), 'position' => 10 ),
145
  'group-avatar' => array( 'name' => __( 'Group Avatar', 'buddypress' ), 'position' => 20 ),
146
  'group-invites' => array( 'name' => __( 'Group Invites', 'buddypress' ), 'position' => 30 )
147
  ) );
148
+
149
  $bp->groups->valid_status = apply_filters( 'groups_valid_status', array( 'public', 'private', 'hidden' ) );
150
 
151
  do_action( 'groups_setup_globals' );
152
  }
153
+ add_action( 'plugins_loaded', 'groups_setup_globals', 5 );
154
  add_action( 'admin_menu', 'groups_setup_globals', 2 );
155
 
156
  function groups_setup_root_component() {
159
  }
160
  add_action( 'plugins_loaded', 'groups_setup_root_component', 2 );
161
 
162
+ function groups_check_installed() {
163
  global $wpdb, $bp;
164
+
165
  require ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-admin.php' );
166
 
167
  /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
172
 
173
  function groups_add_admin_menu() {
174
  global $wpdb, $bp;
175
+
176
  if ( !is_site_admin() )
177
  return false;
178
+
179
  /* Add the administration tab under the "Site Admin" tab for site administrators */
180
  add_submenu_page( 'wpmu-admin.php', __("Groups", 'buddypress'), __("Groups", 'buddypress'), 1, "groups_admin_settings", "groups_admin_settings" );
181
  }
183
 
184
  function groups_setup_nav() {
185
  global $bp, $current_blog, $group_obj;
186
+
187
  if ( $group_id = BP_Groups_Group::group_exists($bp->current_action) ) {
188
+
189
  /* This is a single group page. */
190
  $bp->is_single_item = true;
191
  $bp->groups->current_group = &new BP_Groups_Group( $group_id );
192
+
193
  /* Using "item" not "group" for generic support in other components. */
194
  if ( is_site_admin() )
195
  $bp->is_item_admin = 1;
196
  else
197
  $bp->is_item_admin = groups_is_user_admin( $bp->loggedin_user->id, $bp->groups->current_group->id );
198
+
199
  /* If the user is not an admin, check if they are a moderator */
200
  if ( !$bp->is_item_admin )
201
  $bp->is_item_mod = groups_is_user_mod( $bp->loggedin_user->id, $bp->groups->current_group->id );
202
+
203
  /* Is the logged in user a member of the group? */
204
  $bp->groups->current_group->is_user_member = ( is_user_logged_in() && groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) ? true : false;
205
+
206
  /* Should this group be visible to the logged in user? */
207
  $bp->groups->current_group->is_group_visible_to_member = ( 'public' == $bp->groups->current_group->status || $is_member ) ? true : false;
208
+
209
  /* Pre 1.1 backwards compatibility - use $bp->groups->current_group instead */
210
  $group_obj = &$bp->groups->current_group;
211
  }
212
 
213
  /* Add 'Groups' to the main navigation */
214
  bp_core_new_nav_item( array( 'name' => __('Groups', 'buddypress'), 'slug' => $bp->groups->slug, 'position' => 70, 'screen_function' => 'groups_screen_my_groups', 'default_subnav_slug' => 'my-groups', 'item_css_id' => $bp->groups->id ) );
215
+
216
  $groups_link = $bp->loggedin_user->domain . $bp->groups->slug . '/';
217
+
218
  /* Add the subnav items to the groups nav item */
219
  bp_core_new_subnav_item( array( 'name' => __( 'My Groups', 'buddypress' ), 'slug' => 'my-groups', 'parent_url' => $groups_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_my_groups', 'position' => 10, 'item_css_id' => 'groups-my-groups' ) );
220
  bp_core_new_subnav_item( array( 'name' => __( 'Create a Group', 'buddypress' ), 'slug' => 'create', 'parent_url' => $groups_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_create_group', 'position' => 20, 'user_has_access' => bp_is_home() ) );
221
  bp_core_new_subnav_item( array( 'name' => __( 'Invites', 'buddypress' ), 'slug' => 'invites', 'parent_url' => $groups_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_invites', 'position' => 30, 'user_has_access' => bp_is_home() ) );
222
 
223
  if ( $bp->current_component == $bp->groups->slug ) {
224
+
225
  if ( bp_is_home() && !$bp->is_single_item ) {
226
+
227
  $bp->bp_options_title = __( 'My Groups', 'buddypress' );
228
+
229
  } else if ( !bp_is_home() && !$bp->is_single_item ) {
230
 
231
  $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) );
232
  $bp->bp_options_title = $bp->displayed_user->fullname;
233
+
234
  } else if ( $bp->is_single_item ) {
235
  // We are viewing a single group, so set up the
236
  // group navigation menu using the $bp->groups->current_group global.
237
+
238
  /* When in a single group, the first action is bumped down one because of the
239
  group name, so we need to adjust this and set the group name to current_item. */
240
  $bp->current_item = $bp->current_action;
241
  $bp->current_action = $bp->action_variables[0];
242
  array_shift($bp->action_variables);
243
+
244
  $bp->bp_options_title = $bp->groups->current_group->name;
245
+
246
  if ( !$bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->groups->current_group->id, 'object' => 'group', 'type' => 'thumb', 'avatar_dir' => 'group-avatars', 'alt' => __( 'Group Avatar', 'buddypress' ) ) ) )
247
  $bp->bp_options_avatar = '<img src="' . attribute_escape( $group->avatar_full ) . '" class="avatar" alt="' . attribute_escape( $group->name ) . '" />';
248
+
249
  $group_link = $bp->root_domain . '/' . $bp->groups->slug . '/' . $bp->groups->current_group->slug . '/';
250
+
251
  // If this is a private or hidden group, does the user have access?
252
  if ( 'private' == $bp->groups->current_group->status || 'hidden' == $bp->groups->current_group->status ) {
253
  if ( $bp->groups->current_group->is_user_member && is_user_logged_in() )
260
 
261
  /* Reset the existing subnav items */
262
  bp_core_reset_subnav_items($bp->groups->slug);
263
+
264
  /* Add a new default subnav item for when the groups nav is selected. */
265
  bp_core_new_nav_default( array( 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_home', 'subnav_slug' => 'home' ) );
266
+
267
  /* Add the "Home" subnav item, as this will always be present */
268
  bp_core_new_subnav_item( array( 'name' => __( 'Home', 'buddypress' ), 'slug' => 'home', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_home', 'position' => 10, 'item_css_id' => 'group-home' ) );
269
+
270
  /* If the user is a group mod or more, then show the group admin nav item */
271
  if ( $bp->is_item_mod || $bp->is_item_admin )
272
  bp_core_new_subnav_item( array( 'name' => __( 'Admin', 'buddypress' ), 'slug' => 'admin', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_admin', 'position' => 20, 'user_has_access' => ( $bp->is_item_admin + (int)$bp->is_item_mod ), 'item_css_id' => 'group-admin' ) );
282
  bp_core_new_subnav_item( array( 'name' => __( 'Wire', 'buddypress' ), 'slug' => BP_WIRE_SLUG, 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_wire', 'position' => 50, 'user_has_access' => $bp->groups->current_group->user_has_access, 'item_css_id' => 'group-wire' ) );
283
 
284
  bp_core_new_subnav_item( array( 'name' => __( 'Members', 'buddypress' ), 'slug' => 'members', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_members', 'position' => 60, 'user_has_access' => $bp->groups->current_group->user_has_access, 'item_css_id' => 'group-members' ) );
285
+
286
  if ( is_user_logged_in() && groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) {
287
  if ( function_exists('friends_install') )
288
  bp_core_new_subnav_item( array( 'name' => __( 'Send Invites', 'buddypress' ), 'slug' => 'send-invites', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_invite', 'item_css_id' => 'group-invite', 'position' => 70, 'user_has_access' => $bp->groups->current_group->user_has_access ) );
291
  }
292
  }
293
  }
294
+
295
  do_action( 'groups_setup_nav', $bp->groups->current_group->user_has_access );
296
  }
297
  add_action( 'plugins_loaded', 'groups_setup_nav' );
311
 
312
  function groups_setup_adminbar_menu() {
313
  global $bp;
314
+
315
  if ( !$bp->groups->current_group )
316
  return false;
317
 
321
  ?>
322
  <li id="bp-adminbar-adminoptions-menu">
323
  <a href=""><?php _e( 'Admin Options', 'buddypress' ) ?></a>
324
+
325
  <ul>
326
  <li><a class="confirm" href="<?php echo wp_nonce_url( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/delete-group/', 'groups_delete_group' ) ?>&amp;delete-group-button=1&amp;delete-group-understand=1"><?php _e( "Delete Group", 'buddypress' ) ?></a></li>
327
+
328
  <?php do_action( 'groups_adminbar_menu_items' ) ?>
329
  </ul>
330
  </li>
343
 
344
  function groups_screen_my_groups() {
345
  global $bp;
346
+
347
  bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'member_promoted_to_mod' );
348
  bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'member_promoted_to_admin' );
349
 
350
  do_action( 'groups_screen_my_groups' );
351
+
352
  bp_core_load_template( apply_filters( 'groups_template_my_groups', 'groups/index' ) );
353
  }
354
 
355
  function groups_screen_group_invites() {
356
  global $bp;
357
+
358
  $group_id = $bp->action_variables[1];
359
+
360
  if ( isset($bp->action_variables) && in_array( 'accept', (array)$bp->action_variables ) && is_numeric($group_id) ) {
361
  /* Check the nonce */
362
  if ( !check_admin_referer( 'groups_accept_invite' ) )
363
  return false;
364
+
365
  if ( !groups_accept_invite( $bp->loggedin_user->id, $group_id ) ) {
366
+ bp_core_add_message( __('Group invite could not be accepted', 'buddypress'), 'error' );
367
  } else {
368
  bp_core_add_message( __('Group invite accepted', 'buddypress') );
369
+
370
  /* Record this in activity streams */
371
  $group = new BP_Groups_Group( $group_id, false, false );
372
 
373
  groups_record_activity( array(
374
+ 'content' => apply_filters( 'groups_activity_accepted_invite', sprintf( __( '%s joined the group %s', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . attribute_escape( $group->name ) . '</a>' ), $bp->loggedin_user->id, &$group ),
375
  'primary_link' => apply_filters( 'groups_activity_accepted_invite_primary_link', bp_get_group_permalink( $group ), &$group ),
376
  'component_action' => 'joined_group',
377
  'item_id' => $group->id
379
  }
380
 
381
  bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action );
382
+
383
  } else if ( isset($bp->action_variables) && in_array( 'reject', (array)$bp->action_variables ) && is_numeric($group_id) ) {
384
  /* Check the nonce */
385
  if ( !check_admin_referer( 'groups_reject_invite' ) )
386
  return false;
387
+
388
  if ( !groups_reject_invite( $bp->loggedin_user->id, $group_id ) ) {
389
+ bp_core_add_message( __('Group invite could not be rejected', 'buddypress'), 'error' );
390
+ } else {
391
+ bp_core_add_message( __('Group invite rejected', 'buddypress') );
392
  }
393
 
394
  bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action );
395
  }
396
+
397
  // Remove notifications
398
  bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'group_invite' );
399
 
400
  do_action( 'groups_screen_group_invites', $group_id );
401
+
402
  if ( '' != locate_template( array( 'groups/invites.php' ), false ) )
403
  bp_core_load_template( apply_filters( 'groups_template_group_invites', 'groups/invites' ) );
404
  else
405
+ bp_core_load_template( apply_filters( 'groups_template_group_invites', 'groups/list-invites' ) );
406
  }
407
 
408
  function groups_screen_create_group() {
409
  global $bp;
410
 
411
+ /* Initial check of action variable[0] to prevent conflicts */
412
+ if ( !empty( $bp->action_variables[0] ) && $bp->action_variables[0] != 'step' )
413
+ return false;
414
+
415
  /* If no current step is set, reset everything so we can start a fresh group creation */
416
  if ( !$bp->groups->current_create_step = $bp->action_variables[1] ) {
417
 
418
  unset( $bp->groups->current_create_step );
419
  unset( $bp->groups->completed_create_steps );
420
+
421
  setcookie( 'bp_new_group_id', false, time() - 1000, COOKIEPATH );
422
  setcookie( 'bp_completed_create_steps', false, time() - 1000, COOKIEPATH );
423
+
424
  $reset_steps = true;
425
  bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . array_shift( array_keys( $bp->groups->group_creation_steps ) ) );
426
  }
427
+
428
  /* If this is a creation step that is not recognized, just redirect them back to the first screen */
429
  if ( $bp->action_variables[1] && !$bp->groups->group_creation_steps[$bp->action_variables[1]] ) {
430
  bp_core_add_message( __('There was an error saving group details. Please try again.', 'buddypress'), 'error' );
443
 
444
  /* If the save, upload or skip button is hit, lets calculate what we need to save */
445
  if ( isset( $_POST['save'] ) ) {
446
+
447
  /* Check the nonce */
448
  check_admin_referer( 'groups_create_save_' . $bp->groups->current_create_step );
449
+
450
  if ( 'group-details' == $bp->groups->current_create_step ) {
451
  if ( empty( $_POST['group-name'] ) || empty( $_POST['group-desc'] ) ) {
452
  bp_core_add_message( __( 'Please fill in all of the required fields', 'buddypress' ), 'error' );
453
  bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $bp->groups->current_create_step );
454
  }
455
+
456
  if ( !$bp->groups->new_group_id = groups_create_group( array( 'group_id' => $bp->groups->new_group_id, 'name' => $_POST['group-name'], 'description' => $_POST['group-desc'], 'news' => $_POST['group-news'], 'slug' => groups_check_slug( sanitize_title($_POST['group-name']) ), 'date_created' => time() ) ) ) {
457
  bp_core_add_message( __( 'There was an error saving group details, please try again.', 'buddypress' ), 'error' );
458
+ bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $bp->groups->current_create_step );
459
  }
460
+
461
  groups_update_groupmeta( $bp->groups->new_group_id, 'total_member_count', 1 );
462
  groups_update_groupmeta( $bp->groups->new_group_id, 'last_activity', time() );
463
  groups_update_groupmeta( $bp->groups->new_group_id, 'theme', 'buddypress' );
464
  groups_update_groupmeta( $bp->groups->new_group_id, 'stylesheet', 'buddypress' );
465
  }
466
+
467
  if ( 'group-settings' == $bp->groups->current_create_step ) {
468
  $group_status = 'public';
469
  $group_enable_wire = 1;
470
  $group_enable_forum = 1;
471
+
472
  if ( !isset($_POST['group-show-wire']) )
473
  $group_enable_wire = 0;
474
+
475
  if ( !isset($_POST['group-show-forum']) ) {
476
  $group_enable_forum = 0;
477
  } else {
480
  groups_new_group_forum();
481
  }
482
  }
483
+
484
  if ( 'private' == $_POST['group-status'] )
485
  $group_status = 'private';
486
  else if ( 'hidden' == $_POST['group-status'] )
487
  $group_status = 'hidden';
488
+
489
  if ( !$bp->groups->new_group_id = groups_create_group( array( 'group_id' => $bp->groups->new_group_id, 'status' => $group_status, 'enable_wire' => $group_enable_wire, 'enable_forum' => $group_enable_forum ) ) ) {
490
  bp_core_add_message( __( 'There was an error saving group details, please try again.', 'buddypress' ), 'error' );
491
+ bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $bp->groups->current_create_step );
492
  }
493
  }
494
 
498
 
499
  do_action( 'groups_create_group_step_save_' . $bp->groups->current_create_step );
500
  do_action( 'groups_create_group_step_complete' ); // Mostly for clearing cache on a generic action name
501
+
502
  /**
503
  * Once we have successfully saved the details for this step of the creation process
504
  * we need to add the current step to the array of completed steps, then update the cookies
506
  */
507
  if ( !in_array( $bp->groups->current_create_step, (array)$bp->groups->completed_create_steps ) )
508
  $bp->groups->completed_create_steps[] = $bp->groups->current_create_step;
509
+
510
  /* Reset cookie info */
511
  setcookie( 'bp_new_group_id', $bp->groups->new_group_id, time()+60*60*24, COOKIEPATH );
512
+ setcookie( 'bp_completed_create_steps', serialize( $bp->groups->completed_create_steps ), time()+60*60*24, COOKIEPATH );
513
 
514
  /* If we have completed all steps and hit done on the final step we can redirect to the completed group */
515
  if ( count( $bp->groups->completed_create_steps ) == count( $bp->groups->group_creation_steps ) && $bp->groups->current_create_step == array_pop( array_keys( $bp->groups->group_creation_steps ) ) ) {
516
  unset( $bp->groups->current_create_step );
517
  unset( $bp->groups->completed_create_steps );
518
+
519
  /* Once we compelete all steps, record the group creation in the activity stream. */
520
  groups_record_activity( array(
521
+ 'content' => apply_filters( 'groups_activity_created_group', sprintf( __( '%s created the group %s', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' ) ),
522
  'primary_link' => apply_filters( 'groups_activity_created_group_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ),
523
  'component_action' => 'created_group',
524
  'item_id' => $bp->groups->new_group_id
525
  ) );
526
+
527
  do_action( 'groups_group_create_complete', $bp->groups->new_group_id );
528
+
529
  bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
530
  } else {
531
  /**
534
  */
535
  foreach ( $bp->groups->group_creation_steps as $key => $value ) {
536
  if ( $key == $bp->groups->current_create_step ) {
537
+ $next = 1;
538
  continue;
539
  }
540
+
541
  if ( $next ) {
542
+ $next_step = $key;
543
  break;
544
  }
545
  }
547
  bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $next_step );
548
  }
549
  }
550
+
551
+ /* Group avatar is handled separately */
552
  if ( 'group-avatar' == $bp->groups->current_create_step && isset( $_POST['upload'] ) ) {
553
  if ( !empty( $_FILES ) && isset( $_POST['upload'] ) ) {
554
  /* Normally we would check a nonce here, but the group save nonce is used instead */
555
 
556
  /* Pass the file to the avatar upload handler */
557
+ if ( bp_core_avatar_handle_upload( $_FILES, 'groups_avatar_upload_dir' ) ) {
558
  $bp->avatar_admin->step = 'crop-image';
559
 
560
  /* Make sure we include the jQuery jCrop file for image cropping */
565
  /* If the image cropping is done, crop the image and save a full/thumb version */
566
  if ( isset( $_POST['avatar-crop-submit'] ) && isset( $_POST['upload'] ) ) {
567
  /* Normally we would check a nonce here, but the group save nonce is used instead */
568
+
569
  if ( !bp_core_avatar_handle_crop( array( 'object' => 'group', 'avatar_dir' => 'group-avatars', 'item_id' => $bp->groups->current_group->id, 'original_file' => $_POST['image_src'], 'crop_x' => $_POST['x'], 'crop_y' => $_POST['y'], 'crop_w' => $_POST['w'], 'crop_h' => $_POST['h'] ) ) )
570
  bp_core_add_message( __( 'There was an error saving the group avatar, please try uploading again.', 'buddypress' ), 'error' );
571
  else
579
 
580
  function groups_screen_group_home() {
581
  global $bp;
582
+
583
  if ( $bp->is_single_item ) {
584
+
585
  if ( isset($_GET['new']) ) {
586
  // Delete group request notifications for the user
587
  bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'membership_request_accepted' );
588
  bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'membership_request_rejected' );
589
  bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'member_promoted_to_mod' );
590
  bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'member_promoted_to_admin' );
591
+ }
592
+
593
+ do_action( 'groups_screen_group_home' );
594
 
 
 
595
  if ( '' != locate_template( array( 'groups/single/home.php' ), false ) )
596
  bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) );
597
  else
601
 
602
  function groups_screen_group_forum() {
603
  global $bp;
604
+
605
  if ( $bp->is_single_item && $bp->groups->current_group->user_has_access ) {
606
+
607
  /* Fetch the details we need */
608
  $topic_slug = $bp->action_variables[1];
609
  $topic_id = bp_forums_get_topic_id_from_slug( $topic_slug );
615
  if ( !$bp->action_variables[2] && isset( $_POST['submit_reply'] ) ) {
616
  /* Check the nonce */
617
  check_admin_referer( 'bp_forums_new_reply' );
618
+
619
  /* Auto join this user if they are not yet a member of this group */
620
  if ( !is_site_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) )
621
  groups_join_group( $bp->groups->current_group->id, $bp->loggedin_user->id );
622
+
623
  if ( !groups_new_group_forum_post( $_POST['reply_text'], $topic_id ) )
624
  bp_core_add_message( __( 'There was an error when replying to that topic', 'buddypress'), 'error' );
625
  else
626
  bp_core_add_message( __( 'Your reply was posted successfully', 'buddypress') );
627
+
628
  if ( $_SERVER['QUERY_STRING'] )
629
+ $query_vars = '?' . $_SERVER['QUERY_STRING'];
630
+
631
  bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic_slug . '/' . $query_vars );
632
  }
633
+
634
  /* Sticky a topic */
635
  else if ( 'stick' == $bp->action_variables[2] && ( $bp->is_item_admin || $bp->is_item_mod ) ) {
636
  /* Check the nonce */
640
  bp_core_add_message( __( 'There was an error when making that topic a sticky', 'buddypress' ), 'error' );
641
  else
642
  bp_core_add_message( __( 'The topic was made sticky successfully', 'buddypress' ) );
643
+
644
  do_action( 'groups_stick_forum_topic', $topic_id );
645
  bp_core_redirect( wp_get_referer() );
646
  }
647
+
648
  /* Un-Sticky a topic */
649
  else if ( 'unstick' == $bp->action_variables[2] && ( $bp->is_item_admin || $bp->is_item_mod ) ) {
650
  /* Check the nonce */
651
  check_admin_referer( 'bp_forums_unstick_topic' );
652
+
653
  if ( !bp_forums_sticky_topic( array( 'topic_id' => $topic_id, 'mode' => 'unstick' ) ) )
654
  bp_core_add_message( __( 'There was an error when unsticking that topic', 'buddypress'), 'error' );
655
  else
656
  bp_core_add_message( __( 'The topic was unstuck successfully', 'buddypress') );
657
+
658
  do_action( 'groups_unstick_forum_topic', $topic_id );
659
  bp_core_redirect( wp_get_referer() );
660
  }
661
+
662
  /* Close a topic */
663
  else if ( 'close' == $bp->action_variables[2] && ( $bp->is_item_admin || $bp->is_item_mod ) ) {
664
  /* Check the nonce */
665
  check_admin_referer( 'bp_forums_close_topic' );
666
+
667
  if ( !bp_forums_openclose_topic( array( 'topic_id' => $topic_id ) ) )
668
  bp_core_add_message( __( 'There was an error when closing that topic', 'buddypress'), 'error' );
669
  else
670
  bp_core_add_message( __( 'The topic was closed successfully', 'buddypress') );
671
+
672
  do_action( 'groups_close_forum_topic', $topic_id );
673
  bp_core_redirect( wp_get_referer() );
674
  }
677
  else if ( 'open' == $bp->action_variables[2] && ( $bp->is_item_admin || $bp->is_item_mod ) ) {
678
  /* Check the nonce */
679
  check_admin_referer( 'bp_forums_open_topic' );
680
+
681
  if ( !bp_forums_openclose_topic( array( 'topic_id' => $topic_id, 'mode' => 'open' ) ) )
682
  bp_core_add_message( __( 'There was an error when opening that topic', 'buddypress'), 'error' );
683
  else
684
  bp_core_add_message( __( 'The topic was opened successfully', 'buddypress') );
685
+
686
  do_action( 'groups_open_forum_topic', $topic_id );
687
  bp_core_redirect( wp_get_referer() );
688
  }
695
  /* Check the logged in user can delete this topic */
696
  if ( !$bp->is_item_admin && !$bp->is_item_mod && (int)$bp->loggedin_user->id != (int)$topic->topic_poster )
697
  bp_core_redirect( wp_get_referer() );
698
+
699
  /* Check the nonce */
700
  check_admin_referer( 'bp_forums_delete_topic' );
701
+
702
  if ( !groups_delete_group_forum_topic( $topic_id ) )
703
  bp_core_add_message( __( 'There was an error deleting the topic', 'buddypress'), 'error' );
704
  else
705
  bp_core_add_message( __( 'The topic was deleted successfully', 'buddypress') );
706
+
707
  do_action( 'groups_delete_forum_topic', $topic_id );
708
  bp_core_redirect( wp_get_referer() );
709
  }
710
+
711
  /* Editing a topic */
712
  else if ( 'edit' == $bp->action_variables[2] && empty( $bp->action_variables[3] ) ) {
713
  /* Fetch the topic */
720
  if ( isset( $_POST['save_changes'] ) ) {
721
  /* Check the nonce */
722
  check_admin_referer( 'bp_forums_edit_topic' );
723
+
724
  if ( !groups_update_group_forum_topic( $topic_id, $_POST['topic_title'], $_POST['topic_text'] ) )
725
  bp_core_add_message( __( 'There was an error when editing that topic', 'buddypress'), 'error' );
726
  else
727
  bp_core_add_message( __( 'The topic was edited successfully', 'buddypress') );
728
+
729
  do_action( 'groups_edit_forum_topic', $topic_id );
730
  bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic_slug . '/' );
731
  }
732
+
733
  bp_core_load_template( apply_filters( 'groups_template_group_forum_topic_edit', 'groups/single/forum/edit' ) );
734
  }
735
+
736
  /* Delete a post */
737
  else if ( 'delete' == $bp->action_variables[2] && $post_id = $bp->action_variables[4] ) {
738
  /* Fetch the post */
749
  bp_core_add_message( __( 'There was an error deleting that post', 'buddypress'), 'error' );
750
  else
751
  bp_core_add_message( __( 'The post was deleted successfully', 'buddypress') );
752
+
753
  do_action( 'groups_delete_forum_post', $post_id );
754
  bp_core_redirect( wp_get_referer() );
755
  }
756
+
757
  /* Editing a post */
758
  else if ( 'edit' == $bp->action_variables[2] && $post_id = $bp->action_variables[4] ) {
759
  /* Fetch the post */
766
  if ( isset( $_POST['save_changes'] ) ) {
767
  /* Check the nonce */
768
  check_admin_referer( 'bp_forums_edit_post' );
769
+
770
  if ( !groups_update_group_forum_post( $post_id, $_POST['post_text'], $topic_id ) )
771
  bp_core_add_message( __( 'There was an error when editing that post', 'buddypress'), 'error' );
772
  else
773
  bp_core_add_message( __( 'The post was edited successfully', 'buddypress') );
774
+
775
  do_action( 'groups_edit_forum_post', $post_id );
776
  bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic_slug . '/' );
777
  }
778
+
779
  bp_core_load_template( apply_filters( 'groups_template_group_forum_topic_edit', 'groups/single/forum/edit' ) );
780
  }
781
 
786
  else
787
  bp_core_load_template( apply_filters( 'groups_template_group_forum_topic', 'groups/forum/topic' ) );
788
  }
789
+
790
  } else {
791
 
792
  /* Posting a topic */
793
  if ( isset( $_POST['submit_topic'] ) && function_exists( 'bp_forums_new_topic') ) {
794
+ /* Check the nonce */
795
  check_admin_referer( 'bp_forums_new_topic' );
796
+
797
  /* Auto join this user if they are not yet a member of this group */
798
  if ( !is_site_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) )
799
  groups_join_group( $bp->groups->current_group->id, $bp->loggedin_user->id );
802
  bp_core_add_message( __( 'There was an error when creating the topic', 'buddypress'), 'error' );
803
  else
804
  bp_core_add_message( __( 'The topic was created successfully', 'buddypress') );
805
+
806
  bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic->topic_slug . '/' );
807
  }
808
+
809
  do_action( 'groups_screen_group_forum', $topic_id, $forum_id );
810
+
811
  if ( '' != locate_template( array( 'groups/single/forum/index.php' ), false ) )
812
  bp_core_load_template( apply_filters( 'groups_template_group_forum', 'groups/single/forum/index' ) );
813
  else
814
+ bp_core_load_template( apply_filters( 'groups_template_group_forum', 'groups/forum/index' ) );
815
  }
816
  }
817
  }
818
 
819
  function groups_screen_group_wire() {
820
  global $bp;
821
+
822
  $wire_action = $bp->action_variables[0];
823
+
824
  if ( $bp->is_single_item ) {
825
+ if ( 'post' == $wire_action && ( is_site_admin() || groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) ) {
826
  /* Check the nonce first. */
827
+ if ( !check_admin_referer( 'bp_wire_post' ) )
828
  return false;
829
+
830
  if ( !groups_new_wire_post( $bp->groups->current_group->id, $_POST['wire-post-textarea'] ) )
831
  bp_core_add_message( __('Wire message could not be posted.', 'buddypress'), 'error' );
832
  else
836
  bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
837
  else
838
  bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/' . $bp->wire->slug );
839
+
840
+ } else if ( 'delete' == $wire_action && ( is_site_admin() || groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) ) {
841
  $wire_message_id = $bp->action_variables[1];
842
 
843
  /* Check the nonce first. */
844
  if ( !check_admin_referer( 'bp_wire_delete_link' ) )
845
  return false;
846
+
847
  if ( !groups_delete_wire_post( $wire_message_id, $bp->groups->table_name_wire ) )
848
  bp_core_add_message( __('There was an error deleting the wire message.', 'buddypress'), 'error' );
849
  else
850
  bp_core_add_message( __('Wire message successfully deleted.', 'buddypress') );
851
+
852
  if ( !strpos( wp_get_referer(), $bp->wire->slug ) )
853
  bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
854
  else
855
  bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/' . $bp->wire->slug );
856
+
857
  } else if ( ( !$wire_action || 'latest' == $bp->action_variables[1] ) ) {
858
  if ( '' != locate_template( array( 'groups/single/wire.php' ), false ) )
859
  bp_core_load_template( apply_filters( 'groups_template_group_wire', 'groups/single/wire' ) );
860
+ else
861
  bp_core_load_template( apply_filters( 'groups_template_group_wire', 'groups/wire' ) );
862
  } else {
863
  if ( '' != locate_template( array( 'groups/single/home.php' ), false ) )
864
  bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) );
865
+ else
866
  bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/group-home' ) );
867
  }
868
  }
870
 
871
  function groups_screen_group_members() {
872
  global $bp;
873
+
874
  if ( $bp->is_single_item ) {
875
  do_action( 'groups_screen_group_members', $bp->groups->current_group->id );
876
 
877
  if ( '' != locate_template( array( 'groups/single/members.php' ), false ) )
878
  bp_core_load_template( apply_filters( 'groups_template_group_forum', 'groups/single/members' ) );
879
  else
880
+ bp_core_load_template( apply_filters( 'groups_template_group_forum', 'groups/list-members' ) );
881
  }
882
  }
883
 
884
  function groups_screen_group_invite() {
885
  global $bp;
886
+
887
  if ( $bp->is_single_item ) {
888
  if ( isset($bp->action_variables) && 'send' == $bp->action_variables[0] ) {
889
+
890
  if ( !check_admin_referer( 'groups_send_invites', '_wpnonce_send_invites' ) )
891
  return false;
892
+
893
  // Send the invites.
894
  groups_send_invites( $bp->loggedin_user->id, $bp->groups->current_group->id );
895
+
896
  bp_core_add_message( __('Group invites sent.', 'buddypress') );
897
 
898
  do_action( 'groups_screen_group_invite', $bp->groups->current_group->id );
901
  } else {
902
  // Show send invite page
903
  if ( '' != locate_template( array( 'groups/single/send-invite.php' ), false ) )
904
+ bp_core_load_template( apply_filters( 'groups_template_group_invite', 'groups/single/send-invite' ) );
905
  else
906
+ bp_core_load_template( apply_filters( 'groups_template_group_invite', 'groups/send-invite' ) );
907
  }
908
  }
909
  }
910
 
911
  function groups_screen_group_leave() {
912
  global $bp;
913
+
914
  if ( $bp->is_single_item ) {
915
  if ( isset($bp->action_variables) && 'yes' == $bp->action_variables[0] ) {
 
916
  // Check if the user is the group admin first.
917
+ if ( count( groups_get_group_admins( $bp->groups->current_group->id ) ) < 2 ) {
918
+ if ( groups_is_user_admin( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) {
919
+ bp_core_add_message( __('As the only group administrator, you cannot leave this group.', 'buddypress'), 'error' );
920
+ bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
921
+ }
922
  }
923
+
924
  // remove the user from the group.
925
  if ( !groups_leave_group( $bp->groups->current_group->id ) ) {
926
  bp_core_add_message( __('There was an error leaving the group. Please try again.', 'buddypress'), 'error' );
929
  bp_core_add_message( __('You left the group successfully.', 'buddypress') );
930
  bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug );
931
  }
932
+
933
  } else if ( isset($bp->action_variables) && 'no' == $bp->action_variables[0] ) {
934
+
935
  bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
936
+
937
  } else {
938
+
939
  do_action( 'groups_screen_group_leave', $bp->groups->current_group->id );
940
+
941
  // Show leave group page
942
  if ( '' != locate_template( array( 'groups/single/leave-confirm.php' ), false ) )
943
  bp_core_load_template( apply_filters( 'groups_template_group_leave', 'groups/single/leave-confirm' ) );
944
  else
945
+ bp_core_load_template( apply_filters( 'groups_template_group_leave', 'groups/leave-group-confirm' ) );
946
  }
947
  }
948
  }
949
 
950
  function groups_screen_group_request_membership() {
951
  global $bp;
952
+
953
  if ( !is_user_logged_in() )
954
  return false;
955
+
956
  if ( 'private' == $bp->groups->current_group->status ) {
957
  // If the user has submitted a request, send it.
958
  if ( isset( $_POST['group-request-send']) ) {
959
  /* Check the nonce first. */
960
  if ( !check_admin_referer( 'groups_request_membership' ) )
961
  return false;
962
+
963
  if ( !groups_send_membership_request( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) {
964
  bp_core_add_message( __( 'There was an error sending your group membership request, please try again.', 'buddypress' ), 'error' );
965
  } else {
967
  }
968
  bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
969
  }
970
+
971
  do_action( 'groups_screen_group_request_membership', $bp->groups->current_group->id );
972
+
973
  if ( '' != locate_template( array( 'groups/single/request-membership.php' ), false ) )
974
  bp_core_load_template( apply_filters( 'groups_template_group_request_membership', 'groups/single/request-membership' ) );
975
  else
976
+ bp_core_load_template( apply_filters( 'groups_template_group_request_membership', 'groups/request-membership' ) );
977
  }
978
  }
979
 
980
  function groups_screen_group_admin() {
981
  global $bp;
982
+
983
  if ( $bp->current_component != BP_GROUPS_SLUG || 'admin' != $bp->current_action )
984
  return false;
985
+
986
  if ( !empty( $bp->action_variables[0] ) )
987
  return false;
988
+
989
  bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/edit-details' );
990
  }
991
 
992
  function groups_screen_group_admin_edit_details() {
993
  global $bp;
994
+
995
  if ( $bp->current_component == $bp->groups->slug && 'edit-details' == $bp->action_variables[0] ) {
996
+
997
  if ( $bp->is_item_admin || $bp->is_item_mod ) {
998
+
999
  // If the edit form has been submitted, save the edited details
1000
  if ( isset( $_POST['save'] ) ) {
1001
  /* Check the nonce first. */
1002
  if ( !check_admin_referer( 'groups_edit_group_details' ) )
1003
  return false;
1004
+
1005
  if ( !groups_edit_base_group_details( $_POST['group-id'], $_POST['group-name'], $_POST['group-desc'], $_POST['group-news'], (int)$_POST['group-notify-members'] ) ) {
1006
  bp_core_add_message( __( 'There was an error updating group details, please try again.', 'buddypress' ), 'error' );
1007
  } else {
1008
  bp_core_add_message( __( 'Group details were successfully updated.', 'buddypress' ) );
1009
  }
1010
+
1011
  do_action( 'groups_group_details_edited', $bp->groups->current_group->id );
1012
+
1013
  bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/edit-details' );
1014
  }
1015
 
1016
  do_action( 'groups_screen_group_admin_edit_details', $bp->groups->current_group->id );
1017
 
1018
  if ( '' != locate_template( array( 'groups/single/admin.php' ), false ) )
1019
+ bp_core_load_template( apply_filters( 'groups_template_group_admin', 'groups/single/admin' ) );
1020
  else
1021
+ bp_core_load_template( apply_filters( 'groups_template_group_admin', 'groups/admin/edit-details' ) );
1022
  }
1023
  }
1024
  }
1026
 
1027
  function groups_screen_group_admin_settings() {
1028
  global $bp;
1029
+
1030
  if ( $bp->current_component == $bp->groups->slug && 'group-settings' == $bp->action_variables[0] ) {
1031
+
1032
  if ( !$bp->is_item_admin )
1033
  return false;
1034
+
1035
  // If the edit form has been submitted, save the edited details
1036
  if ( isset( $_POST['save'] ) ) {
1037
  $enable_wire = ( isset($_POST['group-show-wire'] ) ) ? 1 : 0;
1038
  $enable_forum = ( isset($_POST['group-show-forum'] ) ) ? 1 : 0;
1039
  $enable_photos = ( isset($_POST['group-show-photos'] ) ) ? 1 : 0;
1040
  $photos_admin_only = ( $_POST['group-photos-status'] != 'all' ) ? 1 : 0;
1041
+
1042
  $allowed_status = apply_filters( 'groups_allowed_status', array( 'public', 'private', 'hidden' ) );
1043
  $status = ( in_array( $_POST['group-status'], (array)$allowed_status ) ) ? $_POST['group-status'] : 'public';
1044
+
1045
  /* Check the nonce first. */
1046
  if ( !check_admin_referer( 'groups_edit_group_settings' ) )
1047
  return false;
1048
+
1049
  if ( !groups_edit_group_settings( $_POST['group-id'], $enable_wire, $enable_forum, $enable_photos, $photos_admin_only, $status ) ) {
1050
  bp_core_add_message( __( 'There was an error updating group settings, please try again.', 'buddypress' ), 'error' );
1051
  } else {
1053
  }
1054
 
1055
  do_action( 'groups_group_settings_edited', $bp->groups->current_group->id );
1056
+
1057
  bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/group-settings' );
1058
  }
1059
 
1060
  do_action( 'groups_screen_group_admin_settings', $bp->groups->current_group->id );
1061
+
1062
  if ( '' != locate_template( array( 'groups/single/admin.php' ), false ) )
1063
+ bp_core_load_template( apply_filters( 'groups_template_group_admin_settings', 'groups/single/admin' ) );
1064
  else
1065
  bp_core_load_template( apply_filters( 'groups_template_group_admin_settings', 'groups/admin/group-settings' ) );
1066
  }
1069
 
1070
  function groups_screen_group_admin_avatar() {
1071
  global $bp;
1072
+
1073
  if ( $bp->current_component == $bp->groups->slug && 'group-avatar' == $bp->action_variables[0] ) {
1074
+
1075
  if ( !$bp->is_item_admin )
1076
  return false;
1077
+
1078
  /* If the group admin has deleted the admin avatar */
1079
  if ( 'delete' == $bp->action_variables[1] ) {
1080
+
1081
  /* Check the nonce */
1082
  check_admin_referer( 'bp_group_avatar_delete' );
1083
+
1084
  if ( bp_core_delete_existing_avatar( array( 'item_id' => $bp->groups->current_group->id, 'object' => 'group' ) ) )
1085
  bp_core_add_message( __( 'Your avatar was deleted successfully!', 'buddypress' ) );
1086
  else
1087
  bp_core_add_message( __( 'There was a problem deleting that avatar, please try again.', 'buddypress' ), 'error' );
1088
+
1089
+ }
1090
+
1091
  $bp->avatar_admin->step = 'upload-image';
1092
 
1093
  if ( !empty( $_FILES ) ) {
1096
  check_admin_referer( 'bp_avatar_upload' );
1097
 
1098
  /* Pass the file to the avatar upload handler */
1099
+ if ( bp_core_avatar_handle_upload( $_FILES, 'groups_avatar_upload_dir' ) ) {
1100
  $bp->avatar_admin->step = 'crop-image';
1101
 
1102
  /* Make sure we include the jQuery jCrop file for image cropping */
1118
 
1119
  }
1120
 
1121
+ do_action( 'groups_screen_group_admin_avatar', $bp->groups->current_group->id );
1122
+
1123
  if ( '' != locate_template( array( 'groups/single/admin.php' ), false ) )
1124
+ bp_core_load_template( apply_filters( 'groups_template_group_admin_avatar', 'groups/single/admin' ) );
1125
  else
1126
+ bp_core_load_template( apply_filters( 'groups_template_group_admin_avatar', 'groups/admin/group-avatar' ) );
1127
  }
1128
  }
1129
  add_action( 'wp', 'groups_screen_group_admin_avatar', 4 );
1132
  global $bp;
1133
 
1134
  if ( $bp->current_component == $bp->groups->slug && 'manage-members' == $bp->action_variables[0] ) {
1135
+
1136
  if ( !$bp->is_item_admin )
1137
  return false;
1138
+
1139
  if ( 'promote' == $bp->action_variables[1] && ( 'mod' == $bp->action_variables[2] || 'admin' == $bp->action_variables[2] ) && is_numeric( $bp->action_variables[3] ) ) {
1140
  $user_id = $bp->action_variables[3];
1141
  $status = $bp->action_variables[2];
1142
+
1143
  /* Check the nonce first. */
1144
  if ( !check_admin_referer( 'groups_promote_member' ) )
1145
  return false;
1146
+
1147
  // Promote a user.
1148
  if ( !groups_promote_member( $user_id, $bp->groups->current_group->id, $status ) ) {
1149
  bp_core_add_message( __( 'There was an error when promoting that user, please try again', 'buddypress' ), 'error' );
1150
  } else {
1151
  bp_core_add_message( __( 'User promoted successfully', 'buddypress' ) );
1152
  }
1153
+
1154
  do_action( 'groups_promoted_member', $user_id, $bp->groups->current_group->id );
1155
 
1156
  bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/manage-members' );
1157
  }
1158
+
1159
  if ( 'demote' == $bp->action_variables[1] && is_numeric( $bp->action_variables[2] ) ) {
1160
  $user_id = $bp->action_variables[2];
1161
 
1162
  /* Check the nonce first. */
1163
  if ( !check_admin_referer( 'groups_demote_member' ) )
1164
  return false;
1165
+
1166
  // Demote a user.
1167
  if ( !groups_demote_member( $user_id, $bp->groups->current_group->id ) ) {
1168
  bp_core_add_message( __( 'There was an error when demoting that user, please try again', 'buddypress' ), 'error' );
1174
 
1175
  bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/manage-members' );
1176
  }
1177
+
1178
  if ( 'ban' == $bp->action_variables[1] && is_numeric( $bp->action_variables[2] ) ) {
1179
  $user_id = $bp->action_variables[2];
1180
 
1181
  /* Check the nonce first. */
1182
  if ( !check_admin_referer( 'groups_ban_member' ) )
1183
  return false;
1184
+
1185
  // Ban a user.
1186
  if ( !groups_ban_member( $user_id, $bp->groups->current_group->id ) ) {
1187
  bp_core_add_message( __( 'There was an error when banning that user, please try again', 'buddypress' ), 'error' );
1193
 
1194
  bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/manage-members' );
1195
  }
1196
+
1197
  if ( 'unban' == $bp->action_variables[1] && is_numeric( $bp->action_variables[2] ) ) {
1198
  $user_id = $bp->action_variables[2];
1199
 
1200
  /* Check the nonce first. */
1201
  if ( !check_admin_referer( 'groups_unban_member' ) )
1202
  return false;
1203
+
1204
  // Remove a ban for user.
1205
  if ( !groups_unban_member( $user_id, $bp->groups->current_group->id ) ) {
1206
  bp_core_add_message( __( 'There was an error when unbanning that user, please try again', 'buddypress' ), 'error' );
1214
  }
1215
 
1216
  do_action( 'groups_screen_group_admin_manage_members', $bp->groups->current_group->id );
1217
+
1218
  if ( '' != locate_template( array( 'groups/single/admin.php' ), false ) )
1219
+ bp_core_load_template( apply_filters( 'groups_template_group_admin_manage_members', 'groups/single/admin' ) );
1220
  else
1221
  bp_core_load_template( apply_filters( 'groups_template_group_admin_manage_members', 'groups/admin/manage-members' ) );
1222
  }
1225
 
1226
  function groups_screen_group_admin_requests() {
1227
  global $bp;
1228
+
1229
  if ( $bp->current_component == $bp->groups->slug && 'membership-requests' == $bp->action_variables[0] ) {
1230
+
1231
  if ( !$bp->is_item_admin || 'public' == $bp->groups->current_group->status )
1232
  return false;
1233
+
1234
  // Remove any screen notifications
1235
  bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'new_membership_request' );
1236
+
1237
  $request_action = $bp->action_variables[1];
1238
  $membership_id = $bp->action_variables[2];
1239
 
1243
  /* Check the nonce first. */
1244
  if ( !check_admin_referer( 'groups_accept_membership_request' ) )
1245
  return false;
1246
+
1247
  // Accept the membership request
1248
  if ( !groups_accept_membership_request( $membership_id ) ) {
1249
  bp_core_add_message( __( 'There was an error accepting the membership request, please try again.', 'buddypress' ), 'error' );
1255
  /* Check the nonce first. */
1256
  if ( !check_admin_referer( 'groups_reject_membership_request' ) )
1257
  return false;
1258
+
1259
  // Reject the membership request
1260
  if ( !groups_reject_membership_request( $membership_id ) ) {
1261
  bp_core_add_message( __( 'There was an error rejecting the membership request, please try again.', 'buddypress' ), 'error' );
1262
  } else {
1263
  bp_core_add_message( __( 'Group membership request rejected', 'buddypress' ) );
1264
+ }
1265
 
1266
  }
1267
+
1268
  do_action( 'groups_group_request_managed', $bp->groups->current_group->id, $request_action, $membership_id );
1269
 
1270
  bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/membership-requests' );
1273
  do_action( 'groups_screen_group_admin_requests', $bp->groups->current_group->id );
1274
 
1275
  if ( '' != locate_template( array( 'groups/single/admin.php' ), false ) )
1276
+ bp_core_load_template( apply_filters( 'groups_template_group_admin_requests', 'groups/single/admin' ) );
1277
  else
1278
+ bp_core_load_template( apply_filters( 'groups_template_group_admin_requests', 'groups/admin/membership-requests' ) );
1279
  }
1280
  }
1281
  add_action( 'wp', 'groups_screen_group_admin_requests', 4 );
1282
 
1283
  function groups_screen_group_admin_delete_group() {
1284
  global $bp;
1285
+
1286
  if ( $bp->current_component == $bp->groups->slug && 'delete-group' == $bp->action_variables[0] ) {
1287
+
1288
  if ( !$bp->is_item_admin && !is_site_admin() )
1289
  return false;
1290
+
1291
  if ( isset( $_REQUEST['delete-group-button'] ) && isset( $_REQUEST['delete-group-understand'] ) ) {
1292
  /* Check the nonce first. */
1293
  if ( !check_admin_referer( 'groups_delete_group' ) )
1294
  return false;
1295
+
1296
  // Group admin has deleted the group, now do it.
1297
  if ( !groups_delete_group( $bp->groups->current_group->id ) ) {
1298
  bp_core_add_message( __( 'There was an error deleting the group, please try again.', 'buddypress' ), 'error' );
1310
  do_action( 'groups_screen_group_admin_delete_group', $bp->groups->current_group->id );
1311
 
1312
  if ( '' != locate_template( array( 'groups/single/admin.php' ), false ) )
1313
+ bp_core_load_template( apply_filters( 'groups_template_group_admin_delete_group', 'groups/single/admin' ) );
1314
  else
1315
+ bp_core_load_template( apply_filters( 'groups_template_group_admin_delete_group', 'groups/admin/delete-group' ) );
1316
  }
1317
  }
1318
  add_action( 'wp', 'groups_screen_group_admin_delete_group', 4 );
1319
 
1320
+ function groups_screen_notification_settings() {
1321
  global $current_user; ?>
1322
  <table class="notification-settings" id="groups-notification-settings">
1323
  <tr>
1358
  <td class="yes"><input type="radio" name="notifications[notification_groups_membership_request]" value="yes" <?php if ( !get_usermeta( $current_user->id, 'notification_groups_membership_request') || 'yes' == get_usermeta( $current_user->id, 'notification_groups_membership_request') ) { ?>checked="checked" <?php } ?>/></td>
1359
  <td class="no"><input type="radio" name="notifications[notification_groups_membership_request]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id, 'notification_groups_membership_request') ) { ?>checked="checked" <?php } ?>/></td>
1360
  </tr>
1361
+
1362
  <?php do_action( 'groups_screen_notification_settings' ); ?>
1363
  </table>
1364
+ <?php
1365
  }
1366
  add_action( 'bp_notification_settings', 'groups_screen_notification_settings' );
1367
 
1376
 
1377
  function groups_action_join_group() {
1378
  global $bp;
1379
+
1380
  if ( !$bp->is_single_item || $bp->current_component != $bp->groups->slug || $bp->current_action != 'join' )
1381
  return false;
1382
+
1383
  // user wants to join a group
1384
  if ( !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) && !groups_is_user_banned( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) {
1385
  if ( !groups_join_group($bp->groups->current_group->id) ) {
1391
  }
1392
 
1393
  if ( '' != locate_template( array( 'groups/single/admin.php' ), false ) )
1394
+ bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) );
1395
  else
1396
  bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/group-home' ) );
1397
  }
1399
 
1400
  function groups_action_sort_creation_steps() {
1401
  global $bp;
1402
+
1403
  if ( $bp->current_component != BP_GROUPS_SLUG && $bp->current_action != 'create' )
1404
  return false;
1405
 
1406
  if ( !is_array( $bp->groups->group_creation_steps ) )
1407
  return false;
1408
+
1409
  foreach ( $bp->groups->group_creation_steps as $slug => $step )
1410
  $temp[$step['position']] = array( 'name' => $step['name'], 'slug' => $slug );
1411
 
1412
  /* Sort the steps by their position key */
1413
  ksort($temp);
1414
  unset($bp->groups->group_creation_steps);
1415
+
1416
  foreach( $temp as $position => $step )
1417
  $bp->groups->group_creation_steps[$step['slug']] = array( 'name' => $step['name'], 'position' => $position );
1418
  }
1420
 
1421
  function groups_aciton_redirect_to_random_group() {
1422
  global $bp, $wpdb;
1423
+
1424
  if ( $bp->current_component == $bp->groups->slug && isset( $_GET['random-group'] ) ) {
1425
  $group = groups_get_random_groups( 1, 1 );
1426
 
1439
 
1440
  function groups_register_activity_actions() {
1441
  global $bp;
1442
+
1443
  if ( !function_exists( 'bp_activity_set_action' ) )
1444
  return false;
1445
 
1455
 
1456
  function groups_record_activity( $args = '' ) {
1457
  global $bp;
1458
+
1459
  if ( !function_exists( 'bp_activity_add' ) )
1460
  return false;
1461
+
1462
  /* If the group is not public, no recording of activity please. */
1463
+ if ( 'public' != $bp->groups->current_group->status )
1464
  return false;
1465
+
1466
  $defaults = array(
1467
  'user_id' => $bp->loggedin_user->id,
1468
  'content' => false,
1476
  );
1477
 
1478
  $r = wp_parse_args( $args, $defaults );
1479
+ extract( $r, EXTR_SKIP );
1480
 
1481
  return bp_activity_add( array( 'user_id' => $user_id, 'content' => $content, 'primary_link' => $primary_link, 'component_name' => $component_name, 'component_action' => $component_action, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) );
1482
  }
1494
 
1495
  function groups_format_notifications( $action, $item_id, $secondary_item_id, $total_items ) {
1496
  global $bp;
1497
+
1498
  switch ( $action ) {
1499
  case 'new_membership_request':
1500
  $group_id = $secondary_item_id;
1501
  $requesting_user_id = $item_id;
1502
 
1503
  $group = new BP_Groups_Group( $group_id, false, false );
1504
+
1505
  $group_link = bp_get_group_permalink( $group );
1506
 
1507
  if ( (int)$total_items > 1 ) {
1508
+ return apply_filters( 'bp_groups_multiple_new_membership_requests_notification', '<a href="' . $group_link . '/admin/membership-requests/" title="' . __( 'Group Membership Requests', 'buddypress' ) . '">' . sprintf( __('%d new membership requests for the group "%s"', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $group_link, $total_items, $group->name );
1509
  } else {
1510
  $user_fullname = bp_core_get_user_displayname( $requesting_user_id );
1511
  return apply_filters( 'bp_groups_single_new_membership_request_notification', '<a href="' . $group_link . '/admin/membership-requests/" title="' . $user_fullname .' requests group membership">' . sprintf( __('%s requests membership for the group "%s"', 'buddypress' ), $user_fullname, $group->name ) . '</a>', $group_link, $user_fullname, $group->name );
1512
+ }
1513
  break;
1514
+
1515
  case 'membership_request_accepted':
1516
  $group_id = $item_id;
1517
+
1518
  $group = new BP_Groups_Group( $group_id, false, false );
1519
  $group_link = bp_get_group_permalink( $group ) . '/?new';
1520
+
1521
  if ( (int)$total_items > 1 ) {
1522
+ return apply_filters( 'bp_groups_multiple_membership_request_accepted_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('%d accepted group membership requests', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $total_items, $group_name );
1523
  } else {
1524
  return apply_filters( 'bp_groups_single_membership_request_accepted_notification', '<a href="' . $group_link . '">' . sprintf( __('Membership for group "%s" accepted'), $group->name ) . '</a>', $group_link, $group->name );
1525
+ }
1526
  break;
1527
+
1528
  case 'membership_request_rejected':
1529
  $group_id = $item_id;
1530
+
1531
  $group = new BP_Groups_Group( $group_id, false, false );
1532
  $group_link = bp_get_group_permalink( $group ) . '/?new';
1533
+
1534
  if ( (int)$total_items > 1 ) {
1535
+ return apply_filters( 'bp_groups_multiple_membership_request_rejected_notification', '<a href="' . site_url() . '/' . BP_MEMBERS_SLUG . '/' . $bp->groups->slug . '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('%d rejected group membership requests', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $total_items, $group->name );
1536
  } else {
1537
  return apply_filters( 'bp_groups_single_membership_request_rejected_notification', '<a href="' . $group_link . '">' . sprintf( __('Membership for group "%s" rejected'), $group->name ) . '</a>', $group_link, $group->name );
1538
+ }
1539
+
1540
  break;
1541
+
1542
  case 'member_promoted_to_admin':
1543
  $group_id = $item_id;
1544
+
1545
  $group = new BP_Groups_Group( $group_id, false, false );
1546
  $group_link = bp_get_group_permalink( $group ) . '/?new';
1547
+
1548
  if ( (int)$total_items > 1 ) {
1549
+ return apply_filters( 'bp_groups_multiple_member_promoted_to_admin_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('You were promoted to an admin in %d groups', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
1550
  } else {
1551
  return apply_filters( 'bp_groups_single_member_promoted_to_admin_notification', '<a href="' . $group_link . '">' . sprintf( __('You were promoted to an admin in the group %s'), $group->name ) . '</a>', $group_link, $group->name );
1552
+ }
1553
  break;
1554
+
1555
  case 'member_promoted_to_mod':
1556
  $group_id = $item_id;
1557
+
1558
  $group = new BP_Groups_Group( $group_id, false, false );
1559
  $group_link = bp_get_group_permalink( $group ) . '/?new';
1560
+
1561
  if ( (int)$total_items > 1 ) {
1562
+ return apply_filters( 'bp_groups_multiple_member_promoted_to_mod_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('You were promoted to a mod in %d groups', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
1563
  } else {
1564
  return apply_filters( 'bp_groups_single_member_promoted_to_mod_notification', '<a href="' . $group_link . '">' . sprintf( __('You were promoted to a mod in the group %s'), $group->name ) . '</a>', $group_link, $group->name );
1565
+ }
1566
  break;
1567
+
1568
  case 'group_invite':
1569
  $group_id = $item_id;
1570
 
1571
  $group = new BP_Groups_Group( $group_id, false, false );
1572
  $user_url = bp_core_get_userurl( $user_id );
1573
+
1574
  if ( (int)$total_items > 1 ) {
1575
+ return apply_filters( 'bp_groups_multiple_group_invite_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/invites" title="' . __( 'Group Invites', 'buddypress' ) . '">' . sprintf( __('You have %d new group invitations', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
1576
  } else {
1577
  return apply_filters( 'bp_groups_single_group_invite_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/invites" title="' . __( 'Group Invites', 'buddypress' ) . '">' . sprintf( __('You have an invitation to the group: %s', 'buddypress' ), $group->name ) . '</a>', $group->name );
1578
+ }
1579
  break;
1580
  }
1581
 
1582
  do_action( 'groups_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
1583
+
1584
  return false;
1585
  }
1586
 
1598
 
1599
  function groups_create_group( $args = '' ) {
1600
  global $bp;
1601
+
1602
  extract( $args );
1603
+
1604
  /**
1605
  * Possible parameters (pass as assoc array):
1606
  * 'group_id'
1619
  $group = new BP_Groups_Group( $group_id );
1620
  else
1621
  $group = new BP_Groups_Group;
1622
+
1623
  if ( $creator_id ) {
1624
  $group->creator_id = $creator_id;
1625
  } else {
1626
  $group->creator_id = $bp->loggedin_user->id;
1627
  }
1628
+
1629
  if ( isset( $name ) )
1630
  $group->name = $name;
1631
+
1632
  if ( isset( $description ) )
1633
  $group->description = $description;
1634
+
1635
  if ( isset( $news ) )
1636
  $group->news = $news;
1637
+
1638
  if ( isset( $slug ) && groups_check_slug( $slug ) )
1639
  $group->slug = $slug;
1640
+
1641
  if ( isset( $status ) ) {
1642
  if ( groups_is_valid_status( $status ) )
1643
  $group->status = $status;
1644
  }
1645
+
1646
  if ( isset( $enable_wire ) )
1647
  $group->enable_wire = $enable_wire;
1648
  else if ( !$group_id && !isset( $enable_wire ) )
1649
  $group->enable_wire = 1;
1650
+
1651
  if ( isset( $enable_forum ) )
1652
  $group->enable_forum = $enable_forum;
1653
  else if ( !$group_id && !isset( $enable_forum ) )
1654
  $group->enable_forum = 1;
1655
+
1656
  if ( isset( $date_created ) )
1657
  $group->date_created = $date_created;
1658
+
1659
  if ( !$group->save() )
1660
  return false;
1661
 
1667
  $member->is_admin = 1;
1668
  $member->user_title = __( 'Group Admin', 'buddypress' );
1669
  $member->is_confirmed = 1;
1670
+
1671
  $member->save();
1672
  }
1673
 
1679
 
1680
  if ( empty( $group_name ) || empty( $group_desc ) )
1681
  return false;
1682
+
1683
  $group = new BP_Groups_Group( $group_id, false, false );
1684
  $group->name = $group_name;
1685
  $group->description = $group_desc;
1692
  require_once ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' );
1693
  groups_notification_group_updated( $group->id );
1694
  }
1695
+
1696
  do_action( 'groups_details_updated', $group->id );
1697
+
1698
  return true;
1699
  }
1700
 
1701
  function groups_edit_group_settings( $group_id, $enable_wire, $enable_forum, $enable_photos, $photos_admin_only, $status ) {
1702
  global $bp;
1703
+
1704
  $group = new BP_Groups_Group( $group_id, false, false );
1705
  $group->enable_wire = $enable_wire;
1706
  $group->enable_forum = $enable_forum;
1707
  $group->enable_photos = $enable_photos;
1708
  $group->photos_admin_only = $photos_admin_only;
1709
+
1710
+ /***
1711
  * Before we potentially switch the group status, if it has been changed to public
1712
  * from private and there are outstanding membership requests, auto-accept those requests.
1713
  */
1714
  if ( 'private' == $group->status && 'public' == $status )
1715
  groups_accept_all_pending_membership_requests( $group->id );
1716
+
1717
  /* Now update the status */
1718
  $group->status = $status;
1719
+
1720
  if ( !$group->save() )
1721
  return false;
1722
+
1723
  /* If forums have been enabled, and a forum does not yet exist, we need to create one. */
1724
  if ( $group->enable_forum ) {
1725
  if ( function_exists( 'bp_forums_setup' ) && '' == groups_get_groupmeta( $group->id, 'forum_id' ) ) {
1726
  groups_new_group_forum( $group->id, $group->name, $group->description );
1727
  }
1728
  }
1729
+
1730
  do_action( 'groups_settings_updated', $group->id );
1731
+
1732
  return true;
1733
  }
1734
 
1735
  function groups_delete_group( $group_id ) {
1736
  global $bp;
1737
+
1738
  // Check the user is the group admin.
1739
  if ( !$bp->is_item_admin )
1740
  return false;
1741
+
1742
  // Get the group object
1743
  $group = new BP_Groups_Group( $group_id );
1744
+
1745
  if ( !$group->delete() )
1746
  return false;
1747
 
1749
  if ( function_exists( 'bp_activity_delete_by_item_id' ) ) {
1750
  bp_activity_delete_by_item_id( array( 'item_id' => $group_id, 'component_name' => $bp->groups->id ) );
1751
  }
1752
+
1753
  // Remove all outstanding invites for this group
1754
  groups_delete_all_group_invites( $group_id );
1755
 
1756
  // Remove all notifications for any user belonging to this group
1757
  bp_core_delete_all_notifications_by_type( $group_id, $bp->groups->slug );
1758
+
1759
  do_action( 'groups_delete_group', $group_id );
1760
+
1761
  return true;
1762
  }
1763
 
1764
  function groups_is_valid_status( $status ) {
1765
  global $bp;
1766
+
1767
  return in_array( $status, (array)$bp->groups->valid_status );
1768
  }
1769
 
1772
 
1773
  if ( 'wp' == substr( $slug, 0, 2 ) )
1774
  $slug = substr( $slug, 2, strlen( $slug ) - 2 );
1775
+
1776
  if ( in_array( $slug, (array)$bp->groups->forbidden_names ) ) {
1777
  $slug = $slug . '-' . rand();
1778
  }
1779
+
1780
  if ( BP_Groups_Group::check_slug( $slug ) ) {
1781
  do {
1782
  $slug = $slug . '-' . rand();
1783
  }
1784
  while ( BP_Groups_Group::check_slug( $slug ) );
1785
  }
1786
+
1787
  return $slug;
1788
  }
1789
 
1799
 
1800
  if ( !$user_id )
1801
  $user_id = $bp->loggedin_user->id;
1802
+
 
 
 
 
1803
  // This is exactly the same as deleting and invite, just is_confirmed = 1 NOT 0.
1804
  if ( !groups_uninvite_user( $user_id, $group_id, true ) )
1805
  return false;
1808
 
1809
  /* Modify group member count */
1810
  groups_update_groupmeta( $group_id, 'total_member_count', (int) groups_get_groupmeta( $group_id, 'total_member_count') - 1 );
1811
+
1812
  return true;
1813
  }
1814
 
1815
  function groups_join_group( $group_id, $user_id = false ) {
1816
  global $bp;
1817
+
1818
  if ( !$user_id )
1819
  $user_id = $bp->loggedin_user->id;
1820
 
1821
  if ( groups_check_user_has_invite( $user_id, $group_id ) )
1822
  groups_delete_invite( $user_id, $group_id );
1823
+
1824
+ if ( !$bp->groups->current_group )
1825
+ $bp->groups->current_group = new BP_Groups_Group( $group_id, false, false );
1826
+
1827
  $new_member = new BP_Groups_Member;
1828
  $new_member->group_id = $group_id;
1829
  $new_member->user_id = $user_id;
1832
  $new_member->user_title = '';
1833
  $new_member->date_modified = time();
1834
  $new_member->is_confirmed = 1;
1835
+
1836
  if ( !$new_member->save() )
1837
  return false;
1838
 
1839
  /* Record this in activity streams */
1840
  groups_record_activity( array(
1841
+ 'content' => apply_filters( 'groups_activity_joined_group', sprintf( __( '%s joined the group %s', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' ) ),
1842
  'primary_link' => apply_filters( 'groups_activity_joined_group_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ),
1843
  'component_action' => 'joined_group',
1844
+ 'item_id' => $group_id
1845
  ) );
1846
 
1847
  /* Modify group meta */
1894
  }
1895
 
1896
  function groups_get_alphabetically( $limit = null, $page = 1 ) {
1897
+ return BP_Groups_Group::get_alphabetically( $limit, $page );
1898
  }
1899
 
1900
  function groups_get_by_most_forum_topics( $limit = null, $page = 1 ) {
1907
 
1908
  function groups_get_user_groups( $user_id = false, $pag_num = false, $pag_page = false ) {
1909
  global $bp;
1910
+
1911
  if ( !$user_id )
1912
  $user_id = $bp->displayed_user->id;
1913
+
1914
  return BP_Groups_Member::get_group_ids( $user_id, $pag_num, $pag_page );
1915
  }
1916
 
1918
 
1919
  function groups_get_recently_joined_for_user( $user_id = false, $pag_num = false, $pag_page = false, $filter = false ) {
1920
  global $bp;
1921
+
1922
  if ( !$user_id )
1923
  $user_id = $bp->displayed_user->id;
1924
 
1927
 
1928
  function groups_get_most_popular_for_user( $user_id = false, $pag_num = false, $pag_page = false, $filter = false ) {
1929
  global $bp;
1930
+
1931
  if ( !$user_id )
1932
  $user_id = $bp->displayed_user->id;
1933
 
1934
+ return BP_Groups_Member::get_most_popular( $user_id, $pag_num, $pag_page, $filter );
1935
  }
1936
 
1937
  function groups_get_recently_active_for_user( $user_id = false, $pag_num = false, $pag_page = false, $filter = false ) {
1938
  global $bp;
1939
+
1940
  if ( !$user_id )
1941
  $user_id = $bp->displayed_user->id;
1942
+
1943
  return BP_Groups_Member::get_recently_active( $user_id, $pag_num, $pag_page, $filter );
1944
  }
1945
 
1946
  function groups_get_alphabetically_for_user( $user_id = false, $pag_num = false, $pag_page = false, $filter = false ) {
1947
  global $bp;
1948
+
1949
  if ( !$user_id )
1950
  $user_id = $bp->displayed_user->id;
1951
 
1952
+ return BP_Groups_Member::get_alphabetically( $user_id, $pag_num, $pag_page, $filter );
1953
  }
1954
 
1955
  function groups_get_user_is_admin_of( $user_id = false, $pag_num = false, $pag_page = false, $filter = false ) {
1956
  global $bp;
1957
+
1958
  if ( !$user_id )
1959
  $user_id = $bp->displayed_user->id;
1960
+
1961
+ return BP_Groups_Member::get_is_admin_of( $user_id, $pag_num, $pag_page, $filter );
1962
  }
1963
 
1964
  function groups_get_user_is_mod_of( $user_id = false, $pag_num = false, $pag_page = false, $filter = false ) {
1965
  global $bp;
1966
+
1967
  if ( !$user_id )
1968
  $user_id = $bp->displayed_user->id;
1969
+
1970
+ return BP_Groups_Member::get_is_mod_of( $user_id, $pag_num, $pag_page, $filter );
1971
  }
1972
 
1973
  function groups_total_groups_for_user( $user_id = false ) {
1974
  global $bp;
1975
+
1976
  if ( !$user_id )
1977
  $user_id = $bp->displayed_user->id;
1978
+
1979
  return BP_Groups_Member::total_group_count( $user_id );
1980
  }
1981
 
1982
  function groups_get_random_groups_for_user( $user_id = false, $total_groups = 5 ) {
1983
  global $bp;
1984
+
1985
  if ( !$user_id )
1986
  $user_id = $bp->displayed_user->id;
1987
+
1988
  return BP_Groups_Member::get_random_groups( $user_id, $total_groups );
1989
  }
1990
 
2003
 
2004
  if ( !$group_id )
2005
  $group_id = $bp->groups->current_group->id;
2006
+
2007
  $path = get_blog_option( BP_ROOT_BLOG, 'upload_path' );
2008
  $newdir = WP_CONTENT_DIR . str_replace( 'wp-content', '', $path );
2009
  $newdir .= '/group-avatars/' . $group_id;
2010
 
2011
  $newbdir = $newdir;
2012
+
2013
  if ( !file_exists( $newdir ) )
2014
  @wp_mkdir_p( $newdir );
2015
 
2017
  $newburl = $newurl;
2018
  $newsubdir = '/group-avatars/' . $group_id;
2019
 
2020
+ return apply_filters( 'groups_avatar_upload_dir', array( 'path' => $newdir, 'url' => $newurl, 'subdir' => $newsubdir, 'basedir' => $newbdir, 'baseurl' => $newburl, 'error' => false ) );
2021
  }
2022
 
2023
  /*** Group Member Status Checks ************************************************/
2042
 
2043
  function groups_new_wire_post( $group_id, $content ) {
2044
  global $bp;
2045
+
2046
  if ( !function_exists( 'bp_wire_new_post' ) )
2047
  return false;
2048
+
2049
  if ( $wire_post = bp_wire_new_post( $group_id, $content, 'groups' ) ) {
2050
+
2051
  /* Post an email notification if settings allow */
2052
  require_once ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' );
2053
  groups_notification_new_wire_post( $group_id, $wire_post->id );
2054
+
2055
  /* Record this in activity streams */
2056
  $activity_content = sprintf( __( '%s wrote on the wire of the group %s:', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' );
2057
  $activity_content .= '<blockquote>' . bp_create_excerpt( attribute_escape( $content ) ) . '</blockquote>';
2058
+
2059
  groups_record_activity( array(
2060
+ 'content' => apply_filters( 'groups_activity_new_wire_post', $activity_content ),
2061
  'primary_link' => apply_filters( 'groups_activity_new_wire_post_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ),
2062
  'component_action' => 'new_wire_post',
2063
  'item_id' => $bp->groups->current_group->id,
2065
  ) );
2066
 
2067
  do_action( 'groups_new_wire_post', $group_id, $wire_post->id );
2068
+
2069
  return true;
2070
  }
2071
+
2072
  return false;
2073
  }
2074
 
2078
  if ( function_exists( 'bp_activity_delete_by_item_id' ) ) {
2079
  bp_activity_delete_by_item_id( array( 'item_id' => $wire_post_id, 'component_name' => 'groups', 'component_action' => 'new_wire_post' ) );
2080
  }
2081
+
2082
  do_action( 'groups_deleted_wire_post', $wire_post_id );
2083
  return true;
2084
  }
2085
+
2086
  return false;
2087
  }
2088
 
2093
 
2094
  if ( !$group_id )
2095
  $group_id = $bp->groups->current_group->id;
2096
+
2097
  if ( !$group_name )
2098
  $group_name = $bp->groups->current_group->name;
2099
+
2100
  if ( !$group_desc )
2101
  $group_desc = $bp->groups->current_group->description;
2102
+
2103
  $forum_id = bp_forums_new_forum( array( 'forum_name' => $group_name, 'forum_desc' => $group_desc ) );
2104
 
2105
  groups_update_groupmeta( $group_id, 'forum_id', $forum_id );
2106
+
2107
  do_action( 'groups_new_group_forum', $forum, $group_id );
2108
  }
2109
 
2110
  function groups_new_group_forum_post( $post_text, $topic_id ) {
2111
  global $bp;
2112
+
2113
  if ( empty( $post_text ) )
2114
  return false;
2115
+
2116
  if ( $forum_post = bp_forums_insert_post( array( 'post_text' => $post_text, 'topic_id' => $topic_id ) ) ) {
2117
  $topic = bp_forums_get_topic_details( $topic_id );
2118
+
2119
  $activity_content = sprintf( __( '%s posted on the forum topic %s in the group %s:', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic->topic_slug .'">' . attribute_escape( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' );
2120
  $activity_content .= '<blockquote>' . bp_create_excerpt( attribute_escape( $post_text ) ) . '</blockquote>';
2121
+
2122
  /* Record this in activity streams */
2123
  groups_record_activity( array(
2124
+ 'content' => apply_filters( 'groups_activity_new_forum_post', $activity_content, $post_text, &$topic, &$forum_post ),
2125
  'primary_link' => apply_filters( 'groups_activity_new_forum_post_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ),
2126
  'component_action' => 'new_forum_post',
2127
  'item_id' => $bp->groups->current_group->id,
2129
  ) );
2130
 
2131
  do_action( 'groups_new_forum_topic_post', $bp->groups->current_group->id, $forum_post );
2132
+
2133
  return $forum_post;
2134
  }
2135
+
2136
  return false;
2137
  }
2138
 
2139
  function groups_new_group_forum_topic( $topic_title, $topic_text, $topic_tags, $forum_id ) {
2140
  global $bp;
2141
+
2142
  if ( empty( $topic_title ) || empty( $topic_text ) )
2143
  return false;
2144
+
2145
  if ( $topic_id = bp_forums_new_topic( array( 'topic_title' => $topic_title, 'topic_text' => $topic_text, 'topic_tags' => $topic_tags, 'forum_id' => $forum_id ) ) ) {
2146
  $topic = bp_forums_get_topic_details( $topic_id );
2147
 
2148
  $activity_content = sprintf( __( '%s started the forum topic %s in the group %s:', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic->topic_slug .'">' . attribute_escape( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' );
2149
  $activity_content .= '<blockquote>' . bp_create_excerpt( attribute_escape( $topic_text ) ) . '</blockquote>';
2150
+
2151
  /* Record this in activity streams */
2152
  groups_record_activity( array(
2153
+ 'content' => apply_filters( 'groups_activity_new_forum_topic', $activity_content, $topic_text, &$topic ),
2154
  'primary_link' => apply_filters( 'groups_activity_new_forum_topic_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ),
2155
  'component_action' => 'new_forum_topic',
2156
  'item_id' => $bp->groups->current_group->id,
2157
  'secondary_item_id' => $topic->topic_id
2158
  ) );
2159
+
2160
  do_action( 'groups_new_forum_topic', $bp->groups->current_group->id, &$topic );
2161
 
2162
  return $topic;
2163
  }
2164
+
2165
  return false;
2166
  }
2167
 
2168
  function groups_update_group_forum_topic( $topic_id, $topic_title, $topic_text ) {
2169
  global $bp;
2170
+
2171
  if ( $topic = bp_forums_update_topic( array( 'topic_title' => $topic_title, 'topic_text' => $topic_text, 'topic_id' => $topic_id ) ) ) {
2172
  /* Update the activity stream item */
2173
  if ( function_exists( 'bp_activity_delete_by_item_id' ) )
2174
  bp_activity_delete_by_item_id( array( 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $topic_id, 'component_name' => $bp->groups->id, 'component_action' => 'new_forum_topic' ) );
2175
+
2176
  $activity_content = sprintf( __( '%s started the forum topic %s in the group %s:', 'buddypress'), bp_core_get_userlink( $topic->topic_poster ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic->topic_slug .'">' . attribute_escape( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' );
2177
  $activity_content .= '<blockquote>' . bp_create_excerpt( attribute_escape( $topic_text ) ) . '</blockquote>';
2178
 
2179
  /* Record this in activity streams */
2180
  groups_record_activity( array(
2181
+ 'content' => apply_filters( 'groups_activity_new_forum_topic', $activity_content, $topic_text, &$topic ),
2182
  'primary_link' => apply_filters( 'groups_activity_new_forum_topic_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ),
2183
  'component_action' => 'new_forum_topic',
2184
  'item_id' => (int)$bp->groups->current_group->id,
2188
  ) );
2189
 
2190
  do_action( 'groups_update_group_forum_topic', &$topic );
2191
+
2192
  return true;
2193
  }
2194
+
2195
  return false;
2196
  }
2197
 
2198
  function groups_update_group_forum_post( $post_id, $post_text, $topic_id ) {
2199
  global $bp;
2200
+
2201
  $post = bp_forums_get_post( $post_id );
2202
+
2203
  if ( $post_id = bp_forums_insert_post( array( 'post_id' => $post_id, 'post_text' => $post_text, 'post_time' => $post->post_time, 'topic_id' => $topic_id, 'poster_id' => $post->poster_id ) ) ) {
2204
  $topic = bp_forums_get_topic_details( $topic_id );
2205
 
2206
  /* Update the activity stream item */
2207
  if ( function_exists( 'bp_activity_delete_by_item_id' ) )
2208
  bp_activity_delete_by_item_id( array( 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $post_id, 'component_name' => $bp->groups->id, 'component_action' => 'new_forum_post' ) );
2209
+
2210
  $activity_content = sprintf( __( '%s posted on the forum topic %s in the group %s:', 'buddypress'), bp_core_get_userlink( $post->poster_id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic->topic_slug .'">' . attribute_escape( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' );
2211
  $activity_content .= '<blockquote>' . bp_create_excerpt( attribute_escape( $post_text ) ) . '</blockquote>';
2212
+
2213
  /* Record this in activity streams */
2214
  groups_record_activity( array(
2215
+ 'content' => apply_filters( 'groups_activity_new_forum_post', $activity_content, $post_text, &$topic, &$forum_post ),
2216
  'primary_link' => apply_filters( 'groups_activity_new_forum_post_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ),
2217
  'component_action' => 'new_forum_post',
2218
  'item_id' => (int)$bp->groups->current_group->id,
2222
  ) );
2223
 
2224
  do_action( 'groups_update_group_forum_post', &$post, &$topic );
2225
+
2226
  return true;
2227
  }
2228
+
2229
  return false;
2230
  }
2231
 
2232
  function groups_delete_group_forum_topic( $topic_id ) {
2233
  global $bp;
2234
+
2235
  if ( bp_forums_delete_topic( array( 'topic_id' => $topic_id ) ) ) {
2236
  /* Delete the activity stream item */
2237
  if ( function_exists( 'bp_activity_delete_by_item_id' ) ) {
2240
  }
2241
 
2242
  do_action( 'groups_delete_group_forum_topic', $topic_id );
2243
+
2244
  return true;
2245
  }
2246
+
2247
  return false;
2248
  }
2249
 
2250
  function groups_delete_group_forum_post( $post_id, $topic_id ) {
2251
  global $bp;
2252
+
2253
  if ( bp_forums_delete_post( array( 'post_id' => $post_id ) ) ) {
2254
  /* Delete the activity stream item */
2255
  if ( function_exists( 'bp_activity_delete_by_item_id' ) ) {
2257
  }
2258
 
2259
  do_action( 'groups_delete_group_forum_post', $post_id, $topic_id );
2260
+
2261
  return true;
2262
  }
2263
+
2264
  return false;
2265
  }
2266
 
2273
 
2274
  function groups_get_invites_for_user( $user_id = false ) {
2275
  global $bp;
2276
+
2277
  if ( !$user_id )
2278
  $user_id = $bp->loggedin_user->id;
2279
+
2280
  return BP_Groups_Member::get_invites( $user_id );
2281
  }
2282
 
2283
  function groups_invite_user( $args = '' ) {
2284
  global $bp;
2285
+
2286
  $defaults = array(
2287
  'user_id' => false,
2288
  'group_id' => false,
2292
  );
2293
 
2294
  $args = wp_parse_args( $args, $defaults );
2295
+ extract( $args, EXTR_SKIP );
2296
 
2297
  if ( !$user_id || !$group_id )
2298
  return false;
2299
+
2300
  if ( groups_is_user_member( $user_id, $group_id ) )
2301
  return false;
2302
+
2303
  $invite = new BP_Groups_Member;
2304
  $invite->group_id = $group_id;
2305
  $invite->user_id = $user_id;
2306
  $invite->date_modified = $date_modified;
2307
  $invite->inviter_id = $inviter_id;
2308
  $invite->is_confirmed = $is_confirmed;
2309
+
2310
  if ( !$invite->save() )
2311
  return false;
2312
+
2313
  do_action( 'groups_invite_user', $args );
2314
+
2315
  return true;
2316
  }
2317
 
2318
  function groups_uninvite_user( $user_id, $group_id ) {
2319
  global $bp;
2320
+
2321
  if ( !BP_Groups_Member::delete( $user_id, $group_id ) )
2322
  return false;
2323
 
2329
  function groups_accept_invite( $user_id, $group_id ) {
2330
  if ( groups_is_user_member( $user_id, $group_id ) )
2331
  return false;
2332
+
2333
  $member = new BP_Groups_Member( $user_id, $group_id );
2334
  $member->accept_invite();
2335
 
2336
+ if ( !$member->save() )
2337
  return false;
2338
+
2339
  do_action( 'groups_accept_invite', $user_id, $group_id );
2340
  return true;
2341
  }
2343
  function groups_reject_invite( $user_id, $group_id ) {
2344
  if ( !BP_Groups_Member::delete( $user_id, $group_id ) )
2345
  return false;
2346
+
2347
  do_action( 'groups_reject_invite', $user_id, $group_id );
2348
+
2349
  return true;
2350
  }
2351
 
2352
  function groups_delete_invite( $user_id, $group_id ) {
2353
  global $bp;
2354
+
2355
  $delete = BP_Groups_Member::delete_invite( $user_id, $group_id );
2356
+
2357
  if ( $delete )
2358
  bp_core_delete_notifications_for_user_by_item_id( $user_id, $group_id, $bp->groups->slug, 'group_invite' );
2359
+
2360
  return $delete;
2361
  }
2362
 
2363
  function groups_send_invites( $user_id, $group_id ) {
2364
  global $bp;
2365
+
2366
  require_once ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' );
2367
+
2368
  if ( !$user_id )
2369
  $user_id = $bp->loggedin_user->id;
2370
 
2377
 
2378
  // Send the actual invite
2379
  groups_notification_group_invites( $group, $member, $user_id );
2380
+
2381
  $member->invite_sent = 1;
2382
  $member->save();
2383
  }
2384
+
2385
  do_action( 'groups_send_invites', $bp->groups->current_group->id, $invited_users );
2386
  }
2387
 
2401
 
2402
  function groups_promote_member( $user_id, $group_id, $status ) {
2403
  global $bp;
2404
+
2405
  if ( !$bp->is_item_admin )
2406
  return false;
2407
+
2408
  $member = new BP_Groups_Member( $user_id, $group_id );
2409
 
2410
  do_action( 'groups_premote_member', $user_id, $group_id, $status );
2411
+
2412
  return $member->promote( $status );
2413
  }
2414
 
2416
  global $bp;
2417
 
2418
  $member = new BP_Groups_Member( $user_id, $group_id );
2419
+
2420
  do_action( 'groups_demote_member', $user_id, $group_id );
2421
 
2422
  return $member->demote();
2427
 
2428
  if ( !$bp->is_item_admin )
2429
  return false;
2430
+
2431
  $member = new BP_Groups_Member( $user_id, $group_id );
2432
 
2433
  do_action( 'groups_ban_member', $user_id, $group_id );
2434
+
2435
  return $member->ban();
2436
  }
2437
 
2438
  function groups_unban_member( $user_id, $group_id ) {
2439
  global $bp;
2440
+
2441
  if ( !$bp->is_item_admin )
2442
  return false;
2443
+
2444
  $member = new BP_Groups_Member( $user_id, $group_id );
2445
+
2446
  do_action( 'groups_unban_member', $user_id, $group_id );
2447
+
2448
  return $member->unban();
2449
  }
2450
 
2462
  $requesting_user->date_modified = time();
2463
  $requesting_user->is_confirmed = 0;
2464
  $requesting_user->comments = $_POST['group-request-membership-comments'];
2465
+
2466
  if ( $requesting_user->save() ) {
2467
  $admins = groups_get_group_admins( $group_id );
2468
 
2472
  // Saved okay, now send the email notification
2473
  groups_notification_new_membership_request( $requesting_user_id, $admins[$i]->user_id, $group_id, $requesting_user->id );
2474
  }
2475
+
2476
  do_action( 'groups_membership_requested', $requesting_user_id, $admins, $group_id, $requesting_user->id );
2477
+
2478
  return true;
2479
  }
2480
+
2481
  return false;
2482
  }
2483
 
2484
  function groups_accept_membership_request( $membership_id, $user_id = false, $group_id = false ) {
2485
  global $bp;
2486
+
2487
  if ( $user_id && $group_id )
2488
  $membership = new BP_Groups_Member( $user_id, $group_id );
2489
  else
2490
  $membership = new BP_Groups_Member( false, false, $membership_id );
2491
 
2492
  $membership->accept_request();
2493
+
2494
  if ( !$membership->save() )
2495
  return false;
2496
+
2497
  /* Modify group member count */
2498
  groups_update_groupmeta( $membership->group_id, 'total_member_count', (int) groups_get_groupmeta( $membership->group_id, 'total_member_count') + 1 );
2499
+
2500
  /* Record this in activity streams */
2501
  $group = new BP_Groups_Group( $group_id, false, false );
2502
 
2503
  groups_record_activity( array(
2504
+ 'content' => apply_filters( 'groups_activity_membership_accepted', sprintf( __( '%s joined the group %s', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . attribute_escape( $group->name ) . '</a>' ), $user_id, &$group ),
2505
  'primary_link' => apply_filters( 'groups_activity_membership_accepted_primary_link', bp_get_group_permalink( $group ), &$group ),
2506
  'component_action' => 'joined_group',
2507
  'item_id' => $group->id,
2511
  /* Send a notification to the user. */
2512
  require_once ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' );
2513
  groups_notification_membership_request_completed( $membership->user_id, $membership->group_id, true );
2514
+
2515
  do_action( 'groups_membership_accepted', $membership->user_id, $membership->group_id );
2516
+
2517
  return true;
2518
  }
2519
 
2520
+ function groups_reject_membership_request( $membership_id, $user_id = false, $group_id = false ) {
2521
  if ( $user_id && $group_id )
2522
  $membership = new BP_Groups_Member( $user_id, $group_id );
2523
  else
2524
  $membership = new BP_Groups_Member( false, false, $membership_id );
2525
+
2526
  if ( !BP_Groups_Member::delete( $membership->user_id, $membership->group_id ) )
2527
  return false;
2528
+
2529
  // Send a notification to the user.
2530
  require_once ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' );
2531
  groups_notification_membership_request_completed( $membership->user_id, $membership->group_id, false );
2532
+
2533
  do_action( 'groups_membership_rejected', $membership->user_id, $membership->group_id );
2534
+
2535
  return true;
2536
  }
2537
 
2544
 
2545
  if ( !$user_ids )
2546
  return false;
2547
+
2548
  foreach ( (array) $user_ids as $user_id ) {
2549
  groups_accept_membership_request( false, $user_id, $group_id );
2550
  }
2551
+
2552
  do_action( 'groups_accept_all_pending_membership_requests', $group_id );
2553
+
2554
  return true;
2555
  }
2556
 
2558
 
2559
  function groups_delete_groupmeta( $group_id, $meta_key = false, $meta_value = false ) {
2560
  global $wpdb, $bp;
2561
+
2562
  if ( !is_numeric( $group_id ) )
2563
  return false;
2564
+
2565
  $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
2566
 
2567
  if ( is_array($meta_value) || is_object($meta_value) )
2568
  $meta_value = serialize($meta_value);
2569
+
2570
  $meta_value = trim( $meta_value );
2571
 
2572
  if ( !$meta_key ) {
2573
+ $wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d", $group_id ) );
2574
  } else if ( $meta_value ) {
2575
  $wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d AND meta_key = %s AND meta_value = %s", $group_id, $meta_key, $meta_value ) );
2576
  } else {
2577
  $wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d AND meta_key = %s", $group_id, $meta_key ) );
2578
  }
2579
+
2580
  // TODO need to look into using this.
2581
  // wp_cache_delete($group_id, 'groups');
2582
 
2585
 
2586
  function groups_get_groupmeta( $group_id, $meta_key = '') {
2587
  global $wpdb, $bp;
2588
+
2589
  $group_id = (int) $group_id;
2590
 
2591
  if ( !$group_id )
2593
 
2594
  if ( !empty($meta_key) ) {
2595
  $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
2596
+
2597
  // TODO need to look into using this.
2598
  //$user = wp_cache_get($user_id, 'users');
2599
+
2600
  // Check the cached user object
2601
  //if ( false !== $user && isset($user->$meta_key) )
2602
  // $metas = array($user->$meta_key);
2623
 
2624
  function groups_update_groupmeta( $group_id, $meta_key, $meta_value ) {
2625
  global $wpdb, $bp;
2626
+
2627
  if ( !is_numeric( $group_id ) )
2628
  return false;
2629
+
2630
  $meta_key = preg_replace( '|[^a-z0-9_]|i', '', $meta_key );
2631
 
2632
  if ( is_string($meta_value) )
2633
  $meta_value = stripslashes($wpdb->escape($meta_value));
2634
+
2635
  $meta_value = maybe_serialize($meta_value);
2636
+
2637
  if (empty($meta_value)) {
2638
  return groups_delete_groupmeta( $group_id, $meta_key );
2639
  }
2658
 
2659
  function groups_remove_data_for_user( $user_id ) {
2660
  BP_Groups_Member::delete_all_for_user($user_id);
2661
+
2662
  do_action( 'groups_remove_data_for_user', $user_id );
2663
  }
2664
  add_action( 'wpmu_delete_user', 'groups_remove_data_for_user', 1 );
bp-groups/bp-groups-admin.php CHANGED
@@ -1,11 +1,11 @@
1
  <?php
2
 
3
- function groups_admin_settings() {
4
-
5
  if ( isset( $_POST['groups_admin_delete']) && isset( $_POST['allgroups'] ) ) {
6
  if ( !check_admin_referer('bp-groups-admin') )
7
  return false;
8
-
9
  $errors = false;
10
  foreach ( $_POST['allgroups'] as $group_id ) {
11
  $group = new BP_Groups_Group( $group_id );
@@ -13,7 +13,7 @@ function groups_admin_settings() {
13
  $errors = true;
14
  }
15
  }
16
-
17
  if ( $errors ) {
18
  $message = __( 'There were errors when deleting groups, please try again', 'buddypress' );
19
  $type = 'error';
@@ -31,12 +31,12 @@ function groups_admin_settings() {
31
 
32
  <div class="wrap" style="position: relative">
33
  <h2><?php _e( 'Groups', 'buddypress' ) ?></h2>
34
-
35
  <form id="wpmu-search" method="post" action="">
36
  <input type="text" size="17" value="<?php echo attribute_escape( stripslashes( $_REQUEST['s'] ) ); ?>" name="s" />
37
  <input id="post-query-submit" class="button" type="submit" value="<?php _e( 'Search Groups', 'buddypress' ) ?>" />
38
  </form>
39
-
40
  <?php if ( bp_has_site_groups( 'type=active&per_page=10' ) ) : ?>
41
  <form id="bp-group-admin-list" method="post" action="">
42
  <div class="tablenav">
@@ -49,9 +49,9 @@ function groups_admin_settings() {
49
  <br class="clear"/>
50
  </div>
51
  </div>
52
-
53
  <br class="clear"/>
54
-
55
  <?php if ( isset( $_REQUEST['s'] ) && $_REQUEST['s'] != '' ) { ?>
56
  <p><?php echo sprintf( __( 'Groups matching: "%s"', 'buddypress' ), $_REQUEST['s'] ) ?></p>
57
  <?php } ?>
@@ -110,7 +110,7 @@ function groups_admin_settings() {
110
  <?php $counter++ ?>
111
  <?php endwhile; ?>
112
  </tbody>
113
- </table>
114
 
115
  <?php else: ?>
116
 
@@ -123,7 +123,7 @@ function groups_admin_settings() {
123
  <?php bp_the_site_group_hidden_fields() ?>
124
  </form>
125
  </div>
126
- <?php
127
  }
128
 
129
  ?>
1
  <?php
2
 
3
+ function groups_admin_settings() {
4
+
5
  if ( isset( $_POST['groups_admin_delete']) && isset( $_POST['allgroups'] ) ) {
6
  if ( !check_admin_referer('bp-groups-admin') )
7
  return false;
8
+
9
  $errors = false;
10
  foreach ( $_POST['allgroups'] as $group_id ) {
11
  $group = new BP_Groups_Group( $group_id );
13
  $errors = true;
14
  }
15
  }
16
+
17
  if ( $errors ) {
18
  $message = __( 'There were errors when deleting groups, please try again', 'buddypress' );
19
  $type = 'error';
31
 
32
  <div class="wrap" style="position: relative">
33
  <h2><?php _e( 'Groups', 'buddypress' ) ?></h2>
34
+
35
  <form id="wpmu-search" method="post" action="">
36
  <input type="text" size="17" value="<?php echo attribute_escape( stripslashes( $_REQUEST['s'] ) ); ?>" name="s" />
37
  <input id="post-query-submit" class="button" type="submit" value="<?php _e( 'Search Groups', 'buddypress' ) ?>" />
38
  </form>
39
+
40
  <?php if ( bp_has_site_groups( 'type=active&per_page=10' ) ) : ?>
41
  <form id="bp-group-admin-list" method="post" action="">
42
  <div class="tablenav">
49
  <br class="clear"/>
50
  </div>
51
  </div>
52
+
53
  <br class="clear"/>
54
+
55
  <?php if ( isset( $_REQUEST['s'] ) && $_REQUEST['s'] != '' ) { ?>
56
  <p><?php echo sprintf( __( 'Groups matching: "%s"', 'buddypress' ), $_REQUEST['s'] ) ?></p>
57
  <?php } ?>
110
  <?php $counter++ ?>
111
  <?php endwhile; ?>
112
  </tbody>
113
+ </table>
114
 
115
  <?php else: ?>
116
 
123
  <?php bp_the_site_group_hidden_fields() ?>
124
  </form>
125
  </div>
126
+ <?php
127
  }
128
 
129
  ?>
bp-groups/bp-groups-classes.php CHANGED
@@ -13,29 +13,29 @@ Class BP_Groups_Group {
13
  var $date_created;
14
 
15
  var $user_dataset;
16
-
17
  var $admins;
18
  var $total_member_count;
19
  var $random_members;
20
  var $latest_wire_posts;
21
-
22
  function bp_groups_group( $id = null, $single = false, $get_user_dataset = true ) {
23
  if ( $id ) {
24
  $this->id = $id;
25
  $this->populate( $get_user_dataset );
26
  }
27
-
28
  if ( $single ) {
29
  $this->populate_meta();
30
  }
31
  }
32
-
33
  function populate( $get_user_dataset ) {
34
  global $wpdb, $bp;
35
 
36
  $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} WHERE id = %d", $this->id );
37
  $group = $wpdb->get_row($sql);
38
-
39
  if ( $group ) {
40
  $this->id = $group->id;
41
  $this->creator_id = $group->creator_id;
@@ -48,28 +48,28 @@ Class BP_Groups_Group {
48
  $this->enable_forum = $group->enable_forum;
49
  $this->date_created = strtotime($group->date_created);
50
  $this->total_member_count = groups_get_groupmeta( $this->id, 'total_member_count' );
51
-
52
  if ( $get_user_dataset ) {
53
  $this->user_dataset = $this->get_user_dataset();
54
-
55
  //if ( !$this->total_member_count ) {
56
  $this->total_member_count = count( $this->user_dataset );
57
  groups_update_groupmeta( $this->id, 'total_member_count', $this->total_member_count );
58
  //}
59
  }
60
- }
61
  }
62
-
63
  function populate_meta() {
64
  if ( $this->id ) {
65
  $this->admins = $this->get_administrators();
66
  $this->random_members = $this->get_random_members();
67
  }
68
  }
69
-
70
  function save() {
71
  global $wpdb, $bp;
72
-
73
  $this->creator_id = apply_filters( 'groups_group_creator_id_before_save', $this->creator_id, $this->id );
74
  $this->name = apply_filters( 'groups_group_name_before_save', $this->name, $this->id );
75
  $this->slug = apply_filters( 'groups_group_slug_before_save', $this->slug, $this->id );
@@ -81,36 +81,36 @@ Class BP_Groups_Group {
81
  $this->date_created = apply_filters( 'groups_group_date_created_before_save', $this->date_created, $this->id );
82
 
83
  do_action( 'groups_group_before_save', $this );
84
-
85
  if ( $this->id ) {
86
- $sql = $wpdb->prepare(
87
- "UPDATE {$bp->groups->table_name} SET
88
- creator_id = %d,
89
- name = %s,
90
- slug = %s,
91
- description = %s,
92
- news = %s,
93
- status = %s,
94
- enable_wire = %d,
95
- enable_forum = %d,
96
  date_created = FROM_UNIXTIME(%d)
97
  WHERE
98
  id = %d
99
  ",
100
- $this->creator_id,
101
- $this->name,
102
- $this->slug,
103
- $this->description,
104
- $this->news,
105
- $this->status,
106
- $this->enable_wire,
107
- $this->enable_forum,
108
  $this->date_created,
109
  $this->id
110
  );
111
  } else {
112
- $sql = $wpdb->prepare(
113
- "INSERT INTO {$bp->groups->table_name} (
114
  creator_id,
115
  name,
116
  slug,
@@ -123,111 +123,111 @@ Class BP_Groups_Group {
123
  ) VALUES (
124
  %d, %s, %s, %s, %s, %s, %d, %d, FROM_UNIXTIME(%d)
125
  )",
126
- $this->creator_id,
127
- $this->name,
128
- $this->slug,
129
- $this->description,
130
- $this->news,
131
- $this->status,
132
- $this->enable_wire,
133
  $this->enable_forum,
134
  $this->date_created
135
  );
136
  }
137
-
138
  if ( false === $wpdb->query($sql) )
139
  return false;
140
-
141
  if ( !$this->id ) {
142
  $this->id = $wpdb->insert_id;
143
  }
144
 
145
  do_action( 'groups_group_after_save', $this );
146
-
147
  return true;
148
  }
149
-
150
  function get_user_dataset() {
151
  global $wpdb, $bp;
152
-
153
  return $wpdb->get_results( $wpdb->prepare( "SELECT user_id, is_admin, inviter_id, user_title, is_mod FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 1 AND is_banned = 0 ORDER BY rand()", $this->id ) );
154
  }
155
-
156
  function get_administrators() {
157
  for ( $i = 0; $i < count($this->user_dataset); $i++ ) {
158
  if ( $this->user_dataset[$i]->is_admin )
159
  $admins[] = new BP_Groups_Member( $this->user_dataset[$i]->user_id, $this->id );
160
- }
161
-
162
  return $admins;
163
  }
164
 
165
  function get_random_members() {
166
  $total_randoms = ( $this->total_member_count > 5 ) ? 5 : $this->total_member_count;
167
-
168
  for ( $i = 0; $i < $total_randoms; $i++ ) {
169
  if ( !(int)$this->user_dataset[$i]->is_banned )
170
  $users[] = new BP_Groups_Member( $this->user_dataset[$i]->user_id, $this->id );
171
  }
172
  return $users;
173
  }
174
-
175
  function is_member() {
176
  global $bp;
177
-
178
  for ( $i = 0; $i < count($this->user_dataset); $i++ ) {
179
  if ( $this->user_dataset[$i]->user_id == $bp->loggedin_user->id ) {
180
  return true;
181
  }
182
- }
183
-
184
  return false;
185
  }
186
-
187
  function delete() {
188
  global $wpdb, $bp;
189
-
190
  // Delete groupmeta for the group
191
  groups_delete_groupmeta( $this->id );
192
 
193
  // Modify group count usermeta for members
194
  for ( $i = 0; $i < count($this->user_dataset); $i++ ) {
195
  $user = $this->user_dataset[$i];
196
-
197
  $total_count = get_usermeta( $user->user_id, 'total_group_count' );
198
-
199
  if ( $total_count != '' ) {
200
  update_usermeta( $user->user_id, 'total_group_count', (int)$total_count - 1 );
201
  }
202
-
203
  // Now delete the group member record
204
  BP_Groups_Member::delete( $user->user_id, $this->id, false );
205
  }
206
-
207
  // Delete the wire posts for this group if the wire is installed
208
  if ( function_exists('bp_wire_install') ) {
209
  BP_Wire_Post::delete_all_for_item( $this->id, $bp->groups->table_name_wire );
210
  }
211
-
212
  // Finally remove the group entry from the DB
213
  if ( !$wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name} WHERE id = %d", $this->id ) ) )
214
  return false;
215
 
216
  return true;
217
  }
218
-
219
 
220
  /* Static Functions */
221
-
222
  function group_exists( $slug, $table_name = false ) {
223
  global $wpdb, $bp;
224
-
225
  if ( !$table_name )
226
  $table_name = $bp->groups->table_name;
227
-
228
  if ( !$slug )
229
  return false;
230
-
231
  return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$table_name} WHERE slug = %s", $slug ) );
232
  }
233
 
@@ -239,37 +239,37 @@ Class BP_Groups_Group {
239
  global $wpdb, $bp;
240
  return $wpdb->get_col( $wpdb->prepare( "SELECT user_id FROM {$bp->groups->table_name_members} WHERE group_id = %d and is_confirmed = 0 AND inviter_id = %d", $group_id, $user_id ) );
241
  }
242
-
243
  function filter_user_groups( $filter, $user_id = false, $order = false, $limit = null, $page = null ) {
244
  global $wpdb, $bp;
245
-
246
  if ( !$user_id )
247
  $user_id = $bp->displayed_user->id;
248
-
249
  $filter = like_escape( $wpdb->escape( $filter ) );
250
-
251
  if ( $limit && $page )
252
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
253
-
254
  // Get all the group ids for the current user's groups.
255
  $gids = BP_Groups_Member::get_group_ids( $user_id );
256
-
257
  if ( !$gids['groups'] )
258
  return false;
259
-
260
  $gids = implode( ',', $gids['groups'] );
261
-
262
  $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT id as group_id FROM {$bp->groups->table_name} WHERE ( name LIKE '{$filter}%%' OR description LIKE '{$filter}%%' ) AND id IN ({$gids}) {$pag_sql}" ) );
263
- $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->groups->table_name} WHERE ( name LIKE '{$filter}%%' OR description LIKE '{$filter}%%' ) AND id IN ({$gids})" ) );
264
-
265
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
266
  }
267
-
268
  function search_groups( $filter, $limit = null, $page = null, $sort_by = false, $order = false ) {
269
  global $wpdb, $bp;
270
-
271
  $filter = like_escape( $wpdb->escape( $filter ) );
272
-
273
  if ( $limit && $page )
274
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
275
 
@@ -278,202 +278,211 @@ Class BP_Groups_Group {
278
  $order = $wpdb->escape( $order );
279
  $order_sql = "ORDER BY $sort_by $order";
280
  }
281
-
282
  if ( !is_site_admin() )
283
  $hidden_sql = "AND status != 'hidden'";
284
 
285
  $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT id as group_id FROM {$bp->groups->table_name} WHERE ( name LIKE '%%$filter%%' OR description LIKE '%%$filter%%' ) {$hidden_sql} {$order_sql} {$pag_sql}" ) );
286
- $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->groups->table_name} WHERE ( name LIKE '%%$filter%%' OR description LIKE '%%$filter%%' ) {$hidden_sq}" ) );
287
-
288
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
289
  }
290
-
291
  function check_slug( $slug ) {
292
  global $wpdb, $bp;
293
-
294
- return $wpdb->get_var( $wpdb->prepare( "SELECT slug FROM {$bp->groups->table_name} WHERE slug = %s", $slug ) );
295
  }
296
-
297
  function get_slug( $group_id ) {
298
  global $wpdb, $bp;
299
-
300
- return $wpdb->get_var( $wpdb->prepare( "SELECT slug FROM {$bp->groups->table_name} WHERE id = %d", $group_id ) );
301
  }
302
-
303
  function has_members( $group_id ) {
304
  global $wpdb, $bp;
305
-
306
- $members = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->groups->table_name_members} WHERE group_id = %d", $group_id ) );
307
 
308
  if ( !$members )
309
  return false;
310
-
311
  return true;
312
  }
313
-
314
  function has_membership_requests( $group_id ) {
315
  global $wpdb, $bp;
316
-
317
- return $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 0", $group_id ) );
318
  }
319
-
320
  function get_membership_requests( $group_id, $limit = null, $page = null ) {
321
  global $wpdb, $bp;
322
-
323
  if ( $limit && $page ) {
324
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
325
  }
326
-
327
  $paged_requests = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 0 AND inviter_id = 0{$pag_sql}", $group_id ) );
328
  $total_requests = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 0 AND inviter_id = 0", $group_id ) );
329
 
330
  return array( 'requests' => $paged_requests, 'total' => $total_requests );
331
  }
332
-
333
  function get_newest( $limit = null, $page = null ) {
334
  global $wpdb, $bp;
335
-
336
  if ( $limit && $page )
337
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
338
-
339
  if ( !is_site_admin() )
340
  $hidden_sql = "WHERE status != 'hidden'";
341
-
342
  $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT id as group_id FROM {$bp->groups->table_name} {$hidden_sql} ORDER BY date_created DESC {$pag_sql}" ) );
343
  $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name} {$hidden_sql} ORDER BY date_created DESC", $limit ) );
344
 
345
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
346
  }
347
-
348
  function get_active( $limit = null, $page = null ) {
349
  global $wpdb, $bp;
350
-
351
  if ( $limit && $page )
352
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
353
 
354
  if ( !is_site_admin() )
355
  $hidden_sql = "AND g.status != 'hidden'";
356
-
357
  $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT group_id FROM {$bp->groups->table_name_groupmeta} gm, {$bp->groups->table_name} g WHERE g.id = gm.group_id {$hidden_sql} AND gm.meta_key = 'last_activity' ORDER BY CONVERT(gm.meta_value, SIGNED) DESC {$pag_sql}" ) );
358
  $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(group_id) FROM {$bp->groups->table_name_groupmeta} gm, {$bp->groups->table_name} g WHERE g.id = gm.group_id {$hidden_sql} AND gm.meta_key = 'last_activity' ORDER BY CONVERT(gm.meta_value, SIGNED) DESC" ) );
359
 
360
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
361
  }
362
-
363
  function get_popular( $limit = null, $page = null ) {
364
  global $wpdb, $bp;
365
-
366
  if ( $limit && $page ) {
367
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
368
  }
369
 
370
  if ( !is_site_admin() )
371
  $hidden_sql = "AND g.status != 'hidden'";
372
-
373
  $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT gm.group_id FROM {$bp->groups->table_name_groupmeta} gm, {$bp->groups->table_name} g WHERE g.id = gm.group_id {$hidden_sql} AND gm.meta_key = 'total_member_count' ORDER BY CONVERT(gm.meta_value, SIGNED) DESC {$pag_sql}" ) );
374
  $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(gm.group_id) FROM {$bp->groups->table_name_groupmeta} gm, {$bp->groups->table_name} g WHERE g.id = gm.group_id {$hidden_sql} AND gm.meta_key = 'total_member_count' ORDER BY CONVERT(gm.meta_value, SIGNED) DESC" ) );
375
 
376
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
377
  }
378
-
379
  function get_alphabetically( $limit = null, $page = null ) {
380
  global $wpdb, $bp;
381
-
382
  if ( $limit && $page )
383
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
384
-
385
  if ( !is_site_admin() )
386
  $hidden_sql = "WHERE status != 'hidden'";
387
-
388
  $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT id as group_id FROM {$bp->groups->table_name} {$hidden_sql} ORDER BY name ASC {$pag_sql}" ) );
389
  $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name} {$hidden_sql} ORDER BY name ASC", $limit ) );
390
 
391
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
392
  }
393
-
394
  function get_by_most_forum_topics( $limit = null, $page = null ) {
395
  global $wpdb, $bp, $bbdb;
396
-
397
  if ( $limit && $page ) {
398
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
399
  }
400
 
401
  $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT gm.group_id FROM {$bbdb->forums} AS f, {$bp->groups->table_name} AS g LEFT JOIN {$bp->groups->table_name_groupmeta} AS gm ON g.id = gm.group_id WHERE (gm.meta_key = 'forum_id' AND gm.meta_value = f.forum_id) AND g.status = 'public' ORDER BY f.topics DESC {$pag_sql}" ) );
402
- $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT COUNT(gm.group_id) FROM {$bbdb->forums} AS f, {$bp->groups->table_name} AS g LEFT JOIN {$bp->groups->table_name_groupmeta} AS gm ON g.id = gm.group_id WHERE (gm.meta_key = 'forum_id' AND gm.meta_value = f.forum_id) AND g.status = 'public' ORDER BY f.topics DESC" ) );
403
 
404
- return array( 'groups' => $paged_groups, 'total' => $total_groups );
405
  }
406
 
407
  function get_by_most_forum_posts( $limit = null, $page = null ) {
408
  global $wpdb, $bp, $bbdb;
409
-
410
  if ( $limit && $page ) {
411
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
412
  }
413
-
414
  $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT gm.group_id FROM {$bbdb->forums} AS f, {$bp->groups->table_name} AS g LEFT JOIN {$bp->groups->table_name_groupmeta} AS gm ON g.id = gm.group_id WHERE (gm.meta_key = 'forum_id' AND gm.meta_value = f.forum_id) AND g.status = 'public' ORDER BY f.posts DESC {$pag_sql}" ) );
415
- $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT COUNT(gm.group_id) FROM {$bbdb->forums} AS f, {$bp->groups->table_name} AS g LEFT JOIN {$bp->groups->table_name_groupmeta} AS gm ON g.id = gm.group_id WHERE (gm.meta_key = 'forum_id' AND gm.meta_value = f.forum_id) AND g.status = 'public' ORDER BY f.posts DESC" ) );
416
 
417
- return array( 'groups' => $paged_groups, 'total' => $total_groups );
418
  }
419
 
420
-
421
  function get_all( $limit = null, $page = null, $only_public = true, $sort_by = false, $order = false ) {
422
  global $wpdb, $bp;
423
-
 
 
 
 
 
424
  if ( $only_public )
425
- $public_sql = $wpdb->prepare( " WHERE g.status = 'public'" );
426
-
427
  if ( !is_site_admin() )
428
- $hidden_sql = $wpdb->prepare( " AND g.status != 'hidden'");
429
-
 
 
 
 
430
  if ( $limit && $page )
431
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
432
-
433
  if ( $sort_by && $order ) {
434
  $sort_by = $wpdb->escape( $sort_by );
435
  $order = $wpdb->escape( $order );
436
  $order_sql = "ORDER BY g.$sort_by $order";
437
-
438
  switch ( $sort_by ) {
439
  default:
440
- $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g {$public_sql} {$hidden_sql} {$order_sql} {$pag_sql}" );
441
  break;
442
  case 'members':
443
- $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g, {$bp->groups->table_name_groupmeta} gm WHERE g.id = gm.group_id AND gm.meta_key = 'total_member_count' {$hidden_sql} {$public_sql} ORDER BY CONVERT(gm.meta_value, SIGNED) {$order} {$pag_sql}" );
444
  break;
445
  case 'last_active':
446
- $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g, {$bp->groups->table_name_groupmeta} gm WHERE g.id = gm.group_id AND gm.meta_key = 'last_activity' {$hidden_sql} {$public_sql} ORDER BY CONVERT(gm.meta_value, SIGNED) {$order} {$pag_sql}" );
447
  break;
448
  }
449
  } else {
450
- $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g {$public_sql} {$hidden_sql} {$order_sql} {$pag_sql}" );
451
  }
452
-
453
  return $wpdb->get_results($sql);
454
  }
455
-
456
  function get_by_letter( $letter, $limit = null, $page = null ) {
457
  global $wpdb, $bp;
458
-
459
  if ( strlen($letter) > 1 || is_numeric($letter) || !$letter )
460
  return false;
461
-
462
  if ( !is_site_admin() )
463
  $hidden_sql = $wpdb->prepare( " AND status != 'hidden'");
464
-
465
  $letter = like_escape( $wpdb->escape( $letter ) );
466
 
467
  if ( $limit && $page ) {
468
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
469
- $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->groups->table_name} WHERE name LIKE '$letter%%' {$hidden_sql} ORDER BY name ASC" ) );
470
  }
471
-
472
  $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT id as group_id FROM {$bp->groups->table_name} WHERE name LIKE '$letter%%' {$hidden_sql} ORDER BY name ASC {$pag_sql}" ) );
473
-
474
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
475
  }
476
-
477
  function get_random( $limit = null, $page = null ) {
478
  global $wpdb, $bp;
479
 
@@ -484,27 +493,27 @@ Class BP_Groups_Group {
484
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
485
  $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT id as group_id, slug FROM {$bp->groups->table_name} WHERE status = 'public' {$hidden_sql} ORDER BY rand()" ) );
486
  }
487
-
488
- $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT id as group_id, slug FROM {$bp->groups->table_name} WHERE status = 'public' {$hidden_sql} ORDER BY rand() {$pag_sql}" ) );
489
-
490
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
491
  }
492
-
493
  function delete_all_invites( $group_id ) {
494
  global $wpdb, $bp;
495
-
496
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE group_id = %d AND invite_sent = 1", $group_id ) );
497
  }
498
-
499
  function get_global_forum_topic_count( $type ) {
500
  global $bbdb, $wpdb, $bp;
501
-
502
  if ( 'unreplied' == $type )
503
  $bp->groups->filter_sql = ' AND t.topic_posts = 1';
504
-
505
  $extra_sql = apply_filters( 'groups_total_public_forum_topic_count', $bp->groups->filter_sql, $type );
506
 
507
- return $wpdb->get_var( "SELECT count(t.topic_id) FROM {$bbdb->topics} AS t, {$bp->groups->table_name} AS g LEFT JOIN {$bp->groups->table_name_groupmeta} AS gm ON g.id = gm.group_id WHERE (gm.meta_key = 'forum_id' AND gm.meta_value = t.forum_id) AND g.status = 'public' AND t.topic_status = '0' AND t.topic_sticky != '2' {$extra_sql} " );
508
  }
509
  }
510
 
@@ -521,37 +530,37 @@ Class BP_Groups_Member {
521
  var $is_confirmed;
522
  var $comments;
523
  var $invite_sent;
524
-
525
  var $user;
526
-
527
  function bp_groups_member( $user_id = false, $group_id = false, $id = false, $populate = true ) {
528
  if ( $user_id && $group_id && !$id ) {
529
  $this->user_id = $user_id;
530
  $this->group_id = $group_id;
531
-
532
  if ( $populate )
533
  $this->populate();
534
  }
535
-
536
  if ( $id ) {
537
  $this->id = $id;
538
-
539
  if ( $populate )
540
  $this->populate();
541
- }
542
  }
543
-
544
  function populate() {
545
  global $wpdb, $bp;
546
-
547
  if ( $this->user_id && $this->group_id && !$this->id )
548
  $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d", $this->user_id, $this->group_id );
549
-
550
  if ( $this->id )
551
  $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name_members} WHERE id = %d", $this->id );
552
-
553
  $member = $wpdb->get_row($sql);
554
-
555
  if ( $member ) {
556
  $this->id = $member->id;
557
  $this->group_id = $member->group_id;
@@ -565,14 +574,14 @@ Class BP_Groups_Member {
565
  $this->is_confirmed = $member->is_confirmed;
566
  $this->comments = $member->comments;
567
  $this->invite_sent = $member->invite_sent;
568
-
569
  $this->user = new BP_Core_User( $this->user_id );
570
  }
571
  }
572
-
573
  function save() {
574
  global $wpdb, $bp;
575
-
576
  $this->user_id = apply_filters( 'groups_member_user_id_before_save', $this->user_id, $this->id );
577
  $this->group_id = apply_filters( 'groups_member_group_id_before_save', $this->group_id, $this->id );
578
  $this->inviter_id = apply_filters( 'groups_member_inviter_id_before_save', $this->inviter_id, $this->id );
@@ -584,9 +593,9 @@ Class BP_Groups_Member {
584
  $this->is_confirmed = apply_filters( 'groups_member_is_confirmed_before_save', $this->is_confirmed, $this->id );
585
  $this->comments = apply_filters( 'groups_member_comments_before_save', $this->comments, $this->id );
586
  $this->invite_sent = apply_filters( 'groups_member_invite_sent_before_save', $this->invite_sent, $this->id );
587
-
588
  do_action( 'groups_member_before_save', $this );
589
-
590
  if ( $this->id ) {
591
  $sql = $wpdb->prepare( "UPDATE {$bp->groups->table_name_members} SET inviter_id = %d, is_admin = %d, is_mod = %d, is_banned = %d, user_title = %s, date_modified = FROM_UNIXTIME(%d), is_confirmed = %d, comments = %s, invite_sent = %d WHERE id = %d", $this->inviter_id, $this->is_admin, $this->is_mod, $this->is_banned, $this->user_title, $this->date_modified, $this->is_confirmed, $this->comments, $this->invite_sent, $this->id );
592
  } else {
@@ -595,102 +604,102 @@ Class BP_Groups_Member {
595
 
596
  if ( !$wpdb->query($sql) )
597
  return false;
598
-
599
  $this->id = $wpdb->insert_id;
600
-
601
  do_action( 'groups_member_after_save', $this );
602
-
603
  return true;
604
  }
605
-
606
  function promote( $status = 'mod' ) {
607
  if ( 'mod' == $status ) {
608
  $this->is_admin = 0;
609
  $this->is_mod = 1;
610
  $this->user_title = __( 'Group Mod', 'buddypress' );
611
  }
612
-
613
  if ( 'admin' == $status ) {
614
  $this->is_admin = 1;
615
  $this->is_mod = 0;
616
  $this->user_title = __( 'Group Admin', 'buddypress' );
617
  }
618
-
619
  return $this->save();
620
  }
621
-
622
- function demote() {
623
  $this->is_mod = 0;
624
  $this->is_admin = 0;
625
  $this->user_title = false;
626
-
627
- return $this->save();
628
  }
629
-
630
  function ban() {
631
- if ( $this->is_admin )
632
  return false;
633
-
634
  $this->is_mod = 0;
635
  $this->is_banned = 1;
636
-
637
  groups_update_groupmeta( $this->group_id, 'total_member_count', ( (int) groups_get_groupmeta( $this->group_id, 'total_member_count' ) - 1 ) );
638
-
639
- return $this->save();
640
  }
641
-
642
  function unban() {
643
- if ( $this->is_admin )
644
  return false;
645
-
646
  $this->is_banned = 0;
647
 
648
  groups_update_groupmeta( $this->group_id, 'total_member_count', ( (int) groups_get_groupmeta( $this->group_id, 'total_member_count' ) + 1 ) );
649
-
650
- return $this->save();
651
  }
652
-
653
  function accept_invite() {
654
  $this->inviter_id = 0;
655
  $this->is_confirmed = 1;
656
  $this->date_modified = time();
657
  }
658
-
659
  function accept_request() {
660
  $this->is_confirmed = 1;
661
- $this->date_modified = time();
662
  }
663
-
664
  /* Static Functions */
665
 
666
  function delete( $user_id, $group_id, $check_empty = true ) {
667
  global $wpdb, $bp;
668
 
669
  $delete_result = $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d", $user_id, $group_id ) );
670
-
671
  return $delete_result;
672
  }
673
-
674
  function get_group_ids( $user_id, $limit = false, $page = false ) {
675
  global $wpdb, $bp;
676
 
677
  if ( $limit && $page )
678
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
679
-
680
  // If the user is logged in and viewing their own groups, we can show hidden and private groupss
681
  if ( bp_is_home() ) {
682
- $group_sql = $wpdb->prepare( "SELECT DISTINCT group_id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND inviter_id = 0 AND is_banned = 0{$pag_sql}", $user_id );
683
- $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(group_id) FROM {$bp->groups->table_name_members} WHERE user_id = %d AND inviter_id = 0 AND is_banned = 0", $user_id ) );
684
  } else {
685
- $group_sql = $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id AND g.status != 'hidden' AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0{$pag_sql}", $user_id );
686
- $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id AND g.status != 'hidden' AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0", $user_id ) );
687
  }
688
-
689
  $groups = $wpdb->get_col( $group_sql );
690
 
691
  return array( 'groups' => $groups, 'total' => (int) $total_groups );
692
  }
693
-
694
  function get_recently_joined( $user_id, $limit = false, $page = false, $filter = false ) {
695
  global $wpdb, $bp;
696
 
@@ -699,18 +708,18 @@ Class BP_Groups_Member {
699
 
700
  if ( $filter ) {
701
  $filter = like_escape( $wpdb->escape( $filter ) );
702
- $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )";
703
  }
704
 
705
  if ( !bp_is_home() )
706
  $hidden_sql = " AND g.status != 'hidden'";
707
-
708
- $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_confirmed = 1 ORDER BY m.date_modified DESC {$pag_sql}", $user_id ) );
709
- $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_confirmed = 1 ORDER BY m.date_modified DESC", $user_id ) );
710
 
711
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
712
  }
713
-
714
  function get_most_popular( $user_id, $limit = false, $page = false, $filter = false ) {
715
  global $wpdb, $bp;
716
 
@@ -719,249 +728,249 @@ Class BP_Groups_Member {
719
 
720
  if ( $filter ) {
721
  like_escape( $wpdb->escape( $filter ) );
722
- $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )";
723
  }
724
 
725
  if ( !bp_is_home() )
726
  $hidden_sql = " AND g.status != 'hidden'";
727
 
728
- $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_confirmed = 1 LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id AND gm.meta_key = 'total_member_count' ORDER BY CONVERT( gm.meta_value, SIGNED ) DESC {$pag_sql}", $user_id ) );
729
- $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(m.group_id) FROM {$bp->groups->table_name_members} m INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_confirmed = 1 LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id AND gm.meta_key = 'total_member_count' ORDER BY CONVERT( gm.meta_value, SIGNED ) DESC", $user_id ) );
730
-
731
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
732
  }
733
-
734
  function get_recently_active( $user_id, $limit = false, $page = false, $filter = false ) {
735
  global $wpdb, $bp;
736
-
737
  if ( $limit && $page )
738
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
739
-
740
  if ( $filter ) {
741
  $filter = like_escape( $wpdb->escape( $filter ) );
742
- $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )";
743
  }
744
 
745
  if ( !bp_is_home() )
746
  $hidden_sql = " AND g.status != 'hidden'";
747
-
748
- $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY gm.meta_value DESC {$pag_sql}", $user_id ) );
749
- $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(m.group_id) FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY gm.meta_value DESC", $user_id ) );
750
 
751
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
752
  }
753
-
754
  function get_alphabetically( $user_id, $limit = false, $page = false, $filter = false ) {
755
  global $wpdb, $bp;
756
-
757
  if ( $limit && $page )
758
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
759
 
760
  if ( $filter ) {
761
  $filter = like_escape( $wpdb->escape( $filter ) );
762
- $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )";
763
  }
764
 
765
  if ( !bp_is_home() )
766
- $hidden_sql = " AND g.status != 'hidden'";
 
 
 
767
 
768
- $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY g.name ASC {$pag_sql}", $user_id ) );
769
- $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY g.name ASC", $user_id ) );
770
-
771
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
772
  }
773
-
774
  function get_is_admin_of( $user_id, $limit = false, $page = false, $filter = false ) {
775
  global $wpdb, $bp;
776
-
777
  if ( $limit && $page )
778
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
779
 
780
  if ( $filter ) {
781
  $filter = like_escape( $wpdb->escape( $filter ) );
782
- $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )";
783
  }
784
 
785
  if ( !bp_is_home() )
786
- $hidden_sql = " AND g.status != 'hidden'";
787
-
788
- $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_admin = 1 ORDER BY date_modified ASC {$pag_sql}", $user_id ) );
789
- $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_admin = 1 ORDER BY date_modified ASC", $user_id ) );
790
-
791
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
792
  }
793
-
794
  function get_is_mod_of( $user_id, $limit = false, $page = false, $filter = false ) {
795
  global $wpdb, $bp;
796
-
797
  if ( $limit && $page )
798
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
799
 
800
  if ( $filter ) {
801
  $filter = like_escape( $wpdb->escape( $filter ) );
802
- $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )";
803
  }
804
 
805
  if ( !bp_is_home() )
806
- $hidden_sql = " AND g.status != 'hidden'";
 
 
 
807
 
808
- $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_mod = 1 ORDER BY date_modified ASC {$pag_sql}", $user_id ) );
809
- $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_mod = 1 ORDER BY date_modified ASC", $user_id ) );
810
-
811
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
812
  }
813
-
814
  function total_group_count( $user_id = false ) {
815
  global $bp, $wpdb;
816
-
817
  if ( !$user_id )
818
  $user_id = $bp->displayed_user->id;
819
-
820
  if ( bp_is_home() ) {
821
- return $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(group_id) FROM {$bp->groups->table_name_members} WHERE user_id = %d AND inviter_id = 0 AND is_banned = 0", $user_id ) );
822
  } else {
823
- return $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id AND g.status != 'hidden' AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0", $user_id ) );
824
  }
825
  }
826
-
827
  function get_invites( $user_id ) {
828
  global $wpdb, $bp;
829
-
830
  $group_ids = $wpdb->get_results( $wpdb->prepare( "SELECT group_id FROM {$bp->groups->table_name_members} WHERE user_id = %d and is_confirmed = 0 AND inviter_id != 0 AND invite_sent = 1", $user_id ) );
831
-
832
  return $group_ids;
833
  }
834
-
835
  function check_has_invite( $user_id, $group_id ) {
836
  global $wpdb, $bp;
837
-
838
  if ( !$user_id )
839
  return false;
840
-
841
- return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 0 AND inviter_id != 0 AND invite_sent = 1", $user_id, $group_id ) );
842
  }
843
-
844
  function delete_invite( $user_id, $group_id ) {
845
  global $wpdb, $bp;
846
-
847
  if ( !$user_id )
848
  return false;
849
-
850
- return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 0 AND inviter_id != 0 AND invite_sent = 1", $user_id, $group_id ) );
851
  }
852
-
853
  function check_is_admin( $user_id, $group_id ) {
854
  global $wpdb, $bp;
855
-
856
  if ( !$user_id )
857
  return false;
858
-
859
  return $wpdb->query( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_admin = 1 AND is_banned = 0", $user_id, $group_id ) );
860
  }
861
-
862
  function check_is_mod( $user_id, $group_id ) {
863
  global $wpdb, $bp;
864
-
865
  if ( !$user_id )
866
  return false;
867
-
868
  return $wpdb->query( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_mod = 1 AND is_banned = 0", $user_id, $group_id ) );
869
  }
870
-
871
  function check_is_member( $user_id, $group_id ) {
872
  global $wpdb, $bp;
873
-
874
  if ( !$user_id )
875
  return false;
876
-
877
- return $wpdb->query( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 1 AND is_banned = 0", $user_id, $group_id ) );
878
  }
879
-
880
  function check_is_banned( $user_id, $group_id ) {
881
  global $wpdb, $bp;
882
-
883
  if ( !$user_id )
884
  return false;
885
-
886
  return $wpdb->get_var( $wpdb->prepare( "SELECT is_banned FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d", $user_id, $group_id ) );
887
  }
888
-
889
  function check_for_membership_request( $user_id, $group_id ) {
890
  global $wpdb, $bp;
891
-
892
  if ( !$user_id )
893
  return false;
894
-
895
- return $wpdb->query( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 0 AND is_banned = 0 AND inviter_id = 0", $user_id, $group_id ) );
896
  }
897
-
898
  function get_random_groups( $user_id, $total_groups = 5 ) {
899
  global $wpdb, $bp;
900
-
901
  // If the user is logged in and viewing their random groups, we can show hidden and private groups
902
  if ( bp_is_home() ) {
903
  return $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT group_id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND is_confirmed = 1 AND is_banned = 0 ORDER BY rand() LIMIT $total_groups", $user_id ) );
904
  } else {
905
- return $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id AND g.status != 'hidden' AND m.user_id = %d AND m.is_confirmed = 1 AND m.is_banned = 0 ORDER BY rand() LIMIT $total_groups", $user_id ) );
906
  }
907
  }
908
-
909
  function get_group_administrator_ids( $group_id ) {
910
  global $bp, $wpdb;
911
-
912
  return $wpdb->get_results( $wpdb->prepare( "SELECT user_id, date_modified FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_admin = 1 AND is_banned = 0", $group_id ) );
913
  }
914
-
915
  function get_group_moderator_ids( $group_id ) {
916
  global $bp, $wpdb;
917
 
918
  return $wpdb->get_results( $wpdb->prepare( "SELECT user_id, date_modified FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_mod = 1 AND is_banned = 0", $group_id ) );
919
  }
920
-
921
  function get_all_membership_request_user_ids( $group_id ) {
922
  global $bp, $wpdb;
923
 
924
- return $wpdb->get_col( $wpdb->prepare( "SELECT user_id FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 0 AND inviter_id = 0", $group_id ) );
925
  }
926
-
927
  function get_all_for_group( $group_id, $limit = false, $page = false, $exclude_admins_mods = true, $exclude_banned = true ) {
928
  global $bp, $wpdb;
929
-
930
  if ( $limit && $page )
931
  $pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
932
-
933
  if ( $exclude_admins_mods )
934
  $exclude_sql = $wpdb->prepare( "AND is_admin = 0 AND is_mod = 0" );
935
-
936
  if ( $exclude_banned )
937
  $banned_sql = $wpdb->prepare( " AND is_banned = 0" );
938
-
939
  $members = $wpdb->get_results( $wpdb->prepare( "SELECT user_id, date_modified FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 1 {$banned_sql} {$exclude_sql} {$pag_sql}", $group_id ) );
940
 
941
  if ( !$members )
942
  return false;
943
-
944
- if ( !isset($pag_sql) )
945
  $total_member_count = count($members);
946
  else
947
- $total_member_count = $wpdb->get_var( $wpdb->prepare( "SELECT count(user_id) FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 1 {$banned_sql} {$exclude_sql}", $group_id ) );
948
-
949
  return array( 'members' => $members, 'count' => $total_member_count );
950
  }
951
-
952
  function delete_all_for_user( $user_id ) {
953
  global $wpdb, $bp;
954
-
955
- return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d", $user_id ) );
956
  }
957
  }
958
 
959
  /**
960
  * API for creating group extensions without having to hardcode the content into
961
- * the theme.
962
  *
963
  * This class must be extended for each group extension and the following methods overridden:
964
- *
965
  * BP_Group_Extension::widget_display(), BP_Group_Extension::display(),
966
  * BP_Group_Extension::edit_screen_save(), BP_Group_Extension::edit_screen(),
967
  * BP_Group_Extension::create_screen_save(), BP_Group_Extension::create_screen()
@@ -973,50 +982,50 @@ Class BP_Groups_Member {
973
  class BP_Group_Extension {
974
  var $name = false;
975
  var $slug = false;
976
-
977
  /* Will this extension be visible to non-members of a group? Options: public/private */
978
  var $visibility = 'public';
979
-
980
  var $create_step_position = 81;
981
  var $nav_item_position = 81;
982
-
983
  var $enable_create_step = true;
984
  var $enable_nav_item = true;
985
  var $enable_edit_item = true;
986
-
987
  var $nav_item_name = false;
988
-
989
  var $display_hook = 'groups_custom_group_boxes';
990
  var $template_file = 'plugin-template';
991
-
992
  // Methods you should override
993
-
994
  function display() {
995
  die( 'function BP_Group_Extension::display() must be over-ridden in a sub-class.' );
996
  }
997
-
998
  function widget_display() {
999
  die( 'function BP_Group_Extension::widget_display() must be over-ridden in a sub-class.' );
1000
  }
1001
-
1002
  function edit_screen() {
1003
  die( 'function BP_Group_Extension::edit_screen() must be over-ridden in a sub-class.' );
1004
  }
1005
-
1006
  function edit_screen_save() {
1007
  die( 'function BP_Group_Extension::edit_screen_save() must be over-ridden in a sub-class.' );
1008
  }
1009
-
1010
  function create_screen() {
1011
  die( 'function BP_Group_Extension::create_screen() must be over-ridden in a sub-class.' );
1012
  }
1013
-
1014
  function create_screen_save() {
1015
- die( 'function BP_Group_Extension::create_screen_save() must be over-ridden in a sub-class.' );
1016
  }
1017
-
1018
  // Private Methods
1019
-
1020
  function _register() {
1021
  global $bp;
1022
 
@@ -1026,14 +1035,14 @@ class BP_Group_Extension {
1026
 
1027
  /* Attach the group creation step display content action */
1028
  add_action( 'groups_custom_create_steps', array( &$this, 'create_screen' ) );
1029
-
1030
  /* Attach the group creation step save content action */
1031
  add_action( 'groups_create_group_step_save_' . $this->slug, array( &$this, 'create_screen_save' ) );
1032
  }
1033
-
1034
  /* Construct the admin edit tab for the new group extension */
1035
  if ( $this->enable_edit_item ) {
1036
- add_action( 'groups_admin_tabs', create_function( '$current, $group_slug', 'if ( "' . attribute_escape( $this->slug ) . '" == $current ) $selected = " class=\"current\""; echo "<li{$selected}><a href=\"' . $bp->root_domain . '/' . $bp->groups->slug . '/{$group_slug}/admin/' . attribute_escape( $this->slug ) . '\">' . attribute_escape( $this->name ) . '</a></li>";' ), 10, 2 );
1037
 
1038
  /* Catch the edit screen and forward it to the plugin template */
1039
  if ( $bp->current_component == $bp->groups->slug && 'admin' == $bp->current_action && $this->slug == $bp->action_variables[0] ) {
@@ -1041,11 +1050,11 @@ class BP_Group_Extension {
1041
  add_action( 'groups_custom_edit_steps', array( &$this, 'edit_screen' ) );
1042
 
1043
  if ( '' != locate_template( array( 'groups/single/admin.php' ), false ) ) {
1044
- bp_core_load_template( apply_filters( 'groups_template_group_admin', 'groups/single/admin' ) );
1045
  } else {
1046
  add_action( 'bp_template_content_header', create_function( '', 'echo "<ul class=\"content-header-nav\">"; bp_group_admin_tabs(); echo "</ul>";' ) );
1047
  add_action( 'bp_template_content', array( &$this, 'edit_screen' ) );
1048
- bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'plugin-template' ) );
1049
  }
1050
  }
1051
  }
@@ -1054,7 +1063,7 @@ class BP_Group_Extension {
1054
  if ( $this->visbility == 'public' || ( $this->visbility != 'public' && $bp->groups->current_group->user_has_access ) ) {
1055
  if ( $this->enable_nav_item ) {
1056
  if ( $bp->current_component == $bp->groups->slug && $bp->is_single_item )
1057
- bp_core_new_subnav_item( array( 'name' => ( !$this->nav_item_name ) ? $this->name : $this->nav_item_name, 'slug' => $this->slug, 'parent_slug' => BP_GROUPS_SLUG, 'parent_url' => bp_get_group_permalink( $bp->groups->current_group ) . '/', 'position' => $this->nav_item_position, 'item_css_id' => 'nav-' . $this->slug, 'screen_function' => array( &$this, '_display_hook' ), 'user_has_access' => $this->enable_nav_item ) );
1058
 
1059
  /* When we are viewing the extension display page, set the title and options title */
1060
  if ( $bp->current_component == $bp->groups->slug && $bp->is_single_item && $bp->current_action == $this->slug ) {
@@ -1062,13 +1071,13 @@ class BP_Group_Extension {
1062
  add_action( 'bp_template_title', create_function( '', 'echo "' . attribute_escape( $this->name ) . '";' ) );
1063
  }
1064
  }
1065
-
1066
  /* Hook the group home widget */
1067
  if ( $bp->current_component == $bp->groups->slug && $bp->is_single_item && ( !$bp->current_action || 'home' == $bp->current_action ) )
1068
  add_action( $this->display_hook, array( &$this, 'widget_display' ) );
1069
  }
1070
  }
1071
-
1072
  function _display_hook() {
1073
  add_action( 'bp_template_content', array( &$this, 'display' ) );
1074
  bp_core_load_template( $this->template_file );
@@ -1077,10 +1086,10 @@ class BP_Group_Extension {
1077
 
1078
  function bp_register_group_extension( $group_extension_class ) {
1079
  global $bp;
1080
-
1081
  if ( !class_exists( $group_extension_class ) )
1082
  return false;
1083
-
1084
  /* Register the group extension on the plugins_loaded action so we have access to all plugins */
1085
  add_action( 'plugins_loaded', create_function( '', '$extension = new ' . $group_extension_class . '; add_action( "wp", array( &$extension, "_register" ), 2 );' ) );
1086
  }
13
  var $date_created;
14
 
15
  var $user_dataset;
16
+
17
  var $admins;
18
  var $total_member_count;
19
  var $random_members;
20
  var $latest_wire_posts;
21
+
22
  function bp_groups_group( $id = null, $single = false, $get_user_dataset = true ) {
23
  if ( $id ) {
24
  $this->id = $id;
25
  $this->populate( $get_user_dataset );
26
  }
27
+
28
  if ( $single ) {
29
  $this->populate_meta();
30
  }
31
  }
32
+
33
  function populate( $get_user_dataset ) {
34
  global $wpdb, $bp;
35
 
36
  $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} WHERE id = %d", $this->id );
37
  $group = $wpdb->get_row($sql);
38
+
39
  if ( $group ) {
40
  $this->id = $group->id;
41
  $this->creator_id = $group->creator_id;
48
  $this->enable_forum = $group->enable_forum;
49
  $this->date_created = strtotime($group->date_created);
50
  $this->total_member_count = groups_get_groupmeta( $this->id, 'total_member_count' );
51
+
52
  if ( $get_user_dataset ) {
53
  $this->user_dataset = $this->get_user_dataset();
54
+
55
  //if ( !$this->total_member_count ) {
56
  $this->total_member_count = count( $this->user_dataset );
57
  groups_update_groupmeta( $this->id, 'total_member_count', $this->total_member_count );
58
  //}
59
  }
60
+ }
61
  }
62
+
63
  function populate_meta() {
64
  if ( $this->id ) {
65
  $this->admins = $this->get_administrators();
66
  $this->random_members = $this->get_random_members();
67
  }
68
  }
69
+
70
  function save() {
71
  global $wpdb, $bp;
72
+
73
  $this->creator_id = apply_filters( 'groups_group_creator_id_before_save', $this->creator_id, $this->id );
74
  $this->name = apply_filters( 'groups_group_name_before_save', $this->name, $this->id );
75
  $this->slug = apply_filters( 'groups_group_slug_before_save', $this->slug, $this->id );
81
  $this->date_created = apply_filters( 'groups_group_date_created_before_save', $this->date_created, $this->id );
82
 
83
  do_action( 'groups_group_before_save', $this );
84
+
85
  if ( $this->id ) {
86
+ $sql = $wpdb->prepare(
87
+ "UPDATE {$bp->groups->table_name} SET
88
+ creator_id = %d,
89
+ name = %s,
90
+ slug = %s,
91
+ description = %s,
92
+ news = %s,
93
+ status = %s,
94
+ enable_wire = %d,
95
+ enable_forum = %d,
96
  date_created = FROM_UNIXTIME(%d)
97
  WHERE
98
  id = %d
99
  ",
100
+ $this->creator_id,
101
+ $this->name,
102
+ $this->slug,
103
+ $this->description,
104
+ $this->news,
105
+ $this->status,
106
+ $this->enable_wire,
107
+ $this->enable_forum,
108
  $this->date_created,
109
  $this->id
110
  );
111
  } else {
112
+ $sql = $wpdb->prepare(
113
+ "INSERT INTO {$bp->groups->table_name} (
114
  creator_id,
115
  name,
116
  slug,
123
  ) VALUES (
124
  %d, %s, %s, %s, %s, %s, %d, %d, FROM_UNIXTIME(%d)
125
  )",
126
+ $this->creator_id,
127
+ $this->name,
128
+ $this->slug,
129
+ $this->description,
130
+ $this->news,
131
+ $this->status,
132
+ $this->enable_wire,
133
  $this->enable_forum,
134
  $this->date_created
135
  );
136
  }
137
+
138
  if ( false === $wpdb->query($sql) )
139
  return false;
140
+
141
  if ( !$this->id ) {
142
  $this->id = $wpdb->insert_id;
143
  }
144
 
145
  do_action( 'groups_group_after_save', $this );
146
+
147
  return true;
148
  }
149
+
150
  function get_user_dataset() {
151
  global $wpdb, $bp;
152
+
153
  return $wpdb->get_results( $wpdb->prepare( "SELECT user_id, is_admin, inviter_id, user_title, is_mod FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 1 AND is_banned = 0 ORDER BY rand()", $this->id ) );
154
  }
155
+
156
  function get_administrators() {
157
  for ( $i = 0; $i < count($this->user_dataset); $i++ ) {
158
  if ( $this->user_dataset[$i]->is_admin )
159
  $admins[] = new BP_Groups_Member( $this->user_dataset[$i]->user_id, $this->id );
160
+ }
161
+
162
  return $admins;
163
  }
164
 
165
  function get_random_members() {
166
  $total_randoms = ( $this->total_member_count > 5 ) ? 5 : $this->total_member_count;
167
+
168
  for ( $i = 0; $i < $total_randoms; $i++ ) {
169
  if ( !(int)$this->user_dataset[$i]->is_banned )
170
  $users[] = new BP_Groups_Member( $this->user_dataset[$i]->user_id, $this->id );
171
  }
172
  return $users;
173
  }
174
+
175
  function is_member() {
176
  global $bp;
177
+
178
  for ( $i = 0; $i < count($this->user_dataset); $i++ ) {
179
  if ( $this->user_dataset[$i]->user_id == $bp->loggedin_user->id ) {
180
  return true;
181
  }
182
+ }
183
+
184
  return false;
185
  }
186
+
187
  function delete() {
188
  global $wpdb, $bp;
189
+
190
  // Delete groupmeta for the group
191
  groups_delete_groupmeta( $this->id );
192
 
193
  // Modify group count usermeta for members
194
  for ( $i = 0; $i < count($this->user_dataset); $i++ ) {
195
  $user = $this->user_dataset[$i];
196
+
197
  $total_count = get_usermeta( $user->user_id, 'total_group_count' );
198
+
199
  if ( $total_count != '' ) {
200
  update_usermeta( $user->user_id, 'total_group_count', (int)$total_count - 1 );
201
  }
202
+
203
  // Now delete the group member record
204
  BP_Groups_Member::delete( $user->user_id, $this->id, false );
205
  }
206
+
207
  // Delete the wire posts for this group if the wire is installed
208
  if ( function_exists('bp_wire_install') ) {
209
  BP_Wire_Post::delete_all_for_item( $this->id, $bp->groups->table_name_wire );
210
  }
211
+
212
  // Finally remove the group entry from the DB
213
  if ( !$wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name} WHERE id = %d", $this->id ) ) )
214
  return false;
215
 
216
  return true;
217
  }
218
+
219
 
220
  /* Static Functions */
221
+
222
  function group_exists( $slug, $table_name = false ) {
223
  global $wpdb, $bp;
224
+
225
  if ( !$table_name )
226
  $table_name = $bp->groups->table_name;
227
+
228
  if ( !$slug )
229
  return false;
230
+
231
  return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$table_name} WHERE slug = %s", $slug ) );
232
  }
233
 
239
  global $wpdb, $bp;
240
  return $wpdb->get_col( $wpdb->prepare( "SELECT user_id FROM {$bp->groups->table_name_members} WHERE group_id = %d and is_confirmed = 0 AND inviter_id = %d", $group_id, $user_id ) );
241
  }
242
+
243
  function filter_user_groups( $filter, $user_id = false, $order = false, $limit = null, $page = null ) {
244
  global $wpdb, $bp;
245
+
246
  if ( !$user_id )
247
  $user_id = $bp->displayed_user->id;
248
+
249
  $filter = like_escape( $wpdb->escape( $filter ) );
250
+
251
  if ( $limit && $page )
252
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
253
+
254
  // Get all the group ids for the current user's groups.
255
  $gids = BP_Groups_Member::get_group_ids( $user_id );
256
+
257
  if ( !$gids['groups'] )
258
  return false;
259
+
260
  $gids = implode( ',', $gids['groups'] );
261
+
262
  $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT id as group_id FROM {$bp->groups->table_name} WHERE ( name LIKE '{$filter}%%' OR description LIKE '{$filter}%%' ) AND id IN ({$gids}) {$pag_sql}" ) );
263
+ $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name} WHERE ( name LIKE '{$filter}%%' OR description LIKE '{$filter}%%' ) AND id IN ({$gids})" ) );
264
+
265
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
266
  }
267
+
268
  function search_groups( $filter, $limit = null, $page = null, $sort_by = false, $order = false ) {
269
  global $wpdb, $bp;
270
+
271
  $filter = like_escape( $wpdb->escape( $filter ) );
272
+
273
  if ( $limit && $page )
274
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
275
 
278
  $order = $wpdb->escape( $order );
279
  $order_sql = "ORDER BY $sort_by $order";
280
  }
281
+
282
  if ( !is_site_admin() )
283
  $hidden_sql = "AND status != 'hidden'";
284
 
285
  $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT id as group_id FROM {$bp->groups->table_name} WHERE ( name LIKE '%%$filter%%' OR description LIKE '%%$filter%%' ) {$hidden_sql} {$order_sql} {$pag_sql}" ) );
286
+ $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name} WHERE ( name LIKE '%%$filter%%' OR description LIKE '%%$filter%%' ) {$hidden_sq}" ) );
287
+
288
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
289
  }
290
+
291
  function check_slug( $slug ) {
292
  global $wpdb, $bp;
293
+
294
+ return $wpdb->get_var( $wpdb->prepare( "SELECT slug FROM {$bp->groups->table_name} WHERE slug = %s", $slug ) );
295
  }
296
+
297
  function get_slug( $group_id ) {
298
  global $wpdb, $bp;
299
+
300
+ return $wpdb->get_var( $wpdb->prepare( "SELECT slug FROM {$bp->groups->table_name} WHERE id = %d", $group_id ) );
301
  }
302
+
303
  function has_members( $group_id ) {
304
  global $wpdb, $bp;
305
+
306
+ $members = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name_members} WHERE group_id = %d", $group_id ) );
307
 
308
  if ( !$members )
309
  return false;
310
+
311
  return true;
312
  }
313
+
314
  function has_membership_requests( $group_id ) {
315
  global $wpdb, $bp;
316
+
317
+ return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 0", $group_id ) );
318
  }
319
+
320
  function get_membership_requests( $group_id, $limit = null, $page = null ) {
321
  global $wpdb, $bp;
322
+
323
  if ( $limit && $page ) {
324
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
325
  }
326
+
327
  $paged_requests = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 0 AND inviter_id = 0{$pag_sql}", $group_id ) );
328
  $total_requests = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 0 AND inviter_id = 0", $group_id ) );
329
 
330
  return array( 'requests' => $paged_requests, 'total' => $total_requests );
331
  }
332
+
333
  function get_newest( $limit = null, $page = null ) {
334
  global $wpdb, $bp;
335
+
336
  if ( $limit && $page )
337
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
338
+
339
  if ( !is_site_admin() )
340
  $hidden_sql = "WHERE status != 'hidden'";
341
+
342
  $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT id as group_id FROM {$bp->groups->table_name} {$hidden_sql} ORDER BY date_created DESC {$pag_sql}" ) );
343
  $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name} {$hidden_sql} ORDER BY date_created DESC", $limit ) );
344
 
345
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
346
  }
347
+
348
  function get_active( $limit = null, $page = null ) {
349
  global $wpdb, $bp;
350
+
351
  if ( $limit && $page )
352
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
353
 
354
  if ( !is_site_admin() )
355
  $hidden_sql = "AND g.status != 'hidden'";
356
+
357
  $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT group_id FROM {$bp->groups->table_name_groupmeta} gm, {$bp->groups->table_name} g WHERE g.id = gm.group_id {$hidden_sql} AND gm.meta_key = 'last_activity' ORDER BY CONVERT(gm.meta_value, SIGNED) DESC {$pag_sql}" ) );
358
  $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(group_id) FROM {$bp->groups->table_name_groupmeta} gm, {$bp->groups->table_name} g WHERE g.id = gm.group_id {$hidden_sql} AND gm.meta_key = 'last_activity' ORDER BY CONVERT(gm.meta_value, SIGNED) DESC" ) );
359
 
360
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
361
  }
362
+
363
  function get_popular( $limit = null, $page = null ) {
364
  global $wpdb, $bp;
365
+
366
  if ( $limit && $page ) {
367
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
368
  }
369
 
370
  if ( !is_site_admin() )
371
  $hidden_sql = "AND g.status != 'hidden'";
372
+
373
  $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT gm.group_id FROM {$bp->groups->table_name_groupmeta} gm, {$bp->groups->table_name} g WHERE g.id = gm.group_id {$hidden_sql} AND gm.meta_key = 'total_member_count' ORDER BY CONVERT(gm.meta_value, SIGNED) DESC {$pag_sql}" ) );
374
  $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(gm.group_id) FROM {$bp->groups->table_name_groupmeta} gm, {$bp->groups->table_name} g WHERE g.id = gm.group_id {$hidden_sql} AND gm.meta_key = 'total_member_count' ORDER BY CONVERT(gm.meta_value, SIGNED) DESC" ) );
375
 
376
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
377
  }
378
+
379
  function get_alphabetically( $limit = null, $page = null ) {
380
  global $wpdb, $bp;
381
+
382
  if ( $limit && $page )
383
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
384
+
385
  if ( !is_site_admin() )
386
  $hidden_sql = "WHERE status != 'hidden'";
387
+
388
  $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT id as group_id FROM {$bp->groups->table_name} {$hidden_sql} ORDER BY name ASC {$pag_sql}" ) );
389
  $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name} {$hidden_sql} ORDER BY name ASC", $limit ) );
390
 
391
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
392
  }
393
+
394
  function get_by_most_forum_topics( $limit = null, $page = null ) {
395
  global $wpdb, $bp, $bbdb;
396
+
397
  if ( $limit && $page ) {
398
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
399
  }
400
 
401
  $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT gm.group_id FROM {$bbdb->forums} AS f, {$bp->groups->table_name} AS g LEFT JOIN {$bp->groups->table_name_groupmeta} AS gm ON g.id = gm.group_id WHERE (gm.meta_key = 'forum_id' AND gm.meta_value = f.forum_id) AND g.status = 'public' ORDER BY f.topics DESC {$pag_sql}" ) );
402
+ $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT gm.group_id) FROM {$bbdb->forums} AS f, {$bp->groups->table_name} AS g LEFT JOIN {$bp->groups->table_name_groupmeta} AS gm ON g.id = gm.group_id WHERE (gm.meta_key = 'forum_id' AND gm.meta_value = f.forum_id) AND g.status = 'public' ORDER BY f.topics DESC" ) );
403
 
404
+ return array( 'groups' => $paged_groups, 'total' => $total_groups );
405
  }
406
 
407
  function get_by_most_forum_posts( $limit = null, $page = null ) {
408
  global $wpdb, $bp, $bbdb;
409
+
410
  if ( $limit && $page ) {
411
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
412
  }
413
+
414
  $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT gm.group_id FROM {$bbdb->forums} AS f, {$bp->groups->table_name} AS g LEFT JOIN {$bp->groups->table_name_groupmeta} AS gm ON g.id = gm.group_id WHERE (gm.meta_key = 'forum_id' AND gm.meta_value = f.forum_id) AND g.status = 'public' ORDER BY f.posts DESC {$pag_sql}" ) );
415
+ $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT gm.group_id) FROM {$bbdb->forums} AS f, {$bp->groups->table_name} AS g LEFT JOIN {$bp->groups->table_name_groupmeta} AS gm ON g.id = gm.group_id WHERE (gm.meta_key = 'forum_id' AND gm.meta_value = f.forum_id) AND g.status = 'public' ORDER BY f.posts DESC" ) );
416
 
417
+ return array( 'groups' => $paged_groups, 'total' => $total_groups );
418
  }
419
 
420
+
421
  function get_all( $limit = null, $page = null, $only_public = true, $sort_by = false, $order = false ) {
422
  global $wpdb, $bp;
423
+
424
+ // Default sql WHERE conditions are blank. TODO: generic handler function.
425
+ $where_sql = null;
426
+ $where_conditions = array();
427
+
428
+ // Limit results to public status
429
  if ( $only_public )
430
+ $where_conditions[] = $wpdb->prepare( "g.status = 'public'" );
431
+
432
  if ( !is_site_admin() )
433
+ $where_conditions[] = $wpdb->prepare( "g.status != 'hidden'");
434
+
435
+ // Build where sql statement if necessary
436
+ if ( !empty( $where_conditions ) )
437
+ $where_sql = 'WHERE ' . join( ' AND ', $where_conditions );
438
+
439
  if ( $limit && $page )
440
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
441
+
442
  if ( $sort_by && $order ) {
443
  $sort_by = $wpdb->escape( $sort_by );
444
  $order = $wpdb->escape( $order );
445
  $order_sql = "ORDER BY g.$sort_by $order";
446
+
447
  switch ( $sort_by ) {
448
  default:
449
+ $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g {$where_sql} {$order_sql} {$pag_sql}" );
450
  break;
451
  case 'members':
452
+ $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g, {$bp->groups->table_name_groupmeta} gm WHERE g.id = gm.group_id AND gm.meta_key = 'total_member_count' {$hidden_sql} {$public_sql} ORDER BY CONVERT(gm.meta_value, SIGNED) {$order} {$pag_sql}" );
453
  break;
454
  case 'last_active':
455
+ $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g, {$bp->groups->table_name_groupmeta} gm WHERE g.id = gm.group_id AND gm.meta_key = 'last_activity' {$hidden_sql} {$public_sql} ORDER BY CONVERT(gm.meta_value, SIGNED) {$order} {$pag_sql}" );
456
  break;
457
  }
458
  } else {
459
+ $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g {$where_sql} {$order_sql} {$pag_sql}" );
460
  }
461
+
462
  return $wpdb->get_results($sql);
463
  }
464
+
465
  function get_by_letter( $letter, $limit = null, $page = null ) {
466
  global $wpdb, $bp;
467
+
468
  if ( strlen($letter) > 1 || is_numeric($letter) || !$letter )
469
  return false;
470
+
471
  if ( !is_site_admin() )
472
  $hidden_sql = $wpdb->prepare( " AND status != 'hidden'");
473
+
474
  $letter = like_escape( $wpdb->escape( $letter ) );
475
 
476
  if ( $limit && $page ) {
477
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
478
+ $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name} WHERE name LIKE '$letter%%' {$hidden_sql} ORDER BY name ASC" ) );
479
  }
480
+
481
  $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT id as group_id FROM {$bp->groups->table_name} WHERE name LIKE '$letter%%' {$hidden_sql} ORDER BY name ASC {$pag_sql}" ) );
482
+
483
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
484
  }
485
+
486
  function get_random( $limit = null, $page = null ) {
487
  global $wpdb, $bp;
488
 
493
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
494
  $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT id as group_id, slug FROM {$bp->groups->table_name} WHERE status = 'public' {$hidden_sql} ORDER BY rand()" ) );
495
  }
496
+
497
+ $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT id as group_id, slug FROM {$bp->groups->table_name} WHERE status = 'public' {$hidden_sql} ORDER BY rand() {$pag_sql}" ) );
498
+
499
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
500
  }
501
+
502
  function delete_all_invites( $group_id ) {
503
  global $wpdb, $bp;
504
+
505
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE group_id = %d AND invite_sent = 1", $group_id ) );
506
  }
507
+
508
  function get_global_forum_topic_count( $type ) {
509
  global $bbdb, $wpdb, $bp;
510
+
511
  if ( 'unreplied' == $type )
512
  $bp->groups->filter_sql = ' AND t.topic_posts = 1';
513
+
514
  $extra_sql = apply_filters( 'groups_total_public_forum_topic_count', $bp->groups->filter_sql, $type );
515
 
516
+ return $wpdb->get_var( "SELECT COUNT(t.topic_id) FROM {$bbdb->topics} AS t, {$bp->groups->table_name} AS g LEFT JOIN {$bp->groups->table_name_groupmeta} AS gm ON g.id = gm.group_id WHERE (gm.meta_key = 'forum_id' AND gm.meta_value = t.forum_id) AND g.status = 'public' AND t.topic_status = '0' AND t.topic_sticky != '2' {$extra_sql} " );
517
  }
518
  }
519
 
530
  var $is_confirmed;
531
  var $comments;
532
  var $invite_sent;
533
+
534
  var $user;
535
+
536
  function bp_groups_member( $user_id = false, $group_id = false, $id = false, $populate = true ) {
537
  if ( $user_id && $group_id && !$id ) {
538
  $this->user_id = $user_id;
539
  $this->group_id = $group_id;
540
+
541
  if ( $populate )
542
  $this->populate();
543
  }
544
+
545
  if ( $id ) {
546
  $this->id = $id;
547
+
548
  if ( $populate )
549
  $this->populate();
550
+ }
551
  }
552
+
553
  function populate() {
554
  global $wpdb, $bp;
555
+
556
  if ( $this->user_id && $this->group_id && !$this->id )
557
  $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d", $this->user_id, $this->group_id );
558
+
559
  if ( $this->id )
560
  $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name_members} WHERE id = %d", $this->id );
561
+
562
  $member = $wpdb->get_row($sql);
563
+
564
  if ( $member ) {
565
  $this->id = $member->id;
566
  $this->group_id = $member->group_id;
574
  $this->is_confirmed = $member->is_confirmed;
575
  $this->comments = $member->comments;
576
  $this->invite_sent = $member->invite_sent;
577
+
578
  $this->user = new BP_Core_User( $this->user_id );
579
  }
580
  }
581
+
582
  function save() {
583
  global $wpdb, $bp;
584
+
585
  $this->user_id = apply_filters( 'groups_member_user_id_before_save', $this->user_id, $this->id );
586
  $this->group_id = apply_filters( 'groups_member_group_id_before_save', $this->group_id, $this->id );
587
  $this->inviter_id = apply_filters( 'groups_member_inviter_id_before_save', $this->inviter_id, $this->id );
593
  $this->is_confirmed = apply_filters( 'groups_member_is_confirmed_before_save', $this->is_confirmed, $this->id );
594
  $this->comments = apply_filters( 'groups_member_comments_before_save', $this->comments, $this->id );
595
  $this->invite_sent = apply_filters( 'groups_member_invite_sent_before_save', $this->invite_sent, $this->id );
596
+
597
  do_action( 'groups_member_before_save', $this );
598
+
599
  if ( $this->id ) {
600
  $sql = $wpdb->prepare( "UPDATE {$bp->groups->table_name_members} SET inviter_id = %d, is_admin = %d, is_mod = %d, is_banned = %d, user_title = %s, date_modified = FROM_UNIXTIME(%d), is_confirmed = %d, comments = %s, invite_sent = %d WHERE id = %d", $this->inviter_id, $this->is_admin, $this->is_mod, $this->is_banned, $this->user_title, $this->date_modified, $this->is_confirmed, $this->comments, $this->invite_sent, $this->id );
601
  } else {
604
 
605
  if ( !$wpdb->query($sql) )
606
  return false;
607
+
608
  $this->id = $wpdb->insert_id;
609
+
610
  do_action( 'groups_member_after_save', $this );
611
+
612
  return true;
613
  }
614
+
615
  function promote( $status = 'mod' ) {
616
  if ( 'mod' == $status ) {
617
  $this->is_admin = 0;
618
  $this->is_mod = 1;
619
  $this->user_title = __( 'Group Mod', 'buddypress' );
620
  }
621
+
622
  if ( 'admin' == $status ) {
623
  $this->is_admin = 1;
624
  $this->is_mod = 0;
625
  $this->user_title = __( 'Group Admin', 'buddypress' );
626
  }
627
+
628
  return $this->save();
629
  }
630
+
631
+ function demote() {
632
  $this->is_mod = 0;
633
  $this->is_admin = 0;
634
  $this->user_title = false;
635
+
636
+ return $this->save();
637
  }
638
+
639
  function ban() {
640
+ if ( $this->is_admin )
641
  return false;
642
+
643
  $this->is_mod = 0;
644
  $this->is_banned = 1;
645
+
646
  groups_update_groupmeta( $this->group_id, 'total_member_count', ( (int) groups_get_groupmeta( $this->group_id, 'total_member_count' ) - 1 ) );
647
+
648
+ return $this->save();
649
  }
650
+
651
  function unban() {
652
+ if ( $this->is_admin )
653
  return false;
654
+
655
  $this->is_banned = 0;
656
 
657
  groups_update_groupmeta( $this->group_id, 'total_member_count', ( (int) groups_get_groupmeta( $this->group_id, 'total_member_count' ) + 1 ) );
658
+
659
+ return $this->save();
660
  }
661
+
662
  function accept_invite() {
663
  $this->inviter_id = 0;
664
  $this->is_confirmed = 1;
665
  $this->date_modified = time();
666
  }
667
+
668
  function accept_request() {
669
  $this->is_confirmed = 1;
670
+ $this->date_modified = time();
671
  }
672
+
673
  /* Static Functions */
674
 
675
  function delete( $user_id, $group_id, $check_empty = true ) {
676
  global $wpdb, $bp;
677
 
678
  $delete_result = $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d", $user_id, $group_id ) );
679
+
680
  return $delete_result;
681
  }
682
+
683
  function get_group_ids( $user_id, $limit = false, $page = false ) {
684
  global $wpdb, $bp;
685
 
686
  if ( $limit && $page )
687
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
688
+
689
  // If the user is logged in and viewing their own groups, we can show hidden and private groupss
690
  if ( bp_is_home() ) {
691
+ $group_sql = $wpdb->prepare( "SELECT DISTINCT group_id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND inviter_id = 0 AND is_banned = 0{$pag_sql}", $user_id );
692
+ $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT group_id) FROM {$bp->groups->table_name_members} WHERE user_id = %d AND inviter_id = 0 AND is_banned = 0", $user_id ) );
693
  } else {
694
+ $group_sql = $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id AND g.status != 'hidden' AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0{$pag_sql}", $user_id );
695
+ $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id AND g.status != 'hidden' AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0", $user_id ) );
696
  }
697
+
698
  $groups = $wpdb->get_col( $group_sql );
699
 
700
  return array( 'groups' => $groups, 'total' => (int) $total_groups );
701
  }
702
+
703
  function get_recently_joined( $user_id, $limit = false, $page = false, $filter = false ) {
704
  global $wpdb, $bp;
705
 
708
 
709
  if ( $filter ) {
710
  $filter = like_escape( $wpdb->escape( $filter ) );
711
+ $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )";
712
  }
713
 
714
  if ( !bp_is_home() )
715
  $hidden_sql = " AND g.status != 'hidden'";
716
+
717
+ $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_confirmed = 1 ORDER BY m.date_modified DESC {$pag_sql}", $user_id ) );
718
+ $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_confirmed = 1 ORDER BY m.date_modified DESC", $user_id ) );
719
 
720
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
721
  }
722
+
723
  function get_most_popular( $user_id, $limit = false, $page = false, $filter = false ) {
724
  global $wpdb, $bp;
725
 
728
 
729
  if ( $filter ) {
730
  like_escape( $wpdb->escape( $filter ) );
731
+ $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )";
732
  }
733
 
734
  if ( !bp_is_home() )
735
  $hidden_sql = " AND g.status != 'hidden'";
736
 
737
+ $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_confirmed = 1 LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id AND gm.meta_key = 'total_member_count' ORDER BY CONVERT( gm.meta_value, SIGNED ) DESC {$pag_sql}", $user_id ) );
738
+ $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_confirmed = 1 LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id AND gm.meta_key = 'total_member_count' ORDER BY CONVERT( gm.meta_value, SIGNED ) DESC", $user_id ) );
739
+
740
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
741
  }
742
+
743
  function get_recently_active( $user_id, $limit = false, $page = false, $filter = false ) {
744
  global $wpdb, $bp;
745
+
746
  if ( $limit && $page )
747
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
748
+
749
  if ( $filter ) {
750
  $filter = like_escape( $wpdb->escape( $filter ) );
751
+ $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )";
752
  }
753
 
754
  if ( !bp_is_home() )
755
  $hidden_sql = " AND g.status != 'hidden'";
756
+
757
+ $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY gm.meta_value DESC {$pag_sql}", $user_id ) );
758
+ $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY gm.meta_value DESC", $user_id ) );
759
 
760
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
761
  }
762
+
763
  function get_alphabetically( $user_id, $limit = false, $page = false, $filter = false ) {
764
  global $wpdb, $bp;
765
+
766
  if ( $limit && $page )
767
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
768
 
769
  if ( $filter ) {
770
  $filter = like_escape( $wpdb->escape( $filter ) );
771
+ $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )";
772
  }
773
 
774
  if ( !bp_is_home() )
775
+ $hidden_sql = " AND g.status != 'hidden'";
776
+
777
+ $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY g.name ASC {$pag_sql}", $user_id ) );
778
+ $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY g.name ASC", $user_id ) );
779
 
 
 
 
780
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
781
  }
782
+
783
  function get_is_admin_of( $user_id, $limit = false, $page = false, $filter = false ) {
784
  global $wpdb, $bp;
785
+
786
  if ( $limit && $page )
787
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
788
 
789
  if ( $filter ) {
790
  $filter = like_escape( $wpdb->escape( $filter ) );
791
+ $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )";
792
  }
793
 
794
  if ( !bp_is_home() )
795
+ $hidden_sql = " AND g.status != 'hidden'";
796
+
797
+ $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_admin = 1 ORDER BY date_modified ASC {$pag_sql}", $user_id ) );
798
+ $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_admin = 1 ORDER BY date_modified ASC", $user_id ) );
799
+
800
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
801
  }
802
+
803
  function get_is_mod_of( $user_id, $limit = false, $page = false, $filter = false ) {
804
  global $wpdb, $bp;
805
+
806
  if ( $limit && $page )
807
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
808
 
809
  if ( $filter ) {
810
  $filter = like_escape( $wpdb->escape( $filter ) );
811
+ $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )";
812
  }
813
 
814
  if ( !bp_is_home() )
815
+ $hidden_sql = " AND g.status != 'hidden'";
816
+
817
+ $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_mod = 1 ORDER BY date_modified ASC {$pag_sql}", $user_id ) );
818
+ $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_mod = 1 ORDER BY date_modified ASC", $user_id ) );
819
 
 
 
 
820
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
821
  }
822
+
823
  function total_group_count( $user_id = false ) {
824
  global $bp, $wpdb;
825
+
826
  if ( !$user_id )
827
  $user_id = $bp->displayed_user->id;
828
+
829
  if ( bp_is_home() ) {
830
+ return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT group_id) FROM {$bp->groups->table_name_members} WHERE user_id = %d AND inviter_id = 0 AND is_banned = 0", $user_id ) );
831
  } else {
832
+ return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id AND g.status != 'hidden' AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0", $user_id ) );
833
  }
834
  }
835
+
836
  function get_invites( $user_id ) {
837
  global $wpdb, $bp;
838
+
839
  $group_ids = $wpdb->get_results( $wpdb->prepare( "SELECT group_id FROM {$bp->groups->table_name_members} WHERE user_id = %d and is_confirmed = 0 AND inviter_id != 0 AND invite_sent = 1", $user_id ) );
840
+
841
  return $group_ids;
842
  }
843
+
844
  function check_has_invite( $user_id, $group_id ) {
845
  global $wpdb, $bp;
846
+
847
  if ( !$user_id )
848
  return false;
849
+
850
+ return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 0 AND inviter_id != 0 AND invite_sent = 1", $user_id, $group_id ) );
851
  }
852
+
853
  function delete_invite( $user_id, $group_id ) {
854
  global $wpdb, $bp;
855
+
856
  if ( !$user_id )
857
  return false;
858
+
859
+ return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 0 AND inviter_id != 0 AND invite_sent = 1", $user_id, $group_id ) );
860
  }
861
+
862
  function check_is_admin( $user_id, $group_id ) {
863
  global $wpdb, $bp;
864
+
865
  if ( !$user_id )
866
  return false;
867
+
868
  return $wpdb->query( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_admin = 1 AND is_banned = 0", $user_id, $group_id ) );
869
  }
870
+
871
  function check_is_mod( $user_id, $group_id ) {
872
  global $wpdb, $bp;
873
+
874
  if ( !$user_id )
875
  return false;
876
+
877
  return $wpdb->query( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_mod = 1 AND is_banned = 0", $user_id, $group_id ) );
878
  }
879
+
880
  function check_is_member( $user_id, $group_id ) {
881
  global $wpdb, $bp;
882
+
883
  if ( !$user_id )
884
  return false;
885
+
886
+ return $wpdb->query( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 1 AND is_banned = 0", $user_id, $group_id ) );
887
  }
888
+
889
  function check_is_banned( $user_id, $group_id ) {
890
  global $wpdb, $bp;
891
+
892
  if ( !$user_id )
893
  return false;
894
+
895
  return $wpdb->get_var( $wpdb->prepare( "SELECT is_banned FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d", $user_id, $group_id ) );
896
  }
897
+
898
  function check_for_membership_request( $user_id, $group_id ) {
899
  global $wpdb, $bp;
900
+
901
  if ( !$user_id )
902
  return false;
903
+
904
+ return $wpdb->query( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 0 AND is_banned = 0 AND inviter_id = 0", $user_id, $group_id ) );
905
  }
906
+
907
  function get_random_groups( $user_id, $total_groups = 5 ) {
908
  global $wpdb, $bp;
909
+
910
  // If the user is logged in and viewing their random groups, we can show hidden and private groups
911
  if ( bp_is_home() ) {
912
  return $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT group_id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND is_confirmed = 1 AND is_banned = 0 ORDER BY rand() LIMIT $total_groups", $user_id ) );
913
  } else {
914
+ return $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id AND g.status != 'hidden' AND m.user_id = %d AND m.is_confirmed = 1 AND m.is_banned = 0 ORDER BY rand() LIMIT $total_groups", $user_id ) );
915
  }
916
  }
917
+
918
  function get_group_administrator_ids( $group_id ) {
919
  global $bp, $wpdb;
920
+
921
  return $wpdb->get_results( $wpdb->prepare( "SELECT user_id, date_modified FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_admin = 1 AND is_banned = 0", $group_id ) );
922
  }
923
+
924
  function get_group_moderator_ids( $group_id ) {
925
  global $bp, $wpdb;
926
 
927
  return $wpdb->get_results( $wpdb->prepare( "SELECT user_id, date_modified FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_mod = 1 AND is_banned = 0", $group_id ) );
928
  }
929
+
930
  function get_all_membership_request_user_ids( $group_id ) {
931
  global $bp, $wpdb;
932
 
933
+ return $wpdb->get_col( $wpdb->prepare( "SELECT user_id FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 0 AND inviter_id = 0", $group_id ) );
934
  }
935
+
936
  function get_all_for_group( $group_id, $limit = false, $page = false, $exclude_admins_mods = true, $exclude_banned = true ) {
937
  global $bp, $wpdb;
938
+
939
  if ( $limit && $page )
940
  $pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
941
+
942
  if ( $exclude_admins_mods )
943
  $exclude_sql = $wpdb->prepare( "AND is_admin = 0 AND is_mod = 0" );
944
+
945
  if ( $exclude_banned )
946
  $banned_sql = $wpdb->prepare( " AND is_banned = 0" );
947
+
948
  $members = $wpdb->get_results( $wpdb->prepare( "SELECT user_id, date_modified FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 1 {$banned_sql} {$exclude_sql} {$pag_sql}", $group_id ) );
949
 
950
  if ( !$members )
951
  return false;
952
+
953
+ if ( !isset($pag_sql) )
954
  $total_member_count = count($members);
955
  else
956
+ $total_member_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(user_id) FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 1 {$banned_sql} {$exclude_sql}", $group_id ) );
957
+
958
  return array( 'members' => $members, 'count' => $total_member_count );
959
  }
960
+
961
  function delete_all_for_user( $user_id ) {
962
  global $wpdb, $bp;
963
+
964
+ return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d", $user_id ) );
965
  }
966
  }
967
 
968
  /**
969
  * API for creating group extensions without having to hardcode the content into
970
+ * the theme.
971
  *
972
  * This class must be extended for each group extension and the following methods overridden:
973
+ *
974
  * BP_Group_Extension::widget_display(), BP_Group_Extension::display(),
975
  * BP_Group_Extension::edit_screen_save(), BP_Group_Extension::edit_screen(),
976
  * BP_Group_Extension::create_screen_save(), BP_Group_Extension::create_screen()
982
  class BP_Group_Extension {
983
  var $name = false;
984
  var $slug = false;
985
+
986
  /* Will this extension be visible to non-members of a group? Options: public/private */
987
  var $visibility = 'public';
988
+
989
  var $create_step_position = 81;
990
  var $nav_item_position = 81;
991
+
992
  var $enable_create_step = true;
993
  var $enable_nav_item = true;
994
  var $enable_edit_item = true;
995
+
996
  var $nav_item_name = false;
997
+
998
  var $display_hook = 'groups_custom_group_boxes';
999
  var $template_file = 'plugin-template';
1000
+
1001
  // Methods you should override
1002
+
1003
  function display() {
1004
  die( 'function BP_Group_Extension::display() must be over-ridden in a sub-class.' );
1005
  }
1006
+
1007
  function widget_display() {
1008
  die( 'function BP_Group_Extension::widget_display() must be over-ridden in a sub-class.' );
1009
  }
1010
+
1011
  function edit_screen() {
1012
  die( 'function BP_Group_Extension::edit_screen() must be over-ridden in a sub-class.' );
1013
  }
1014
+
1015
  function edit_screen_save() {
1016
  die( 'function BP_Group_Extension::edit_screen_save() must be over-ridden in a sub-class.' );
1017
  }
1018
+
1019
  function create_screen() {
1020
  die( 'function BP_Group_Extension::create_screen() must be over-ridden in a sub-class.' );
1021
  }
1022
+
1023
  function create_screen_save() {
1024
+ die( 'function BP_Group_Extension::create_screen_save() must be over-ridden in a sub-class.' );
1025
  }
1026
+
1027
  // Private Methods
1028
+
1029
  function _register() {
1030
  global $bp;
1031
 
1035
 
1036
  /* Attach the group creation step display content action */
1037
  add_action( 'groups_custom_create_steps', array( &$this, 'create_screen' ) );
1038
+
1039
  /* Attach the group creation step save content action */
1040
  add_action( 'groups_create_group_step_save_' . $this->slug, array( &$this, 'create_screen_save' ) );
1041
  }
1042
+
1043
  /* Construct the admin edit tab for the new group extension */
1044
  if ( $this->enable_edit_item ) {
1045
+ add_action( 'groups_admin_tabs', create_function( '$current, $group_slug', 'if ( "' . attribute_escape( $this->slug ) . '" == $current ) $selected = " class=\"current\""; echo "<li{$selected}><a href=\"' . $bp->root_domain . '/' . $bp->groups->slug . '/{$group_slug}/admin/' . attribute_escape( $this->slug ) . '\">' . attribute_escape( $this->name ) . '</a></li>";' ), 10, 2 );
1046
 
1047
  /* Catch the edit screen and forward it to the plugin template */
1048
  if ( $bp->current_component == $bp->groups->slug && 'admin' == $bp->current_action && $this->slug == $bp->action_variables[0] ) {
1050
  add_action( 'groups_custom_edit_steps', array( &$this, 'edit_screen' ) );
1051
 
1052
  if ( '' != locate_template( array( 'groups/single/admin.php' ), false ) ) {
1053
+ bp_core_load_template( apply_filters( 'groups_template_group_admin', 'groups/single/admin' ) );
1054
  } else {
1055
  add_action( 'bp_template_content_header', create_function( '', 'echo "<ul class=\"content-header-nav\">"; bp_group_admin_tabs(); echo "</ul>";' ) );
1056
  add_action( 'bp_template_content', array( &$this, 'edit_screen' ) );
1057
+ bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'plugin-template' ) );
1058
  }
1059
  }
1060
  }
1063
  if ( $this->visbility == 'public' || ( $this->visbility != 'public' && $bp->groups->current_group->user_has_access ) ) {
1064
  if ( $this->enable_nav_item ) {
1065
  if ( $bp->current_component == $bp->groups->slug && $bp->is_single_item )
1066
+ bp_core_new_subnav_item( array( 'name' => ( !$this->nav_item_name ) ? $this->name : $this->nav_item_name, 'slug' => $this->slug, 'parent_slug' => BP_GROUPS_SLUG, 'parent_url' => bp_get_group_permalink( $bp->groups->current_group ) . '/', 'position' => $this->nav_item_position, 'item_css_id' => 'nav-' . $this->slug, 'screen_function' => array( &$this, '_display_hook' ), 'user_has_access' => $this->enable_nav_item ) );
1067
 
1068
  /* When we are viewing the extension display page, set the title and options title */
1069
  if ( $bp->current_component == $bp->groups->slug && $bp->is_single_item && $bp->current_action == $this->slug ) {
1071
  add_action( 'bp_template_title', create_function( '', 'echo "' . attribute_escape( $this->name ) . '";' ) );
1072
  }
1073
  }
1074
+
1075
  /* Hook the group home widget */
1076
  if ( $bp->current_component == $bp->groups->slug && $bp->is_single_item && ( !$bp->current_action || 'home' == $bp->current_action ) )
1077
  add_action( $this->display_hook, array( &$this, 'widget_display' ) );
1078
  }
1079
  }
1080
+
1081
  function _display_hook() {
1082
  add_action( 'bp_template_content', array( &$this, 'display' ) );
1083
  bp_core_load_template( $this->template_file );
1086
 
1087
  function bp_register_group_extension( $group_extension_class ) {
1088
  global $bp;
1089
+
1090
  if ( !class_exists( $group_extension_class ) )
1091
  return false;
1092
+
1093
  /* Register the group extension on the plugins_loaded action so we have access to all plugins */
1094
  add_action( 'plugins_loaded', create_function( '', '$extension = new ' . $group_extension_class . '; add_action( "wp", array( &$extension, "_register" ), 2 );' ) );
1095
  }
bp-groups/bp-groups-filters.php CHANGED
@@ -60,7 +60,7 @@ add_filter( 'groups_group_news_before_save', 'force_balance_tags' );
60
 
61
  function groups_add_forum_privacy_sql() {
62
  global $bp;
63
-
64
  /* Only filter the forum SQL on group pages or on the forums directory */
65
  if ( ( $bp->groups->current_group && 'public' == $bp->groups->current_group->status ) || bp_is_directory() ) {
66
  add_filter( 'get_topics_fields', 'groups_add_forum_fields_sql' );
@@ -81,7 +81,7 @@ function groups_add_forum_tables_sql( $sql ) {
81
 
82
  function groups_add_forum_where_sql( $sql ) {
83
  global $bp;
84
-
85
  $bp->groups->filter_sql = ' AND ' . $sql;
86
  return "(gm.meta_key = 'forum_id' AND gm.meta_value = t.forum_id) AND g.status = 'public' AND " . $sql;
87
  }
@@ -91,13 +91,13 @@ function groups_filter_bbpress_caps( $value, $cap, $args ) {
91
 
92
  if ( is_site_admin() )
93
  return true;
94
-
95
  if ( 'add_tag_to' == $cap )
96
  if ( $bp->groups->current_group->user_has_access ) return true;
97
-
98
  if ( 'manage_forums' == $cap && is_user_logged_in() )
99
  return true;
100
-
101
  return $value;
102
  }
103
  add_filter( 'bb_current_user_can', 'groups_filter_bbpress_caps', 10, 3 );
60
 
61
  function groups_add_forum_privacy_sql() {
62
  global $bp;
63
+
64
  /* Only filter the forum SQL on group pages or on the forums directory */
65
  if ( ( $bp->groups->current_group && 'public' == $bp->groups->current_group->status ) || bp_is_directory() ) {
66
  add_filter( 'get_topics_fields', 'groups_add_forum_fields_sql' );
81
 
82
  function groups_add_forum_where_sql( $sql ) {
83
  global $bp;
84
+
85
  $bp->groups->filter_sql = ' AND ' . $sql;
86
  return "(gm.meta_key = 'forum_id' AND gm.meta_value = t.forum_id) AND g.status = 'public' AND " . $sql;
87
  }
91
 
92
  if ( is_site_admin() )
93
  return true;
94
+
95
  if ( 'add_tag_to' == $cap )
96
  if ( $bp->groups->current_group->user_has_access ) return true;
97
+
98
  if ( 'manage_forums' == $cap && is_user_logged_in() )
99
  return true;
100
+
101
  return $value;
102
  }
103
  add_filter( 'bb_current_user_can', 'groups_filter_bbpress_caps', 10, 3 );
bp-groups/bp-groups-notifications.php CHANGED
@@ -2,31 +2,31 @@
2
 
3
  function groups_notification_new_wire_post( $group_id, $wire_post_id ) {
4
  global $bp;
5
-
6
  if ( !isset( $_POST['wire-post-email-notify'] ) )
7
  return false;
8
-
9
  $wire_post = new BP_Wire_Post( $bp->groups->table_name_wire, $wire_post_id );
10
  $group = new BP_Groups_Group( $group_id, false, true );
11
-
12
  $poster_name = bp_core_get_user_displayname( $wire_post->user_id );
13
- $poster_profile_link = bp_core_get_user_domain( $wire_post->user_id );
14
 
15
  $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'New wire post on group: %s', 'buddypress' ), stripslashes( attribute_escape( $group->name ) ) );
16
 
17
  foreach ( $group->user_dataset as $user ) {
18
  if ( 'no' == get_usermeta( $user->user_id, 'notification_groups_wire_post' ) ) continue;
19
-
20
  $ud = get_userdata( $user->user_id );
21
-
22
  // Set up and send the message
23
  $to = $ud->user_email;
24
 
25
  $wire_link = site_url( $bp->groups->slug . '/' . $group->slug . '/wire/' );
26
  $group_link = site_url( $bp->groups->slug . '/' . $group->slug . '/' );
27
- $settings_link = bp_core_get_user_domain( $user->user_id ) . 'settings/notifications/';
28
 
29
- $message = sprintf( __(
30
  '%s posted on the wire of the group "%s":
31
 
32
  "%s"
@@ -44,29 +44,29 @@ To view %s\'s profile page: %s
44
 
45
  // Send it
46
  wp_mail( $to, $subject, $message );
47
-
48
  unset( $message, $to );
49
  }
50
  }
51
 
52
  function groups_notification_group_updated( $group_id ) {
53
  global $bp;
54
-
55
  $group = new BP_Groups_Group( $group_id, false, true );
56
  $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . __( 'Group Details Updated', 'buddypress' );
57
 
58
  foreach ( $group->user_dataset as $user ) {
59
  if ( 'no' == get_usermeta( $user->user_id, 'notification_groups_group_updated' ) ) continue;
60
-
61
  $ud = get_userdata( $user->user_id );
62
-
63
  // Set up and send the message
64
  $to = $ud->user_email;
65
 
66
  $group_link = site_url( $bp->groups->slug . '/' . $group->slug );
67
- $settings_link = bp_core_get_user_domain( $user->user_id ) . 'settings/notifications/';
68
 
69
- $message = sprintf( __(
70
  'Group details for the group "%s" were updated:
71
 
72
  To view the group: %s
@@ -90,22 +90,22 @@ function groups_notification_new_membership_request( $requesting_user_id, $admin
90
 
91
  if ( 'no' == get_usermeta( $admin_id, 'notification_groups_membership_request' ) )
92
  return false;
93
-
94
  $requesting_user_name = bp_core_get_user_displayname( $requesting_user_id );
95
  $group = new BP_Groups_Group( $group_id, false, false );
96
-
97
  $ud = get_userdata($admin_id);
98
  $requesting_ud = get_userdata($requesting_user_id);
99
 
100
  $group_requests = bp_get_group_permalink( $group ) . '/admin/membership-requests';
101
  $profile_link = bp_core_get_user_domain( $requesting_user_id );
102
- $settings_link = bp_core_get_user_domain( $requesting_user_id ) . 'settings/notifications/';
103
 
104
  // Set up and send the message
105
  $to = $ud->user_email;
106
  $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'Membership request for group: %s', 'buddypress' ), stripslashes( attribute_escape( $group->name ) ) );
107
 
108
- $message = sprintf( __(
109
  '%s wants to join the group "%s".
110
 
111
  Because you are the administrator of this group, you must either accept or reject the membership request.
@@ -121,44 +121,44 @@ To view %s\'s profile: %s
121
  $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
122
 
123
  // Send it
124
- wp_mail( $to, $subject, $message );
125
  }
126
 
127
  function groups_notification_membership_request_completed( $requesting_user_id, $group_id, $accepted = true ) {
128
  global $bp;
129
-
130
  // Post a screen notification first.
131
  if ( $accepted )
132
  bp_core_add_notification( $group_id, $requesting_user_id, 'groups', 'membership_request_accepted' );
133
  else
134
  bp_core_add_notification( $group_id, $requesting_user_id, 'groups', 'membership_request_rejected' );
135
-
136
  if ( 'no' == get_usermeta( $requesting_user_id, 'notification_membership_request_completed' ) )
137
  return false;
138
-
139
  $group = new BP_Groups_Group( $group_id, false, false );
140
-
141
  $ud = get_userdata($requesting_user_id);
142
 
143
  $group_link = bp_get_group_permalink( $group );
144
- $settings_link = bp_core_get_user_domain( $requesting_user_id ) . 'settings/notifications/';
145
 
146
  // Set up and send the message
147
  $to = $ud->user_email;
148
-
149
  if ( $accepted ) {
150
  $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'Membership request for group "%s" accepted', 'buddypress' ), stripslashes( attribute_escape( $group->name ) ) );
151
- $message = sprintf( __(
152
  'Your membership request for the group "%s" has been accepted.
153
 
154
  To view the group please login and visit: %s
155
 
156
  ---------------------
157
  ', 'buddypress' ), stripslashes( attribute_escape( $group->name ) ), $group_link );
158
-
159
  } else {
160
  $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'Membership request for group "%s" rejected', 'buddypress' ), stripslashes( attribute_escape( $group->name ) ) );
161
- $message = sprintf( __(
162
  'Your membership request for the group "%s" has been rejected.
163
 
164
  To submit another request please log in and visit: %s
@@ -166,11 +166,11 @@ To submit another request please log in and visit: %s
166
  ---------------------
167
  ', 'buddypress' ), stripslashes( attribute_escape( $group->name ) ), $group_link );
168
  }
169
-
170
  $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
171
 
172
  // Send it
173
- wp_mail( $to, $subject, $message );
174
  }
175
 
176
  function groups_notification_promoted_member( $user_id, $group_id ) {
@@ -183,7 +183,7 @@ function groups_notification_promoted_member( $user_id, $group_id ) {
183
  $promoted_to = __( 'a moderator', 'buddypress' );
184
  $type = 'member_promoted_to_mod';
185
  }
186
-
187
  // Post a screen notification first.
188
  bp_core_add_notification( $group_id, $user_id, 'groups', $type );
189
 
@@ -194,14 +194,14 @@ function groups_notification_promoted_member( $user_id, $group_id ) {
194
  $ud = get_userdata($user_id);
195
 
196
  $group_link = bp_get_group_permalink( $group );
197
- $settings_link = bp_core_get_user_domain( $user_id ) . 'settings/notifications/';
198
 
199
  // Set up and send the message
200
  $to = $ud->user_email;
201
 
202
  $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'You have been promoted in the group: "%s"', 'buddypress' ), stripslashes( attribute_escape( $group->name ) ) );
203
 
204
- $message = sprintf( __(
205
  'You have been promoted to %s for the group: "%s".
206
 
207
  To view the group please visit: %s
@@ -218,13 +218,13 @@ add_action( 'groups_promoted_member', 'groups_notification_promoted_member', 10,
218
 
219
  function groups_notification_group_invites( &$group, &$member, $inviter_user_id ) {
220
  global $bp;
221
-
222
  $inviter_ud = get_userdata( $inviter_user_id );
223
  $inviter_name = bp_core_get_userlink( $inviter_user_id, true, false, true );
224
  $inviter_link = bp_core_get_user_domain( $inviter_user_id );
225
-
226
  $group_link = bp_get_group_permalink( $group );
227
-
228
  if ( !$member->invite_sent ) {
229
  $invited_user_id = $member->user_id;
230
 
@@ -235,17 +235,17 @@ function groups_notification_group_invites( &$group, &$member, $inviter_user_id
235
  return false;
236
 
237
  $invited_ud = get_userdata($invited_user_id);
238
-
239
- $settings_link = bp_core_get_user_domain( $invited_user_id ) . 'settings/notifications/';
240
  $invited_link = bp_core_get_user_domain( $invited_user_id );
241
- $invites_link = $invited_link . '/' . $bp->groups->slug . '/invites';
242
 
243
  // Set up and send the message
244
  $to = $invited_ud->user_email;
245
 
246
  $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'You have an invitation to the group: "%s"', 'buddypress' ), stripslashes( attribute_escape( $group->name ) ) );
247
 
248
- $message = sprintf( __(
249
  'One of your friends %s has invited you to the group: "%s".
250
 
251
  To view your group invites visit: %s
2
 
3
  function groups_notification_new_wire_post( $group_id, $wire_post_id ) {
4
  global $bp;
5
+
6
  if ( !isset( $_POST['wire-post-email-notify'] ) )
7
  return false;
8
+
9
  $wire_post = new BP_Wire_Post( $bp->groups->table_name_wire, $wire_post_id );
10
  $group = new BP_Groups_Group( $group_id, false, true );
11
+
12
  $poster_name = bp_core_get_user_displayname( $wire_post->user_id );
13
+ $poster_profile_link = bp_core_get_user_domain( $wire_post->user_id );
14
 
15
  $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'New wire post on group: %s', 'buddypress' ), stripslashes( attribute_escape( $group->name ) ) );
16
 
17
  foreach ( $group->user_dataset as $user ) {
18
  if ( 'no' == get_usermeta( $user->user_id, 'notification_groups_wire_post' ) ) continue;
19
+
20
  $ud = get_userdata( $user->user_id );
21
+
22
  // Set up and send the message
23
  $to = $ud->user_email;
24
 
25
  $wire_link = site_url( $bp->groups->slug . '/' . $group->slug . '/wire/' );
26
  $group_link = site_url( $bp->groups->slug . '/' . $group->slug . '/' );
27
+ $settings_link = bp_core_get_user_domain( $user->user_id ) . $bp->settings->slug . '/notifications/';
28
 
29
+ $message = sprintf( __(
30
  '%s posted on the wire of the group "%s":
31
 
32
  "%s"
44
 
45
  // Send it
46
  wp_mail( $to, $subject, $message );
47
+
48
  unset( $message, $to );
49
  }
50
  }
51
 
52
  function groups_notification_group_updated( $group_id ) {
53
  global $bp;
54
+
55
  $group = new BP_Groups_Group( $group_id, false, true );
56
  $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . __( 'Group Details Updated', 'buddypress' );
57
 
58
  foreach ( $group->user_dataset as $user ) {
59
  if ( 'no' == get_usermeta( $user->user_id, 'notification_groups_group_updated' ) ) continue;
60
+
61
  $ud = get_userdata( $user->user_id );
62
+
63
  // Set up and send the message
64
  $to = $ud->user_email;
65
 
66
  $group_link = site_url( $bp->groups->slug . '/' . $group->slug );
67
+ $settings_link = bp_core_get_user_domain( $user->user_id ) . $bp->settings->slug . '/notifications/';
68
 
69
+ $message = sprintf( __(
70
  'Group details for the group "%s" were updated:
71
 
72
  To view the group: %s
90
 
91
  if ( 'no' == get_usermeta( $admin_id, 'notification_groups_membership_request' ) )
92
  return false;
93
+
94
  $requesting_user_name = bp_core_get_user_displayname( $requesting_user_id );
95
  $group = new BP_Groups_Group( $group_id, false, false );
96
+
97
  $ud = get_userdata($admin_id);
98
  $requesting_ud = get_userdata($requesting_user_id);
99
 
100
  $group_requests = bp_get_group_permalink( $group ) . '/admin/membership-requests';
101
  $profile_link = bp_core_get_user_domain( $requesting_user_id );
102
+ $settings_link = bp_core_get_user_domain( $requesting_user_id ) . $bp->settings->slug . '/notifications/';
103
 
104
  // Set up and send the message
105
  $to = $ud->user_email;
106
  $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'Membership request for group: %s', 'buddypress' ), stripslashes( attribute_escape( $group->name ) ) );
107
 
108
+ $message = sprintf( __(
109
  '%s wants to join the group "%s".
110
 
111
  Because you are the administrator of this group, you must either accept or reject the membership request.
121
  $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
122
 
123
  // Send it
124
+ wp_mail( $to, $subject, $message );
125
  }
126
 
127
  function groups_notification_membership_request_completed( $requesting_user_id, $group_id, $accepted = true ) {
128
  global $bp;
129
+
130
  // Post a screen notification first.
131
  if ( $accepted )
132
  bp_core_add_notification( $group_id, $requesting_user_id, 'groups', 'membership_request_accepted' );
133
  else
134
  bp_core_add_notification( $group_id, $requesting_user_id, 'groups', 'membership_request_rejected' );
135
+
136
  if ( 'no' == get_usermeta( $requesting_user_id, 'notification_membership_request_completed' ) )
137
  return false;
138
+
139
  $group = new BP_Groups_Group( $group_id, false, false );
140
+
141
  $ud = get_userdata($requesting_user_id);
142
 
143
  $group_link = bp_get_group_permalink( $group );
144
+ $settings_link = bp_core_get_user_domain( $requesting_user_id ) . $bp->settings->slug . '/notifications/';
145
 
146
  // Set up and send the message
147
  $to = $ud->user_email;
148
+
149
  if ( $accepted ) {
150
  $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'Membership request for group "%s" accepted', 'buddypress' ), stripslashes( attribute_escape( $group->name ) ) );
151
+ $message = sprintf( __(
152
  'Your membership request for the group "%s" has been accepted.
153
 
154
  To view the group please login and visit: %s
155
 
156
  ---------------------
157
  ', 'buddypress' ), stripslashes( attribute_escape( $group->name ) ), $group_link );
158
+
159
  } else {
160
  $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'Membership request for group "%s" rejected', 'buddypress' ), stripslashes( attribute_escape( $group->name ) ) );
161
+ $message = sprintf( __(
162
  'Your membership request for the group "%s" has been rejected.
163
 
164
  To submit another request please log in and visit: %s
166
  ---------------------
167
  ', 'buddypress' ), stripslashes( attribute_escape( $group->name ) ), $group_link );
168
  }
169
+
170
  $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
171
 
172
  // Send it
173
+ wp_mail( $to, $subject, $message );
174
  }
175
 
176
  function groups_notification_promoted_member( $user_id, $group_id ) {
183
  $promoted_to = __( 'a moderator', 'buddypress' );
184
  $type = 'member_promoted_to_mod';
185
  }
186
+
187
  // Post a screen notification first.
188
  bp_core_add_notification( $group_id, $user_id, 'groups', $type );
189
 
194
  $ud = get_userdata($user_id);
195
 
196
  $group_link = bp_get_group_permalink( $group );
197
+ $settings_link = bp_core_get_user_domain( $user_id ) . $bp->settings->slug . '/notifications/';
198
 
199
  // Set up and send the message
200
  $to = $ud->user_email;
201
 
202
  $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'You have been promoted in the group: "%s"', 'buddypress' ), stripslashes( attribute_escape( $group->name ) ) );
203
 
204
+ $message = sprintf( __(
205
  'You have been promoted to %s for the group: "%s".
206
 
207
  To view the group please visit: %s
218
 
219
  function groups_notification_group_invites( &$group, &$member, $inviter_user_id ) {
220
  global $bp;
221
+
222
  $inviter_ud = get_userdata( $inviter_user_id );
223
  $inviter_name = bp_core_get_userlink( $inviter_user_id, true, false, true );
224
  $inviter_link = bp_core_get_user_domain( $inviter_user_id );
225
+
226
  $group_link = bp_get_group_permalink( $group );
227
+
228
  if ( !$member->invite_sent ) {
229
  $invited_user_id = $member->user_id;
230
 
235
  return false;
236
 
237
  $invited_ud = get_userdata($invited_user_id);
238
+
239
+ $settings_link = bp_core_get_user_domain( $invited_user_id ) . $bp->settings->slug . '/notifications/';
240
  $invited_link = bp_core_get_user_domain( $invited_user_id );
241
+ $invites_link = $invited_link . $bp->groups->slug . '/invites';
242
 
243
  // Set up and send the message
244
  $to = $invited_ud->user_email;
245
 
246
  $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'You have an invitation to the group: "%s"', 'buddypress' ), stripslashes( attribute_escape( $group->name ) ) );
247
 
248
+ $message = sprintf( __(
249
  'One of your friends %s has invited you to the group: "%s".
250
 
251
  To view your group invites visit: %s
bp-groups/bp-groups-templatetags.php CHANGED
@@ -8,16 +8,16 @@ function bp_groups_header_tabs() {
8
  <li<?php if ( 'most-popular' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/most-popular""><?php _e( 'Most Popular', 'buddypress' ) ?></a></li>
9
  <li<?php if ( 'admin-of' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/admin-of""><?php _e( 'Administrator Of', 'buddypress' ) ?></a></li>
10
  <li<?php if ( 'mod-of' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/mod-of""><?php _e( 'Moderator Of', 'buddypress' ) ?></a></li>
11
- <li<?php if ( 'alphabetically' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/alphabetically""><?php _e( 'Alphabetically', 'buddypress' ) ?></a></li>
12
  <?php
13
  do_action( 'groups_header_tabs' );
14
  }
15
 
16
  function bp_groups_filter_title() {
17
  global $bp;
18
-
19
  $current_filter = $bp->action_variables[0];
20
-
21
  switch ( $current_filter ) {
22
  case 'recently-active': default:
23
  _e( 'Recently Active', 'buddypress' );
@@ -43,19 +43,19 @@ function bp_groups_filter_title() {
43
 
44
  function bp_is_group_admin_screen( $slug ) {
45
  global $bp;
46
-
47
  if ( $bp->current_component != BP_GROUPS_SLUG || 'admin' != $bp->current_action )
48
  return false;
49
-
50
  if ( $bp->action_variables[0] == $slug )
51
  return true;
52
-
53
  return false;
54
  }
55
 
56
  function bp_group_current_avatar() {
57
  global $bp;
58
-
59
  if ( $bp->groups->current_group->avatar_full ) { ?>
60
  <img src="<?php echo attribute_escape( $bp->groups->current_group->avatar_full ) ?>" alt="<?php _e( 'Group Avatar', 'buddypress' ) ?>" class="avatar" />
61
  <?php } else { ?>
@@ -69,7 +69,7 @@ function bp_get_group_has_avatar() {
69
 
70
  if ( !empty( $_FILES ) || !bp_core_fetch_avatar( array( 'item_id' => $bp->groups->current_group->id, 'object' => 'group', 'no_grav' => true ) ) )
71
  return false;
72
-
73
  return true;
74
  }
75
 
@@ -78,7 +78,7 @@ function bp_group_avatar_delete_link() {
78
  }
79
  function bp_get_group_avatar_delete_link() {
80
  global $bp;
81
-
82
  return apply_filters( 'bp_get_group_avatar_delete_link', wp_nonce_url( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/group-avatar/delete', 'bp_group_avatar_delete' ) );
83
  }
84
 
@@ -112,25 +112,25 @@ class BP_Groups_User_Groups_Template {
112
  var $group_count;
113
  var $groups;
114
  var $group;
115
-
116
  var $in_the_loop;
117
-
118
  var $pag_page;
119
  var $pag_num;
120
  var $pag_links;
121
  var $total_group_count;
122
-
123
  var $single_group = false;
124
-
125
  var $sort_by;
126
  var $order;
127
-
128
  function bp_groups_user_groups_template( $user_id, $type, $per_page, $max, $slug, $filter ) {
129
  global $bp;
130
-
131
  if ( !$user_id )
132
  $user_id = $bp->displayed_user->id;
133
-
134
  $this->pag_page = isset( $_REQUEST['grpage'] ) ? intval( $_REQUEST['grpage'] ) : 1;
135
  $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
136
 
@@ -140,19 +140,19 @@ class BP_Groups_User_Groups_Template {
140
  break;
141
 
142
  case 'popular':
143
- $this->groups = groups_get_most_popular_for_user( $user_id, $this->pag_num, $this->pag_page, $filter );
144
  break;
145
 
146
  case 'admin-of':
147
- $this->groups = groups_get_user_is_admin_of( $user_id, $this->pag_num, $this->pag_page, $filter );
148
- break;
149
 
150
  case 'mod-of':
151
- $this->groups = groups_get_user_is_mod_of( $user_id, $this->pag_num, $this->pag_page, $filter );
152
  break;
153
 
154
  case 'alphabetical':
155
- $this->groups = groups_get_alphabetically_for_user( $user_id, $this->pag_num, $this->pag_page, $filter );
156
  break;
157
 
158
  case 'invites':
@@ -161,7 +161,7 @@ class BP_Groups_User_Groups_Template {
161
 
162
  case 'single-group':
163
  $group = new stdClass;
164
- $group->group_id = BP_Groups_Group::get_id_from_slug($slug);
165
  $this->groups = array( $group );
166
  break;
167
 
@@ -169,7 +169,7 @@ class BP_Groups_User_Groups_Template {
169
  $this->groups = groups_get_recently_active_for_user( $user_id, $this->pag_num, $this->pag_page, $filter );
170
  break;
171
  }
172
-
173
  if ( 'invites' == $type ) {
174
  $this->total_group_count = count($this->groups);
175
  $this->group_count = count($this->groups);
@@ -209,25 +209,25 @@ class BP_Groups_User_Groups_Template {
209
  function has_groups() {
210
  if ( $this->group_count )
211
  return true;
212
-
213
  return false;
214
  }
215
-
216
  function next_group() {
217
  $this->current_group++;
218
  $this->group = $this->groups[$this->current_group];
219
-
220
  return $this->group;
221
  }
222
-
223
  function rewind_groups() {
224
  $this->current_group = -1;
225
  if ( $this->group_count > 0 ) {
226
  $this->group = $this->groups[0];
227
  }
228
  }
229
-
230
- function user_groups() {
231
  if ( $this->current_group + 1 < $this->group_count ) {
232
  return true;
233
  } elseif ( $this->current_group + 1 == $this->group_count ) {
@@ -239,13 +239,13 @@ class BP_Groups_User_Groups_Template {
239
  $this->in_the_loop = false;
240
  return false;
241
  }
242
-
243
  function the_group() {
244
  global $group;
245
 
246
  $this->in_the_loop = true;
247
  $this->group = $this->next_group();
248
-
249
  // If this is a single group then instantiate group meta when creating the object.
250
  if ( $this->single_group ) {
251
  if ( !$group = wp_cache_get( 'groups_group_' . $this->group->group_id, 'bp' ) ) {
@@ -258,9 +258,9 @@ class BP_Groups_User_Groups_Template {
258
  wp_cache_set( 'groups_group_nouserdata_' . $this->group->group_id, $group, 'bp' );
259
  }
260
  }
261
-
262
  $this->group = $group;
263
-
264
  if ( 0 == $this->current_group ) // loop has just started
265
  do_action('loop_start');
266
  }
@@ -268,7 +268,7 @@ class BP_Groups_User_Groups_Template {
268
 
269
  function bp_has_groups( $args = '' ) {
270
  global $groups_template, $bp;
271
-
272
  $defaults = array(
273
  'type' => 'active',
274
  'user_id' => false,
@@ -280,7 +280,7 @@ function bp_has_groups( $args = '' ) {
280
 
281
  $r = wp_parse_args( $args, $defaults );
282
  extract( $r, EXTR_SKIP );
283
-
284
  /* The following code will auto set parameters based on the page being viewed.
285
  * for example on example.com/members/andy/groups/my-groups/most-popular/
286
  * $type = 'most-popular'
@@ -303,10 +303,10 @@ function bp_has_groups( $args = '' ) {
303
  $type = 'single-group';
304
  $slug = $bp->groups->current_group->slug;
305
  }
306
-
307
  if ( isset( $_REQUEST['group-filter-box'] ) )
308
  $filter = $_REQUEST['group-filter-box'];
309
-
310
  $groups_template = new BP_Groups_User_Groups_Template( $user_id, $type, $per_page, $max, $slug, $filter );
311
  return apply_filters( 'bp_has_groups', $groups_template->has_groups(), &$groups_template );
312
  }
@@ -323,10 +323,10 @@ function bp_the_group() {
323
 
324
  function bp_group_is_visible( $group = false ) {
325
  global $bp, $groups_template;
326
-
327
  if ( !$group )
328
  $group =& $groups_template->group;
329
-
330
  if ( 'public' == $group->status ) {
331
  return true;
332
  } else {
@@ -334,19 +334,19 @@ function bp_group_is_visible( $group = false ) {
334
  return true;
335
  }
336
  }
337
-
338
  return false;
339
  }
340
 
341
  function bp_group_has_news( $group = false ) {
342
  global $groups_template;
343
-
344
  if ( !$group )
345
  $group =& $groups_template->group;
346
-
347
  if ( empty( $group->news ) )
348
  return false;
349
-
350
  return true;
351
  }
352
 
@@ -366,7 +366,7 @@ function bp_group_id( $deprecated = true, $deprecated2 = false ) {
366
 
367
  return apply_filters( 'bp_get_group_id', $group->id );
368
  }
369
-
370
  function bp_group_name( $deprecated = true, $deprecated2 = false ) {
371
  global $groups_template;
372
 
@@ -395,7 +395,7 @@ function bp_group_type() {
395
 
396
  if ( 'public' == $group->status ) {
397
  $type = __( "Public Group", "buddypress" );
398
- } else if ( 'hidden' == $group->status ) {
399
  $type = __( "Hidden Group", "buddypress" );
400
  } else if ( 'private' == $group->status ) {
401
  $type = __( "Private Group", "buddypress" );
@@ -403,7 +403,7 @@ function bp_group_type() {
403
  $type = ucwords( $group->status ) . ' ' . __( 'Group', 'buddypress' );
404
  }
405
 
406
- return apply_filters( 'bp_get_group_type', $type );
407
  }
408
 
409
  function bp_group_status() {
@@ -415,7 +415,7 @@ function bp_group_status() {
415
  if ( !$group )
416
  $group =& $groups_template->group;
417
 
418
- return apply_filters( 'bp_get_group_status', $group->status );
419
  }
420
 
421
  function bp_group_avatar( $args = '' ) {
@@ -430,12 +430,12 @@ function bp_group_avatar( $args = '' ) {
430
  'height' => false,
431
  'class' => 'avatar',
432
  'id' => false,
433
- 'alt' => __( 'Group avatar', 'buddypress' )
434
  );
435
 
436
  $r = wp_parse_args( $args, $defaults );
437
  extract( $r, EXTR_SKIP );
438
-
439
  /* Fetch the avatar from the folder, if not provide backwards compat. */
440
  if ( !$avatar = bp_core_fetch_avatar( array( 'item_id' => $groups_template->group->id, 'object' => 'group', 'type' => $type, 'avatar_dir' => 'group-avatars', 'alt' => $alt, 'css_id' => $id, 'class' => $class, 'width' => $width, 'height' => $height ) ) )
441
  $avatar = '<img src="' . attribute_escape( $groups_template->group->avatar_thumb ) . '" class="avatar" alt="' . attribute_escape( $groups_template->group->name ) . '" />';
@@ -461,7 +461,7 @@ function bp_group_last_active( $deprecated = true, $deprecated2 = false ) {
461
  if ( !$deprecated )
462
  return bp_get_group_last_active();
463
  else
464
- echo bp_get_group_last_active();
465
  }
466
  function bp_get_group_last_active( $group = false ) {
467
  global $groups_template;
@@ -474,10 +474,10 @@ function bp_group_last_active( $deprecated = true, $deprecated2 = false ) {
474
  if ( empty( $last_active ) ) {
475
  return __( 'not yet active', 'buddypress' );
476
  } else {
477
- return apply_filters( 'bp_get_group_last_active', bp_core_time_since( $last_active ) );
478
  }
479
  }
480
-
481
  function bp_group_permalink( $deprecated = false, $deprecated2 = true ) {
482
  if ( !$deprecated2 )
483
  return bp_get_group_permalink();
@@ -505,7 +505,7 @@ function bp_group_admin_permalink( $deprecated = true, $deprecated2 = false ) {
505
  if ( !$group )
506
  $group =& $groups_template->group;
507
 
508
- return apply_filters( 'bp_get_group_admin_permalink', $bp->root_domain . '/' . $bp->groups->slug . '/' . $group->slug . '/admin' );
509
  }
510
 
511
  function bp_group_slug() {
@@ -556,7 +556,7 @@ function bp_group_description_excerpt( $deprecated = false ) {
556
  if ( !$group )
557
  $group =& $groups_template->group;
558
 
559
- return apply_filters( 'bp_get_group_description_excerpt', bp_create_excerpt( $group->description, 20 ) );
560
  }
561
 
562
  function bp_group_news( $deprecated = false ) {
@@ -598,7 +598,7 @@ function bp_group_public_status( $deprecated = false ) {
598
  return __( 'Private', 'buddypress' );
599
  }
600
  }
601
-
602
  function bp_group_is_public( $deprecated = false ) {
603
  echo bp_get_group_is_public();
604
  }
@@ -625,22 +625,22 @@ function bp_group_date_created( $deprecated = false ) {
625
 
626
  function bp_group_is_admin() {
627
  global $bp;
628
-
629
  return $bp->is_item_admin;
630
  }
631
 
632
  function bp_group_is_mod() {
633
  global $bp;
634
-
635
  return $bp->is_item_mod;
636
  }
637
 
638
  function bp_group_list_admins( $full_list = true, $group = false ) {
639
  global $groups_template;
640
-
641
  if ( !$group )
642
  $group =& $groups_template->group;
643
-
644
  if ( !$admins = &$group->admins )
645
  $admins = $group->get_administrators();
646
 
@@ -664,18 +664,18 @@ function bp_group_list_admins( $full_list = true, $group = false ) {
664
  <?php } else { ?>
665
  <span class="activity"><?php _e( 'No Admins', 'buddypress' ) ?></span>
666
  <?php } ?>
667
-
668
  <?php
669
  }
670
 
671
  function bp_group_list_mods( $full_list = true, $group = false ) {
672
  global $groups_template;
673
-
674
  if ( !$group )
675
  $group =& $groups_template->group;
676
-
677
  $group_mods = groups_get_group_mods( $group->id );
678
-
679
  if ( $group_mods ) {
680
  if ( $full_list ) { ?>
681
  <ul id="group-mods" class="mods-list">
@@ -696,7 +696,7 @@ function bp_group_list_mods( $full_list = true, $group = false ) {
696
  <?php } else { ?>
697
  <span class="activity"><?php _e( 'No Mods', 'buddypress' ) ?></span>
698
  <?php } ?>
699
-
700
  <?php
701
  }
702
 
@@ -705,7 +705,7 @@ function bp_group_all_members_permalink( $deprecated = true, $deprecated2 = fals
705
 
706
  if ( !$group )
707
  $group =& $groups_template->group;
708
-
709
  if ( !$deprecated )
710
  return bp_get_group_all_members_permalink();
711
  else
@@ -730,7 +730,7 @@ function bp_group_search_form() {
730
  <form action="<?php echo $action ?>" id="group-search-form" method="post">
731
  <label for="<?php echo $name ?>" id="<?php echo $name ?>-label"><?php echo $label ?></label>
732
  <input type="search" name="<?php echo $name ?>" id="<?php echo $name ?>" value="<?php echo $value ?>"<?php echo $disabled ?> />
733
-
734
  <?php wp_nonce_field( 'group-filter-box', '_wpnonce_group_filter' ) ?>
735
  </form>
736
  <?php
@@ -738,10 +738,10 @@ function bp_group_search_form() {
738
 
739
  function bp_group_show_no_groups_message() {
740
  global $bp;
741
-
742
  if ( !groups_total_groups_for_user( $bp->displayed_user->id ) )
743
  return true;
744
-
745
  return false;
746
  }
747
 
@@ -750,7 +750,7 @@ function bp_group_pagination() {
750
  }
751
  function bp_get_group_pagination() {
752
  global $groups_template;
753
-
754
  return apply_filters( 'bp_get_group_pagination', $groups_template->pag_links );
755
  }
756
 
@@ -761,7 +761,7 @@ function bp_group_pagination_count() {
761
  $to_num = ( $from_num + ( $groups_template->pag_num - 1 ) > $groups_template->total_group_count ) ? $groups_template->total_group_count : $from_num + ( $groups_template->pag_num - 1) ;
762
 
763
  echo sprintf( __( 'Viewing group %d to %d (of %d groups)', 'buddypress' ), $from_num, $to_num, $groups_template->total_group_count ); ?> &nbsp;
764
- <span class="ajax-loader"></span><?php
765
  }
766
 
767
  function bp_total_group_count() {
@@ -803,10 +803,10 @@ function bp_group_is_wire_enabled( $group = false ) {
803
 
804
  if ( !$group )
805
  $group =& $groups_template->group;
806
-
807
  if ( $group->enable_wire )
808
  return true;
809
-
810
  return false;
811
  }
812
 
@@ -832,14 +832,14 @@ function bp_group_is_forum_enabled( $group = false ) {
832
  if ( bp_forums_is_installed_correctly() ) {
833
  if ( $group->enable_forum )
834
  return true;
835
-
836
  return false;
837
  } else {
838
  return false;
839
  }
840
  }
841
-
842
- return false;
843
  }
844
 
845
  function bp_group_show_forum_setting( $group = false ) {
@@ -847,7 +847,7 @@ function bp_group_show_forum_setting( $group = false ) {
847
 
848
  if ( !$group )
849
  $group =& $groups_template->group;
850
-
851
  if ( $group->enable_forum )
852
  echo ' checked="checked"';
853
  }
@@ -857,17 +857,17 @@ function bp_group_show_status_setting( $setting, $group = false ) {
857
 
858
  if ( !$group )
859
  $group =& $groups_template->group;
860
-
861
  if ( $setting == $group->status )
862
  echo ' checked="checked"';
863
  }
864
 
865
  function bp_group_admin_memberlist( $admin_list = false, $group = false ) {
866
  global $groups_template;
867
-
868
  if ( !$group )
869
  $group =& $groups_template->group;
870
-
871
  $admins = groups_get_group_admins( $group->id );
872
  ?>
873
  <?php if ( $admins ) { ?>
@@ -883,13 +883,13 @@ function bp_group_admin_memberlist( $admin_list = false, $group = false ) {
883
  <?php echo bp_core_fetch_avatar( array( 'item_id' => $admin->user_id, 'type' => 'thumb' ) ) ?>
884
  <h5><?php echo bp_core_get_userlink( $admin->user_id ) ?></h5>
885
  <span class="activity"><?php echo bp_core_get_last_activity( strtotime( $admin->date_modified ), __( 'joined %s ago', 'buddypress') ); ?></span>
886
-
887
  <?php if ( function_exists( 'friends_install' ) ) : ?>
888
  <div class="action">
889
  <?php bp_add_friend_button( $admin->user_id ) ?>
890
  </div>
891
  <?php endif; ?>
892
- </li>
893
  <?php } ?>
894
  <?php } ?>
895
  </ul>
@@ -901,11 +901,11 @@ function bp_group_admin_memberlist( $admin_list = false, $group = false ) {
901
  }
902
 
903
  function bp_group_mod_memberlist( $admin_list = false, $group = false ) {
904
- global $groups_template, $group_mods;
905
 
906
  if ( !$group )
907
  $group =& $groups_template->group;
908
-
909
  $group_mods = groups_get_group_mods( $group->id );
910
  ?>
911
  <?php if ( $group_mods ) { ?>
@@ -921,14 +921,14 @@ function bp_group_mod_memberlist( $admin_list = false, $group = false ) {
921
  <?php echo bp_core_fetch_avatar( array( 'item_id' => $mod->user_id, 'type' => 'thumb' ) ) ?>
922
  <h5><?php echo bp_core_get_userlink( $mod->user_id ) ?></h5>
923
  <span class="activity"><?php echo bp_core_get_last_activity( strtotime( $mod->date_modified ), __( 'joined %s ago', 'buddypress') ); ?></span>
924
-
925
  <?php if ( function_exists( 'friends_install' ) ) : ?>
926
  <div class="action">
927
  <?php bp_add_friend_button( $mod->user_id ) ?>
928
  </div>
929
  <?php endif; ?>
930
- </li>
931
- <?php } ?>
932
  <?php } ?>
933
  </ul>
934
  <?php } else { ?>
@@ -1000,7 +1000,7 @@ function bp_group_member_demote_link( $user_id = false, $deprecated = false ) {
1000
 
1001
  return apply_filters( 'bp_get_group_member_demote_link', wp_nonce_url( bp_get_group_permalink( $group ) . '/admin/manage-members/demote/' . $user_id, 'groups_demote_member' ) );
1002
  }
1003
-
1004
  function bp_group_member_ban_link( $user_id = false, $deprecated = false ) {
1005
  global $members_template;
1006
 
@@ -1023,19 +1023,19 @@ function bp_group_member_unban_link( $user_id = false, $deprecated = false ) {
1023
 
1024
  if ( !$user_id )
1025
  $user_id = $members_template->member->user_id;
1026
-
1027
- echo bp_get_group_member_unban_link( $user_id );
1028
  }
1029
  function bp_get_group_member_unban_link( $user_id = false, $group = false ) {
1030
  global $members_template;
1031
 
1032
  if ( !$user_id )
1033
  $user_id = $members_template->member->user_id;
1034
-
1035
  if ( !$group )
1036
  $group =& $groups_template->group;
1037
 
1038
- return apply_filters( 'bp_get_group_member_unban_link', wp_nonce_url( bp_get_group_permalink( $group ) . '/admin/manage-members/unban/' . $user_id, 'groups_unban_member' ) );
1039
  }
1040
 
1041
  function bp_group_admin_tabs( $group = false ) {
@@ -1043,13 +1043,13 @@ function bp_group_admin_tabs( $group = false ) {
1043
 
1044
  if ( !$group )
1045
  $group = ( $groups_template->group ) ? $groups_template->group : $bp->groups->current_group;
1046
-
1047
  $current_tab = $bp->action_variables[0];
1048
  ?>
1049
  <?php if ( $bp->is_item_admin || $bp->is_item_mod ) { ?>
1050
  <li<?php if ( 'edit-details' == $current_tab || empty( $current_tab ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/edit-details"><?php _e('Edit Details', 'buddypress') ?></a></li>
1051
  <?php } ?>
1052
-
1053
  <?php
1054
  if ( !$bp->is_item_admin )
1055
  return false;
@@ -1061,9 +1061,9 @@ function bp_group_admin_tabs( $group = false ) {
1061
  <?php if ( $groups_template->group->status == 'private' ) : ?>
1062
  <li<?php if ( 'membership-requests' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/membership-requests"><?php _e('Membership Requests', 'buddypress') ?></a></li>
1063
  <?php endif; ?>
1064
-
1065
  <?php do_action( 'groups_admin_tabs', $current_tab, $group->slug ) ?>
1066
-
1067
  <li<?php if ( 'delete-group' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/delete-group"><?php _e('Delete Group', 'buddypress') ?></a></li>
1068
  <?php
1069
  }
@@ -1086,7 +1086,7 @@ function bp_group_form_action( $page, $deprecated = false ) {
1086
 
1087
  return apply_filters( 'bp_group_form_action', bp_get_group_permalink( $group ) . '/' . $page );
1088
  }
1089
-
1090
  function bp_group_admin_form_action( $page = false, $deprecated = false ) {
1091
  echo bp_get_group_admin_form_action( $page );
1092
  }
@@ -1104,13 +1104,13 @@ function bp_group_admin_form_action( $page = false, $deprecated = false ) {
1104
 
1105
  function bp_group_has_requested_membership( $group = false ) {
1106
  global $bp, $groups_template;
1107
-
1108
  if ( !$group )
1109
  $group =& $groups_template->group;
1110
-
1111
  if ( groups_check_for_membership_request( $bp->loggedin_user->id, $group->id ) )
1112
  return true;
1113
-
1114
  return false;
1115
  }
1116
 
@@ -1119,10 +1119,10 @@ function bp_group_is_member( $group = false ) {
1119
 
1120
  if ( !$group )
1121
  $group =& $groups_template->group;
1122
-
1123
  if ( groups_is_user_member( $bp->loggedin_user->id, $group->id ) )
1124
  return true;
1125
-
1126
  return false;
1127
  }
1128
 
@@ -1135,7 +1135,7 @@ function bp_group_accept_invite_link( $deprecated = false ) {
1135
  if ( !$group )
1136
  $group =& $groups_template->group;
1137
 
1138
- return apply_filters( 'bp_get_group_accept_invite_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->groups->slug . '/invites/accept/' . $group->id, 'groups_accept_invite' ) );
1139
  }
1140
 
1141
  function bp_group_reject_invite_link( $deprecated = false ) {
@@ -1159,7 +1159,7 @@ function bp_group_leave_confirm_link( $deprecated = false ) {
1159
  if ( !$group )
1160
  $group =& $groups_template->group;
1161
 
1162
- return apply_filters( 'bp_group_leave_confirm_link', wp_nonce_url( bp_get_group_permalink( $group ) . '/leave-group/yes', 'groups_leave_group' ) );
1163
  }
1164
 
1165
  function bp_group_leave_reject_link( $deprecated = false ) {
@@ -1188,71 +1188,71 @@ function bp_group_send_invite_form_action( $deprecated = false ) {
1188
 
1189
  function bp_has_friends_to_invite( $group = false ) {
1190
  global $groups_template, $bp;
1191
-
1192
  if ( !function_exists('friends_install') )
1193
  return false;
1194
 
1195
  if ( !$group )
1196
  $group =& $groups_template->group;
1197
-
1198
  if ( !friends_check_user_has_friends( $bp->loggedin_user->id ) || !friends_count_invitable_friends( $bp->loggedin_user->id, $group->id ) )
1199
  return false;
1200
-
1201
  return true;
1202
  }
1203
 
1204
  function bp_group_join_button( $group = false ) {
1205
  global $bp, $groups_template;
1206
-
1207
  if ( !$group )
1208
  $group =& $groups_template->group;
1209
-
1210
  // If they're not logged in or are banned from the group, no join button.
1211
  if ( !is_user_logged_in() || groups_is_user_banned( $bp->loggedin_user->id, $group->id ) )
1212
  return false;
1213
 
1214
  if ( !$group->status )
1215
  return false;
1216
-
1217
  echo '<div class="generic-button group-button ' . $group->status . '" id="groupbutton-' . $group->id . '">';
1218
-
1219
  switch ( $group->status ) {
1220
  case 'public':
1221
  if ( BP_Groups_Member::check_is_member( $bp->loggedin_user->id, $group->id ) )
1222
- echo '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>';
1223
  else
1224
- echo '<a class="join-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/join', 'groups_join_group' ) . '">' . __( 'Join Group', 'buddypress' ) . '</a>';
1225
  break;
1226
-
1227
  case 'private':
1228
  if ( BP_Groups_Member::check_is_member( $bp->loggedin_user->id, $group->id ) ) {
1229
- echo '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>';
1230
  } else {
1231
  if ( !bp_group_has_requested_membership( $group ) )
1232
- echo '<a class="request-membership" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/request-membership', 'groups_request_membership' ) . '">' . __('Request Membership', 'buddypress') . '</a>';
1233
  else
1234
- echo '<a class="membership-requested" href="' . bp_get_group_permalink( $group ) . '">' . __( 'Request Sent', 'buddypress' ) . '</a>';
1235
  }
1236
  break;
1237
  }
1238
-
1239
  echo '</div>';
1240
  }
1241
 
1242
  function bp_group_status_message( $group = false ) {
1243
  global $groups_template;
1244
-
1245
  if ( !$group )
1246
  $group =& $groups_template->group;
1247
-
1248
  if ( 'private' == $group->status ) {
1249
  if ( !bp_group_has_requested_membership() )
1250
  if ( is_user_logged_in() )
1251
  _e( 'This is a private group and you must request group membership in order to join.', 'buddypress' );
1252
  else
1253
  _e( 'This is a private group. To join you must be a registered site member and request group membership.', 'buddypress' );
1254
- else
1255
- _e( 'This is a private group. Your membership request is awaiting approval from the group administrator.', 'buddypress' );
1256
  } else {
1257
  _e( 'This is a hidden group and only invited members can join.', 'buddypress' );
1258
  }
@@ -1268,29 +1268,29 @@ class BP_Groups_Group_Members_Template {
1268
  var $member_count;
1269
  var $members;
1270
  var $member;
1271
-
1272
  var $in_the_loop;
1273
-
1274
  var $pag_page;
1275
  var $pag_num;
1276
  var $pag_links;
1277
  var $total_group_count;
1278
-
1279
  function bp_groups_group_members_template( $group_id, $per_page, $max, $exclude_admins_mods, $exclude_banned ) {
1280
  global $bp;
1281
-
1282
  $this->pag_page = isset( $_REQUEST['mlpage'] ) ? intval( $_REQUEST['mlpage'] ) : 1;
1283
  $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
1284
-
1285
  $this->members = BP_Groups_Member::get_all_for_group( $group_id, $this->pag_num, $this->pag_page, $exclude_admins_mods, $exclude_banned );
1286
-
1287
  if ( !$max || $max >= (int)$this->members['count'] )
1288
  $this->total_member_count = (int)$this->members['count'];
1289
  else
1290
  $this->total_member_count = (int)$max;
1291
 
1292
  $this->members = $this->members['members'];
1293
-
1294
  if ( $max ) {
1295
  if ( $max >= count($this->members) )
1296
  $this->member_count = count($this->members);
@@ -1310,29 +1310,29 @@ class BP_Groups_Group_Members_Template {
1310
  'mid_size' => 1
1311
  ));
1312
  }
1313
-
1314
  function has_members() {
1315
  if ( $this->member_count )
1316
  return true;
1317
 
1318
  return false;
1319
  }
1320
-
1321
  function next_member() {
1322
  $this->current_member++;
1323
  $this->member = $this->members[$this->current_member];
1324
-
1325
  return $this->member;
1326
  }
1327
-
1328
  function rewind_members() {
1329
  $this->current_member = -1;
1330
  if ( $this->member_count > 0 ) {
1331
  $this->member = $this->members[0];
1332
  }
1333
  }
1334
-
1335
- function members() {
1336
  if ( $this->current_member + 1 < $this->member_count ) {
1337
  return true;
1338
  } elseif ( $this->current_member + 1 == $this->member_count ) {
@@ -1344,7 +1344,7 @@ class BP_Groups_Group_Members_Template {
1344
  $this->in_the_loop = false;
1345
  return false;
1346
  }
1347
-
1348
  function the_member() {
1349
  global $member;
1350
 
@@ -1358,7 +1358,7 @@ class BP_Groups_Group_Members_Template {
1358
 
1359
  function bp_group_has_members( $args = '' ) {
1360
  global $bp, $members_template;
1361
-
1362
  $defaults = array(
1363
  'group_id' => $bp->groups->current_group->id,
1364
  'per_page' => 10,
@@ -1376,13 +1376,13 @@ function bp_group_has_members( $args = '' ) {
1376
 
1377
  function bp_group_members() {
1378
  global $members_template;
1379
-
1380
  return $members_template->members();
1381
  }
1382
 
1383
  function bp_group_the_member() {
1384
  global $members_template;
1385
-
1386
  return $members_template->the_member();
1387
  }
1388
 
@@ -1439,7 +1439,7 @@ function bp_group_member_link() {
1439
 
1440
  return apply_filters( 'bp_get_group_member_link', bp_core_get_userlink( $members_template->member->user_id ) );
1441
  }
1442
-
1443
  function bp_group_member_is_banned() {
1444
  echo bp_get_group_member_is_banned();
1445
  }
@@ -1457,7 +1457,7 @@ function bp_group_member_joined_since() {
1457
 
1458
  return apply_filters( 'bp_get_group_member_joined_since', bp_core_get_last_activity( strtotime( $members_template->member->date_modified ), __( 'joined %s ago', 'buddypress') ) );
1459
  }
1460
-
1461
  function bp_group_member_id() {
1462
  echo bp_get_group_member_id();
1463
  }
@@ -1472,7 +1472,7 @@ function bp_group_member_needs_pagination() {
1472
 
1473
  if ( $members_template->total_member_count > $members_template->pag_num )
1474
  return true;
1475
-
1476
  return false;
1477
  }
1478
 
@@ -1501,9 +1501,9 @@ function bp_group_member_pagination_count() {
1501
  global $members_template;
1502
 
1503
  $from_num = intval( ( $members_template->pag_page - 1 ) * $members_template->pag_num ) + 1;
1504
- $to_num = ( $from_num + ( $members_template->pag_num - 1 ) > $members_template->total_member_count ) ? $members_template->total_member_count : $from_num + ( $members_template->pag_num - 1 );
1505
 
1506
- return apply_filters( 'bp_get_group_member_pagination_count', sprintf( __( 'Viewing members %d to %d (of %d members)', 'buddypress' ), $from_num, $to_num, $members_template->total_member_count ) );
1507
  }
1508
 
1509
  function bp_group_member_admin_pagination() {
@@ -1512,7 +1512,7 @@ function bp_group_member_admin_pagination() {
1512
  }
1513
  function bp_get_group_member_admin_pagination() {
1514
  global $members_template;
1515
-
1516
  return $members_template->pag_links;
1517
  }
1518
 
@@ -1523,29 +1523,29 @@ function bp_group_member_admin_pagination() {
1523
 
1524
  function bp_group_creation_tabs() {
1525
  global $bp;
1526
-
1527
  if ( !is_array( $bp->groups->group_creation_steps ) )
1528
  return false;
1529
-
1530
  if ( !$bp->groups->current_create_step )
1531
  $bp->groups->current_create_step = array_shift( array_keys( $bp->groups->group_creation_steps ) );
1532
 
1533
  $counter = 1;
1534
  foreach ( $bp->groups->group_creation_steps as $slug => $step ) {
1535
  $is_enabled = bp_are_previous_group_creation_steps_complete( $slug ); ?>
1536
-
1537
  <li<?php if ( $bp->groups->current_create_step == $slug ) : ?> class="current"<?php endif; ?>><?php if ( $is_enabled ) : ?><a href="<?php echo $bp->loggedin_user->domain . $bp->groups->slug ?>/create/step/<?php echo $slug ?>"><?php endif; ?><?php echo $counter ?>. <?php echo $step['name'] ?><?php if ( $is_enabled ) : ?></a><?php endif; ?></li><?php
1538
  $counter++;
1539
  }
1540
-
1541
  unset( $is_enabled );
1542
-
1543
  do_action( 'groups_creation_tabs' );
1544
  }
1545
 
1546
  function bp_group_creation_stage_title() {
1547
  global $bp;
1548
-
1549
  echo apply_filters( 'bp_group_creation_stage_title', '<span>&mdash; ' . $bp->groups->group_creation_steps[$bp->groups->current_create_step]['name'] . '</span>' );
1550
  }
1551
 
@@ -1554,54 +1554,54 @@ function bp_group_creation_form_action() {
1554
  }
1555
  function bp_get_group_creation_form_action() {
1556
  global $bp;
1557
-
1558
  if ( empty( $bp->action_variables[1] ) )
1559
  $bp->action_variables[1] = array_shift( array_keys( $bp->groups->group_creation_steps ) );
1560
-
1561
  return apply_filters( 'bp_get_group_creation_form_action', $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $bp->action_variables[1] );
1562
  }
1563
 
1564
  function bp_is_group_creation_step( $step_slug ) {
1565
  global $bp;
1566
-
1567
  /* Make sure we are in the groups component */
1568
  if ( $bp->current_component != BP_GROUPS_SLUG || 'create' != $bp->current_action )
1569
  return false;
1570
-
1571
  /* If this the first step, we can just accept and return true */
1572
  if ( !$bp->action_variables[1] && array_shift( array_keys( $bp->groups->group_creation_steps ) ) == $step_slug )
1573
  return true;
1574
-
1575
  /* Before allowing a user to see a group creation step we must make sure previous steps are completed */
1576
  if ( !bp_is_first_group_creation_step() ) {
1577
  if ( !bp_are_previous_group_creation_steps_complete( $step_slug ) )
1578
  return false;
1579
  }
1580
-
1581
  /* Check the current step against the step parameter */
1582
  if ( $bp->action_variables[1] == $step_slug )
1583
  return true;
1584
-
1585
  return false;
1586
  }
1587
 
1588
  function bp_is_group_creation_step_complete( $step_slugs ) {
1589
  global $bp;
1590
-
1591
  if ( !$bp->groups->completed_create_steps )
1592
  return false;
1593
 
1594
  if ( is_array( $step_slugs ) ) {
1595
  $found = true;
1596
-
1597
  foreach ( $step_slugs as $step_slug ) {
1598
  if ( !in_array( $step_slug, $bp->groups->completed_create_steps ) )
1599
  $found = false;
1600
  }
1601
-
1602
  return $found;
1603
  } else {
1604
- return in_array( $step_slugs, $bp->groups->completed_create_steps );
1605
  }
1606
 
1607
  return true;
@@ -1609,22 +1609,22 @@ function bp_is_group_creation_step_complete( $step_slugs ) {
1609
 
1610
  function bp_are_previous_group_creation_steps_complete( $step_slug ) {
1611
  global $bp;
1612
-
1613
  /* If this is the first group creation step, return true */
1614
  if ( array_shift( array_keys( $bp->groups->group_creation_steps ) ) == $step_slug )
1615
  return true;
1616
-
1617
  reset( $bp->groups->group_creation_steps );
1618
  unset( $previous_steps );
1619
-
1620
  /* Get previous steps */
1621
  foreach ( $bp->groups->group_creation_steps as $slug => $name ) {
1622
  if ( $slug == $step_slug )
1623
  break;
1624
-
1625
  $previous_steps[] = $slug;
1626
  }
1627
-
1628
  return bp_is_group_creation_step_complete( $previous_steps );
1629
  }
1630
 
@@ -1635,7 +1635,7 @@ function bp_new_group_id() {
1635
  global $bp;
1636
  return apply_filters( 'bp_get_new_group_id', $bp->groups->new_group_id );
1637
  }
1638
-
1639
  function bp_new_group_name() {
1640
  echo bp_get_new_group_name();
1641
  }
@@ -1689,19 +1689,19 @@ function bp_new_group_avatar( $args = '' ) {
1689
  }
1690
  function bp_get_new_group_avatar( $args = '' ) {
1691
  global $bp;
1692
-
1693
  $defaults = array(
1694
  'type' => 'full',
1695
  'width' => false,
1696
  'height' => false,
1697
  'class' => 'avatar',
1698
  'id' => 'avatar-crop-preview',
1699
- 'alt' => __( 'Group avatar', 'buddypress' )
1700
  );
1701
 
1702
  $r = wp_parse_args( $args, $defaults );
1703
  extract( $r, EXTR_SKIP );
1704
-
1705
  return apply_filters( 'bp_get_new_group_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->groups->current_group->id, 'object' => 'group', 'type' => $type, 'avatar_dir' => 'group-avatars', 'alt' => $alt, 'width' => $width, 'height' => $height, 'class' => $class ) ) );
1706
  }
1707
 
@@ -1710,11 +1710,11 @@ function bp_group_creation_previous_link() {
1710
  }
1711
  function bp_get_group_creation_previous_link() {
1712
  global $bp;
1713
-
1714
  foreach ( $bp->groups->group_creation_steps as $slug => $name ) {
1715
  if ( $slug == $bp->action_variables[1] )
1716
  break;
1717
-
1718
  $previous_steps[] = $slug;
1719
  }
1720
 
@@ -1723,23 +1723,23 @@ function bp_group_creation_previous_link() {
1723
 
1724
  function bp_is_last_group_creation_step() {
1725
  global $bp;
1726
-
1727
  $last_step = array_pop( array_keys( $bp->groups->group_creation_steps ) );
1728
 
1729
  if ( $last_step == $bp->groups->current_create_step )
1730
  return true;
1731
-
1732
  return false;
1733
  }
1734
 
1735
  function bp_is_first_group_creation_step() {
1736
  global $bp;
1737
-
1738
  $first_step = array_shift( array_keys( $bp->groups->group_creation_steps ) );
1739
 
1740
  if ( $first_step == $bp->groups->current_create_step )
1741
  return true;
1742
-
1743
  return false;
1744
  }
1745
 
@@ -1751,7 +1751,7 @@ function bp_new_group_invite_friend_list() {
1751
 
1752
  if ( !function_exists('friends_install') )
1753
  return false;
1754
-
1755
  $defaults = array(
1756
  'group_id' => false,
1757
  'separator' => 'li'
@@ -1759,12 +1759,12 @@ function bp_new_group_invite_friend_list() {
1759
 
1760
  $r = wp_parse_args( $args, $defaults );
1761
  extract( $r, EXTR_SKIP );
1762
-
1763
  if ( !$group_id )
1764
  $group_id = ( $bp->groups->new_group_id ) ? $bp->groups->new_group_id : $bp->groups->current_group->id;
1765
-
1766
  $friends = friends_get_friends_invite_list( $bp->loggedin_user->id, $group_id );
1767
-
1768
  if ( $friends ) {
1769
  $invites = groups_get_invites_for_group( $bp->loggedin_user->id, $group_id );
1770
 
@@ -1774,13 +1774,13 @@ function bp_new_group_invite_friend_list() {
1774
  $checked = ' checked="checked"';
1775
  } else {
1776
  $checked = '';
1777
- }
1778
  }
1779
-
1780
  $items[] = '<' . $separator . '><input' . $checked . ' type="checkbox" name="friends[]" id="f-' . $friends[$i]['id'] . '" value="' . attribute_escape( $friends[$i]['id'] ) . '" /> ' . $friends[$i]['full_name'] . '</' . $separator . '>';
1781
  }
1782
  }
1783
-
1784
  return implode( "\n", (array)$items );
1785
  }
1786
 
@@ -1793,19 +1793,19 @@ class BP_Groups_Site_Groups_Template {
1793
  var $group_count;
1794
  var $groups;
1795
  var $group;
1796
-
1797
  var $in_the_loop;
1798
-
1799
  var $pag_page;
1800
  var $pag_num;
1801
  var $pag_links;
1802
  var $total_group_count;
1803
-
1804
  function bp_groups_site_groups_template( $type, $per_page, $max ) {
1805
  global $bp;
1806
-
1807
  /* TODO: Move $_REQUEST vars out of here */
1808
-
1809
  $this->pag_page = isset( $_REQUEST['gpage'] ) ? intval( $_REQUEST['gpage'] ) : 1;
1810
  $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
1811
 
@@ -1813,46 +1813,46 @@ class BP_Groups_Site_Groups_Template {
1813
  $this->groups = BP_Groups_Group::search_groups( $_REQUEST['s'], $this->pag_num, $this->pag_page );
1814
  } else if ( isset( $_REQUEST['letter'] ) && '' != $_REQUEST['letter'] ) {
1815
  $this->groups = BP_Groups_Group::get_by_letter( $_REQUEST['letter'], $this->pag_num, $this->pag_page );
1816
-
1817
  } else {
1818
  switch ( $type ) {
1819
  case 'active': default:
1820
  $this->groups = groups_get_active( $this->pag_num, $this->pag_page );
1821
- break;
1822
 
1823
  case 'alphabetical': default:
1824
  $this->groups = groups_get_alphabetically( $this->pag_num, $this->pag_page );
1825
- break;
1826
-
1827
- case 'random':
1828
  $this->groups = groups_get_random_groups( $this->pag_num, $this->pag_page );
1829
  break;
1830
-
1831
  case 'newest':
1832
  $this->groups = groups_get_newest( $this->pag_num, $this->pag_page );
1833
  break;
1834
 
1835
  case 'popular':
1836
  $this->groups = groups_get_popular( $this->pag_num, $this->pag_page );
1837
- break;
1838
 
1839
  case 'most-forum-topics':
1840
  $this->groups = groups_get_by_most_forum_topics( $this->pag_num, $this->pag_page );
1841
  break;
1842
-
1843
  case 'most-forum-posts':
1844
  $this->groups = groups_get_by_most_forum_posts( $this->pag_num, $this->pag_page );
1845
  break;
1846
  }
1847
  }
1848
-
1849
  if ( !$max || $max >= (int)$this->groups['total'] )
1850
  $this->total_group_count = (int)$this->groups['total'];
1851
  else
1852
  $this->total_group_count = (int)$max;
1853
 
1854
  $this->groups = $this->groups['groups'];
1855
-
1856
  if ( $max ) {
1857
  if ( $max >= count($this->groups) )
1858
  $this->group_count = count($this->groups);
@@ -1861,7 +1861,7 @@ class BP_Groups_Site_Groups_Template {
1861
  } else {
1862
  $this->group_count = count($this->groups);
1863
  }
1864
-
1865
  if ( (int) $this->total_group_count && (int) $this->pag_num ) {
1866
  $this->pag_links = paginate_links( array(
1867
  'base' => add_query_arg( 'gpage', '%#%' ),
@@ -1871,32 +1871,32 @@ class BP_Groups_Site_Groups_Template {
1871
  'prev_text' => '&laquo;',
1872
  'next_text' => '&raquo;',
1873
  'mid_size' => 1
1874
- ));
1875
  }
1876
  }
1877
-
1878
  function has_groups() {
1879
  if ( $this->group_count )
1880
  return true;
1881
-
1882
  return false;
1883
  }
1884
-
1885
  function next_group() {
1886
  $this->current_group++;
1887
  $this->group = $this->groups[$this->current_group];
1888
-
1889
  return $this->group;
1890
  }
1891
-
1892
  function rewind_groups() {
1893
  $this->current_group = -1;
1894
  if ( $this->group_count > 0 ) {
1895
  $this->group = $this->groups[0];
1896
  }
1897
  }
1898
-
1899
- function groups() {
1900
  if ( $this->current_group + 1 < $this->group_count ) {
1901
  return true;
1902
  } elseif ( $this->current_group + 1 == $this->group_count ) {
@@ -1908,20 +1908,20 @@ class BP_Groups_Site_Groups_Template {
1908
  $this->in_the_loop = false;
1909
  return false;
1910
  }
1911
-
1912
  function the_group() {
1913
  global $group;
1914
 
1915
  $this->in_the_loop = true;
1916
  $this->group = $this->next_group();
1917
-
1918
  if ( !$group = wp_cache_get( 'groups_group_nouserdata_' . $this->group->group_id, 'bp' ) ) {
1919
  $group = new BP_Groups_Group( $this->group->group_id, false, false );
1920
  wp_cache_set( 'groups_group_nouserdata_' . $this->group->group_id, $group, 'bp' );
1921
  }
1922
-
1923
  $this->group = $group;
1924
-
1925
  if ( 0 == $this->current_group ) // loop has just started
1926
  do_action('loop_start');
1927
  }
@@ -1929,8 +1929,8 @@ class BP_Groups_Site_Groups_Template {
1929
 
1930
  function bp_rewind_site_groups() {
1931
  global $site_groups_template;
1932
-
1933
- $site_groups_template->rewind_groups();
1934
  }
1935
 
1936
  function bp_has_site_groups( $args = '' ) {
@@ -1944,38 +1944,38 @@ function bp_has_site_groups( $args = '' ) {
1944
 
1945
  $r = wp_parse_args( $args, $defaults );
1946
  extract( $r, EXTR_SKIP );
1947
-
1948
  // type: active ( default ) | random | newest | popular
1949
-
1950
  if ( $max ) {
1951
  if ( $per_page > $max )
1952
  $per_page = $max;
1953
  }
1954
-
1955
  $site_groups_template = new BP_Groups_Site_Groups_Template( $type, $per_page, $max );
1956
  return apply_filters( 'bp_has_site_groups', $site_groups_template->has_groups(), &$site_groups_template );
1957
  }
1958
 
1959
  function bp_site_groups() {
1960
  global $site_groups_template;
1961
-
1962
  return $site_groups_template->groups();
1963
  }
1964
 
1965
  function bp_the_site_group() {
1966
  global $site_groups_template;
1967
-
1968
  return $site_groups_template->the_group();
1969
  }
1970
 
1971
  function bp_site_groups_pagination_count() {
1972
  global $bp, $site_groups_template;
1973
-
1974
  $from_num = intval( ( $site_groups_template->pag_page - 1 ) * $site_groups_template->pag_num ) + 1;
1975
  $to_num = ( $from_num + ( $site_groups_template->pag_num - 1 ) > $site_groups_template->total_group_count ) ? $site_groups_template->total_group_count : $from_num + ( $site_groups_template->pag_num - 1) ;
1976
 
1977
  echo sprintf( __( 'Viewing group %d to %d (of %d groups)', 'buddypress' ), $from_num, $to_num, $site_groups_template->total_group_count ); ?> &nbsp;
1978
- <span class="ajax-loader"></span><?php
1979
  }
1980
 
1981
  function bp_site_groups_pagination_links() {
@@ -1983,7 +1983,7 @@ function bp_site_groups_pagination_links() {
1983
  }
1984
  function bp_get_site_groups_pagination_links() {
1985
  global $site_groups_template;
1986
-
1987
  return apply_filters( 'bp_get_site_groups_pagination_links', $site_groups_template->pag_links );
1988
  }
1989
 
@@ -1992,7 +1992,7 @@ function bp_the_site_group_id() {
1992
  }
1993
  function bp_get_the_site_group_id() {
1994
  global $site_groups_template;
1995
-
1996
  return apply_filters( 'bp_get_the_site_group_id', $site_groups_template->group->id );
1997
  }
1998
 
@@ -2010,7 +2010,7 @@ function bp_the_site_group_avatar_thumb() {
2010
  }
2011
  function bp_get_the_site_group_avatar_thumb() {
2012
  global $site_groups_template;
2013
-
2014
  return apply_filters( 'bp_get_the_site_group_avatar_thumb', bp_core_fetch_avatar( array( 'item_id' => $site_groups_template->group->id, 'object' => 'group', 'type' => 'thumb', 'avatar_dir' => 'group-avatars', 'alt' => __( 'Group Avatar', 'buddypress' ) ) ) );
2015
  }
2016
 
@@ -2028,7 +2028,7 @@ function bp_the_site_group_link() {
2028
  }
2029
  function bp_get_the_site_group_link() {
2030
  global $site_groups_template;
2031
-
2032
  return apply_filters( 'bp_get_the_site_group_link', bp_get_group_permalink( $site_groups_template->group ) );
2033
  }
2034
 
@@ -2040,7 +2040,7 @@ function bp_the_site_group_name() {
2040
 
2041
  return apply_filters( 'bp_get_the_site_group_name', bp_get_group_name( $site_groups_template->group ) );
2042
  }
2043
-
2044
 
2045
  function bp_the_site_group_last_active() {
2046
  echo bp_get_the_site_group_last_active();
@@ -2053,7 +2053,7 @@ function bp_the_site_group_last_active() {
2053
 
2054
  function bp_the_site_group_join_button() {
2055
  global $site_groups_template;
2056
-
2057
  echo bp_group_join_button( $site_groups_template->group );
2058
  }
2059
 
@@ -2063,7 +2063,7 @@ function bp_the_site_group_description() {
2063
  function bp_get_the_site_group_description() {
2064
  global $site_groups_template;
2065
 
2066
- return apply_filters( 'bp_get_the_site_group_description', bp_get_group_description( $site_groups_template->group ) );
2067
  }
2068
 
2069
  function bp_the_site_group_description_excerpt() {
@@ -2072,16 +2072,16 @@ function bp_the_site_group_description_excerpt() {
2072
  function bp_get_the_site_group_description_excerpt() {
2073
  global $site_groups_template;
2074
 
2075
- return apply_filters( 'bp_get_the_site_group_description_excerpt', bp_create_excerpt( bp_get_group_description( $site_groups_template->group, false ), 25 ) );
2076
  }
2077
 
2078
  function bp_the_site_group_date_created() {
2079
- echo bp_get_the_site_group_date_created();
2080
  }
2081
  function bp_get_the_site_group_date_created() {
2082
  global $site_groups_template;
2083
 
2084
- return apply_filters( 'bp_get_the_site_group_date_created', bp_core_time_since( $site_groups_template->group->date_created ) );
2085
  }
2086
 
2087
  function bp_the_site_group_member_count() {
@@ -2093,7 +2093,7 @@ function bp_the_site_group_member_count() {
2093
  if ( 1 == (int) $site_groups_template->group->total_member_count )
2094
  return apply_filters( 'bp_get_the_site_group_member_count', sprintf( __( '%d member', 'buddypress' ), (int) $site_groups_template->group->total_member_count ) );
2095
  else
2096
- return apply_filters( 'bp_get_the_site_group_member_count', sprintf( __( '%d members', 'buddypress' ), (int) $site_groups_template->group->total_member_count ) );
2097
  }
2098
 
2099
  function bp_the_site_group_type() {
@@ -2123,7 +2123,7 @@ function bp_the_site_group_forum_topic_count( $args = '' ) {
2123
 
2124
  if ( !function_exists( 'bp_forums_get_forum_topicpost_count' ) )
2125
  return false;
2126
-
2127
  if ( !$site_groups_template->group->forum_counts )
2128
  $site_groups_template->group->forum_counts = bp_forums_get_forum_topicpost_count( (int)$forum_id );
2129
 
@@ -2131,11 +2131,11 @@ function bp_the_site_group_forum_topic_count( $args = '' ) {
2131
  if ( 1 == (int) $site_groups_template->group->forum_counts[0]->topics )
2132
  $total_topics = sprintf( __( '%d topic', 'buddypress' ), (int) $site_groups_template->group->forum_counts[0]->topics );
2133
  else
2134
- $total_topics = sprintf( __( '%d topics', 'buddypress' ), (int) $site_groups_template->group->forum_counts[0]->topics );
2135
  } else {
2136
  $total_topics = (int) $site_groups_template->group->forum_counts[0]->topics;
2137
  }
2138
-
2139
  return apply_filters( 'bp_get_the_site_group_forum_topic_count', $total_topics, (bool)$showtext );
2140
  }
2141
 
@@ -2144,20 +2144,20 @@ function bp_the_site_group_forum_post_count( $args = '' ) {
2144
  }
2145
  function bp_get_the_site_group_forum_post_count( $args = '' ) {
2146
  global $site_groups_template;
2147
-
2148
  $defaults = array(
2149
  'showtext' => false
2150
  );
2151
 
2152
  $r = wp_parse_args( $args, $defaults );
2153
  extract( $r, EXTR_SKIP );
2154
-
2155
  if ( !$forum_id = groups_get_groupmeta( $site_groups_template->group->id, 'forum_id' ) )
2156
  return false;
2157
 
2158
  if ( !function_exists( 'bp_forums_get_forum_topicpost_count' ) )
2159
  return false;
2160
-
2161
  if ( !$site_groups_template->group->forum_counts )
2162
  $site_groups_template->group->forum_counts = bp_forums_get_forum_topicpost_count( (int)$forum_id );
2163
 
@@ -2165,11 +2165,11 @@ function bp_the_site_group_forum_post_count( $args = '' ) {
2165
  if ( 1 == (int) $site_groups_template->group->forum_counts[0]->posts )
2166
  $total_posts = sprintf( __( '%d post', 'buddypress' ), (int) $site_groups_template->group->forum_counts[0]->posts );
2167
  else
2168
- $total_posts = sprintf( __( '%d posts', 'buddypress' ), (int) $site_groups_template->group->forum_counts[0]->posts );
2169
  } else {
2170
  $total_posts = (int) $site_groups_template->group->forum_counts[0]->posts;
2171
  }
2172
-
2173
  return apply_filters( 'bp_get_the_site_group_forum_post_count', $total_posts, (bool)$showtext );
2174
  }
2175
 
@@ -2177,11 +2177,11 @@ function bp_the_site_group_hidden_fields() {
2177
  if ( isset( $_REQUEST['s'] ) ) {
2178
  echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['s'] ) . '" name="search_terms" />';
2179
  }
2180
-
2181
  if ( isset( $_REQUEST['letter'] ) ) {
2182
  echo '<input type="hidden" id="selected_letter" value="' . attribute_escape( $_REQUEST['letter'] ) . '" name="selected_letter" />';
2183
  }
2184
-
2185
  if ( isset( $_REQUEST['groups_search'] ) ) {
2186
  echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['groups_search'] ) . '" name="search_terms" />';
2187
  }
@@ -2205,21 +2205,21 @@ class BP_Groups_Membership_Requests_Template {
2205
  var $request_count;
2206
  var $requests;
2207
  var $request;
2208
-
2209
  var $in_the_loop;
2210
-
2211
  var $pag_page;
2212
  var $pag_num;
2213
  var $pag_links;
2214
  var $total_request_count;
2215
-
2216
  function bp_groups_membership_requests_template( $group_id, $per_page, $max ) {
2217
  global $bp;
2218
-
2219
  $this->pag_page = isset( $_REQUEST['mrpage'] ) ? intval( $_REQUEST['mrpage'] ) : 1;
2220
  $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
2221
-
2222
- $this->requests = BP_Groups_Group::get_membership_requests( $group_id, $this->pag_num, $this->pag_page );
2223
 
2224
  if ( !$max || $max >= (int)$this->requests['total'] )
2225
  $this->total_request_count = (int)$this->requests['total'];
@@ -2227,7 +2227,7 @@ class BP_Groups_Membership_Requests_Template {
2227
  $this->total_request_count = (int)$max;
2228
 
2229
  $this->requests = $this->requests['requests'];
2230
-
2231
  if ( $max ) {
2232
  if ( $max >= count($this->requests) )
2233
  $this->request_count = count($this->requests);
@@ -2247,29 +2247,29 @@ class BP_Groups_Membership_Requests_Template {
2247
  'mid_size' => 1
2248
  ));
2249
  }
2250
-
2251
  function has_requests() {
2252
  if ( $this->request_count )
2253
  return true;
2254
-
2255
  return false;
2256
  }
2257
-
2258
  function next_request() {
2259
  $this->current_request++;
2260
  $this->request = $this->requests[$this->current_request];
2261
-
2262
  return $this->request;
2263
  }
2264
-
2265
  function rewind_requests() {
2266
  $this->current_request = -1;
2267
  if ( $this->request_count > 0 ) {
2268
  $this->request = $this->requests[0];
2269
  }
2270
  }
2271
-
2272
- function requests() {
2273
  if ( $this->current_request + 1 < $this->request_count ) {
2274
  return true;
2275
  } elseif ( $this->current_request + 1 == $this->request_count ) {
@@ -2281,7 +2281,7 @@ class BP_Groups_Membership_Requests_Template {
2281
  $this->in_the_loop = false;
2282
  return false;
2283
  }
2284
-
2285
  function the_request() {
2286
  global $request;
2287
 
@@ -2311,49 +2311,49 @@ function bp_group_has_membership_requests( $args = '' ) {
2311
 
2312
  function bp_group_membership_requests() {
2313
  global $requests_template;
2314
-
2315
  return $requests_template->requests();
2316
  }
2317
 
2318
  function bp_group_the_membership_request() {
2319
  global $requests_template;
2320
-
2321
  return $requests_template->the_request();
2322
  }
2323
 
2324
  function bp_group_request_user_avatar_thumb() {
2325
  global $requests_template;
2326
-
2327
  echo apply_filters( 'bp_group_request_user_avatar_thumb', bp_core_fetch_avatar( array( 'item_id' => $requests_template->request->user_id, 'type' => 'thumb' ) ) );
2328
  }
2329
 
2330
  function bp_group_request_reject_link() {
2331
- global $requests_template, $groups_template;
2332
 
2333
  echo apply_filters( 'bp_group_request_reject_link', wp_nonce_url( bp_get_group_permalink( $groups_template->group ) . '/admin/membership-requests/reject/' . $requests_template->request->id, 'groups_reject_membership_request' ) );
2334
  }
2335
 
2336
  function bp_group_request_accept_link() {
2337
- global $requests_template, $groups_template;
2338
 
2339
  echo apply_filters( 'bp_group_request_accept_link', wp_nonce_url( bp_get_group_permalink( $groups_template->group ) . '/admin/membership-requests/accept/' . $requests_template->request->id, 'groups_accept_membership_request' ) );
2340
  }
2341
 
2342
  function bp_group_request_time_since_requested() {
2343
- global $requests_template;
2344
 
2345
  echo apply_filters( 'bp_group_request_time_since_requested', sprintf( __( 'requested %s ago', 'buddypress' ), bp_core_time_since( strtotime( $requests_template->request->date_modified ) ) ) );
2346
  }
2347
 
2348
  function bp_group_request_comment() {
2349
  global $requests_template;
2350
-
2351
  echo apply_filters( 'bp_group_request_comment', strip_tags( stripslashes( $requests_template->request->comments ) ) );
2352
  }
2353
 
2354
  function bp_group_request_user_link() {
2355
  global $requests_template;
2356
-
2357
  echo apply_filters( 'bp_group_request_user_link', bp_core_get_userlink( $requests_template->request->user_id ) );
2358
  }
2359
 
@@ -2367,43 +2367,43 @@ class BP_Groups_Invite_Template {
2367
  var $invite_count;
2368
  var $invites;
2369
  var $invite;
2370
-
2371
  var $in_the_loop;
2372
-
2373
  var $pag_page;
2374
  var $pag_num;
2375
  var $pag_links;
2376
  var $total_invite_count;
2377
-
2378
  function bp_groups_invite_template( $user_id, $group_id ) {
2379
  global $bp;
2380
 
2381
  $this->invites = groups_get_invites_for_group( $user_id, $group_id );
2382
- $this->invite_count = count( $this->invites );
2383
  }
2384
-
2385
  function has_invites() {
2386
  if ( $this->invite_count )
2387
  return true;
2388
-
2389
  return false;
2390
  }
2391
-
2392
  function next_invite() {
2393
  $this->current_invite++;
2394
  $this->invite = $this->invites[$this->current_invite];
2395
-
2396
  return $this->invite;
2397
  }
2398
-
2399
  function rewind_invites() {
2400
  $this->current_invite = -1;
2401
  if ( $this->invite_count > 0 ) {
2402
  $this->invite = $this->invites[0];
2403
  }
2404
  }
2405
-
2406
- function invites() {
2407
  if ( $this->current_invite + 1 < $this->invite_count ) {
2408
  return true;
2409
  } elseif ( $this->current_invite + 1 == $this->invite_count ) {
@@ -2415,17 +2415,17 @@ class BP_Groups_Invite_Template {
2415
  $this->in_the_loop = false;
2416
  return false;
2417
  }
2418
-
2419
  function the_invite() {
2420
  global $invite;
2421
 
2422
  $this->in_the_loop = true;
2423
  $user_id = $this->next_invite();
2424
-
2425
  $this->invite = new stdClass;
2426
  $this->invite->user = new BP_Core_User( $user_id );
2427
  $this->invite->group_id = $group_id; // Globaled in bp_group_has_invites()
2428
-
2429
  if ( 0 == $this->current_invite ) // loop has just started
2430
  do_action('loop_start');
2431
  }
@@ -2433,7 +2433,7 @@ class BP_Groups_Invite_Template {
2433
 
2434
  function bp_group_has_invites( $args = '' ) {
2435
  global $bp, $invites_template, $group_id;
2436
-
2437
  $defaults = array(
2438
  'group_id' => false,
2439
  'user_id' => $bp->loggedin_user->id
@@ -2441,13 +2441,13 @@ function bp_group_has_invites( $args = '' ) {
2441
 
2442
  $r = wp_parse_args( $args, $defaults );
2443
  extract( $r, EXTR_SKIP );
2444
-
2445
  if ( !$group_id ) {
2446
  /* Backwards compatibility */
2447
  if ( $bp->groups->current_group ) $group_id = $bp->groups->current_group->id;
2448
  if ( $bp->groups->new_group_id ) $group_id = $bp->groups->new_group_id;
2449
  }
2450
-
2451
  if ( !$group_id )
2452
  return false;
2453
 
@@ -2457,13 +2457,13 @@ function bp_group_has_invites( $args = '' ) {
2457
 
2458
  function bp_group_invites() {
2459
  global $invites_template;
2460
-
2461
  return $invites_template->invites();
2462
  }
2463
 
2464
  function bp_group_the_invite() {
2465
  global $invites_template;
2466
-
2467
  return $invites_template->the_invite();
2468
  }
2469
 
@@ -2508,7 +2508,7 @@ function bp_group_invite_user_remove_invite_url() {
2508
  }
2509
  function bp_get_group_invite_user_remove_invite_url() {
2510
  global $invites_template;
2511
-
2512
  return wp_nonce_url( site_url( BP_GROUPS_SLUG . '/' . $invites_template->invite->group_id . '/invites/remove/' . $invites_template->invite->user->id ), 'groups_invite_uninvite_user' );
2513
  }
2514
 
8
  <li<?php if ( 'most-popular' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/most-popular""><?php _e( 'Most Popular', 'buddypress' ) ?></a></li>
9
  <li<?php if ( 'admin-of' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/admin-of""><?php _e( 'Administrator Of', 'buddypress' ) ?></a></li>
10
  <li<?php if ( 'mod-of' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/mod-of""><?php _e( 'Moderator Of', 'buddypress' ) ?></a></li>
11
+ <li<?php if ( 'alphabetically' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/alphabetically""><?php _e( 'Alphabetically', 'buddypress' ) ?></a></li>
12
  <?php
13
  do_action( 'groups_header_tabs' );
14
  }
15
 
16
  function bp_groups_filter_title() {
17
  global $bp;
18
+
19
  $current_filter = $bp->action_variables[0];
20
+
21
  switch ( $current_filter ) {
22
  case 'recently-active': default:
23
  _e( 'Recently Active', 'buddypress' );
43
 
44
  function bp_is_group_admin_screen( $slug ) {
45
  global $bp;
46
+
47
  if ( $bp->current_component != BP_GROUPS_SLUG || 'admin' != $bp->current_action )
48
  return false;
49
+
50
  if ( $bp->action_variables[0] == $slug )
51
  return true;
52
+
53
  return false;
54
  }
55
 
56
  function bp_group_current_avatar() {
57
  global $bp;
58
+
59
  if ( $bp->groups->current_group->avatar_full ) { ?>
60
  <img src="<?php echo attribute_escape( $bp->groups->current_group->avatar_full ) ?>" alt="<?php _e( 'Group Avatar', 'buddypress' ) ?>" class="avatar" />
61
  <?php } else { ?>
69
 
70
  if ( !empty( $_FILES ) || !bp_core_fetch_avatar( array( 'item_id' => $bp->groups->current_group->id, 'object' => 'group', 'no_grav' => true ) ) )
71
  return false;
72
+
73
  return true;
74
  }
75
 
78
  }
79
  function bp_get_group_avatar_delete_link() {
80
  global $bp;
81
+
82
  return apply_filters( 'bp_get_group_avatar_delete_link', wp_nonce_url( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/group-avatar/delete', 'bp_group_avatar_delete' ) );
83
  }
84
 
112
  var $group_count;
113
  var $groups;
114
  var $group;
115
+
116
  var $in_the_loop;
117
+
118
  var $pag_page;
119
  var $pag_num;
120
  var $pag_links;
121
  var $total_group_count;
122
+
123
  var $single_group = false;
124
+
125
  var $sort_by;
126
  var $order;
127
+
128
  function bp_groups_user_groups_template( $user_id, $type, $per_page, $max, $slug, $filter ) {
129
  global $bp;
130
+
131
  if ( !$user_id )
132
  $user_id = $bp->displayed_user->id;
133
+
134
  $this->pag_page = isset( $_REQUEST['grpage'] ) ? intval( $_REQUEST['grpage'] ) : 1;
135
  $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
136
 
140
  break;
141
 
142
  case 'popular':
143
+ $this->groups = groups_get_most_popular_for_user( $user_id, $this->pag_num, $this->pag_page, $filter );
144
  break;
145
 
146
  case 'admin-of':
147
+ $this->groups = groups_get_user_is_admin_of( $user_id, $this->pag_num, $this->pag_page, $filter );
148
+ break;
149
 
150
  case 'mod-of':
151
+ $this->groups = groups_get_user_is_mod_of( $user_id, $this->pag_num, $this->pag_page, $filter );
152
  break;
153
 
154
  case 'alphabetical':
155
+ $this->groups = groups_get_alphabetically_for_user( $user_id, $this->pag_num, $this->pag_page, $filter );
156
  break;
157
 
158
  case 'invites':
161
 
162
  case 'single-group':
163
  $group = new stdClass;
164
+ $group->group_id = BP_Groups_Group::get_id_from_slug($slug);
165
  $this->groups = array( $group );
166
  break;
167
 
169
  $this->groups = groups_get_recently_active_for_user( $user_id, $this->pag_num, $this->pag_page, $filter );
170
  break;
171
  }
172
+
173
  if ( 'invites' == $type ) {
174
  $this->total_group_count = count($this->groups);
175
  $this->group_count = count($this->groups);
209
  function has_groups() {
210
  if ( $this->group_count )
211
  return true;
212
+
213
  return false;
214
  }
215
+
216
  function next_group() {
217
  $this->current_group++;
218
  $this->group = $this->groups[$this->current_group];
219
+
220
  return $this->group;
221
  }
222
+
223
  function rewind_groups() {
224
  $this->current_group = -1;
225
  if ( $this->group_count > 0 ) {
226
  $this->group = $this->groups[0];
227
  }
228
  }
229
+
230
+ function user_groups() {
231
  if ( $this->current_group + 1 < $this->group_count ) {
232
  return true;
233
  } elseif ( $this->current_group + 1 == $this->group_count ) {
239
  $this->in_the_loop = false;
240
  return false;
241
  }
242
+
243
  function the_group() {
244
  global $group;
245
 
246
  $this->in_the_loop = true;
247
  $this->group = $this->next_group();
248
+
249
  // If this is a single group then instantiate group meta when creating the object.
250
  if ( $this->single_group ) {
251
  if ( !$group = wp_cache_get( 'groups_group_' . $this->group->group_id, 'bp' ) ) {
258
  wp_cache_set( 'groups_group_nouserdata_' . $this->group->group_id, $group, 'bp' );
259
  }
260
  }
261
+
262
  $this->group = $group;
263
+
264
  if ( 0 == $this->current_group ) // loop has just started
265
  do_action('loop_start');
266
  }
268
 
269
  function bp_has_groups( $args = '' ) {
270
  global $groups_template, $bp;
271
+
272
  $defaults = array(
273
  'type' => 'active',
274
  'user_id' => false,
280
 
281
  $r = wp_parse_args( $args, $defaults );
282
  extract( $r, EXTR_SKIP );
283
+
284
  /* The following code will auto set parameters based on the page being viewed.
285
  * for example on example.com/members/andy/groups/my-groups/most-popular/
286
  * $type = 'most-popular'
303
  $type = 'single-group';
304
  $slug = $bp->groups->current_group->slug;
305
  }
306
+
307
  if ( isset( $_REQUEST['group-filter-box'] ) )
308
  $filter = $_REQUEST['group-filter-box'];
309
+
310
  $groups_template = new BP_Groups_User_Groups_Template( $user_id, $type, $per_page, $max, $slug, $filter );
311
  return apply_filters( 'bp_has_groups', $groups_template->has_groups(), &$groups_template );
312
  }
323
 
324
  function bp_group_is_visible( $group = false ) {
325
  global $bp, $groups_template;
326
+
327
  if ( !$group )
328
  $group =& $groups_template->group;
329
+
330
  if ( 'public' == $group->status ) {
331
  return true;
332
  } else {
334
  return true;
335
  }
336
  }
337
+
338
  return false;
339
  }
340
 
341
  function bp_group_has_news( $group = false ) {
342
  global $groups_template;
343
+
344
  if ( !$group )
345
  $group =& $groups_template->group;
346
+
347
  if ( empty( $group->news ) )
348
  return false;
349
+
350
  return true;
351
  }
352
 
366
 
367
  return apply_filters( 'bp_get_group_id', $group->id );
368
  }
369
+
370
  function bp_group_name( $deprecated = true, $deprecated2 = false ) {
371
  global $groups_template;
372
 
395
 
396
  if ( 'public' == $group->status ) {
397
  $type = __( "Public Group", "buddypress" );
398
+ } else if ( 'hidden' == $group->status ) {
399
  $type = __( "Hidden Group", "buddypress" );
400
  } else if ( 'private' == $group->status ) {
401
  $type = __( "Private Group", "buddypress" );
403
  $type = ucwords( $group->status ) . ' ' . __( 'Group', 'buddypress' );
404
  }
405
 
406
+ return apply_filters( 'bp_get_group_type', $type );
407
  }
408
 
409
  function bp_group_status() {
415
  if ( !$group )
416
  $group =& $groups_template->group;
417
 
418
+ return apply_filters( 'bp_get_group_status', $group->status );
419
  }
420
 
421
  function bp_group_avatar( $args = '' ) {
430
  'height' => false,
431
  'class' => 'avatar',
432
  'id' => false,
433
+ 'alt' => __( 'Group avatar', 'buddypress' )
434
  );
435
 
436
  $r = wp_parse_args( $args, $defaults );
437
  extract( $r, EXTR_SKIP );
438
+
439
  /* Fetch the avatar from the folder, if not provide backwards compat. */
440
  if ( !$avatar = bp_core_fetch_avatar( array( 'item_id' => $groups_template->group->id, 'object' => 'group', 'type' => $type, 'avatar_dir' => 'group-avatars', 'alt' => $alt, 'css_id' => $id, 'class' => $class, 'width' => $width, 'height' => $height ) ) )
441
  $avatar = '<img src="' . attribute_escape( $groups_template->group->avatar_thumb ) . '" class="avatar" alt="' . attribute_escape( $groups_template->group->name ) . '" />';
461
  if ( !$deprecated )
462
  return bp_get_group_last_active();
463
  else
464
+ echo bp_get_group_last_active();
465
  }
466
  function bp_get_group_last_active( $group = false ) {
467
  global $groups_template;
474
  if ( empty( $last_active ) ) {
475
  return __( 'not yet active', 'buddypress' );
476
  } else {
477
+ return apply_filters( 'bp_get_group_last_active', bp_core_time_since( $last_active ) );
478
  }
479
  }
480
+
481
  function bp_group_permalink( $deprecated = false, $deprecated2 = true ) {
482
  if ( !$deprecated2 )
483
  return bp_get_group_permalink();
505
  if ( !$group )
506
  $group =& $groups_template->group;
507
 
508
+ return apply_filters( 'bp_get_group_admin_permalink', $bp->root_domain . '/' . $bp->groups->slug . '/' . $group->slug . '/admin' );
509
  }
510
 
511
  function bp_group_slug() {
556
  if ( !$group )
557
  $group =& $groups_template->group;
558
 
559
+ return apply_filters( 'bp_get_group_description_excerpt', bp_create_excerpt( $group->description, 20 ) );
560
  }
561
 
562
  function bp_group_news( $deprecated = false ) {
598
  return __( 'Private', 'buddypress' );
599
  }
600
  }
601
+
602
  function bp_group_is_public( $deprecated = false ) {
603
  echo bp_get_group_is_public();
604
  }
625
 
626
  function bp_group_is_admin() {
627
  global $bp;
628
+
629
  return $bp->is_item_admin;
630
  }
631
 
632
  function bp_group_is_mod() {
633
  global $bp;
634
+
635
  return $bp->is_item_mod;
636
  }
637
 
638
  function bp_group_list_admins( $full_list = true, $group = false ) {
639
  global $groups_template;
640
+
641
  if ( !$group )
642
  $group =& $groups_template->group;
643
+
644
  if ( !$admins = &$group->admins )
645
  $admins = $group->get_administrators();
646
 
664
  <?php } else { ?>
665
  <span class="activity"><?php _e( 'No Admins', 'buddypress' ) ?></span>
666
  <?php } ?>
667
+
668
  <?php
669
  }
670
 
671
  function bp_group_list_mods( $full_list = true, $group = false ) {
672
  global $groups_template;
673
+
674
  if ( !$group )
675
  $group =& $groups_template->group;
676
+
677
  $group_mods = groups_get_group_mods( $group->id );
678
+
679
  if ( $group_mods ) {
680
  if ( $full_list ) { ?>
681
  <ul id="group-mods" class="mods-list">
696
  <?php } else { ?>
697
  <span class="activity"><?php _e( 'No Mods', 'buddypress' ) ?></span>
698
  <?php } ?>
699
+
700
  <?php
701
  }
702
 
705
 
706
  if ( !$group )
707
  $group =& $groups_template->group;
708
+
709
  if ( !$deprecated )
710
  return bp_get_group_all_members_permalink();
711
  else
730
  <form action="<?php echo $action ?>" id="group-search-form" method="post">
731
  <label for="<?php echo $name ?>" id="<?php echo $name ?>-label"><?php echo $label ?></label>
732
  <input type="search" name="<?php echo $name ?>" id="<?php echo $name ?>" value="<?php echo $value ?>"<?php echo $disabled ?> />
733
+
734
  <?php wp_nonce_field( 'group-filter-box', '_wpnonce_group_filter' ) ?>
735
  </form>
736
  <?php
738
 
739
  function bp_group_show_no_groups_message() {
740
  global $bp;
741
+
742
  if ( !groups_total_groups_for_user( $bp->displayed_user->id ) )
743
  return true;
744
+
745
  return false;
746
  }
747
 
750
  }
751
  function bp_get_group_pagination() {
752
  global $groups_template;
753
+
754
  return apply_filters( 'bp_get_group_pagination', $groups_template->pag_links );
755
  }
756
 
761
  $to_num = ( $from_num + ( $groups_template->pag_num - 1 ) > $groups_template->total_group_count ) ? $groups_template->total_group_count : $from_num + ( $groups_template->pag_num - 1) ;
762
 
763
  echo sprintf( __( 'Viewing group %d to %d (of %d groups)', 'buddypress' ), $from_num, $to_num, $groups_template->total_group_count ); ?> &nbsp;
764
+ <span class="ajax-loader"></span><?php
765
  }
766
 
767
  function bp_total_group_count() {
803
 
804
  if ( !$group )
805
  $group =& $groups_template->group;
806
+
807
  if ( $group->enable_wire )
808
  return true;
809
+
810
  return false;
811
  }
812
 
832
  if ( bp_forums_is_installed_correctly() ) {
833
  if ( $group->enable_forum )
834
  return true;
835
+
836
  return false;
837
  } else {
838
  return false;
839
  }
840
  }
841
+
842
+ return false;
843
  }
844
 
845
  function bp_group_show_forum_setting( $group = false ) {
847
 
848
  if ( !$group )
849
  $group =& $groups_template->group;
850
+
851
  if ( $group->enable_forum )
852
  echo ' checked="checked"';
853
  }
857
 
858
  if ( !$group )
859
  $group =& $groups_template->group;
860
+
861
  if ( $setting == $group->status )
862
  echo ' checked="checked"';
863
  }
864
 
865
  function bp_group_admin_memberlist( $admin_list = false, $group = false ) {
866
  global $groups_template;
867
+
868
  if ( !$group )
869
  $group =& $groups_template->group;
870
+
871
  $admins = groups_get_group_admins( $group->id );
872
  ?>
873
  <?php if ( $admins ) { ?>
883
  <?php echo bp_core_fetch_avatar( array( 'item_id' => $admin->user_id, 'type' => 'thumb' ) ) ?>
884
  <h5><?php echo bp_core_get_userlink( $admin->user_id ) ?></h5>
885
  <span class="activity"><?php echo bp_core_get_last_activity( strtotime( $admin->date_modified ), __( 'joined %s ago', 'buddypress') ); ?></span>
886
+
887
  <?php if ( function_exists( 'friends_install' ) ) : ?>
888
  <div class="action">
889
  <?php bp_add_friend_button( $admin->user_id ) ?>
890
  </div>
891
  <?php endif; ?>
892
+ </li>
893
  <?php } ?>
894
  <?php } ?>
895
  </ul>
901
  }
902
 
903
  function bp_group_mod_memberlist( $admin_list = false, $group = false ) {
904
+ global $groups_template, $group_mods;
905
 
906
  if ( !$group )
907
  $group =& $groups_template->group;
908
+
909
  $group_mods = groups_get_group_mods( $group->id );
910
  ?>
911
  <?php if ( $group_mods ) { ?>
921
  <?php echo bp_core_fetch_avatar( array( 'item_id' => $mod->user_id, 'type' => 'thumb' ) ) ?>
922
  <h5><?php echo bp_core_get_userlink( $mod->user_id ) ?></h5>
923
  <span class="activity"><?php echo bp_core_get_last_activity( strtotime( $mod->date_modified ), __( 'joined %s ago', 'buddypress') ); ?></span>
924
+
925
  <?php if ( function_exists( 'friends_install' ) ) : ?>
926
  <div class="action">
927
  <?php bp_add_friend_button( $mod->user_id ) ?>
928
  </div>
929
  <?php endif; ?>
930
+ </li>
931
+ <?php } ?>
932
  <?php } ?>
933
  </ul>
934
  <?php } else { ?>
1000
 
1001
  return apply_filters( 'bp_get_group_member_demote_link', wp_nonce_url( bp_get_group_permalink( $group ) . '/admin/manage-members/demote/' . $user_id, 'groups_demote_member' ) );
1002
  }
1003
+
1004
  function bp_group_member_ban_link( $user_id = false, $deprecated = false ) {
1005
  global $members_template;
1006
 
1023
 
1024
  if ( !$user_id )
1025
  $user_id = $members_template->member->user_id;
1026
+
1027
+ echo bp_get_group_member_unban_link( $user_id );
1028
  }
1029
  function bp_get_group_member_unban_link( $user_id = false, $group = false ) {
1030
  global $members_template;
1031
 
1032
  if ( !$user_id )
1033
  $user_id = $members_template->member->user_id;
1034
+
1035
  if ( !$group )
1036
  $group =& $groups_template->group;
1037
 
1038
+ return apply_filters( 'bp_get_group_member_unban_link', wp_nonce_url( bp_get_group_permalink( $group ) . '/admin/manage-members/unban/' . $user_id, 'groups_unban_member' ) );
1039
  }
1040
 
1041
  function bp_group_admin_tabs( $group = false ) {
1043
 
1044
  if ( !$group )
1045
  $group = ( $groups_template->group ) ? $groups_template->group : $bp->groups->current_group;
1046
+
1047
  $current_tab = $bp->action_variables[0];
1048
  ?>
1049
  <?php if ( $bp->is_item_admin || $bp->is_item_mod ) { ?>
1050
  <li<?php if ( 'edit-details' == $current_tab || empty( $current_tab ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/edit-details"><?php _e('Edit Details', 'buddypress') ?></a></li>
1051
  <?php } ?>
1052
+
1053
  <?php
1054
  if ( !$bp->is_item_admin )
1055
  return false;
1061
  <?php if ( $groups_template->group->status == 'private' ) : ?>
1062
  <li<?php if ( 'membership-requests' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/membership-requests"><?php _e('Membership Requests', 'buddypress') ?></a></li>
1063
  <?php endif; ?>
1064
+
1065
  <?php do_action( 'groups_admin_tabs', $current_tab, $group->slug ) ?>
1066
+
1067
  <li<?php if ( 'delete-group' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/delete-group"><?php _e('Delete Group', 'buddypress') ?></a></li>
1068
  <?php
1069
  }
1086
 
1087
  return apply_filters( 'bp_group_form_action', bp_get_group_permalink( $group ) . '/' . $page );
1088
  }
1089
+
1090
  function bp_group_admin_form_action( $page = false, $deprecated = false ) {
1091
  echo bp_get_group_admin_form_action( $page );
1092
  }
1104
 
1105
  function bp_group_has_requested_membership( $group = false ) {
1106
  global $bp, $groups_template;
1107
+
1108
  if ( !$group )
1109
  $group =& $groups_template->group;
1110
+
1111
  if ( groups_check_for_membership_request( $bp->loggedin_user->id, $group->id ) )
1112
  return true;
1113
+
1114
  return false;
1115
  }
1116
 
1119
 
1120
  if ( !$group )
1121
  $group =& $groups_template->group;
1122
+
1123
  if ( groups_is_user_member( $bp->loggedin_user->id, $group->id ) )
1124
  return true;
1125
+
1126
  return false;
1127
  }
1128
 
1135
  if ( !$group )
1136
  $group =& $groups_template->group;
1137
 
1138
+ return apply_filters( 'bp_get_group_accept_invite_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->groups->slug . '/invites/accept/' . $group->id, 'groups_accept_invite' ) );
1139
  }
1140
 
1141
  function bp_group_reject_invite_link( $deprecated = false ) {
1159
  if ( !$group )
1160
  $group =& $groups_template->group;
1161
 
1162
+ return apply_filters( 'bp_group_leave_confirm_link', wp_nonce_url( bp_get_group_permalink( $group ) . '/leave-group/yes', 'groups_leave_group' ) );
1163
  }
1164
 
1165
  function bp_group_leave_reject_link( $deprecated = false ) {
1188
 
1189
  function bp_has_friends_to_invite( $group = false ) {
1190
  global $groups_template, $bp;
1191
+
1192
  if ( !function_exists('friends_install') )
1193
  return false;
1194
 
1195
  if ( !$group )
1196
  $group =& $groups_template->group;
1197
+
1198
  if ( !friends_check_user_has_friends( $bp->loggedin_user->id ) || !friends_count_invitable_friends( $bp->loggedin_user->id, $group->id ) )
1199
  return false;
1200
+
1201
  return true;
1202
  }
1203
 
1204
  function bp_group_join_button( $group = false ) {
1205
  global $bp, $groups_template;
1206
+
1207
  if ( !$group )
1208
  $group =& $groups_template->group;
1209
+
1210
  // If they're not logged in or are banned from the group, no join button.
1211
  if ( !is_user_logged_in() || groups_is_user_banned( $bp->loggedin_user->id, $group->id ) )
1212
  return false;
1213
 
1214
  if ( !$group->status )
1215
  return false;
1216
+
1217
  echo '<div class="generic-button group-button ' . $group->status . '" id="groupbutton-' . $group->id . '">';
1218
+
1219
  switch ( $group->status ) {
1220
  case 'public':
1221
  if ( BP_Groups_Member::check_is_member( $bp->loggedin_user->id, $group->id ) )
1222
+ echo '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>';
1223
  else
1224
+ echo '<a class="join-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/join', 'groups_join_group' ) . '">' . __( 'Join Group', 'buddypress' ) . '</a>';
1225
  break;
1226
+
1227
  case 'private':
1228
  if ( BP_Groups_Member::check_is_member( $bp->loggedin_user->id, $group->id ) ) {
1229
+ echo '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>';
1230
  } else {
1231
  if ( !bp_group_has_requested_membership( $group ) )
1232
+ echo '<a class="request-membership" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/request-membership', 'groups_request_membership' ) . '">' . __('Request Membership', 'buddypress') . '</a>';
1233
  else
1234
+ echo '<a class="membership-requested" href="' . bp_get_group_permalink( $group ) . '">' . __( 'Request Sent', 'buddypress' ) . '</a>';
1235
  }
1236
  break;
1237
  }
1238
+
1239
  echo '</div>';
1240
  }
1241
 
1242
  function bp_group_status_message( $group = false ) {
1243
  global $groups_template;
1244
+
1245
  if ( !$group )
1246
  $group =& $groups_template->group;
1247
+
1248
  if ( 'private' == $group->status ) {
1249
  if ( !bp_group_has_requested_membership() )
1250
  if ( is_user_logged_in() )
1251
  _e( 'This is a private group and you must request group membership in order to join.', 'buddypress' );
1252
  else
1253
  _e( 'This is a private group. To join you must be a registered site member and request group membership.', 'buddypress' );
1254
+ else
1255
+ _e( 'This is a private group. Your membership request is awaiting approval from the group administrator.', 'buddypress' );
1256
  } else {
1257
  _e( 'This is a hidden group and only invited members can join.', 'buddypress' );
1258
  }
1268
  var $member_count;
1269
  var $members;
1270
  var $member;
1271
+
1272
  var $in_the_loop;
1273
+
1274
  var $pag_page;
1275
  var $pag_num;
1276
  var $pag_links;
1277
  var $total_group_count;
1278
+
1279
  function bp_groups_group_members_template( $group_id, $per_page, $max, $exclude_admins_mods, $exclude_banned ) {
1280
  global $bp;
1281
+
1282
  $this->pag_page = isset( $_REQUEST['mlpage'] ) ? intval( $_REQUEST['mlpage'] ) : 1;
1283
  $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
1284
+
1285
  $this->members = BP_Groups_Member::get_all_for_group( $group_id, $this->pag_num, $this->pag_page, $exclude_admins_mods, $exclude_banned );
1286
+
1287
  if ( !$max || $max >= (int)$this->members['count'] )
1288
  $this->total_member_count = (int)$this->members['count'];
1289
  else
1290
  $this->total_member_count = (int)$max;
1291
 
1292
  $this->members = $this->members['members'];
1293
+
1294
  if ( $max ) {
1295
  if ( $max >= count($this->members) )
1296
  $this->member_count = count($this->members);
1310
  'mid_size' => 1
1311
  ));
1312
  }
1313
+
1314
  function has_members() {
1315
  if ( $this->member_count )
1316
  return true;
1317
 
1318
  return false;
1319
  }
1320
+
1321
  function next_member() {
1322
  $this->current_member++;
1323
  $this->member = $this->members[$this->current_member];
1324
+
1325
  return $this->member;
1326
  }
1327
+
1328
  function rewind_members() {
1329
  $this->current_member = -1;
1330
  if ( $this->member_count > 0 ) {
1331
  $this->member = $this->members[0];
1332
  }
1333
  }
1334
+
1335
+ function members() {
1336
  if ( $this->current_member + 1 < $this->member_count ) {
1337
  return true;
1338
  } elseif ( $this->current_member + 1 == $this->member_count ) {
1344
  $this->in_the_loop = false;
1345
  return false;
1346
  }
1347
+
1348
  function the_member() {
1349
  global $member;
1350
 
1358
 
1359
  function bp_group_has_members( $args = '' ) {
1360
  global $bp, $members_template;
1361
+
1362
  $defaults = array(
1363
  'group_id' => $bp->groups->current_group->id,
1364
  'per_page' => 10,
1376
 
1377
  function bp_group_members() {
1378
  global $members_template;
1379
+
1380
  return $members_template->members();
1381
  }
1382
 
1383
  function bp_group_the_member() {
1384
  global $members_template;
1385
+
1386
  return $members_template->the_member();
1387
  }
1388
 
1439
 
1440
  return apply_filters( 'bp_get_group_member_link', bp_core_get_userlink( $members_template->member->user_id ) );
1441
  }
1442
+
1443
  function bp_group_member_is_banned() {
1444
  echo bp_get_group_member_is_banned();
1445
  }
1457
 
1458
  return apply_filters( 'bp_get_group_member_joined_since', bp_core_get_last_activity( strtotime( $members_template->member->date_modified ), __( 'joined %s ago', 'buddypress') ) );
1459
  }
1460
+
1461
  function bp_group_member_id() {
1462
  echo bp_get_group_member_id();
1463
  }
1472
 
1473
  if ( $members_template->total_member_count > $members_template->pag_num )
1474
  return true;
1475
+
1476
  return false;
1477
  }
1478
 
1501
  global $members_template;
1502
 
1503
  $from_num = intval( ( $members_template->pag_page - 1 ) * $members_template->pag_num ) + 1;
1504
+ $to_num = ( $from_num + ( $members_template->pag_num - 1 ) > $members_template->total_member_count ) ? $members_template->total_member_count : $from_num + ( $members_template->pag_num - 1 );
1505
 
1506
+ return apply_filters( 'bp_get_group_member_pagination_count', sprintf( __( 'Viewing members %d to %d (of %d members)', 'buddypress' ), $from_num, $to_num, $members_template->total_member_count ) );
1507
  }
1508
 
1509
  function bp_group_member_admin_pagination() {
1512
  }
1513
  function bp_get_group_member_admin_pagination() {
1514
  global $members_template;
1515
+
1516
  return $members_template->pag_links;
1517
  }
1518
 
1523
 
1524
  function bp_group_creation_tabs() {
1525
  global $bp;
1526
+
1527
  if ( !is_array( $bp->groups->group_creation_steps ) )
1528
  return false;
1529
+
1530
  if ( !$bp->groups->current_create_step )
1531
  $bp->groups->current_create_step = array_shift( array_keys( $bp->groups->group_creation_steps ) );
1532
 
1533
  $counter = 1;
1534
  foreach ( $bp->groups->group_creation_steps as $slug => $step ) {
1535
  $is_enabled = bp_are_previous_group_creation_steps_complete( $slug ); ?>
1536
+
1537
  <li<?php if ( $bp->groups->current_create_step == $slug ) : ?> class="current"<?php endif; ?>><?php if ( $is_enabled ) : ?><a href="<?php echo $bp->loggedin_user->domain . $bp->groups->slug ?>/create/step/<?php echo $slug ?>"><?php endif; ?><?php echo $counter ?>. <?php echo $step['name'] ?><?php if ( $is_enabled ) : ?></a><?php endif; ?></li><?php
1538
  $counter++;
1539
  }
1540
+
1541
  unset( $is_enabled );
1542
+
1543
  do_action( 'groups_creation_tabs' );
1544
  }
1545
 
1546
  function bp_group_creation_stage_title() {
1547
  global $bp;
1548
+
1549
  echo apply_filters( 'bp_group_creation_stage_title', '<span>&mdash; ' . $bp->groups->group_creation_steps[$bp->groups->current_create_step]['name'] . '</span>' );
1550
  }
1551
 
1554
  }
1555
  function bp_get_group_creation_form_action() {
1556
  global $bp;
1557
+
1558
  if ( empty( $bp->action_variables[1] ) )
1559
  $bp->action_variables[1] = array_shift( array_keys( $bp->groups->group_creation_steps ) );
1560
+
1561
  return apply_filters( 'bp_get_group_creation_form_action', $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $bp->action_variables[1] );
1562
  }
1563
 
1564
  function bp_is_group_creation_step( $step_slug ) {
1565
  global $bp;
1566
+
1567
  /* Make sure we are in the groups component */
1568
  if ( $bp->current_component != BP_GROUPS_SLUG || 'create' != $bp->current_action )
1569
  return false;
1570
+
1571
  /* If this the first step, we can just accept and return true */
1572
  if ( !$bp->action_variables[1] && array_shift( array_keys( $bp->groups->group_creation_steps ) ) == $step_slug )
1573
  return true;
1574
+
1575
  /* Before allowing a user to see a group creation step we must make sure previous steps are completed */
1576
  if ( !bp_is_first_group_creation_step() ) {
1577
  if ( !bp_are_previous_group_creation_steps_complete( $step_slug ) )
1578
  return false;
1579
  }
1580
+
1581
  /* Check the current step against the step parameter */
1582
  if ( $bp->action_variables[1] == $step_slug )
1583
  return true;
1584
+
1585
  return false;
1586
  }
1587
 
1588
  function bp_is_group_creation_step_complete( $step_slugs ) {
1589
  global $bp;
1590
+
1591
  if ( !$bp->groups->completed_create_steps )
1592
  return false;
1593
 
1594
  if ( is_array( $step_slugs ) ) {
1595
  $found = true;
1596
+
1597
  foreach ( $step_slugs as $step_slug ) {
1598
  if ( !in_array( $step_slug, $bp->groups->completed_create_steps ) )
1599
  $found = false;
1600
  }
1601
+
1602
  return $found;
1603
  } else {
1604
+ return in_array( $step_slugs, $bp->groups->completed_create_steps );
1605
  }
1606
 
1607
  return true;
1609
 
1610
  function bp_are_previous_group_creation_steps_complete( $step_slug ) {
1611
  global $bp;
1612
+
1613
  /* If this is the first group creation step, return true */
1614
  if ( array_shift( array_keys( $bp->groups->group_creation_steps ) ) == $step_slug )
1615
  return true;
1616
+
1617
  reset( $bp->groups->group_creation_steps );
1618
  unset( $previous_steps );
1619
+
1620
  /* Get previous steps */
1621
  foreach ( $bp->groups->group_creation_steps as $slug => $name ) {
1622
  if ( $slug == $step_slug )
1623
  break;
1624
+
1625
  $previous_steps[] = $slug;
1626
  }
1627
+
1628
  return bp_is_group_creation_step_complete( $previous_steps );
1629
  }
1630
 
1635
  global $bp;
1636
  return apply_filters( 'bp_get_new_group_id', $bp->groups->new_group_id );
1637
  }
1638
+
1639
  function bp_new_group_name() {
1640
  echo bp_get_new_group_name();
1641
  }
1689
  }
1690
  function bp_get_new_group_avatar( $args = '' ) {
1691
  global $bp;
1692
+
1693
  $defaults = array(
1694
  'type' => 'full',
1695
  'width' => false,
1696
  'height' => false,
1697
  'class' => 'avatar',
1698
  'id' => 'avatar-crop-preview',
1699
+ 'alt' => __( 'Group avatar', 'buddypress' )
1700
  );
1701
 
1702
  $r = wp_parse_args( $args, $defaults );
1703
  extract( $r, EXTR_SKIP );
1704
+
1705
  return apply_filters( 'bp_get_new_group_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->groups->current_group->id, 'object' => 'group', 'type' => $type, 'avatar_dir' => 'group-avatars', 'alt' => $alt, 'width' => $width, 'height' => $height, 'class' => $class ) ) );
1706
  }
1707
 
1710
  }
1711
  function bp_get_group_creation_previous_link() {
1712
  global $bp;
1713
+
1714
  foreach ( $bp->groups->group_creation_steps as $slug => $name ) {
1715
  if ( $slug == $bp->action_variables[1] )
1716
  break;
1717
+
1718
  $previous_steps[] = $slug;
1719
  }
1720
 
1723
 
1724
  function bp_is_last_group_creation_step() {
1725
  global $bp;
1726
+
1727
  $last_step = array_pop( array_keys( $bp->groups->group_creation_steps ) );
1728
 
1729
  if ( $last_step == $bp->groups->current_create_step )
1730
  return true;
1731
+
1732
  return false;
1733
  }
1734
 
1735
  function bp_is_first_group_creation_step() {
1736
  global $bp;
1737
+
1738
  $first_step = array_shift( array_keys( $bp->groups->group_creation_steps ) );
1739
 
1740
  if ( $first_step == $bp->groups->current_create_step )
1741
  return true;
1742
+
1743
  return false;
1744
  }
1745
 
1751
 
1752
  if ( !function_exists('friends_install') )
1753
  return false;
1754
+
1755
  $defaults = array(
1756
  'group_id' => false,
1757
  'separator' => 'li'
1759
 
1760
  $r = wp_parse_args( $args, $defaults );
1761
  extract( $r, EXTR_SKIP );
1762
+
1763
  if ( !$group_id )
1764
  $group_id = ( $bp->groups->new_group_id ) ? $bp->groups->new_group_id : $bp->groups->current_group->id;
1765
+
1766
  $friends = friends_get_friends_invite_list( $bp->loggedin_user->id, $group_id );
1767
+
1768
  if ( $friends ) {
1769
  $invites = groups_get_invites_for_group( $bp->loggedin_user->id, $group_id );
1770
 
1774
  $checked = ' checked="checked"';
1775
  } else {
1776
  $checked = '';
1777
+ }
1778
  }
1779
+
1780
  $items[] = '<' . $separator . '><input' . $checked . ' type="checkbox" name="friends[]" id="f-' . $friends[$i]['id'] . '" value="' . attribute_escape( $friends[$i]['id'] ) . '" /> ' . $friends[$i]['full_name'] . '</' . $separator . '>';
1781
  }
1782
  }
1783
+
1784
  return implode( "\n", (array)$items );
1785
  }
1786
 
1793
  var $group_count;
1794
  var $groups;
1795
  var $group;
1796
+
1797
  var $in_the_loop;
1798
+
1799
  var $pag_page;
1800
  var $pag_num;
1801
  var $pag_links;
1802
  var $total_group_count;
1803
+
1804
  function bp_groups_site_groups_template( $type, $per_page, $max ) {
1805
  global $bp;
1806
+
1807
  /* TODO: Move $_REQUEST vars out of here */
1808
+
1809
  $this->pag_page = isset( $_REQUEST['gpage'] ) ? intval( $_REQUEST['gpage'] ) : 1;
1810
  $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
1811
 
1813
  $this->groups = BP_Groups_Group::search_groups( $_REQUEST['s'], $this->pag_num, $this->pag_page );
1814
  } else if ( isset( $_REQUEST['letter'] ) && '' != $_REQUEST['letter'] ) {
1815
  $this->groups = BP_Groups_Group::get_by_letter( $_REQUEST['letter'], $this->pag_num, $this->pag_page );
1816
+
1817
  } else {
1818
  switch ( $type ) {
1819
  case 'active': default:
1820
  $this->groups = groups_get_active( $this->pag_num, $this->pag_page );
1821
+ break;
1822
 
1823
  case 'alphabetical': default:
1824
  $this->groups = groups_get_alphabetically( $this->pag_num, $this->pag_page );
1825
+ break;
1826
+
1827
+ case 'random':
1828
  $this->groups = groups_get_random_groups( $this->pag_num, $this->pag_page );
1829
  break;
1830
+
1831
  case 'newest':
1832
  $this->groups = groups_get_newest( $this->pag_num, $this->pag_page );
1833
  break;
1834
 
1835
  case 'popular':
1836
  $this->groups = groups_get_popular( $this->pag_num, $this->pag_page );
1837
+ break;
1838
 
1839
  case 'most-forum-topics':
1840
  $this->groups = groups_get_by_most_forum_topics( $this->pag_num, $this->pag_page );
1841
  break;
1842
+
1843
  case 'most-forum-posts':
1844
  $this->groups = groups_get_by_most_forum_posts( $this->pag_num, $this->pag_page );
1845
  break;
1846
  }
1847
  }
1848
+
1849
  if ( !$max || $max >= (int)$this->groups['total'] )
1850
  $this->total_group_count = (int)$this->groups['total'];
1851
  else
1852
  $this->total_group_count = (int)$max;
1853
 
1854
  $this->groups = $this->groups['groups'];
1855
+
1856
  if ( $max ) {
1857
  if ( $max >= count($this->groups) )
1858
  $this->group_count = count($this->groups);
1861
  } else {
1862
  $this->group_count = count($this->groups);
1863
  }
1864
+
1865
  if ( (int) $this->total_group_count && (int) $this->pag_num ) {
1866
  $this->pag_links = paginate_links( array(
1867
  'base' => add_query_arg( 'gpage', '%#%' ),
1871
  'prev_text' => '&laquo;',
1872
  'next_text' => '&raquo;',
1873
  'mid_size' => 1
1874
+ ));
1875
  }
1876
  }
1877
+
1878
  function has_groups() {
1879
  if ( $this->group_count )
1880
  return true;
1881
+
1882
  return false;
1883
  }
1884
+
1885
  function next_group() {
1886
  $this->current_group++;
1887
  $this->group = $this->groups[$this->current_group];
1888
+
1889
  return $this->group;
1890
  }
1891
+
1892
  function rewind_groups() {
1893
  $this->current_group = -1;
1894
  if ( $this->group_count > 0 ) {
1895
  $this->group = $this->groups[0];
1896
  }
1897
  }
1898
+
1899
+ function groups() {
1900
  if ( $this->current_group + 1 < $this->group_count ) {
1901
  return true;
1902
  } elseif ( $this->current_group + 1 == $this->group_count ) {
1908
  $this->in_the_loop = false;
1909
  return false;
1910
  }
1911
+
1912
  function the_group() {
1913
  global $group;
1914
 
1915
  $this->in_the_loop = true;
1916
  $this->group = $this->next_group();
1917
+
1918
  if ( !$group = wp_cache_get( 'groups_group_nouserdata_' . $this->group->group_id, 'bp' ) ) {
1919
  $group = new BP_Groups_Group( $this->group->group_id, false, false );
1920
  wp_cache_set( 'groups_group_nouserdata_' . $this->group->group_id, $group, 'bp' );
1921
  }
1922
+
1923
  $this->group = $group;
1924
+
1925
  if ( 0 == $this->current_group ) // loop has just started
1926
  do_action('loop_start');
1927
  }
1929
 
1930
  function bp_rewind_site_groups() {
1931
  global $site_groups_template;
1932
+
1933
+ $site_groups_template->rewind_groups();
1934
  }
1935
 
1936
  function bp_has_site_groups( $args = '' ) {
1944
 
1945
  $r = wp_parse_args( $args, $defaults );
1946
  extract( $r, EXTR_SKIP );
1947
+
1948
  // type: active ( default ) | random | newest | popular
1949
+
1950
  if ( $max ) {
1951
  if ( $per_page > $max )
1952
  $per_page = $max;
1953
  }
1954
+
1955
  $site_groups_template = new BP_Groups_Site_Groups_Template( $type, $per_page, $max );
1956
  return apply_filters( 'bp_has_site_groups', $site_groups_template->has_groups(), &$site_groups_template );
1957
  }
1958
 
1959
  function bp_site_groups() {
1960
  global $site_groups_template;
1961
+
1962
  return $site_groups_template->groups();
1963
  }
1964
 
1965
  function bp_the_site_group() {
1966
  global $site_groups_template;
1967
+
1968
  return $site_groups_template->the_group();
1969
  }
1970
 
1971
  function bp_site_groups_pagination_count() {
1972
  global $bp, $site_groups_template;
1973
+
1974
  $from_num = intval( ( $site_groups_template->pag_page - 1 ) * $site_groups_template->pag_num ) + 1;
1975
  $to_num = ( $from_num + ( $site_groups_template->pag_num - 1 ) > $site_groups_template->total_group_count ) ? $site_groups_template->total_group_count : $from_num + ( $site_groups_template->pag_num - 1) ;
1976
 
1977
  echo sprintf( __( 'Viewing group %d to %d (of %d groups)', 'buddypress' ), $from_num, $to_num, $site_groups_template->total_group_count ); ?> &nbsp;
1978
+ <span class="ajax-loader"></span><?php
1979
  }
1980
 
1981
  function bp_site_groups_pagination_links() {
1983
  }
1984
  function bp_get_site_groups_pagination_links() {
1985
  global $site_groups_template;
1986
+
1987
  return apply_filters( 'bp_get_site_groups_pagination_links', $site_groups_template->pag_links );
1988
  }
1989
 
1992
  }
1993
  function bp_get_the_site_group_id() {
1994
  global $site_groups_template;
1995
+
1996
  return apply_filters( 'bp_get_the_site_group_id', $site_groups_template->group->id );
1997
  }
1998
 
2010
  }
2011
  function bp_get_the_site_group_avatar_thumb() {
2012
  global $site_groups_template;
2013
+
2014
  return apply_filters( 'bp_get_the_site_group_avatar_thumb', bp_core_fetch_avatar( array( 'item_id' => $site_groups_template->group->id, 'object' => 'group', 'type' => 'thumb', 'avatar_dir' => 'group-avatars', 'alt' => __( 'Group Avatar', 'buddypress' ) ) ) );
2015
  }
2016
 
2028
  }
2029
  function bp_get_the_site_group_link() {
2030
  global $site_groups_template;
2031
+
2032
  return apply_filters( 'bp_get_the_site_group_link', bp_get_group_permalink( $site_groups_template->group ) );
2033
  }
2034
 
2040
 
2041
  return apply_filters( 'bp_get_the_site_group_name', bp_get_group_name( $site_groups_template->group ) );
2042
  }
2043
+
2044
 
2045
  function bp_the_site_group_last_active() {
2046
  echo bp_get_the_site_group_last_active();
2053
 
2054
  function bp_the_site_group_join_button() {
2055
  global $site_groups_template;
2056
+
2057
  echo bp_group_join_button( $site_groups_template->group );
2058
  }
2059
 
2063
  function bp_get_the_site_group_description() {
2064
  global $site_groups_template;
2065
 
2066
+ return apply_filters( 'bp_get_the_site_group_description', bp_get_group_description( $site_groups_template->group ) );
2067
  }
2068
 
2069
  function bp_the_site_group_description_excerpt() {
2072
  function bp_get_the_site_group_description_excerpt() {
2073
  global $site_groups_template;
2074
 
2075
+ return apply_filters( 'bp_get_the_site_group_description_excerpt', bp_create_excerpt( bp_get_group_description( $site_groups_template->group, false ), 25 ) );
2076
  }
2077
 
2078
  function bp_the_site_group_date_created() {
2079
+ echo bp_get_the_site_group_date_created();
2080
  }
2081
  function bp_get_the_site_group_date_created() {
2082
  global $site_groups_template;
2083
 
2084
+ return apply_filters( 'bp_get_the_site_group_date_created', bp_core_time_since( $site_groups_template->group->date_created ) );
2085
  }
2086
 
2087
  function bp_the_site_group_member_count() {
2093
  if ( 1 == (int) $site_groups_template->group->total_member_count )
2094
  return apply_filters( 'bp_get_the_site_group_member_count', sprintf( __( '%d member', 'buddypress' ), (int) $site_groups_template->group->total_member_count ) );
2095
  else
2096
+ return apply_filters( 'bp_get_the_site_group_member_count', sprintf( __( '%d members', 'buddypress' ), (int) $site_groups_template->group->total_member_count ) );
2097
  }
2098
 
2099
  function bp_the_site_group_type() {
2123
 
2124
  if ( !function_exists( 'bp_forums_get_forum_topicpost_count' ) )
2125
  return false;
2126
+
2127
  if ( !$site_groups_template->group->forum_counts )
2128
  $site_groups_template->group->forum_counts = bp_forums_get_forum_topicpost_count( (int)$forum_id );
2129
 
2131
  if ( 1 == (int) $site_groups_template->group->forum_counts[0]->topics )
2132
  $total_topics = sprintf( __( '%d topic', 'buddypress' ), (int) $site_groups_template->group->forum_counts[0]->topics );
2133
  else
2134
+ $total_topics = sprintf( __( '%d topics', 'buddypress' ), (int) $site_groups_template->group->forum_counts[0]->topics );
2135
  } else {
2136
  $total_topics = (int) $site_groups_template->group->forum_counts[0]->topics;
2137
  }
2138
+
2139
  return apply_filters( 'bp_get_the_site_group_forum_topic_count', $total_topics, (bool)$showtext );
2140
  }
2141
 
2144
  }
2145
  function bp_get_the_site_group_forum_post_count( $args = '' ) {
2146
  global $site_groups_template;
2147
+
2148
  $defaults = array(
2149
  'showtext' => false
2150
  );
2151
 
2152
  $r = wp_parse_args( $args, $defaults );
2153
  extract( $r, EXTR_SKIP );
2154
+
2155
  if ( !$forum_id = groups_get_groupmeta( $site_groups_template->group->id, 'forum_id' ) )
2156
  return false;
2157
 
2158
  if ( !function_exists( 'bp_forums_get_forum_topicpost_count' ) )
2159
  return false;
2160
+
2161
  if ( !$site_groups_template->group->forum_counts )
2162
  $site_groups_template->group->forum_counts = bp_forums_get_forum_topicpost_count( (int)$forum_id );
2163
 
2165
  if ( 1 == (int) $site_groups_template->group->forum_counts[0]->posts )
2166
  $total_posts = sprintf( __( '%d post', 'buddypress' ), (int) $site_groups_template->group->forum_counts[0]->posts );
2167
  else
2168
+ $total_posts = sprintf( __( '%d posts', 'buddypress' ), (int) $site_groups_template->group->forum_counts[0]->posts );
2169
  } else {
2170
  $total_posts = (int) $site_groups_template->group->forum_counts[0]->posts;
2171
  }
2172
+
2173
  return apply_filters( 'bp_get_the_site_group_forum_post_count', $total_posts, (bool)$showtext );
2174
  }
2175
 
2177
  if ( isset( $_REQUEST['s'] ) ) {
2178
  echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['s'] ) . '" name="search_terms" />';
2179
  }
2180
+
2181
  if ( isset( $_REQUEST['letter'] ) ) {
2182
  echo '<input type="hidden" id="selected_letter" value="' . attribute_escape( $_REQUEST['letter'] ) . '" name="selected_letter" />';
2183
  }
2184
+
2185
  if ( isset( $_REQUEST['groups_search'] ) ) {
2186
  echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['groups_search'] ) . '" name="search_terms" />';
2187
  }
2205
  var $request_count;
2206
  var $requests;
2207
  var $request;
2208
+
2209
  var $in_the_loop;
2210
+
2211
  var $pag_page;
2212
  var $pag_num;
2213
  var $pag_links;
2214
  var $total_request_count;
2215
+
2216
  function bp_groups_membership_requests_template( $group_id, $per_page, $max ) {
2217
  global $bp;
2218
+
2219
  $this->pag_page = isset( $_REQUEST['mrpage'] ) ? intval( $_REQUEST['mrpage'] ) : 1;
2220
  $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
2221
+
2222
+ $this->requests = BP_Groups_Group::get_membership_requests( $group_id, $this->pag_num, $this->pag_page );
2223
 
2224
  if ( !$max || $max >= (int)$this->requests['total'] )
2225
  $this->total_request_count = (int)$this->requests['total'];
2227
  $this->total_request_count = (int)$max;
2228
 
2229
  $this->requests = $this->requests['requests'];
2230
+
2231
  if ( $max ) {
2232
  if ( $max >= count($this->requests) )
2233
  $this->request_count = count($this->requests);
2247
  'mid_size' => 1
2248
  ));
2249
  }
2250
+
2251
  function has_requests() {
2252
  if ( $this->request_count )
2253
  return true;
2254
+
2255
  return false;
2256
  }
2257
+
2258
  function next_request() {
2259
  $this->current_request++;
2260
  $this->request = $this->requests[$this->current_request];
2261
+
2262
  return $this->request;
2263
  }
2264
+
2265
  function rewind_requests() {
2266
  $this->current_request = -1;
2267
  if ( $this->request_count > 0 ) {
2268
  $this->request = $this->requests[0];
2269
  }
2270
  }
2271
+
2272
+ function requests() {
2273
  if ( $this->current_request + 1 < $this->request_count ) {
2274
  return true;
2275
  } elseif ( $this->current_request + 1 == $this->request_count ) {
2281
  $this->in_the_loop = false;
2282
  return false;
2283
  }
2284
+
2285
  function the_request() {
2286
  global $request;
2287
 
2311
 
2312
  function bp_group_membership_requests() {
2313
  global $requests_template;
2314
+
2315
  return $requests_template->requests();
2316
  }
2317
 
2318
  function bp_group_the_membership_request() {
2319
  global $requests_template;
2320
+
2321
  return $requests_template->the_request();
2322
  }
2323
 
2324
  function bp_group_request_user_avatar_thumb() {
2325
  global $requests_template;
2326
+
2327
  echo apply_filters( 'bp_group_request_user_avatar_thumb', bp_core_fetch_avatar( array( 'item_id' => $requests_template->request->user_id, 'type' => 'thumb' ) ) );
2328
  }
2329
 
2330
  function bp_group_request_reject_link() {
2331
+ global $requests_template, $groups_template;
2332
 
2333
  echo apply_filters( 'bp_group_request_reject_link', wp_nonce_url( bp_get_group_permalink( $groups_template->group ) . '/admin/membership-requests/reject/' . $requests_template->request->id, 'groups_reject_membership_request' ) );
2334
  }
2335
 
2336
  function bp_group_request_accept_link() {
2337
+ global $requests_template, $groups_template;
2338
 
2339
  echo apply_filters( 'bp_group_request_accept_link', wp_nonce_url( bp_get_group_permalink( $groups_template->group ) . '/admin/membership-requests/accept/' . $requests_template->request->id, 'groups_accept_membership_request' ) );
2340
  }
2341
 
2342
  function bp_group_request_time_since_requested() {
2343
+ global $requests_template;
2344
 
2345
  echo apply_filters( 'bp_group_request_time_since_requested', sprintf( __( 'requested %s ago', 'buddypress' ), bp_core_time_since( strtotime( $requests_template->request->date_modified ) ) ) );
2346
  }
2347
 
2348
  function bp_group_request_comment() {
2349
  global $requests_template;
2350
+
2351
  echo apply_filters( 'bp_group_request_comment', strip_tags( stripslashes( $requests_template->request->comments ) ) );
2352
  }
2353
 
2354
  function bp_group_request_user_link() {
2355
  global $requests_template;
2356
+
2357
  echo apply_filters( 'bp_group_request_user_link', bp_core_get_userlink( $requests_template->request->user_id ) );
2358
  }
2359
 
2367
  var $invite_count;
2368
  var $invites;
2369
  var $invite;
2370
+
2371
  var $in_the_loop;
2372
+
2373
  var $pag_page;
2374
  var $pag_num;
2375
  var $pag_links;
2376
  var $total_invite_count;
2377
+
2378
  function bp_groups_invite_template( $user_id, $group_id ) {
2379
  global $bp;
2380
 
2381
  $this->invites = groups_get_invites_for_group( $user_id, $group_id );
2382
+ $this->invite_count = count( $this->invites );
2383
  }
2384
+
2385
  function has_invites() {
2386
  if ( $this->invite_count )
2387
  return true;
2388
+
2389
  return false;
2390
  }
2391
+
2392
  function next_invite() {
2393
  $this->current_invite++;
2394
  $this->invite = $this->invites[$this->current_invite];
2395
+
2396
  return $this->invite;
2397
  }
2398
+
2399
  function rewind_invites() {
2400
  $this->current_invite = -1;
2401
  if ( $this->invite_count > 0 ) {
2402
  $this->invite = $this->invites[0];
2403
  }
2404
  }
2405
+
2406
+ function invites() {
2407
  if ( $this->current_invite + 1 < $this->invite_count ) {
2408
  return true;
2409
  } elseif ( $this->current_invite + 1 == $this->invite_count ) {
2415
  $this->in_the_loop = false;
2416
  return false;
2417
  }
2418
+
2419
  function the_invite() {
2420
  global $invite;
2421
 
2422
  $this->in_the_loop = true;
2423
  $user_id = $this->next_invite();
2424
+
2425
  $this->invite = new stdClass;
2426
  $this->invite->user = new BP_Core_User( $user_id );
2427
  $this->invite->group_id = $group_id; // Globaled in bp_group_has_invites()
2428
+
2429
  if ( 0 == $this->current_invite ) // loop has just started
2430
  do_action('loop_start');
2431
  }
2433
 
2434
  function bp_group_has_invites( $args = '' ) {
2435
  global $bp, $invites_template, $group_id;
2436
+
2437
  $defaults = array(
2438
  'group_id' => false,
2439
  'user_id' => $bp->loggedin_user->id
2441
 
2442
  $r = wp_parse_args( $args, $defaults );
2443
  extract( $r, EXTR_SKIP );
2444
+
2445
  if ( !$group_id ) {
2446
  /* Backwards compatibility */
2447
  if ( $bp->groups->current_group ) $group_id = $bp->groups->current_group->id;
2448
  if ( $bp->groups->new_group_id ) $group_id = $bp->groups->new_group_id;
2449
  }
2450
+
2451
  if ( !$group_id )
2452
  return false;
2453
 
2457
 
2458
  function bp_group_invites() {
2459
  global $invites_template;
2460
+
2461
  return $invites_template->invites();
2462
  }
2463
 
2464
  function bp_group_the_invite() {
2465
  global $invites_template;
2466
+
2467
  return $invites_template->the_invite();
2468
  }
2469
 
2508
  }
2509
  function bp_get_group_invite_user_remove_invite_url() {
2510
  global $invites_template;
2511
+
2512
  return wp_nonce_url( site_url( BP_GROUPS_SLUG . '/' . $invites_template->invite->group_id . '/invites/remove/' . $invites_template->invite->user->id ), 'groups_invite_uninvite_user' );
2513
  }
2514
 
bp-groups/bp-groups-widgets.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  /* Register widgets for groups component */
4
  function groups_register_widgets() {
5
- add_action('widgets_init', create_function('', 'return register_widget("BP_Groups_Widget");') );
6
  }
7
  add_action( 'plugins_loaded', 'groups_register_widgets' );
8
 
@@ -11,29 +11,29 @@ add_action( 'plugins_loaded', 'groups_register_widgets' );
11
  class BP_Groups_Widget extends WP_Widget {
12
  function bp_groups_widget() {
13
  parent::WP_Widget( false, $name = __( 'Groups', 'buddypress' ) );
14
-
15
  if ( is_active_widget( false, false, $this->id_base ) )
16
- wp_enqueue_script( 'groups_widget_groups_list-js', BP_PLUGIN_URL . '/bp-groups/js/widget-groups.js', array('jquery', 'jquery-livequery-pack') );
17
  }
18
 
19
  function widget($args, $instance) {
20
  global $bp;
21
-
22
  extract( $args );
23
-
24
  echo $before_widget;
25
  echo $before_title
26
- . $widget_name
27
  . $after_title; ?>
28
-
29
  <?php if ( bp_has_site_groups( 'type=popular&per_page=' . $instance['max_groups'] . '&max=' . $instance['max_groups'] ) ) : ?>
30
  <div class="item-options" id="groups-list-options">
31
  <span class="ajax-loader" id="ajax-loader-groups"></span>
32
- <a href="<?php echo site_url() . '/' . $bp->groups->slug ?>" id="newest-groups"><?php _e("Newest", 'buddypress') ?></a> |
33
- <a href="<?php echo site_url() . '/' . $bp->groups->slug ?>" id="recently-active-groups"><?php _e("Active", 'buddypress') ?></a> |
34
  <a href="<?php echo site_url() . '/' . $bp->groups->slug ?>" id="popular-groups" class="selected"><?php _e("Popular", 'buddypress') ?></a>
35
  </div>
36
-
37
  <ul id="groups-list" class="item-list">
38
  <?php while ( bp_site_groups() ) : bp_the_site_group(); ?>
39
  <li>
@@ -48,10 +48,10 @@ class BP_Groups_Widget extends WP_Widget {
48
  </li>
49
 
50
  <?php endwhile; ?>
51
- </ul>
52
  <?php wp_nonce_field( 'groups_widget_groups_list', '_wpnonce-groups' ); ?>
53
  <input type="hidden" name="groups_widget_max" id="groups_widget_max" value="<?php echo attribute_escape( $instance['max_groups'] ); ?>" />
54
-
55
  <?php else: ?>
56
 
57
  <div class="widget-error">
@@ -59,7 +59,7 @@ class BP_Groups_Widget extends WP_Widget {
59
  </div>
60
 
61
  <?php endif; ?>
62
-
63
  <?php echo $after_widget; ?>
64
  <?php
65
  }
@@ -83,7 +83,7 @@ class BP_Groups_Widget extends WP_Widget {
83
 
84
  function groups_ajax_widget_groups_list() {
85
  global $bp;
86
-
87
  check_ajax_referer('groups_widget_groups_list');
88
 
89
  switch ( $_POST['filter'] ) {
@@ -100,7 +100,7 @@ function groups_ajax_widget_groups_list() {
100
 
101
  if ( bp_has_site_groups( 'type=' . $type . '&per_page=' . $_POST['max_groups'] . '&max=' . $_POST['max_groups'] ) ) : ?>
102
  <?php echo "0[[SPLIT]]"; ?>
103
-
104
  <ul id="groups-list" class="item-list">
105
  <?php while ( bp_site_groups() ) : bp_the_site_group(); ?>
106
  <li>
@@ -112,7 +112,7 @@ function groups_ajax_widget_groups_list() {
112
  <div class="item-title"><a href="<?php bp_the_site_group_link() ?>" title="<?php bp_the_site_group_name() ?>"><?php bp_the_site_group_name() ?></a></div>
113
  <div class="item-meta">
114
  <span class="activity">
115
- <?php
116
  if ( 'newest-groups' == $_POST['filter'] ) {
117
  bp_the_site_group_date_created();
118
  } else if ( 'recently-active-groups' == $_POST['filter'] ) {
@@ -127,16 +127,16 @@ function groups_ajax_widget_groups_list() {
127
  </li>
128
 
129
  <?php endwhile; ?>
130
- </ul>
131
  <?php wp_nonce_field( 'groups_widget_groups_list', '_wpnonce-groups' ); ?>
132
  <input type="hidden" name="groups_widget_max" id="groups_widget_max" value="<?php echo attribute_escape( $_POST['max_groups'] ); ?>" />
133
-
134
  <?php else: ?>
135
 
136
  <?php echo "-1[[SPLIT]]<li>" . __("No groups matched the current filter.", 'buddypress'); ?>
137
 
138
  <?php endif;
139
-
140
  }
141
  add_action( 'wp_ajax_widget_groups_list', 'groups_ajax_widget_groups_list' );
142
  ?>
2
 
3
  /* Register widgets for groups component */
4
  function groups_register_widgets() {
5
+ add_action('widgets_init', create_function('', 'return register_widget("BP_Groups_Widget");') );
6
  }
7
  add_action( 'plugins_loaded', 'groups_register_widgets' );
8
 
11
  class BP_Groups_Widget extends WP_Widget {
12
  function bp_groups_widget() {
13
  parent::WP_Widget( false, $name = __( 'Groups', 'buddypress' ) );
14
+
15
  if ( is_active_widget( false, false, $this->id_base ) )
16
+ wp_enqueue_script( 'groups_widget_groups_list-js', BP_PLUGIN_URL . '/bp-groups/js/widget-groups.js', array('jquery', 'jquery-livequery-pack') );
17
  }
18
 
19
  function widget($args, $instance) {
20
  global $bp;
21
+
22
  extract( $args );
23
+
24
  echo $before_widget;
25
  echo $before_title
26
+ . $widget_name
27
  . $after_title; ?>
28
+
29
  <?php if ( bp_has_site_groups( 'type=popular&per_page=' . $instance['max_groups'] . '&max=' . $instance['max_groups'] ) ) : ?>
30
  <div class="item-options" id="groups-list-options">
31
  <span class="ajax-loader" id="ajax-loader-groups"></span>
32
+ <a href="<?php echo site_url() . '/' . $bp->groups->slug ?>" id="newest-groups"><?php _e("Newest", 'buddypress') ?></a> |
33
+ <a href="<?php echo site_url() . '/' . $bp->groups->slug ?>" id="recently-active-groups"><?php _e("Active", 'buddypress') ?></a> |
34
  <a href="<?php echo site_url() . '/' . $bp->groups->slug ?>" id="popular-groups" class="selected"><?php _e("Popular", 'buddypress') ?></a>
35
  </div>
36
+
37
  <ul id="groups-list" class="item-list">
38
  <?php while ( bp_site_groups() ) : bp_the_site_group(); ?>
39
  <li>
48
  </li>
49
 
50
  <?php endwhile; ?>
51
+ </ul>
52
  <?php wp_nonce_field( 'groups_widget_groups_list', '_wpnonce-groups' ); ?>
53
  <input type="hidden" name="groups_widget_max" id="groups_widget_max" value="<?php echo attribute_escape( $instance['max_groups'] ); ?>" />
54
+
55
  <?php else: ?>
56
 
57
  <div class="widget-error">
59
  </div>
60
 
61
  <?php endif; ?>
62
+
63
  <?php echo $after_widget; ?>
64
  <?php
65
  }
83
 
84
  function groups_ajax_widget_groups_list() {
85
  global $bp;
86
+
87
  check_ajax_referer('groups_widget_groups_list');
88
 
89
  switch ( $_POST['filter'] ) {
100
 
101
  if ( bp_has_site_groups( 'type=' . $type . '&per_page=' . $_POST['max_groups'] . '&max=' . $_POST['max_groups'] ) ) : ?>
102
  <?php echo "0[[SPLIT]]"; ?>
103
+
104
  <ul id="groups-list" class="item-list">
105
  <?php while ( bp_site_groups() ) : bp_the_site_group(); ?>
106
  <li>
112
  <div class="item-title"><a href="<?php bp_the_site_group_link() ?>" title="<?php bp_the_site_group_name() ?>"><?php bp_the_site_group_name() ?></a></div>
113
  <div class="item-meta">
114
  <span class="activity">
115
+ <?php
116
  if ( 'newest-groups' == $_POST['filter'] ) {
117
  bp_the_site_group_date_created();
118
  } else if ( 'recently-active-groups' == $_POST['filter'] ) {
127
  </li>
128
 
129
  <?php endwhile; ?>
130
+ </ul>
131
  <?php wp_nonce_field( 'groups_widget_groups_list', '_wpnonce-groups' ); ?>
132
  <input type="hidden" name="groups_widget_max" id="groups_widget_max" value="<?php echo attribute_escape( $_POST['max_groups'] ); ?>" />
133
+
134
  <?php else: ?>
135
 
136
  <?php echo "-1[[SPLIT]]<li>" . __("No groups matched the current filter.", 'buddypress'); ?>
137
 
138
  <?php endif;
139
+
140
  }
141
  add_action( 'wp_ajax_widget_groups_list', 'groups_ajax_widget_groups_list' );
142
  ?>
bp-groups/deprecated/bp-groups-deprecated.php CHANGED
@@ -3,7 +3,7 @@
3
  * Deprecated Groups Functionality
4
  *
5
  * This file contains functions that are deprecated.
6
- * You should not under any circumstance use these functions as they are
7
  * either no longer valid, or have been replaced with something much more awesome.
8
  *
9
  * If you are using functions in this file you should slap the back of your head
@@ -12,9 +12,9 @@
12
  *
13
  * Of course, things will still work if you use these functions but you will
14
  * be the laughing stock of the BuddyPress community. We will all point and laugh at
15
- * you. You'll also be making things harder for yourself in the long run,
16
  * and you will miss out on lovely performance and functionality improvements.
17
- *
18
  * If you've checked you are not using any deprecated functions and finished your little
19
  * dance, you can add the following line to your wp-config.php file to prevent any of
20
  * these old functions from being loaded:
@@ -24,14 +24,14 @@
24
 
25
  function groups_deprecated_globals() {
26
  global $bp;
27
-
28
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
29
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
30
  return false;
31
 
32
  $bp->groups->image_base = BP_PLUGIN_URL . '/bp-groups/deprecated/images';
33
  }
34
- add_action( 'plugins_loaded', 'groups_deprecated_globals', 5 );
35
  add_action( 'admin_menu', 'groups_deprecated_globals', 2 );
36
 
37
  function groups_avatar_upload( $deprecated = true ) { ?>
@@ -39,7 +39,7 @@ function groups_avatar_upload( $deprecated = true ) { ?>
39
  <?php if ( !bp_get_avatar_admin_step() ) : ?>
40
 
41
  <p>
42
- <input type="file" name="file" id="file" />
43
  <input type="submit" name="upload" id="upload" value="<?php _e( 'Upload Image', 'buddypress' ) ?>" />
44
  <input type="hidden" name="action" id="action" value="bp_avatar_upload" />
45
  </p>
@@ -49,11 +49,11 @@ function groups_avatar_upload( $deprecated = true ) { ?>
49
  <?php if ( 'crop-image' == bp_get_avatar_admin_step() ) : ?>
50
 
51
  <h3><?php _e( 'Crop Group Avatar', 'buddypress' ) ?></h3>
52
-
53
  <img src="<?php bp_avatar_to_crop() ?>" id="avatar-to-crop" class="avatar" alt="<?php _e( 'Avatar to crop', 'buddypress' ) ?>" />
54
 
55
  <input type="submit" name="avatar-crop-submit" id="avatar-crop-submit" value="<?php _e( 'Crop Image', 'buddypress' ) ?>" />
56
-
57
  <input type="hidden" name="image_src" id="image_src" value="<?php bp_avatar_to_crop_src() ?>" />
58
  <input type="hidden" name="upload" id="upload" />
59
  <input type="hidden" id="x" name="x" />
@@ -67,12 +67,12 @@ function groups_avatar_upload( $deprecated = true ) { ?>
67
 
68
  function groups_get_avatar_hrefs( $avatars ) {
69
  global $bp;
70
-
71
  $src = $bp->root_domain . '/';
72
 
73
  $thumb_href = str_replace( ABSPATH, $src, stripslashes( $avatars['v1_out'] ) );
74
  $full_href = str_replace( ABSPATH, $src, stripslashes ( $avatars['v2_out'] ) );
75
-
76
  return array( 'thumb_href' => $thumb_href, 'full_href' => $full_href );
77
  }
78
 
@@ -92,7 +92,7 @@ function bp_new_group_avatar_upload_form() {
92
  /* DEPRECATED - BuddyPress templates are now merged with WordPress themes */
93
  function groups_force_buddypress_theme( $template ) {
94
  global $bp;
95
-
96
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
97
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
98
  return $template;
@@ -119,7 +119,7 @@ function groups_force_buddypress_stylesheet( $stylesheet ) {
119
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
120
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
121
  return $stylesheet;
122
-
123
  if ( $bp->current_component != $bp->groups->slug )
124
  return $stylesheet;
125
 
@@ -141,7 +141,7 @@ function groups_add_js() {
141
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
142
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
143
  return false;
144
-
145
  if ( $bp->current_component == $bp->groups->slug )
146
  wp_enqueue_script( 'bp-groups-js', BP_PLUGIN_URL . '/bp-groups/deprecated/js/general.js' );
147
  }
@@ -151,9 +151,9 @@ function groups_add_structure_css() {
151
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
152
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
153
  return false;
154
-
155
  /* Enqueue the structure CSS file to give basic positional formatting for components */
156
- wp_enqueue_style( 'bp-groups-structure', BP_PLUGIN_URL . '/bp-groups/deprecated/css/structure.css' );
157
  }
158
  add_action( 'bp_styles', 'groups_add_structure_css' );
159
 
@@ -161,7 +161,7 @@ function groups_add_directory_js() {
161
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
162
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
163
  return false;
164
-
165
  wp_enqueue_script( 'bp-groups-directory-groups', BP_PLUGIN_URL . '/bp-groups/deprecated/js/directory-groups.js', array( 'jquery', 'jquery-livequery-pack' ) );
166
  }
167
  add_action( 'groups_directory_groups_setup', 'groups_add_directory_js' );
@@ -169,21 +169,21 @@ add_action( 'groups_directory_groups_setup', 'groups_add_directory_js' );
169
  /* DEPRECATED - use bp_has_groups( 'type=random' ) template loop */
170
  function bp_groups_random_selection( $total_groups = 5 ) {
171
  global $bp;
172
-
173
  if ( !$group_ids = wp_cache_get( 'groups_random_groups', 'bp' ) ) {
174
  $group_ids = BP_Groups_Group::get_random( $total_groups, 1 );
175
  wp_cache_set( 'groups_random_groups', $group_ids, 'bp' );
176
  }
177
- ?>
178
  <?php if ( $group_ids['groups'] ) { ?>
179
  <ul class="item-list" id="random-groups-list">
180
- <?php
181
- for ( $i = 0; $i < count( $group_ids['groups'] ); $i++ ) {
182
  if ( !$group = wp_cache_get( 'groups_group_nouserdata_' . $group_ids['groups'][$i]->group_id, 'bp' ) ) {
183
  $group = new BP_Groups_Group( $group_ids['groups'][$i]->group_id, false, false );
184
  wp_cache_set( 'groups_group_nouserdata_' . $group_ids['groups'][$i]->group_id, $group, 'bp' );
185
  }
186
- ?>
187
  <li>
188
  <div class="item-avatar">
189
  <a href="<?php echo bp_get_group_permalink( $group ) ?>" title="<?php echo bp_get_group_name( $group ) ?>"><?php echo bp_get_group_avatar_thumb( $group ) ?></a>
@@ -194,12 +194,12 @@ function bp_groups_random_selection( $total_groups = 5 ) {
194
  <div class="item-meta"><span class="activity"><?php echo bp_core_get_last_activity( groups_get_groupmeta( $group->id, 'last_activity' ), __( 'active %s ago', 'buddypress' ) ) ?></span></div>
195
  <div class="item-meta desc"><?php echo bp_create_excerpt( $group->description ) ?></div>
196
  </div>
197
-
198
  <div class="action">
199
  <?php bp_group_join_button( $group ) ?>
200
  <div class="meta">
201
  <?php $member_count = groups_get_groupmeta( $group->id, 'total_member_count' ) ?>
202
- <?php echo ucwords($group->status) ?> <?php _e( 'Group', 'buddypress' ) ?> /
203
  <?php if ( 1 == $member_count ) : ?>
204
  <?php printf( __( '%d member', 'buddypress' ), $member_count ) ?>
205
  <?php else : ?>
@@ -207,7 +207,7 @@ function bp_groups_random_selection( $total_groups = 5 ) {
207
  <?php endif; ?>
208
  </div>
209
  </div>
210
-
211
  <div class="clear"></div>
212
  </li>
213
  <?php } ?>
@@ -215,7 +215,7 @@ function bp_groups_random_selection( $total_groups = 5 ) {
215
  <?php } else { ?>
216
  <div id="message" class="info">
217
  <p><?php _e( "There aren't enough groups to show a random sample just yet.", 'buddypress' ) ?></p>
218
- </div>
219
  <?php } ?>
220
  <?php
221
  }
@@ -223,18 +223,18 @@ function bp_groups_random_selection( $total_groups = 5 ) {
223
  /* DEPRECATED - use bp_has_groups( 'type=random' ) template loop */
224
  function bp_groups_random_groups( $total_groups = 5 ) {
225
  global $bp;
226
-
227
  if ( !$group_ids = wp_cache_get( 'groups_random_user_groups_' . $bp->displayed_user->id . '_' . $total_groups, 'bp' ) ) {
228
  $group_ids = groups_get_random_groups_for_user( $bp->displayed_user->id, $total_groups, 1 );
229
  wp_cache_set( 'groups_random_user_groups_' . $bp->displayed_user->id . '_' . $total_groups, $group_ids, 'bp' );
230
  }
231
-
232
- ?>
233
  <div class="info-group">
234
  <h4><?php bp_word_or_name( __( "My Groups", 'buddypress' ), __( "%s's Groups", 'buddypress' ) ) ?> (<?php echo BP_Groups_Member::total_group_count() ?>) <span><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>"><?php _e('See All', 'buddypress') ?> &raquo;</a></span></h4>
235
  <?php if ( $group_ids ) { ?>
236
  <ul class="horiz-gallery">
237
- <?php
238
  for ( $i = 0; $i < count( $group_ids ); $i++ ) {
239
  if ( !$group = wp_cache_get( 'groups_group_nouserdata_' . $group_ids[$i], 'bp' ) ) {
240
  $group = new BP_Groups_Group( $group_ids[$i], false, false );
@@ -262,38 +262,38 @@ function bp_group_active_forum_topics( $total_topics = 3, $group = false ) {
262
 
263
  if ( !$group )
264
  $group =& $groups_template->group;
265
-
266
  $forum_id = groups_get_groupmeta( $group->id, 'forum_id' );
267
 
268
  if ( $forum_id && $forum_id != '' ) {
269
  if ( function_exists( 'bp_forums_setup' ) ) {
270
  $latest_topics = bp_forums_get_forum_topics( array( 'forum_id' => $forum_id ) );
271
-
272
  if ( $latest_topics ) { ?>
273
  <ul class="item-list" id="recent-forum-topics"><?php
274
-
275
  $counter = 0;
276
-
277
  foreach( $latest_topics as $topic ) {
278
  $alt = ( $counter % 2 == 1 ) ? ' class="alt"' : '';
279
  $forum_template->topic = (object)$topic; ?>
280
-
281
  <li<?php echo $alt ?>>
282
  <div class="avatar">
283
  <?php bp_the_topic_poster_avatar() ?>
284
  </div>
285
 
286
- <a href="<?php bp_the_topic_permalink() ?>" title="<?php bp_the_topic_title() ?> - <?php _e( 'Permalink', 'buddypress' ) ?>"><?php bp_the_topic_title() ?></a>
287
  <span class="small">- <?php bp_the_topic_total_post_count() ?> </span>
288
  <p><span class="activity"><?php echo sprintf( __( 'updated %s ago', 'buddypress' ), bp_the_topic_time_since_last_post( false ) ) ?></span></p>
289
-
290
  <div class="latest-post">
291
  <?php _e( 'Latest by', 'buddypress' ) ?> <?php bp_the_topic_last_poster_name() ?>:
292
  <?php bp_the_topic_latest_post_excerpt() ?>
293
  </div>
294
  </li>
295
  <?php $counter++ ?>
296
-
297
  <?php } ?>
298
  </ul>
299
  <?php
@@ -312,7 +312,7 @@ function bp_group_active_forum_topics( $total_topics = 3, $group = false ) {
312
  /* DEPRECATED - use group invite template loop (see groups/create.php in skeleton BuddyPress theme) */
313
  function bp_group_send_invite_form( $group = false ) {
314
  global $bp, $groups_template, $invites;
315
-
316
  if ( !$group )
317
  $group =& $groups_template->group;
318
  ?>
@@ -324,13 +324,13 @@ function bp_group_send_invite_form( $group = false ) {
324
  </div>
325
 
326
  <div class="main-column">
327
-
328
  <div id="message" class="info">
329
  <p><?php _e('Select people to invite from your friends list.', 'buddypress'); ?></p>
330
  </div>
331
 
332
  <?php $invites = groups_get_invites_for_group( $bp->loggedin_user->id, $group->id ) ?>
333
-
334
  <ul id="friend-list" class="item-list">
335
  <?php for ( $i = 0; $i < count($invites); $i++ ) {
336
  if ( !$user = wp_cache_get( 'bp_user_' . $invites[$i], 'bp' ) ) {
@@ -343,12 +343,12 @@ function bp_group_send_invite_form( $group = false ) {
343
  <h4><?php echo $user->user_link ?></h4>
344
  <span class="activity"><?php echo $user->last_active ?></span>
345
  <div class="action">
346
- <a class="remove" href="<?php echo wp_nonce_url( site_url( $bp->groups->slug . '/' . $group->id . '/invites/remove/' . $user->id ), 'groups_invite_uninvite_user' ) ?>" id="uid-<?php echo $user->id ?>"><?php _e( 'Remove Invite', 'buddypress' ) ?></a>
347
  </div>
348
  </li>
349
  <?php } // end for ?>
350
  </ul>
351
-
352
  <?php wp_nonce_field( 'groups_send_invites', '_wpnonce_send_invites' ) ?>
353
  </div>
354
  <?php
@@ -357,7 +357,7 @@ function bp_group_send_invite_form( $group = false ) {
357
  /* DEPRECATED - use bp_group_has_invites() template loop */
358
  function bp_group_list_invite_friends( $args = '' ) {
359
  global $bp, $invites;
360
-
361
  if ( !function_exists('friends_install') )
362
  return false;
363
 
@@ -369,17 +369,17 @@ function bp_group_list_invite_friends( $args = '' ) {
369
  ?>
370
  <div id="invite-list">
371
  <ul>
372
- <?php
373
  for ( $i = 0; $i < count( $friends ); $i++ ) {
374
  if ( $invites ) {
375
  if ( in_array( $friends[$i]['id'], $invites ) ) {
376
  $checked = ' checked="checked"';
377
  } else {
378
  $checked = '';
379
- }
380
  }
381
  ?>
382
-
383
  <li><input<?php echo $checked ?> type="checkbox" name="friends[]" id="f-<?php echo $friends[$i]['id'] ?>" value="<?php echo attribute_escape( $friends[$i]['id'] ); ?>" /> <?php echo $friends[$i]['full_name']; ?></li>
384
  <?php } ?>
385
  </ul>
@@ -398,7 +398,7 @@ function bp_group_random_members( $group = false ) {
398
  $group =& $groups_template->group;
399
 
400
  $members = &$group->random_members;
401
- ?>
402
  <ul class="horiz-gallery">
403
  <?php for ( $i = 0; $i < count( $members ); $i++ ) { ?>
404
  <li>
@@ -417,7 +417,7 @@ function bp_group_member_promote_link( $user_id = false, $deprecated = false ) {
417
 
418
  if ( !$user_id )
419
  $user_id = $members_template->member->user_id;
420
-
421
  echo bp_get_group_member_promote_link( $user_id );
422
  }
423
  function bp_get_group_member_promote_link( $user_id = false, $group = false ) {
@@ -425,7 +425,7 @@ function bp_group_member_promote_link( $user_id = false, $deprecated = false ) {
425
 
426
  if ( !$user_id )
427
  $user_id = $members_template->member->user_id;
428
-
429
  if ( !$group )
430
  $group =& $groups_template->group;
431
 
@@ -442,19 +442,19 @@ function bp_group_create_form() {
442
  case 'group-details': ?>
443
  <label for="group-name">* <?php _e('Group Name', 'buddypress') ?></label>
444
  <input type="text" name="group-name" id="group-name" value="<?php echo attribute_escape( ( $bp->groups->new_group ) ? $bp->groups->current_group->name : $_POST['group-name'] ); ?>" />
445
-
446
  <label for="group-desc">* <?php _e('Group Description', 'buddypress') ?></label>
447
  <textarea name="group-desc" id="group-desc"><?php echo htmlspecialchars( ( $bp->groups->new_group ) ? $bp->groups->current_group->description : $_POST['group-desc'] ); ?></textarea>
448
-
449
  <label for="group-news"><?php _e('Recent News', 'buddypress') ?></label>
450
  <textarea name="group-news" id="group-news"><?php echo htmlspecialchars( ( $bp->groups->new_group ) ? $bp->groups->current_group->news : $_POST['group-news'] ); ?></textarea>
451
-
452
  <?php do_action( 'groups_custom_group_fields_editable' ) ?>
453
 
454
  <?php wp_nonce_field( 'groups_create_save_group-details' ) ?>
455
 
456
  <?php break; ?>
457
-
458
  <?php case 'group-settings': ?>
459
  <?php if ( bp_are_previous_group_creation_steps_complete( 'group-settings' ) ) { ?>
460
  <?php if ( function_exists('bp_wire_install') ) : ?>
@@ -462,7 +462,7 @@ function bp_group_create_form() {
462
  <label><input type="checkbox" name="group-show-wire" id="group-show-wire" value="1"<?php if ( $bp->groups->current_group->enable_wire ) { ?> checked="checked"<?php } ?> /> <?php _e('Enable comment wire', 'buddypress') ?></label>
463
  </div>
464
  <?php endif; ?>
465
-
466
  <?php if ( function_exists('bp_forums_setup') ) : ?>
467
  <?php if ( bp_forums_is_installed_correctly() ) { ?>
468
  <div class="checkbox">
@@ -478,7 +478,7 @@ function bp_group_create_form() {
478
  }
479
  }?>
480
  <?php endif; ?>
481
-
482
  <?php if ( function_exists('bp_albums_install') ) : ?>
483
  <div class="checkbox with-suboptions">
484
  <label><input type="checkbox" name="group-show-photos" id="group-show-photos" value="1"<?php if ( $bp->groups->current_group->enable_photos ) { ?> checked="checked"<?php } ?> /> <?php _e('Enable photo gallery', 'buddypress') ?></label>
@@ -488,11 +488,11 @@ function bp_group_create_form() {
488
  </div>
489
  </div>
490
  <?php endif; ?>
491
-
492
  <h3><?php _e( 'Privacy Options', 'buddypress' ); ?></h3>
493
-
494
  <div class="radio">
495
- <label><input type="radio" name="group-status" value="public"<?php if ( 'public' == $bp->groups->current_group->status ) { ?> checked="checked"<?php } ?> />
496
  <strong><?php _e( 'This is a public group', 'buddypress' ) ?></strong>
497
  <ul>
498
  <li><?php _e( 'Any site member can join this group.', 'buddypress' ) ?></li>
@@ -500,7 +500,7 @@ function bp_group_create_form() {
500
  <li><?php _e( 'Group content and activity will be visible to any site member.', 'buddypress' ) ?></li>
501
  </ul>
502
  </label>
503
-
504
  <label><input type="radio" name="group-status" value="private"<?php if ( 'private' == $bp->groups->current_group->status ) { ?> checked="checked"<?php } ?> />
505
  <strong><?php _e( 'This is a private group', 'buddypress' ) ?></strong>
506
  <ul>
@@ -509,7 +509,7 @@ function bp_group_create_form() {
509
  <li><?php _e( 'Group content and activity will only be visible to members of the group.', 'buddypress' ) ?></li>
510
  </ul>
511
  </label>
512
-
513
  <label><input type="radio" name="group-status" value="hidden"<?php if ( 'hidden' == $bp->groups->current_group->status ) { ?> checked="checked"<?php } ?> />
514
  <strong><?php _e('This is a hidden group', 'buddypress') ?></strong>
515
  <ul>
@@ -527,20 +527,20 @@ function bp_group_create_form() {
527
  </div>
528
  <?php } ?>
529
  <?php break; ?>
530
-
531
  <?php case 'group-avatar': ?>
532
  <?php if ( bp_are_previous_group_creation_steps_complete( 'group-avatar' ) ) { ?>
533
  <div class="left-menu">
534
  <?php bp_new_group_avatar() ?>
535
  </div>
536
-
537
  <div class="main-column">
538
  <p><?php _e("Upload an image to use as an avatar for this group. The image will be shown on the main group page, and in search results.", 'buddypress') ?></p>
539
-
540
  <?php groups_avatar_upload() ?>
541
 
542
  </div>
543
-
544
  <?php wp_nonce_field( 'groups_step3_save' ) ?>
545
  <?php } else { ?>
546
  <div id="message" class="info">
@@ -548,14 +548,14 @@ function bp_group_create_form() {
548
  </div>
549
  <?php } ?>
550
 
551
- <?php wp_nonce_field( 'groups_create_save_group-avatar' ) ?>
552
 
553
  <?php break; ?>
554
  <?php case 'group-invites': ?>
555
- <?php
556
  if ( bp_are_previous_group_creation_steps_complete( 'group-invites' ) ) {
557
  $group_link = bp_get_group_permalink( $bp->groups->new_group );
558
-
559
  if ( function_exists('friends_install') ) {
560
  if ( friends_get_friend_count_for_user( $bp->loggedin_user->id ) ) {
561
  bp_group_send_invite_form( $bp->groups->new_group );
@@ -569,7 +569,7 @@ function bp_group_create_form() {
569
  } ?>
570
 
571
  <?php wp_nonce_field( 'groups_step4_save' ) ?>
572
-
573
  <?php
574
  } else { ?>
575
  <div id="message" class="info">
@@ -581,11 +581,11 @@ function bp_group_create_form() {
581
 
582
  <?php break; ?>
583
  <?php } ?>
584
-
585
  <?php do_action( 'groups_custom_create_steps' ) // Allow plugins to add custom group creation steps ?>
586
-
587
  <div class="clear"></div>
588
-
589
  <div id="previous-next">
590
  <!-- Previous Button -->
591
  <?php if ( !bp_is_first_group_creation_step() ) : ?>
@@ -596,12 +596,12 @@ function bp_group_create_form() {
596
  <?php if ( !bp_is_last_group_creation_step() && !bp_is_first_group_creation_step() ) : ?>
597
  &nbsp; <input type="submit" value="<?php _e('Next Step', 'buddypress') ?> &rarr;" id="group-creation-next" name="save" />
598
  <?php endif;?>
599
-
600
  <!-- Create Button -->
601
  <?php if ( bp_is_first_group_creation_step() ) : ?>
602
  <input type="submit" value="<?php _e('Create Group and Continue', 'buddypress') ?> &rarr;" id="group-creation-create" name="save" />
603
  <?php endif; ?>
604
-
605
  <!-- Finish Button -->
606
  <?php if ( bp_is_last_group_creation_step() ) : ?>
607
  <input type="submit" value="<?php _e('Finish', 'buddypress') ?> &rarr;" id="group-creation-finish" name="save" />
@@ -621,7 +621,7 @@ function groups_ajax_invite_user() {
621
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
622
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
623
  return false;
624
-
625
  check_ajax_referer( 'groups_invite_uninvite_user' );
626
 
627
  if ( !$_POST['friend_id'] || !$_POST['friend_action'] || !$_POST['group_id'] )
@@ -632,30 +632,30 @@ function groups_ajax_invite_user() {
632
 
633
  if ( !friends_check_friendship( $bp->loggedin_user->id, $_POST['friend_id'] ) )
634
  return false;
635
-
636
  if ( 'invite' == $_POST['friend_action'] ) {
637
-
638
  if ( !groups_invite_user( array( 'user_id' => $_POST['friend_id'], 'group_id' => $_POST['group_id'] ) ) )
639
  return false;
640
-
641
  $user = new BP_Core_User( $_POST['friend_id'] );
642
-
643
  echo '<li id="uid-' . $user->id . '">';
644
  echo $user->avatar_thumb;
645
  echo '<h4>' . $user->user_link . '</h4>';
646
  echo '<span class="activity">' . attribute_escape( $user->last_active ) . '</span>';
647
  echo '<div class="action">
648
- <a class="remove" href="' . wp_nonce_url( $bp->loggedin_user->domain . $bp->groups->slug . '/' . $_POST['group_id'] . '/invites/remove/' . $user->id, 'groups_invite_uninvite_user' ) . '" id="uid-' . attribute_escape( $user->id ) . '">' . __( 'Remove Invite', 'buddypress' ) . '</a>
649
  </div>';
650
  echo '</li>';
651
-
652
  } else if ( 'uninvite' == $_POST['friend_action'] ) {
653
-
654
  if ( !groups_uninvite_user( $_POST['friend_id'], $_POST['group_id'] ) )
655
  return false;
656
-
657
  return true;
658
-
659
  } else {
660
  return false;
661
  }
@@ -668,9 +668,9 @@ function groups_ajax_group_filter() {
668
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
669
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
670
  return false;
671
-
672
  check_ajax_referer( 'group-filter-box' );
673
-
674
  locate_template( array( 'groups/group-loop.php' ), true );
675
  }
676
  add_action( 'wp_ajax_group_filter', 'groups_ajax_group_filter' );
@@ -682,9 +682,9 @@ function groups_ajax_member_list() {
682
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
683
  return false;
684
  ?>
685
-
686
  <?php if ( bp_group_has_members( 'group_id=' . $_REQUEST['group_id'] ) ) : ?>
687
-
688
  <?php if ( bp_group_member_needs_pagination() ) : ?>
689
  <div id="member-count" class="pag-count">
690
  <?php bp_group_member_pagination_count() ?>
@@ -694,14 +694,14 @@ function groups_ajax_member_list() {
694
  <?php bp_group_member_pagination() ?>
695
  </div>
696
  <?php endif; ?>
697
-
698
  <ul id="member-list" class="item-list">
699
  <?php while ( bp_group_members() ) : bp_group_the_member(); ?>
700
  <li>
701
  <?php bp_group_member_avatar() ?>
702
  <h5><?php bp_group_member_link() ?></h5>
703
  <span class="activity"><?php bp_group_member_joined_since() ?></span>
704
-
705
  <?php if ( function_exists( 'friends_install' ) ) : ?>
706
  <div class="action">
707
  <?php bp_add_friend_button( bp_get_group_member_id() ) ?>
@@ -729,9 +729,9 @@ function groups_ajax_member_admin_list() {
729
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
730
  return false;
731
  ?>
732
-
733
  <?php if ( bp_group_has_members( 'group_id=' . $_REQUEST['group_id'] . '&per_page=' . $_REQUEST['num'] ) ) : ?>
734
-
735
  <?php if ( bp_group_member_needs_pagination() ) : ?>
736
  <div id="member-count" class="pag-count">
737
  <?php bp_group_member_pagination_count() ?>
@@ -741,7 +741,7 @@ function groups_ajax_member_admin_list() {
741
  <?php bp_group_member_admin_pagination() ?>
742
  </div>
743
  <?php endif; ?>
744
-
745
  <ul id="members-list" class="item-list single-line">
746
  <?php while ( bp_group_members() ) : bp_group_the_member(); ?>
747
  <?php if ( bp_get_group_member_is_banned() ) : ?>
@@ -776,7 +776,7 @@ function bp_core_ajax_directory_groups() {
776
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
777
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
778
  return false;
779
-
780
  check_ajax_referer('directory_groups');
781
 
782
  locate_template( array( 'directories/groups/groups-loop.php' ), true );
@@ -792,45 +792,45 @@ function groups_ajax_joinleave_group() {
792
 
793
  if ( groups_is_user_banned( $bp->loggedin_user->id, $_POST['gid'] ) )
794
  return false;
795
-
796
  if ( !$group = new BP_Groups_Group( $_POST['gid'], false, false ) )
797
  return false;
798
-
799
  if ( 'hidden' == $group->status )
800
  return false;
801
-
802
  if ( !groups_is_user_member( $bp->loggedin_user->id, $group->id ) ) {
803
 
804
  if ( 'public' == $group->status ) {
805
-
806
  check_ajax_referer( 'groups_join_group' );
807
-
808
  if ( !groups_join_group( $group->id ) ) {
809
  _e( 'Error joining group', 'buddypress' );
810
  } else {
811
  echo '<a id="group-' . attribute_escape( $group->id ) . '" class="leave-group" rel="leave" title="' . __( 'Leave Group', 'buddypress' ) . '" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>';
812
- }
813
-
814
  } else if ( 'private' == $group->status ) {
815
-
816
  check_ajax_referer( 'groups_request_membership' );
817
-
818
  if ( !groups_send_membership_request( $bp->loggedin_user->id, $group->id ) ) {
819
- _e( 'Error requesting membership', 'buddypress' );
820
  } else {
821
- echo '<a id="group-' . attribute_escape( $group->id ) . '" class="membership-requested" rel="membership-requested" title="' . __( 'Membership Requested', 'buddypress' ) . '" href="' . bp_get_group_permalink( $group ) . '">' . __( 'Membership Requested', 'buddypress' ) . '</a>';
822
- }
823
  }
824
-
825
  } else {
826
 
827
  check_ajax_referer( 'groups_leave_group' );
828
-
829
  if ( !groups_leave_group( $group->id ) ) {
830
  _e( 'Error leaving group', 'buddypress' );
831
  } else {
832
  if ( 'public' == $group->status ) {
833
- echo '<a id="group-' . attribute_escape( $group->id ) . '" class="join-group" rel="join" title="' . __( 'Join Group', 'buddypress' ) . '" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/join', 'groups_join_group' ) . '">' . __( 'Join Group', 'buddypress' ) . '</a>';
834
  } else if ( 'private' == $group->status ) {
835
  echo '<a id="group-' . attribute_escape( $group->id ) . '" class="request-membership" rel="join" title="' . __( 'Request Membership', 'buddypress' ) . '" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/request-membership', 'groups_send_membership_request' ) . '">' . __( 'Request Membership', 'buddypress' ) . '</a>';
836
  }
3
  * Deprecated Groups Functionality
4
  *
5
  * This file contains functions that are deprecated.
6
+ * You should not under any circumstance use these functions as they are
7
  * either no longer valid, or have been replaced with something much more awesome.
8
  *
9
  * If you are using functions in this file you should slap the back of your head
12
  *
13
  * Of course, things will still work if you use these functions but you will
14
  * be the laughing stock of the BuddyPress community. We will all point and laugh at
15
+ * you. You'll also be making things harder for yourself in the long run,
16
  * and you will miss out on lovely performance and functionality improvements.
17
+ *
18
  * If you've checked you are not using any deprecated functions and finished your little
19
  * dance, you can add the following line to your wp-config.php file to prevent any of
20
  * these old functions from being loaded:
24
 
25
  function groups_deprecated_globals() {
26
  global $bp;
27
+
28
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
29
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
30
  return false;
31
 
32
  $bp->groups->image_base = BP_PLUGIN_URL . '/bp-groups/deprecated/images';
33
  }
34
+ add_action( 'plugins_loaded', 'groups_deprecated_globals', 5 );
35
  add_action( 'admin_menu', 'groups_deprecated_globals', 2 );
36
 
37
  function groups_avatar_upload( $deprecated = true ) { ?>
39
  <?php if ( !bp_get_avatar_admin_step() ) : ?>
40
 
41
  <p>
42
+ <input type="file" name="file" id="file" />
43
  <input type="submit" name="upload" id="upload" value="<?php _e( 'Upload Image', 'buddypress' ) ?>" />
44
  <input type="hidden" name="action" id="action" value="bp_avatar_upload" />
45
  </p>
49
  <?php if ( 'crop-image' == bp_get_avatar_admin_step() ) : ?>
50
 
51
  <h3><?php _e( 'Crop Group Avatar', 'buddypress' ) ?></h3>
52
+
53
  <img src="<?php bp_avatar_to_crop() ?>" id="avatar-to-crop" class="avatar" alt="<?php _e( 'Avatar to crop', 'buddypress' ) ?>" />
54
 
55
  <input type="submit" name="avatar-crop-submit" id="avatar-crop-submit" value="<?php _e( 'Crop Image', 'buddypress' ) ?>" />
56
+
57
  <input type="hidden" name="image_src" id="image_src" value="<?php bp_avatar_to_crop_src() ?>" />
58
  <input type="hidden" name="upload" id="upload" />
59
  <input type="hidden" id="x" name="x" />
67
 
68
  function groups_get_avatar_hrefs( $avatars ) {
69
  global $bp;
70
+
71
  $src = $bp->root_domain . '/';
72
 
73
  $thumb_href = str_replace( ABSPATH, $src, stripslashes( $avatars['v1_out'] ) );
74
  $full_href = str_replace( ABSPATH, $src, stripslashes ( $avatars['v2_out'] ) );
75
+
76
  return array( 'thumb_href' => $thumb_href, 'full_href' => $full_href );
77
  }
78
 
92
  /* DEPRECATED - BuddyPress templates are now merged with WordPress themes */
93
  function groups_force_buddypress_theme( $template ) {
94
  global $bp;
95
+
96
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
97
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
98
  return $template;
119
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
120
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
121
  return $stylesheet;
122
+
123
  if ( $bp->current_component != $bp->groups->slug )
124
  return $stylesheet;
125
 
141
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
142
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
143
  return false;
144
+
145
  if ( $bp->current_component == $bp->groups->slug )
146
  wp_enqueue_script( 'bp-groups-js', BP_PLUGIN_URL . '/bp-groups/deprecated/js/general.js' );
147
  }
151
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
152
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
153
  return false;
154
+
155
  /* Enqueue the structure CSS file to give basic positional formatting for components */
156
+ wp_enqueue_style( 'bp-groups-structure', BP_PLUGIN_URL . '/bp-groups/deprecated/css/structure.css' );
157
  }
158
  add_action( 'bp_styles', 'groups_add_structure_css' );
159
 
161
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
162
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
163
  return false;
164
+
165
  wp_enqueue_script( 'bp-groups-directory-groups', BP_PLUGIN_URL . '/bp-groups/deprecated/js/directory-groups.js', array( 'jquery', 'jquery-livequery-pack' ) );
166
  }
167
  add_action( 'groups_directory_groups_setup', 'groups_add_directory_js' );
169
  /* DEPRECATED - use bp_has_groups( 'type=random' ) template loop */
170
  function bp_groups_random_selection( $total_groups = 5 ) {
171
  global $bp;
172
+
173
  if ( !$group_ids = wp_cache_get( 'groups_random_groups', 'bp' ) ) {
174
  $group_ids = BP_Groups_Group::get_random( $total_groups, 1 );
175
  wp_cache_set( 'groups_random_groups', $group_ids, 'bp' );
176
  }
177
+ ?>
178
  <?php if ( $group_ids['groups'] ) { ?>
179
  <ul class="item-list" id="random-groups-list">
180
+ <?php
181
+ for ( $i = 0; $i < count( $group_ids['groups'] ); $i++ ) {
182
  if ( !$group = wp_cache_get( 'groups_group_nouserdata_' . $group_ids['groups'][$i]->group_id, 'bp' ) ) {
183
  $group = new BP_Groups_Group( $group_ids['groups'][$i]->group_id, false, false );
184
  wp_cache_set( 'groups_group_nouserdata_' . $group_ids['groups'][$i]->group_id, $group, 'bp' );
185
  }
186
+ ?>
187
  <li>
188
  <div class="item-avatar">
189
  <a href="<?php echo bp_get_group_permalink( $group ) ?>" title="<?php echo bp_get_group_name( $group ) ?>"><?php echo bp_get_group_avatar_thumb( $group ) ?></a>
194
  <div class="item-meta"><span class="activity"><?php echo bp_core_get_last_activity( groups_get_groupmeta( $group->id, 'last_activity' ), __( 'active %s ago', 'buddypress' ) ) ?></span></div>
195
  <div class="item-meta desc"><?php echo bp_create_excerpt( $group->description ) ?></div>
196
  </div>
197
+
198
  <div class="action">
199
  <?php bp_group_join_button( $group ) ?>
200
  <div class="meta">
201
  <?php $member_count = groups_get_groupmeta( $group->id, 'total_member_count' ) ?>
202
+ <?php echo ucwords($group->status) ?> <?php _e( 'Group', 'buddypress' ) ?> /
203
  <?php if ( 1 == $member_count ) : ?>
204
  <?php printf( __( '%d member', 'buddypress' ), $member_count ) ?>
205
  <?php else : ?>
207
  <?php endif; ?>
208
  </div>
209
  </div>
210
+
211
  <div class="clear"></div>
212
  </li>
213
  <?php } ?>
215
  <?php } else { ?>
216
  <div id="message" class="info">
217
  <p><?php _e( "There aren't enough groups to show a random sample just yet.", 'buddypress' ) ?></p>
218
+ </div>
219
  <?php } ?>
220
  <?php
221
  }
223
  /* DEPRECATED - use bp_has_groups( 'type=random' ) template loop */
224
  function bp_groups_random_groups( $total_groups = 5 ) {
225
  global $bp;
226
+
227
  if ( !$group_ids = wp_cache_get( 'groups_random_user_groups_' . $bp->displayed_user->id . '_' . $total_groups, 'bp' ) ) {
228
  $group_ids = groups_get_random_groups_for_user( $bp->displayed_user->id, $total_groups, 1 );
229
  wp_cache_set( 'groups_random_user_groups_' . $bp->displayed_user->id . '_' . $total_groups, $group_ids, 'bp' );
230
  }
231
+
232
+ ?>
233
  <div class="info-group">
234
  <h4><?php bp_word_or_name( __( "My Groups", 'buddypress' ), __( "%s's Groups", 'buddypress' ) ) ?> (<?php echo BP_Groups_Member::total_group_count() ?>) <span><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>"><?php _e('See All', 'buddypress') ?> &raquo;</a></span></h4>
235
  <?php if ( $group_ids ) { ?>
236
  <ul class="horiz-gallery">
237
+ <?php
238
  for ( $i = 0; $i < count( $group_ids ); $i++ ) {
239
  if ( !$group = wp_cache_get( 'groups_group_nouserdata_' . $group_ids[$i], 'bp' ) ) {
240
  $group = new BP_Groups_Group( $group_ids[$i], false, false );
262
 
263
  if ( !$group )
264
  $group =& $groups_template->group;
265
+
266
  $forum_id = groups_get_groupmeta( $group->id, 'forum_id' );
267
 
268
  if ( $forum_id && $forum_id != '' ) {
269
  if ( function_exists( 'bp_forums_setup' ) ) {
270
  $latest_topics = bp_forums_get_forum_topics( array( 'forum_id' => $forum_id ) );
271
+
272
  if ( $latest_topics ) { ?>
273
  <ul class="item-list" id="recent-forum-topics"><?php
274
+
275
  $counter = 0;
276
+
277
  foreach( $latest_topics as $topic ) {
278
  $alt = ( $counter % 2 == 1 ) ? ' class="alt"' : '';
279
  $forum_template->topic = (object)$topic; ?>
280
+
281
  <li<?php echo $alt ?>>
282
  <div class="avatar">
283
  <?php bp_the_topic_poster_avatar() ?>
284
  </div>
285
 
286
+ <a href="<?php bp_the_topic_permalink() ?>" title="<?php bp_the_topic_title() ?> - <?php _e( 'Permalink', 'buddypress' ) ?>"><?php bp_the_topic_title() ?></a>
287
  <span class="small">- <?php bp_the_topic_total_post_count() ?> </span>
288
  <p><span class="activity"><?php echo sprintf( __( 'updated %s ago', 'buddypress' ), bp_the_topic_time_since_last_post( false ) ) ?></span></p>
289
+
290
  <div class="latest-post">
291
  <?php _e( 'Latest by', 'buddypress' ) ?> <?php bp_the_topic_last_poster_name() ?>:
292
  <?php bp_the_topic_latest_post_excerpt() ?>
293
  </div>
294
  </li>
295
  <?php $counter++ ?>
296
+
297
  <?php } ?>
298
  </ul>
299
  <?php
312
  /* DEPRECATED - use group invite template loop (see groups/create.php in skeleton BuddyPress theme) */
313
  function bp_group_send_invite_form( $group = false ) {
314
  global $bp, $groups_template, $invites;
315
+
316
  if ( !$group )
317
  $group =& $groups_template->group;
318
  ?>
324
  </div>
325
 
326
  <div class="main-column">
327
+
328
  <div id="message" class="info">
329
  <p><?php _e('Select people to invite from your friends list.', 'buddypress'); ?></p>
330
  </div>
331
 
332
  <?php $invites = groups_get_invites_for_group( $bp->loggedin_user->id, $group->id ) ?>
333
+
334
  <ul id="friend-list" class="item-list">
335
  <?php for ( $i = 0; $i < count($invites); $i++ ) {
336
  if ( !$user = wp_cache_get( 'bp_user_' . $invites[$i], 'bp' ) ) {
343
  <h4><?php echo $user->user_link ?></h4>
344
  <span class="activity"><?php echo $user->last_active ?></span>
345
  <div class="action">
346
+ <a class="remove" href="<?php echo wp_nonce_url( site_url( $bp->groups->slug . '/' . $group->id . '/invites/remove/' . $user->id ), 'groups_invite_uninvite_user' ) ?>" id="uid-<?php echo $user->id ?>"><?php _e( 'Remove Invite', 'buddypress' ) ?></a>
347
  </div>
348
  </li>
349
  <?php } // end for ?>
350
  </ul>
351
+
352
  <?php wp_nonce_field( 'groups_send_invites', '_wpnonce_send_invites' ) ?>
353
  </div>
354
  <?php
357
  /* DEPRECATED - use bp_group_has_invites() template loop */
358
  function bp_group_list_invite_friends( $args = '' ) {
359
  global $bp, $invites;
360
+
361
  if ( !function_exists('friends_install') )
362
  return false;
363
 
369
  ?>
370
  <div id="invite-list">
371
  <ul>
372
+ <?php
373
  for ( $i = 0; $i < count( $friends ); $i++ ) {
374
  if ( $invites ) {
375
  if ( in_array( $friends[$i]['id'], $invites ) ) {
376
  $checked = ' checked="checked"';
377
  } else {
378
  $checked = '';
379
+ }
380
  }
381
  ?>
382
+
383
  <li><input<?php echo $checked ?> type="checkbox" name="friends[]" id="f-<?php echo $friends[$i]['id'] ?>" value="<?php echo attribute_escape( $friends[$i]['id'] ); ?>" /> <?php echo $friends[$i]['full_name']; ?></li>
384
  <?php } ?>
385
  </ul>
398
  $group =& $groups_template->group;
399
 
400
  $members = &$group->random_members;
401
+ ?>
402
  <ul class="horiz-gallery">
403
  <?php for ( $i = 0; $i < count( $members ); $i++ ) { ?>
404
  <li>
417
 
418
  if ( !$user_id )
419
  $user_id = $members_template->member->user_id;
420
+
421
  echo bp_get_group_member_promote_link( $user_id );
422
  }
423
  function bp_get_group_member_promote_link( $user_id = false, $group = false ) {
425
 
426
  if ( !$user_id )
427
  $user_id = $members_template->member->user_id;
428
+
429
  if ( !$group )
430
  $group =& $groups_template->group;
431
 
442
  case 'group-details': ?>
443
  <label for="group-name">* <?php _e('Group Name', 'buddypress') ?></label>
444
  <input type="text" name="group-name" id="group-name" value="<?php echo attribute_escape( ( $bp->groups->new_group ) ? $bp->groups->current_group->name : $_POST['group-name'] ); ?>" />
445
+
446
  <label for="group-desc">* <?php _e('Group Description', 'buddypress') ?></label>
447
  <textarea name="group-desc" id="group-desc"><?php echo htmlspecialchars( ( $bp->groups->new_group ) ? $bp->groups->current_group->description : $_POST['group-desc'] ); ?></textarea>
448
+
449
  <label for="group-news"><?php _e('Recent News', 'buddypress') ?></label>
450
  <textarea name="group-news" id="group-news"><?php echo htmlspecialchars( ( $bp->groups->new_group ) ? $bp->groups->current_group->news : $_POST['group-news'] ); ?></textarea>
451
+
452
  <?php do_action( 'groups_custom_group_fields_editable' ) ?>
453
 
454
  <?php wp_nonce_field( 'groups_create_save_group-details' ) ?>
455
 
456
  <?php break; ?>
457
+
458
  <?php case 'group-settings': ?>
459
  <?php if ( bp_are_previous_group_creation_steps_complete( 'group-settings' ) ) { ?>
460
  <?php if ( function_exists('bp_wire_install') ) : ?>
462
  <label><input type="checkbox" name="group-show-wire" id="group-show-wire" value="1"<?php if ( $bp->groups->current_group->enable_wire ) { ?> checked="checked"<?php } ?> /> <?php _e('Enable comment wire', 'buddypress') ?></label>
463
  </div>
464
  <?php endif; ?>
465
+
466
  <?php if ( function_exists('bp_forums_setup') ) : ?>
467
  <?php if ( bp_forums_is_installed_correctly() ) { ?>
468
  <div class="checkbox">
478
  }
479
  }?>
480
  <?php endif; ?>
481
+
482
  <?php if ( function_exists('bp_albums_install') ) : ?>
483
  <div class="checkbox with-suboptions">
484
  <label><input type="checkbox" name="group-show-photos" id="group-show-photos" value="1"<?php if ( $bp->groups->current_group->enable_photos ) { ?> checked="checked"<?php } ?> /> <?php _e('Enable photo gallery', 'buddypress') ?></label>
488
  </div>
489
  </div>
490
  <?php endif; ?>
491
+
492
  <h3><?php _e( 'Privacy Options', 'buddypress' ); ?></h3>
493
+
494
  <div class="radio">
495
+ <label><input type="radio" name="group-status" value="public"<?php if ( 'public' == $bp->groups->current_group->status ) { ?> checked="checked"<?php } ?> />
496
  <strong><?php _e( 'This is a public group', 'buddypress' ) ?></strong>
497
  <ul>
498
  <li><?php _e( 'Any site member can join this group.', 'buddypress' ) ?></li>
500
  <li><?php _e( 'Group content and activity will be visible to any site member.', 'buddypress' ) ?></li>
501
  </ul>
502
  </label>
503
+
504
  <label><input type="radio" name="group-status" value="private"<?php if ( 'private' == $bp->groups->current_group->status ) { ?> checked="checked"<?php } ?> />
505
  <strong><?php _e( 'This is a private group', 'buddypress' ) ?></strong>
506
  <ul>
509
  <li><?php _e( 'Group content and activity will only be visible to members of the group.', 'buddypress' ) ?></li>
510
  </ul>
511
  </label>
512
+
513
  <label><input type="radio" name="group-status" value="hidden"<?php if ( 'hidden' == $bp->groups->current_group->status ) { ?> checked="checked"<?php } ?> />
514
  <strong><?php _e('This is a hidden group', 'buddypress') ?></strong>
515
  <ul>
527
  </div>
528
  <?php } ?>
529
  <?php break; ?>
530
+
531
  <?php case 'group-avatar': ?>
532
  <?php if ( bp_are_previous_group_creation_steps_complete( 'group-avatar' ) ) { ?>
533
  <div class="left-menu">
534
  <?php bp_new_group_avatar() ?>
535
  </div>
536
+
537
  <div class="main-column">
538
  <p><?php _e("Upload an image to use as an avatar for this group. The image will be shown on the main group page, and in search results.", 'buddypress') ?></p>
539
+
540
  <?php groups_avatar_upload() ?>
541
 
542
  </div>
543
+
544
  <?php wp_nonce_field( 'groups_step3_save' ) ?>
545
  <?php } else { ?>
546
  <div id="message" class="info">
548
  </div>
549
  <?php } ?>
550
 
551
+ <?php wp_nonce_field( 'groups_create_save_group-avatar' ) ?>
552
 
553
  <?php break; ?>
554
  <?php case 'group-invites': ?>
555
+ <?php
556
  if ( bp_are_previous_group_creation_steps_complete( 'group-invites' ) ) {
557
  $group_link = bp_get_group_permalink( $bp->groups->new_group );
558
+
559
  if ( function_exists('friends_install') ) {
560
  if ( friends_get_friend_count_for_user( $bp->loggedin_user->id ) ) {
561
  bp_group_send_invite_form( $bp->groups->new_group );
569
  } ?>
570
 
571
  <?php wp_nonce_field( 'groups_step4_save' ) ?>
572
+
573
  <?php
574
  } else { ?>
575
  <div id="message" class="info">
581
 
582
  <?php break; ?>
583
  <?php } ?>
584
+
585
  <?php do_action( 'groups_custom_create_steps' ) // Allow plugins to add custom group creation steps ?>
586
+
587
  <div class="clear"></div>
588
+
589
  <div id="previous-next">
590
  <!-- Previous Button -->
591
  <?php if ( !bp_is_first_group_creation_step() ) : ?>
596
  <?php if ( !bp_is_last_group_creation_step() && !bp_is_first_group_creation_step() ) : ?>
597
  &nbsp; <input type="submit" value="<?php _e('Next Step', 'buddypress') ?> &rarr;" id="group-creation-next" name="save" />
598
  <?php endif;?>
599
+
600
  <!-- Create Button -->
601
  <?php if ( bp_is_first_group_creation_step() ) : ?>
602
  <input type="submit" value="<?php _e('Create Group and Continue', 'buddypress') ?> &rarr;" id="group-creation-create" name="save" />
603
  <?php endif; ?>
604
+
605
  <!-- Finish Button -->
606
  <?php if ( bp_is_last_group_creation_step() ) : ?>
607
  <input type="submit" value="<?php _e('Finish', 'buddypress') ?> &rarr;" id="group-creation-finish" name="save" />
621
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
622
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
623
  return false;
624
+
625
  check_ajax_referer( 'groups_invite_uninvite_user' );
626
 
627
  if ( !$_POST['friend_id'] || !$_POST['friend_action'] || !$_POST['group_id'] )
632
 
633
  if ( !friends_check_friendship( $bp->loggedin_user->id, $_POST['friend_id'] ) )
634
  return false;
635
+
636
  if ( 'invite' == $_POST['friend_action'] ) {
637
+
638
  if ( !groups_invite_user( array( 'user_id' => $_POST['friend_id'], 'group_id' => $_POST['group_id'] ) ) )
639
  return false;
640
+
641
  $user = new BP_Core_User( $_POST['friend_id'] );
642
+
643
  echo '<li id="uid-' . $user->id . '">';
644
  echo $user->avatar_thumb;
645
  echo '<h4>' . $user->user_link . '</h4>';
646
  echo '<span class="activity">' . attribute_escape( $user->last_active ) . '</span>';
647
  echo '<div class="action">
648
+ <a class="remove" href="' . wp_nonce_url( $bp->loggedin_user->domain . $bp->groups->slug . '/' . $_POST['group_id'] . '/invites/remove/' . $user->id, 'groups_invite_uninvite_user' ) . '" id="uid-' . attribute_escape( $user->id ) . '">' . __( 'Remove Invite', 'buddypress' ) . '</a>
649
  </div>';
650
  echo '</li>';
651
+
652
  } else if ( 'uninvite' == $_POST['friend_action'] ) {
653
+
654
  if ( !groups_uninvite_user( $_POST['friend_id'], $_POST['group_id'] ) )
655
  return false;
656
+
657
  return true;
658
+
659
  } else {
660
  return false;
661
  }
668
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
669
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
670
  return false;
671
+
672
  check_ajax_referer( 'group-filter-box' );
673
+
674
  locate_template( array( 'groups/group-loop.php' ), true );
675
  }
676
  add_action( 'wp_ajax_group_filter', 'groups_ajax_group_filter' );
682
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
683
  return false;
684
  ?>
685
+
686
  <?php if ( bp_group_has_members( 'group_id=' . $_REQUEST['group_id'] ) ) : ?>
687
+
688
  <?php if ( bp_group_member_needs_pagination() ) : ?>
689
  <div id="member-count" class="pag-count">
690
  <?php bp_group_member_pagination_count() ?>
694
  <?php bp_group_member_pagination() ?>
695
  </div>
696
  <?php endif; ?>
697
+
698
  <ul id="member-list" class="item-list">
699
  <?php while ( bp_group_members() ) : bp_group_the_member(); ?>
700
  <li>
701
  <?php bp_group_member_avatar() ?>
702
  <h5><?php bp_group_member_link() ?></h5>
703
  <span class="activity"><?php bp_group_member_joined_since() ?></span>
704
+
705
  <?php if ( function_exists( 'friends_install' ) ) : ?>
706
  <div class="action">
707
  <?php bp_add_friend_button( bp_get_group_member_id() ) ?>
729
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
730
  return false;
731
  ?>
732
+
733
  <?php if ( bp_group_has_members( 'group_id=' . $_REQUEST['group_id'] . '&per_page=' . $_REQUEST['num'] ) ) : ?>
734
+
735
  <?php if ( bp_group_member_needs_pagination() ) : ?>
736
  <div id="member-count" class="pag-count">
737
  <?php bp_group_member_pagination_count() ?>
741
  <?php bp_group_member_admin_pagination() ?>
742
  </div>
743
  <?php endif; ?>
744
+
745
  <ul id="members-list" class="item-list single-line">
746
  <?php while ( bp_group_members() ) : bp_group_the_member(); ?>
747
  <?php if ( bp_get_group_member_is_banned() ) : ?>
776
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
777
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
778
  return false;
779
+
780
  check_ajax_referer('directory_groups');
781
 
782
  locate_template( array( 'directories/groups/groups-loop.php' ), true );
792
 
793
  if ( groups_is_user_banned( $bp->loggedin_user->id, $_POST['gid'] ) )
794
  return false;
795
+
796
  if ( !$group = new BP_Groups_Group( $_POST['gid'], false, false ) )
797
  return false;
798
+
799
  if ( 'hidden' == $group->status )
800
  return false;
801
+
802
  if ( !groups_is_user_member( $bp->loggedin_user->id, $group->id ) ) {
803
 
804
  if ( 'public' == $group->status ) {
805
+
806
  check_ajax_referer( 'groups_join_group' );
807
+
808
  if ( !groups_join_group( $group->id ) ) {
809
  _e( 'Error joining group', 'buddypress' );
810
  } else {
811
  echo '<a id="group-' . attribute_escape( $group->id ) . '" class="leave-group" rel="leave" title="' . __( 'Leave Group', 'buddypress' ) . '" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>';
812
+ }
813
+
814
  } else if ( 'private' == $group->status ) {
815
+
816
  check_ajax_referer( 'groups_request_membership' );
817
+
818
  if ( !groups_send_membership_request( $bp->loggedin_user->id, $group->id ) ) {
819
+ _e( 'Error requesting membership', 'buddypress' );
820
  } else {
821
+ echo '<a id="group-' . attribute_escape( $group->id ) . '" class="membership-requested" rel="membership-requested" title="' . __( 'Membership Requested', 'buddypress' ) . '" href="' . bp_get_group_permalink( $group ) . '">' . __( 'Membership Requested', 'buddypress' ) . '</a>';
822
+ }
823
  }
824
+
825
  } else {
826
 
827
  check_ajax_referer( 'groups_leave_group' );
828
+
829
  if ( !groups_leave_group( $group->id ) ) {
830
  _e( 'Error leaving group', 'buddypress' );
831
  } else {
832
  if ( 'public' == $group->status ) {
833
+ echo '<a id="group-' . attribute_escape( $group->id ) . '" class="join-group" rel="join" title="' . __( 'Join Group', 'buddypress' ) . '" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/join', 'groups_join_group' ) . '">' . __( 'Join Group', 'buddypress' ) . '</a>';
834
  } else if ( 'private' == $group->status ) {
835
  echo '<a id="group-' . attribute_escape( $group->id ) . '" class="request-membership" rel="join" title="' . __( 'Request Membership', 'buddypress' ) . '" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/request-membership', 'groups_send_membership_request' ) . '">' . __( 'Request Membership', 'buddypress' ) . '</a>';
836
  }
bp-groups/deprecated/css/structure.css CHANGED
File without changes
bp-groups/deprecated/images/ajax-loader.gif CHANGED
File without changes
bp-groups/deprecated/images/none-thumbnail.gif CHANGED
File without changes
bp-groups/deprecated/images/none.gif CHANGED
File without changes
bp-groups/deprecated/js/directory-groups.js CHANGED
File without changes
bp-groups/deprecated/js/general.js CHANGED
File without changes
bp-groups/js/widget-groups.js CHANGED
File without changes
bp-languages/buddypress.pot CHANGED
File without changes
bp-loader.php CHANGED
@@ -4,12 +4,12 @@ Plugin Name: BuddyPress
4
  Plugin URI: http://buddypress.org/download/
5
  Description: BuddyPress will add social networking features to a new or existing WordPress MU installation.
6
  Author: The BuddyPress Community
7
- Version: 1.1.2
8
  Author URI: http://buddypress.org/developers/
9
  Site Wide Only: true
10
  */
11
 
12
- define( 'BP_VERSION', '1.1.2' );
13
 
14
  /***
15
  * This file will load in each BuddyPress component based on which
@@ -39,19 +39,19 @@ if ( !isset( $deactivated['bp-friends.php'] ) && file_exists( BP_PLUGIN_DIR . '/
39
  if ( !isset( $deactivated['bp-groups.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-groups.php') )
40
  include( BP_PLUGIN_DIR . '/bp-groups.php' );
41
 
42
- /* Private Messaging */
43
  if ( !isset( $deactivated['bp-messages.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-messages.php') )
44
  include( BP_PLUGIN_DIR . '/bp-messages.php' );
45
-
46
  /* Wire Support */
47
  if ( !isset( $deactivated['bp-wire.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-wire.php') )
48
  include( BP_PLUGIN_DIR . '/bp-wire.php' );
49
 
50
- /* Extended Profiles */
51
  if ( !isset( $deactivated['bp-xprofile.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-xprofile.php') )
52
  include( BP_PLUGIN_DIR . '/bp-xprofile.php' );
53
 
54
- /* Status Updates */
55
  if ( !isset( $deactivated['bp-status.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-status.php') )
56
  include( BP_PLUGIN_DIR . '/bp-status.php' );
57
 
4
  Plugin URI: http://buddypress.org/download/
5
  Description: BuddyPress will add social networking features to a new or existing WordPress MU installation.
6
  Author: The BuddyPress Community
7
+ Version: 1.1.3
8
  Author URI: http://buddypress.org/developers/
9
  Site Wide Only: true
10
  */
11
 
12
+ define( 'BP_VERSION', '1.1.3' );
13
 
14
  /***
15
  * This file will load in each BuddyPress component based on which
39
  if ( !isset( $deactivated['bp-groups.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-groups.php') )
40
  include( BP_PLUGIN_DIR . '/bp-groups.php' );
41
 
42
+ /* Private Messaging */
43
  if ( !isset( $deactivated['bp-messages.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-messages.php') )
44
  include( BP_PLUGIN_DIR . '/bp-messages.php' );
45
+
46
  /* Wire Support */
47
  if ( !isset( $deactivated['bp-wire.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-wire.php') )
48
  include( BP_PLUGIN_DIR . '/bp-wire.php' );
49
 
50
+ /* Extended Profiles */
51
  if ( !isset( $deactivated['bp-xprofile.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-xprofile.php') )
52
  include( BP_PLUGIN_DIR . '/bp-xprofile.php' );
53
 
54
+ /* Status Updates */
55
  if ( !isset( $deactivated['bp-status.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-status.php') )
56
  include( BP_PLUGIN_DIR . '/bp-status.php' );
57
 
bp-messages.php CHANGED
@@ -14,13 +14,13 @@ require ( BP_PLUGIN_DIR . '/bp-messages/bp-messages-filters.php' );
14
  /* Include deprecated functions if settings allow */
15
  if ( !defined( 'BP_IGNORE_DEPRECATED' ) )
16
  require ( BP_PLUGIN_DIR . '/bp-messages/deprecated/bp-messages-deprecated.php' );
17
-
18
  function messages_install() {
19
  global $wpdb, $bp;
20
-
21
  if ( !empty($wpdb->charset) )
22
  $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
23
-
24
  $sql[] = "CREATE TABLE {$bp->messages->table_name_threads} (
25
  id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
26
  message_ids longtext NOT NULL,
@@ -32,7 +32,7 @@ function messages_install() {
32
  KEY last_message_id (last_message_id),
33
  KEY last_sender_id (last_sender_id)
34
  ) {$charset_collate};";
35
-
36
  $sql[] = "CREATE TABLE {$bp->messages->table_name_recipients} (
37
  id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
38
  user_id bigint(20) NOT NULL,
@@ -55,7 +55,7 @@ function messages_install() {
55
  date_sent datetime NOT NULL,
56
  KEY sender_id (sender_id)
57
  ) {$charset_collate};";
58
-
59
  $sql[] = "CREATE TABLE {$bp->messages->table_name_notices} (
60
  id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
61
  subject varchar(200) NOT NULL,
@@ -64,10 +64,10 @@ function messages_install() {
64
  is_active tinyint(1) NOT NULL DEFAULT '0',
65
  KEY is_active (is_active)
66
  ) {$charset_collate};";
67
-
68
  require_once( ABSPATH . 'wp-admin/upgrade-functions.php' );
69
  dbDelta($sql);
70
-
71
  add_site_option( 'bp-messages-db-version', BP_MESSAGES_DB_VERSION );
72
  }
73
 
@@ -76,7 +76,7 @@ function messages_setup_globals() {
76
 
77
  /* For internal identification */
78
  $bp->messages->id = 'messages';
79
-
80
  $bp->messages->table_name_threads = $wpdb->base_prefix . 'bp_messages_threads';
81
  $bp->messages->table_name_messages = $wpdb->base_prefix . 'bp_messages_messages';
82
  $bp->messages->table_name_recipients = $wpdb->base_prefix . 'bp_messages_recipients';
@@ -90,20 +90,20 @@ function messages_setup_globals() {
90
 
91
  do_action( 'messages_setup_globals' );
92
  }
93
- add_action( 'plugins_loaded', 'messages_setup_globals', 5 );
94
  add_action( 'admin_menu', 'messages_setup_globals', 2 );
95
 
96
- function messages_check_installed() {
97
  global $wpdb, $bp;
98
 
99
  if ( !is_site_admin() )
100
  return false;
101
-
102
  /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
103
  if ( get_site_option('bp-messages-db-version') < BP_MESSAGES_DB_VERSION )
104
  messages_install();
105
  }
106
- add_action( 'admin_menu', 'messages_check_installed', 2 );
107
 
108
  function messages_setup_nav() {
109
  global $bp;
@@ -116,26 +116,26 @@ function messages_setup_nav() {
116
 
117
  /* Add 'Messages' to the main navigation */
118
  bp_core_new_nav_item( array( 'name' => __('Messages', 'buddypress'), 'slug' => $bp->messages->slug, 'position' => 50, 'show_for_displayed_user' => false, 'screen_function' => 'messages_screen_inbox', 'default_subnav_slug' => 'inbox', 'item_css_id' => $bp->messages->id ) );
119
-
120
  $messages_link = $bp->loggedin_user->domain . $bp->messages->slug . '/';
121
-
122
  /* Add the subnav items to the profile */
123
  bp_core_new_subnav_item( array( 'name' => __( 'Inbox', 'buddypress' ) . $count_indicator, 'slug' => 'inbox', 'parent_url' => $messages_link, 'parent_slug' => $bp->messages->slug, 'screen_function' => 'messages_screen_inbox', 'position' => 10, 'user_has_access' => bp_is_home() ) );
124
  bp_core_new_subnav_item( array( 'name' => __( 'Sent Messages', 'buddypress' ), 'slug' => 'sentbox', 'parent_url' => $messages_link, 'parent_slug' => $bp->messages->slug, 'screen_function' => 'messages_screen_sentbox', 'position' => 20, 'user_has_access' => bp_is_home() ) );
125
  bp_core_new_subnav_item( array( 'name' => __( 'Compose', 'buddypress' ), 'slug' => 'compose', 'parent_url' => $messages_link, 'parent_slug' => $bp->messages->slug, 'screen_function' => 'messages_screen_compose', 'position' => 30, 'user_has_access' => bp_is_home() ) );
126
-
127
  if ( is_site_admin() )
128
  bp_core_new_subnav_item( array( 'name' => __( 'Notices', 'buddypress' ), 'slug' => 'notices', 'parent_url' => $messages_link, 'parent_slug' => $bp->messages->slug, 'screen_function' => 'messages_screen_notices', 'position' => 90, 'user_has_access' => is_site_admin() ) );
129
 
130
  if ( $bp->current_component == $bp->messages->slug ) {
131
  if ( bp_is_home() ) {
132
- $bp->bp_options_title = __( 'My Messages', 'buddypress' );
133
  } else {
134
  $bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) );
135
  $bp->bp_options_title = $bp->displayed_user->fullname;
136
  }
137
  }
138
-
139
  do_action( 'messages_setup_nav' );
140
  }
141
  add_action( 'plugins_loaded', 'messages_setup_nav' );
@@ -152,7 +152,7 @@ add_action( 'admin_menu', 'messages_setup_nav' );
152
 
153
  function messages_screen_inbox() {
154
  do_action( 'messages_screen_inbox' );
155
- bp_core_load_template( apply_filters( 'messages_template_inbox', 'messages/index' ) );
156
  }
157
 
158
  function messages_screen_sentbox() {
@@ -162,16 +162,16 @@ function messages_screen_sentbox() {
162
 
163
  function messages_screen_compose() {
164
  global $bp;
165
-
166
  // Remove any saved message data from a previous session.
167
  messages_remove_callback_values();
168
 
169
  /* Check if the message form has been submitted */
170
  if ( isset( $_POST['send'] ) ) {
171
-
172
  /* Check the nonce */
173
  check_admin_referer( 'messages_send_message' );
174
-
175
  /* Check we have what we need */
176
  if ( empty( $_POST['subject'] ) || empty( $_POST['content'] ) ) {
177
  bp_core_add_message( __( 'There was an error sending that message, please try again', 'buddypress' ), 'error' );
@@ -184,7 +184,7 @@ function messages_screen_compose() {
184
  $autocomplete_recipients = explode( ',', $_POST['send-to-input'] );
185
  $typed_recipients = explode( ' ', $_POST['send_to_usernames'] );
186
  $recipients = array_merge( (array) $autocomplete_recipients, (array) $typed_recipients );
187
-
188
  /* Send the message */
189
  if ( $thread_id = messages_new_message( array( 'recipients' => $recipients, 'subject' => $_POST['subject'], 'content' => $_POST['content'] ) ) ) {
190
  bp_core_add_message( __( 'Message sent successfully!', 'buddypress' ) );
@@ -196,18 +196,18 @@ function messages_screen_compose() {
196
  }
197
 
198
  }
199
-
200
  do_action( 'messages_screen_compose' );
201
-
202
  bp_core_load_template( apply_filters( 'messages_template_compose', 'messages/compose' ) );
203
  }
204
 
205
  function messages_screen_notices() {
206
  global $bp, $notice_id;
207
-
208
  if ( !is_site_admin() )
209
  return false;
210
-
211
  $notice_id = $bp->action_variables[1];
212
 
213
  if ( $notice_id && is_numeric($notice_id) ) {
@@ -215,7 +215,7 @@ function messages_screen_notices() {
215
 
216
  if ( 'deactivate' == $bp->action_variables[0] ) {
217
  if ( !$notice->deactivate() ) {
218
- bp_core_add_message( __('There was a problem deactivating that notice.', 'buddypress'), 'error' );
219
  } else {
220
  bp_core_add_message( __('Notice deactivated.', 'buddypress') );
221
  }
@@ -234,13 +234,13 @@ function messages_screen_notices() {
234
  }
235
  bp_core_redirect( $bp->loggedin_user->domain . $bp->messages->slug . '/notices' );
236
  }
237
-
238
  do_action( 'messages_screen_notices' );
239
-
240
- bp_core_load_template( apply_filters( 'messages_template_notices', 'messages/notices' ) );
241
  }
242
 
243
- function messages_screen_notification_settings() {
244
  global $current_user; ?>
245
  <table class="notification-settings" id="messages-notification-settings">
246
  <tr>
@@ -261,10 +261,10 @@ function messages_screen_notification_settings() {
261
  <td class="yes"><input type="radio" name="notifications[notification_messages_new_notice]" value="yes" <?php if ( !get_usermeta( $current_user->id, 'notification_messages_new_notice' ) || 'yes' == get_usermeta( $current_user->id, 'notification_messages_new_notice' ) ) { ?>checked="checked" <?php } ?>/></td>
262
  <td class="no"><input type="radio" name="notifications[notification_messages_new_notice]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id, 'notification_messages_new_notice' ) ) { ?>checked="checked" <?php } ?>/></td>
263
  </tr>
264
-
265
  <?php do_action( 'messages_screen_notification_settings' ) ?>
266
  </table>
267
- <?php
268
  }
269
  add_action( 'bp_notification_settings', 'messages_screen_notification_settings', 2 );
270
 
@@ -279,35 +279,35 @@ add_action( 'bp_notification_settings', 'messages_screen_notification_settings',
279
 
280
  function messages_action_view_message() {
281
  global $bp, $thread_id;
282
-
283
  if ( $bp->current_component != $bp->messages->slug || $bp->current_action != 'view' )
284
  return false;
285
-
286
  $thread_id = $bp->action_variables[0];
287
-
288
  if ( !$thread_id || !messages_is_valid_thread( $thread_id ) || ( !messages_check_thread_access($thread_id) && !is_site_admin() ) )
289
  bp_core_redirect( $bp->displayed_user->domain . $bp->current_component );
290
-
291
  /* Check if a new reply has been submitted */
292
  if ( isset( $_POST['send'] ) ) {
293
-
294
  /* Check the nonce */
295
  check_admin_referer( 'messages_send_message', 'send_message_nonce' );
296
-
297
  /* Send the reply */
298
  if ( messages_new_message( array( 'thread_id' => $thread_id, 'subject' => $_POST['subject'], 'content' => $_POST['content'] ) ) )
299
  bp_core_add_message( __( 'Your reply was sent successfully', 'buddypress' ) );
300
  else
301
  bp_core_add_message( __( 'There was a problem sending your reply, please try again', 'buddypress' ), 'error' );
302
-
303
- bp_core_redirect( $bp->displayed_user->domain . $bp->current_component . '/view/' . $thread_id . '/' );
304
  }
305
-
306
  /* Mark message read */
307
  messages_mark_thread_read( $thread_id );
308
-
309
  do_action( 'messages_action_view_message' );
310
-
311
  bp_core_new_subnav_item( array( 'name' => sprintf( __( 'From: %s', 'buddypress'), BP_Messages_Thread::get_last_sender($thread_id) ), 'slug' => 'view', 'parent_url' => $bp->loggedin_user->domain . $bp->messages->slug . '/', 'parent_slug' => $bp->messages->slug, 'screen_function' => true, 'position' => 40, 'user_has_access' => bp_is_home() ) );
312
  bp_core_load_template( apply_filters( 'messages_template_view_message', 'messages/view' ) );
313
  }
@@ -315,10 +315,10 @@ add_action( 'wp', 'messages_action_view_message', 3 );
315
 
316
  function messages_action_delete_message() {
317
  global $bp, $thread_id;
318
-
319
  if ( $bp->current_component != $bp->messages->slug || 'notices' == $bp->current_action || $bp->action_variables[0] != 'delete' )
320
  return false;
321
-
322
  $thread_id = $bp->action_variables[1];
323
 
324
  if ( !$thread_id || !is_numeric($thread_id) || !messages_check_thread_access($thread_id) ) {
@@ -340,18 +340,18 @@ add_action( 'wp', 'messages_action_delete_message', 3 );
340
 
341
  function messages_action_bulk_delete() {
342
  global $bp, $thread_ids;
343
-
344
  if ( $bp->current_component != $bp->messages->slug || $bp->action_variables[0] != 'bulk-delete' )
345
  return false;
346
-
347
  $thread_ids = $_POST['thread_ids'];
348
 
349
  if ( !$thread_ids || !messages_check_thread_access($thread_ids) ) {
350
- bp_core_redirect( $bp->displayed_user->domain . $bp->current_component . '/' . $bp->current_action );
351
  } else {
352
  if ( !check_admin_referer( 'messages_delete_thread' ) )
353
  return false;
354
-
355
  if ( !messages_delete_thread( $thread_ids ) ) {
356
  bp_core_add_message( __('There was an error deleting messages.', 'buddypress'), 'error' );
357
  } else {
@@ -372,16 +372,16 @@ add_action( 'wp', 'messages_action_bulk_delete', 3 );
372
 
373
  function messages_format_notifications( $action, $item_id, $secondary_item_id, $total_items ) {
374
  global $bp;
375
-
376
  if ( 'new_message' == $action ) {
377
  if ( (int)$total_items > 1 )
378
- return apply_filters( 'bp_messages_multiple_new_message_notification', '<a href="' . $bp->loggedin_user->domain . $bp->messages->slug . '/inbox" title="Inbox">' . sprintf( __('You have %d new messages', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
379
  else
380
  return apply_filters( 'bp_messages_single_new_message_notification', '<a href="' . $bp->loggedin_user->domain . $bp->messages->slug . '/inbox" title="Inbox">' . sprintf( __('You have %d new message', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
381
  }
382
-
383
  do_action( 'messages_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
384
-
385
  return false;
386
  }
387
 
@@ -397,7 +397,7 @@ function messages_format_notifications( $action, $item_id, $secondary_item_id, $
397
 
398
  function messages_new_message( $args = '' ) {
399
  global $bp;
400
-
401
  $defaults = array(
402
  'thread_id' => false, // false for a new message, thread id for a reply to a thread.
403
  'sender_id' => $bp->loggedin_user->id,
@@ -408,12 +408,12 @@ function messages_new_message( $args = '' ) {
408
  );
409
 
410
  $r = wp_parse_args( $args, $defaults );
411
- extract( $r, EXTR_SKIP );
412
-
413
  if ( !$sender_id || !$subject || !$content )
414
  return false;
415
-
416
- /* Create a new message object */
417
  $message = new BP_Messages_Message;
418
  $message->thread_id = $thread_id;
419
  $message->sender_id = $sender_id;
@@ -424,16 +424,16 @@ function messages_new_message( $args = '' ) {
424
  /* If we have a thread ID, use the existing recipients, otherwise use the recipients passed */
425
  if ( $thread_id ) {
426
  $thread = new BP_Messages_Thread($thread_id);
427
- $message->recipients = $thread->get_recipients();
428
  } else {
429
  if ( empty( $recipients ) )
430
  return false;
431
-
432
  /* Loop the recipients and convert all usernames to user_ids where needed */
433
  foreach( (array) $recipients as $recipient ) {
434
  if ( is_numeric( trim( $recipient ) ) )
435
  $recipient_ids[] = (int)trim( $recipient );
436
-
437
  if ( $recipient_id = bp_core_get_userid( trim( $recipient ) ) )
438
  $recipient_ids[] = (int)$recipient_id;
439
  }
@@ -444,29 +444,29 @@ function messages_new_message( $args = '' ) {
444
 
445
  /* Remove duplicates */
446
  $recipient_ids = array_unique( (array)$recipient_ids );
447
-
448
  if ( empty( $recipient_ids ) )
449
  return false;
450
-
451
- $message->recipients = $recipient_ids;
452
  }
453
-
454
  if ( $message->send() ) {
455
  require_once( BP_PLUGIN_DIR . '/bp-messages/bp-messages-notifications.php' );
456
 
457
  // Send screen notifications to the recipients
458
  foreach ( (array)$message->recipients as $recipient ) {
459
- bp_core_add_notification( $message->id, $recipient, 'messages', 'new_message' );
460
  }
461
-
462
  // Send email notifications to the recipients
463
  messages_notification_new_message( array( 'item_id' => $message->id, 'recipient_ids' => $message->recipients, 'thread_id' => $message->thread_id, 'component_name' => $bp->messages->slug, 'component_action' => 'message_sent', 'is_private' => 1 ) );
464
-
465
  do_action( 'messages_message_sent', &$message );
466
-
467
  return $message->thread_id;
468
  }
469
-
470
  return false;
471
  }
472
 
@@ -482,9 +482,9 @@ function messages_send_notice( $subject, $message ) {
482
  $notice->date_sent = time();
483
  $notice->is_active = 1;
484
  $notice->save(); // send it.
485
-
486
  do_action( 'messages_send_notice', $subject, $message );
487
-
488
  return true;
489
  }
490
  }
@@ -496,29 +496,29 @@ function messages_delete_thread( $thread_ids ) {
496
  if ( !$status = BP_Messages_Thread::delete($thread_ids[$i]) )
497
  $error = 1;
498
  }
499
-
500
  if ( $error )
501
  return false;
502
-
503
  do_action( 'messages_delete_thread', $thread_ids );
504
-
505
  return true;
506
  } else {
507
  if ( !BP_Messages_Thread::delete($thread_ids) )
508
  return false;
509
-
510
  do_action( 'messages_delete_thread', $thread_ids );
511
-
512
  return true;
513
  }
514
  }
515
 
516
  function messages_check_thread_access( $thread_id, $user_id = false ) {
517
  global $bp;
518
-
519
  if ( !$user_id )
520
  $user_id = $bp->loggedin_user->id;
521
-
522
  return BP_Messages_Thread::check_access( $thread_id, $user_id );
523
  }
524
 
@@ -527,7 +527,7 @@ function messages_mark_thread_read( $thread_id ) {
527
  }
528
 
529
  function messages_mark_thread_unread( $thread_id ) {
530
- return BP_Messages_Thread::mark_as_unread( $thread_id );
531
  }
532
 
533
  function messages_add_callback_values( $recipients, $subject, $content ) {
@@ -544,10 +544,10 @@ function messages_remove_callback_values() {
544
 
545
  function messages_get_unread_count( $user_id = false ) {
546
  global $bp;
547
-
548
- if ( !$user_id )
549
  $user_id = $bp->loggedin_user->id;
550
-
551
  return BP_Messages_Thread::get_inbox_count( $user_id );
552
  }
553
 
14
  /* Include deprecated functions if settings allow */
15
  if ( !defined( 'BP_IGNORE_DEPRECATED' ) )
16
  require ( BP_PLUGIN_DIR . '/bp-messages/deprecated/bp-messages-deprecated.php' );
17
+
18
  function messages_install() {
19
  global $wpdb, $bp;
20
+
21
  if ( !empty($wpdb->charset) )
22
  $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
23
+
24
  $sql[] = "CREATE TABLE {$bp->messages->table_name_threads} (
25
  id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
26
  message_ids longtext NOT NULL,
32
  KEY last_message_id (last_message_id),
33
  KEY last_sender_id (last_sender_id)
34
  ) {$charset_collate};";
35
+
36
  $sql[] = "CREATE TABLE {$bp->messages->table_name_recipients} (
37
  id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
38
  user_id bigint(20) NOT NULL,
55
  date_sent datetime NOT NULL,
56
  KEY sender_id (sender_id)
57
  ) {$charset_collate};";
58
+
59
  $sql[] = "CREATE TABLE {$bp->messages->table_name_notices} (
60
  id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
61
  subject varchar(200) NOT NULL,
64
  is_active tinyint(1) NOT NULL DEFAULT '0',
65
  KEY is_active (is_active)
66
  ) {$charset_collate};";
67
+
68
  require_once( ABSPATH . 'wp-admin/upgrade-functions.php' );
69
  dbDelta($sql);
70
+
71
  add_site_option( 'bp-messages-db-version', BP_MESSAGES_DB_VERSION );
72
  }
73
 
76
 
77
  /* For internal identification */
78
  $bp->messages->id = 'messages';
79
+
80
  $bp->messages->table_name_threads = $wpdb->base_prefix . 'bp_messages_threads';
81
  $bp->messages->table_name_messages = $wpdb->base_prefix . 'bp_messages_messages';
82
  $bp->messages->table_name_recipients = $wpdb->base_prefix . 'bp_messages_recipients';
90
 
91
  do_action( 'messages_setup_globals' );
92
  }
93
+ add_action( 'plugins_loaded', 'messages_setup_globals', 5 );
94
  add_action( 'admin_menu', 'messages_setup_globals', 2 );
95
 
96
+ function messages_check_installed() {
97
  global $wpdb, $bp;
98
 
99
  if ( !is_site_admin() )
100
  return false;
101
+
102
  /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
103
  if ( get_site_option('bp-messages-db-version') < BP_MESSAGES_DB_VERSION )
104
  messages_install();
105
  }
106
+ add_action( 'admin_menu', 'messages_check_installed' );
107
 
108
  function messages_setup_nav() {
109
  global $bp;
116
 
117
  /* Add 'Messages' to the main navigation */
118
  bp_core_new_nav_item( array( 'name' => __('Messages', 'buddypress'), 'slug' => $bp->messages->slug, 'position' => 50, 'show_for_displayed_user' => false, 'screen_function' => 'messages_screen_inbox', 'default_subnav_slug' => 'inbox', 'item_css_id' => $bp->messages->id ) );
119
+
120
  $messages_link = $bp->loggedin_user->domain . $bp->messages->slug . '/';
121
+
122
  /* Add the subnav items to the profile */
123
  bp_core_new_subnav_item( array( 'name' => __( 'Inbox', 'buddypress' ) . $count_indicator, 'slug' => 'inbox', 'parent_url' => $messages_link, 'parent_slug' => $bp->messages->slug, 'screen_function' => 'messages_screen_inbox', 'position' => 10, 'user_has_access' => bp_is_home() ) );
124
  bp_core_new_subnav_item( array( 'name' => __( 'Sent Messages', 'buddypress' ), 'slug' => 'sentbox', 'parent_url' => $messages_link, 'parent_slug' => $bp->messages->slug, 'screen_function' => 'messages_screen_sentbox', 'position' => 20, 'user_has_access' => bp_is_home() ) );
125
  bp_core_new_subnav_item( array( 'name' => __( 'Compose', 'buddypress' ), 'slug' => 'compose', 'parent_url' => $messages_link, 'parent_slug' => $bp->messages->slug, 'screen_function' => 'messages_screen_compose', 'position' => 30, 'user_has_access' => bp_is_home() ) );
126
+
127
  if ( is_site_admin() )
128
  bp_core_new_subnav_item( array( 'name' => __( 'Notices', 'buddypress' ), 'slug' => 'notices', 'parent_url' => $messages_link, 'parent_slug' => $bp->messages->slug, 'screen_function' => 'messages_screen_notices', 'position' => 90, 'user_has_access' => is_site_admin() ) );
129
 
130
  if ( $bp->current_component == $bp->messages->slug ) {
131
  if ( bp_is_home() ) {
132
+ $bp->bp_options_title = __( 'My Messages', 'buddypress' );
133
  } else {
134
  $bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) );
135
  $bp->bp_options_title = $bp->displayed_user->fullname;
136
  }
137
  }
138
+
139
  do_action( 'messages_setup_nav' );
140
  }
141
  add_action( 'plugins_loaded', 'messages_setup_nav' );
152
 
153
  function messages_screen_inbox() {
154
  do_action( 'messages_screen_inbox' );
155
+ bp_core_load_template( apply_filters( 'messages_template_inbox', 'messages/index' ) );
156
  }
157
 
158
  function messages_screen_sentbox() {
162
 
163
  function messages_screen_compose() {
164
  global $bp;
165
+
166
  // Remove any saved message data from a previous session.
167
  messages_remove_callback_values();
168
 
169
  /* Check if the message form has been submitted */
170
  if ( isset( $_POST['send'] ) ) {
171
+
172
  /* Check the nonce */
173
  check_admin_referer( 'messages_send_message' );
174
+
175
  /* Check we have what we need */
176
  if ( empty( $_POST['subject'] ) || empty( $_POST['content'] ) ) {
177
  bp_core_add_message( __( 'There was an error sending that message, please try again', 'buddypress' ), 'error' );
184
  $autocomplete_recipients = explode( ',', $_POST['send-to-input'] );
185
  $typed_recipients = explode( ' ', $_POST['send_to_usernames'] );
186
  $recipients = array_merge( (array) $autocomplete_recipients, (array) $typed_recipients );
187
+
188
  /* Send the message */
189
  if ( $thread_id = messages_new_message( array( 'recipients' => $recipients, 'subject' => $_POST['subject'], 'content' => $_POST['content'] ) ) ) {
190
  bp_core_add_message( __( 'Message sent successfully!', 'buddypress' ) );
196
  }
197
 
198
  }
199
+
200
  do_action( 'messages_screen_compose' );
201
+
202
  bp_core_load_template( apply_filters( 'messages_template_compose', 'messages/compose' ) );
203
  }
204
 
205
  function messages_screen_notices() {
206
  global $bp, $notice_id;
207
+
208
  if ( !is_site_admin() )
209
  return false;
210
+
211
  $notice_id = $bp->action_variables[1];
212
 
213
  if ( $notice_id && is_numeric($notice_id) ) {
215
 
216
  if ( 'deactivate' == $bp->action_variables[0] ) {
217
  if ( !$notice->deactivate() ) {
218
+ bp_core_add_message( __('There was a problem deactivating that notice.', 'buddypress'), 'error' );
219
  } else {
220
  bp_core_add_message( __('Notice deactivated.', 'buddypress') );
221
  }
234
  }
235
  bp_core_redirect( $bp->loggedin_user->domain . $bp->messages->slug . '/notices' );
236
  }
237
+
238
  do_action( 'messages_screen_notices' );
239
+
240
+ bp_core_load_template( apply_filters( 'messages_template_notices', 'messages/notices' ) );
241
  }
242
 
243
+ function messages_screen_notification_settings() {
244
  global $current_user; ?>
245
  <table class="notification-settings" id="messages-notification-settings">
246
  <tr>
261
  <td class="yes"><input type="radio" name="notifications[notification_messages_new_notice]" value="yes" <?php if ( !get_usermeta( $current_user->id, 'notification_messages_new_notice' ) || 'yes' == get_usermeta( $current_user->id, 'notification_messages_new_notice' ) ) { ?>checked="checked" <?php } ?>/></td>
262
  <td class="no"><input type="radio" name="notifications[notification_messages_new_notice]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id, 'notification_messages_new_notice' ) ) { ?>checked="checked" <?php } ?>/></td>
263
  </tr>
264
+
265
  <?php do_action( 'messages_screen_notification_settings' ) ?>
266
  </table>
267
+ <?php
268
  }
269
  add_action( 'bp_notification_settings', 'messages_screen_notification_settings', 2 );
270
 
279
 
280
  function messages_action_view_message() {
281
  global $bp, $thread_id;
282
+
283
  if ( $bp->current_component != $bp->messages->slug || $bp->current_action != 'view' )
284
  return false;
285
+
286
  $thread_id = $bp->action_variables[0];
287
+
288
  if ( !$thread_id || !messages_is_valid_thread( $thread_id ) || ( !messages_check_thread_access($thread_id) && !is_site_admin() ) )
289
  bp_core_redirect( $bp->displayed_user->domain . $bp->current_component );
290
+
291
  /* Check if a new reply has been submitted */
292
  if ( isset( $_POST['send'] ) ) {
293
+
294
  /* Check the nonce */
295
  check_admin_referer( 'messages_send_message', 'send_message_nonce' );
296
+
297
  /* Send the reply */
298
  if ( messages_new_message( array( 'thread_id' => $thread_id, 'subject' => $_POST['subject'], 'content' => $_POST['content'] ) ) )
299
  bp_core_add_message( __( 'Your reply was sent successfully', 'buddypress' ) );
300
  else
301
  bp_core_add_message( __( 'There was a problem sending your reply, please try again', 'buddypress' ), 'error' );
302
+
303
+ bp_core_redirect( $bp->displayed_user->domain . $bp->current_component . '/view/' . $thread_id . '/' );
304
  }
305
+
306
  /* Mark message read */
307
  messages_mark_thread_read( $thread_id );
308
+
309
  do_action( 'messages_action_view_message' );
310
+
311
  bp_core_new_subnav_item( array( 'name' => sprintf( __( 'From: %s', 'buddypress'), BP_Messages_Thread::get_last_sender($thread_id) ), 'slug' => 'view', 'parent_url' => $bp->loggedin_user->domain . $bp->messages->slug . '/', 'parent_slug' => $bp->messages->slug, 'screen_function' => true, 'position' => 40, 'user_has_access' => bp_is_home() ) );
312
  bp_core_load_template( apply_filters( 'messages_template_view_message', 'messages/view' ) );
313
  }
315
 
316
  function messages_action_delete_message() {
317
  global $bp, $thread_id;
318
+
319
  if ( $bp->current_component != $bp->messages->slug || 'notices' == $bp->current_action || $bp->action_variables[0] != 'delete' )
320
  return false;
321
+
322
  $thread_id = $bp->action_variables[1];
323
 
324
  if ( !$thread_id || !is_numeric($thread_id) || !messages_check_thread_access($thread_id) ) {
340
 
341
  function messages_action_bulk_delete() {
342
  global $bp, $thread_ids;
343
+
344
  if ( $bp->current_component != $bp->messages->slug || $bp->action_variables[0] != 'bulk-delete' )
345
  return false;
346
+
347
  $thread_ids = $_POST['thread_ids'];
348
 
349
  if ( !$thread_ids || !messages_check_thread_access($thread_ids) ) {
350
+ bp_core_redirect( $bp->displayed_user->domain . $bp->current_component . '/' . $bp->current_action );
351
  } else {
352
  if ( !check_admin_referer( 'messages_delete_thread' ) )
353
  return false;
354
+
355
  if ( !messages_delete_thread( $thread_ids ) ) {
356
  bp_core_add_message( __('There was an error deleting messages.', 'buddypress'), 'error' );
357
  } else {
372
 
373
  function messages_format_notifications( $action, $item_id, $secondary_item_id, $total_items ) {
374
  global $bp;
375
+
376
  if ( 'new_message' == $action ) {
377
  if ( (int)$total_items > 1 )
378
+ return apply_filters( 'bp_messages_multiple_new_message_notification', '<a href="' . $bp->loggedin_user->domain . $bp->messages->slug . '/inbox" title="Inbox">' . sprintf( __('You have %d new messages', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
379
  else
380
  return apply_filters( 'bp_messages_single_new_message_notification', '<a href="' . $bp->loggedin_user->domain . $bp->messages->slug . '/inbox" title="Inbox">' . sprintf( __('You have %d new message', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
381
  }
382
+
383
  do_action( 'messages_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
384
+
385
  return false;
386
  }
387
 
397
 
398
  function messages_new_message( $args = '' ) {
399
  global $bp;
400
+
401
  $defaults = array(
402
  'thread_id' => false, // false for a new message, thread id for a reply to a thread.
403
  'sender_id' => $bp->loggedin_user->id,
408
  );
409
 
410
  $r = wp_parse_args( $args, $defaults );
411
+ extract( $r, EXTR_SKIP );
412
+
413
  if ( !$sender_id || !$subject || !$content )
414
  return false;
415
+
416
+ /* Create a new message object */
417
  $message = new BP_Messages_Message;
418
  $message->thread_id = $thread_id;
419
  $message->sender_id = $sender_id;
424
  /* If we have a thread ID, use the existing recipients, otherwise use the recipients passed */
425
  if ( $thread_id ) {
426
  $thread = new BP_Messages_Thread($thread_id);
427
+ $message->recipients = $thread->get_recipients();
428
  } else {
429
  if ( empty( $recipients ) )
430
  return false;
431
+
432
  /* Loop the recipients and convert all usernames to user_ids where needed */
433
  foreach( (array) $recipients as $recipient ) {
434
  if ( is_numeric( trim( $recipient ) ) )
435
  $recipient_ids[] = (int)trim( $recipient );
436
+
437
  if ( $recipient_id = bp_core_get_userid( trim( $recipient ) ) )
438
  $recipient_ids[] = (int)$recipient_id;
439
  }
444
 
445
  /* Remove duplicates */
446
  $recipient_ids = array_unique( (array)$recipient_ids );
447
+
448
  if ( empty( $recipient_ids ) )
449
  return false;
450
+
451
+ $message->recipients = $recipient_ids;
452
  }
453
+
454
  if ( $message->send() ) {
455
  require_once( BP_PLUGIN_DIR . '/bp-messages/bp-messages-notifications.php' );
456
 
457
  // Send screen notifications to the recipients
458
  foreach ( (array)$message->recipients as $recipient ) {
459
+ bp_core_add_notification( $message->id, $recipient, 'messages', 'new_message' );
460
  }
461
+
462
  // Send email notifications to the recipients
463
  messages_notification_new_message( array( 'item_id' => $message->id, 'recipient_ids' => $message->recipients, 'thread_id' => $message->thread_id, 'component_name' => $bp->messages->slug, 'component_action' => 'message_sent', 'is_private' => 1 ) );
464
+
465
  do_action( 'messages_message_sent', &$message );
466
+
467
  return $message->thread_id;
468
  }
469
+
470
  return false;
471
  }
472
 
482
  $notice->date_sent = time();
483
  $notice->is_active = 1;
484
  $notice->save(); // send it.
485
+
486
  do_action( 'messages_send_notice', $subject, $message );
487
+
488
  return true;
489
  }
490
  }
496
  if ( !$status = BP_Messages_Thread::delete($thread_ids[$i]) )
497
  $error = 1;
498
  }
499
+
500
  if ( $error )
501
  return false;
502
+
503
  do_action( 'messages_delete_thread', $thread_ids );
504
+
505
  return true;
506
  } else {
507
  if ( !BP_Messages_Thread::delete($thread_ids) )
508
  return false;
509
+
510
  do_action( 'messages_delete_thread', $thread_ids );
511
+
512
  return true;
513
  }
514
  }
515
 
516
  function messages_check_thread_access( $thread_id, $user_id = false ) {
517
  global $bp;
518
+
519
  if ( !$user_id )
520
  $user_id = $bp->loggedin_user->id;
521
+
522
  return BP_Messages_Thread::check_access( $thread_id, $user_id );
523
  }
524
 
527
  }
528
 
529
  function messages_mark_thread_unread( $thread_id ) {
530
+ return BP_Messages_Thread::mark_as_unread( $thread_id );
531
  }
532
 
533
  function messages_add_callback_values( $recipients, $subject, $content ) {
544
 
545
  function messages_get_unread_count( $user_id = false ) {
546
  global $bp;
547
+
548
+ if ( !$user_id )
549
  $user_id = $bp->loggedin_user->id;
550
+
551
  return BP_Messages_Thread::get_inbox_count( $user_id );
552
  }
553
 
bp-messages/bp-messages-classes.php CHANGED
@@ -1,46 +1,46 @@
1
  <?php
2
 
3
- Class BP_Messages_Thread {
4
  var $thread_id;
5
  var $message_ids;
6
  var $first_post_date;
7
-
8
  var $last_post_date;
9
  var $last_sender_id;
10
  var $last_message_id;
11
  var $last_message_subject;
12
  var $last_message_message;
13
  var $last_message_date_sent;
14
-
15
  var $messages = null;
16
  var $has_access = false;
17
  var $unread_count = 0;
18
  var $recipients = null;
19
-
20
  var $box;
21
  var $get_all_messages;
22
-
23
  function bp_messages_thread( $id = null, $get_all_messages = false, $box = 'inbox' ) {
24
  $this->box = $box;
25
  $this->get_all_messages = $get_all_messages;
26
-
27
  if ( $id ) {
28
  $this->populate( $id );
29
  }
30
-
31
  if ( $this->get_all_messages ) {
32
  $this->messages = $this->get_messages();
33
  $this->recipients = $this->get_recipients();
34
  }
35
  }
36
-
37
- function populate( $id ) {
38
  global $wpdb, $bp;
39
 
40
  $thread = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->messages->table_name_threads} WHERE id = %d", $id ) );
41
-
42
  if ( $thread ) {
43
-
44
  // If we're only viewing a thread in a list of threads, don't bother using
45
  // up resources checking if we have access. Only check if we're viewing the full
46
  // thread.
@@ -56,23 +56,23 @@ Class BP_Messages_Thread {
56
  // If we are viewing only the threads in a users inbox/sentbox we need to
57
  // filter the users messages out
58
  if ( !$this->get_all_messages ) {
59
-
60
  // Flip the array to start from the newest message
61
  $this->message_ids = array_reverse( $this->message_ids );
62
-
63
  foreach ( $this->message_ids as $key => $message_id ) {
64
  if ( 'sentbox' == $this->box ) {
65
  if ( !messages_is_user_sender( $bp->loggedin_user->id, $message_id ) ) {
66
  unset( $this->message_ids[$key] );
67
  } else {
68
  break;
69
- }
70
  } else {
71
  if ( messages_is_user_sender( $bp->loggedin_user->id, $message_id ) ) {
72
  unset( $this->message_ids[$key] );
73
  } else {
74
  break;
75
- }
76
  }
77
  }
78
 
@@ -85,30 +85,30 @@ Class BP_Messages_Thread {
85
 
86
  $this->first_post_date = $thread->first_post_date;
87
  $this->last_post_date = $thread->last_post_date;
88
-
89
  if ( !empty($this->message_ids) )
90
  $this->message_ids = implode( ',', $this->message_ids );
91
  else
92
  $this->message_ids = false;
93
-
94
  $this->unread_count = $this->get_unread();
95
 
96
- $last_message = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->messages->table_name_messages} WHERE id = %d", $this->last_message_id ) );
97
-
98
  if ( $last_message ) {
99
  $this->last_message_subject = $last_message->subject;
100
  $this->last_message_message = $last_message->message;
101
  $this->last_message_date_sent = $last_message->date_sent;
102
  }
103
-
104
  $this->recipients = $this->get_recipients();
105
  }
106
  }
107
  }
108
-
109
  function get_messages() {
110
  global $wpdb, $bp;
111
-
112
  if ( $this->message_ids)
113
  return $wpdb->get_results( "SELECT * FROM {$bp->messages->table_name_messages} WHERE id IN (" . $wpdb->escape($this->message_ids) . ")" );
114
  else
@@ -120,18 +120,18 @@ Class BP_Messages_Thread {
120
 
121
  $sql = $wpdb->prepare( "SELECT unread_count FROM {$bp->messages->table_name_recipients} WHERE thread_id = %d AND user_id = %d", $this->thread_id, $bp->loggedin_user->id );
122
  $unread_count = $wpdb->get_var($sql);
123
-
124
  return $unread_count;
125
  }
126
-
127
  function mark_read() {
128
  BP_Messages_Thread::mark_as_read($this->thread_id);
129
  }
130
-
131
  function mark_unread() {
132
  BP_Messages_Thread::mark_as_unread($this->thread_id);
133
  }
134
-
135
  function get_recipients() {
136
  global $wpdb, $bp;
137
 
@@ -143,17 +143,17 @@ Class BP_Messages_Thread {
143
  if ( count($recipients) > 1 && $recipient != $bp->loggedin_user->id )
144
  $recipient_ids[] = $recipient;
145
  }
146
-
147
  return $recipient_ids;
148
  }
149
-
150
  /** Static Functions **/
151
-
152
  function delete( $thread_id ) {
153
  global $wpdb, $bp;
154
-
155
  $delete_for_user = $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET is_deleted = 1 WHERE thread_id = %d AND user_id = %d", $thread_id, $bp->loggedin_user->id ) );
156
-
157
  // Check to see if any more recipients remain for this message
158
  // if not, then delete the message from the database.
159
  $recipients = $wpdb->get_results( $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_recipients} WHERE thread_id = %d AND is_deleted = 0", $thread_id ) );
@@ -162,41 +162,41 @@ Class BP_Messages_Thread {
162
  // Get message ids:
163
  $message_ids = $wpdb->get_var( $wpdb->prepare( "SELECT message_ids FROM {$bp->messages->table_name_threads} WHERE id = %d", $thread_id ) );
164
  $message_ids = unserialize($message_ids);
165
-
166
  // delete thread:
167
  $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->messages->table_name_threads} WHERE id = %d", $thread_id ) );
168
-
169
  // delete messages:
170
  for ( $i = 0; $i < count($message_ids); $i++ ) {
171
  $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->messages->table_name_messages} WHERE id = %d", $message_ids[$i] ) );
172
  }
173
-
174
  // delete the recipients
175
  $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->messages->table_name_recipients} WHERE id = %d", $thread_id ) );
176
  }
177
 
178
  return true;
179
  }
180
-
181
  function get_current_threads_for_user( $user_id, $box = 'inbox', $limit = null, $page = null, $type = 'all' ) {
182
  global $wpdb, $bp;
183
 
184
  // If we have pagination values set we want to pass those to the query
185
  if ( $limit && $page )
186
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
187
-
188
  if ( $type == 'unread' )
189
  $type_sql = $wpdb->prepare( " AND r.unread_count != 0 " );
190
  else if ( $type == 'read' )
191
  $type_sql = $wpdb->prepare( " AND r.unread_count = 0 " );
192
-
193
  $sql = $wpdb->prepare( "SELECT r.thread_id FROM {$bp->messages->table_name_recipients} r, {$bp->messages->table_name_threads} t WHERE t.id = r.thread_id AND r.is_deleted = 0 AND r.user_id = %d$exclude_sender $type_sql ORDER BY t.last_post_date DESC$pag_sql", $bp->loggedin_user->id );
194
 
195
  if ( !$thread_ids = $wpdb->get_results($sql) )
196
  return false;
197
-
198
  $threads = false;
199
-
200
  for ( $i = 0; $i < count($thread_ids); $i++ ) {
201
  $threads[$i] = new BP_Messages_Thread( $thread_ids[$i]->thread_id, false, $box );
202
 
@@ -205,48 +205,48 @@ Class BP_Messages_Thread {
205
  }
206
 
207
  // reset keys
208
- return array_reverse( array_reverse( $threads ) );
209
  }
210
-
211
  function mark_as_read( $thread_id ) {
212
  global $wpdb, $bp;
213
-
214
  $sql = $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET unread_count = 0 WHERE user_id = %d AND thread_id = %d", $bp->loggedin_user->id, $thread_id );
215
  $wpdb->query($sql);
216
  }
217
-
218
  function mark_as_unread( $thread_id ) {
219
  global $wpdb, $bp;
220
-
221
  $sql = $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET unread_count = 1 WHERE user_id = %d AND thread_id = %d", $bp->loggedin_user->id, $thread_id );
222
  $wpdb->query($sql);
223
  }
224
-
225
  function get_total_threads_for_user( $user_id, $box = 'inbox', $type = 'all' ) {
226
  global $wpdb, $bp;
227
 
228
  $exclude_sender = '';
229
  if ( $box != 'sentbox' )
230
  $exclude_sender = ' AND sender_only != 1';
231
-
232
  if ( $type == 'unread' )
233
  $type_sql = $wpdb->prepare( " AND unread_count != 0 " );
234
  else if ( $type == 'read' )
235
  $type_sql = $wpdb->prepare( " AND unread_count = 0 " );
236
 
237
- return (int) $wpdb->get_var( $wpdb->prepare( "SELECT count(thread_id) FROM {$bp->messages->table_name_recipients} WHERE user_id = %d AND is_deleted = 0$exclude_sender $type_sql", $user_id ) );
238
  }
239
-
240
  function user_is_sender($thread_id) {
241
  global $wpdb, $bp;
242
-
243
- $sender_ids = $wpdb->get_var( $wpdb->prepare( "SELECT sender_ids FROM {$bp->messages->table_name_threads} WHERE id = %d", $thread_id ) );
244
-
245
  if ( !$sender_ids )
246
  return false;
247
-
248
  $sender_ids = unserialize($sender_ids);
249
-
250
  return in_array( $bp->loggedin_user->id, $sender_ids );
251
  }
252
 
@@ -254,13 +254,13 @@ Class BP_Messages_Thread {
254
  global $wpdb, $bp;
255
 
256
  $sql = $wpdb->prepare("SELECT last_sender_id FROM {$bp->messages->table_name_threads} WHERE id = %d", $thread_id);
257
-
258
  if ( !$sender_id = $wpdb->get_var($sql) )
259
  return false;
260
-
261
  return bp_core_get_userlink( $sender_id, true );
262
  }
263
-
264
  function get_inbox_count() {
265
  global $wpdb, $bp;
266
 
@@ -268,30 +268,30 @@ Class BP_Messages_Thread {
268
 
269
  if ( !$unread_counts = $wpdb->get_results($sql) )
270
  return false;
271
-
272
  $count = 0;
273
  for ( $i = 0; $i < count($unread_counts); $i++ ) {
274
  $count += $unread_counts[$i]->unread_count;
275
  }
276
-
277
  return $count;
278
  }
279
-
280
  function check_access( $thread_id, $user_id = false ) {
281
  global $wpdb, $bp;
282
-
283
  if ( !$user_id )
284
  $user_id = $bp->loggedin_user->id;
285
-
286
  return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_recipients} WHERE thread_id = %d AND user_id = %d", $thread_id, $user_id ) );
287
  }
288
 
289
  function is_valid( $thread_id ) {
290
  global $wpdb, $bp;
291
-
292
  return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_threads} WHERE id = %d", $thread_id ) );
293
  }
294
-
295
  function get_recipient_links($recipients) {
296
  if ( count($recipients) >= 5 )
297
  return count($recipients) . __(' Recipients', 'buddypress');
@@ -310,7 +310,7 @@ Class BP_Messages_Message {
310
  var $subject;
311
  var $message;
312
  var $date_sent;
313
-
314
  var $thread_id;
315
  var $recipients = false;
316
 
@@ -324,10 +324,10 @@ Class BP_Messages_Message {
324
  $this->populate($id);
325
  }
326
  }
327
-
328
  function populate( $id ) {
329
  global $wpdb, $bp;
330
-
331
  $sql = $wpdb->prepare("SELECT * FROM {$bp->messages->table_name_messages} WHERE id = %d", $id);
332
 
333
  if ( $message = $wpdb->get_row($sql) ) {
@@ -339,21 +339,21 @@ Class BP_Messages_Message {
339
  }
340
 
341
  }
342
-
343
- function send() {
344
  global $wpdb, $bp;
345
-
346
  $this->sender_id = apply_filters( 'messages_message_sender_id_before_save', $this->sender_id, $this->id );
347
  $this->subject = apply_filters( 'messages_message_subject_before_save', $this->subject, $this->id );
348
  $this->message = apply_filters( 'messages_message_content_before_save', $this->message, $this->id );
349
- $this->date_sent = apply_filters( 'messages_message_date_sent_before_save', $this->date_sent, $this->id );
350
 
351
  do_action( 'messages_message_before_save', $this );
352
-
353
  // First insert the message into the messages table
354
  if ( !$wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->messages->table_name_messages} ( sender_id, subject, message, date_sent ) VALUES ( %d, %s, %s, FROM_UNIXTIME(%d) )", $this->sender_id, $this->subject, $this->message, $this->date_sent ) ) )
355
  return false;
356
-
357
  // Next, if thread_id is set, we are adding to an existing thread, if not, start a new one.
358
  if ( $this->thread_id ) {
359
  // Select and update the current message ids for the thread.
@@ -361,25 +361,25 @@ Class BP_Messages_Message {
361
  $message_ids = unserialize($the_ids->message_ids);
362
  $message_ids[] = $wpdb->insert_id;
363
  $message_ids = serialize($message_ids);
364
-
365
  // We need this so we can return the new message ID.
366
  $message_id = $wpdb->insert_id;
367
-
368
  // Update the sender ids for the thread
369
  $sender_ids = unserialize($the_ids->sender_ids);
370
 
371
  if ( !in_array( $this->sender_id, $sender_ids ) || !$sender_ids )
372
  $sender_ids[] = $this->sender_id;
373
-
374
- $sender_ids = serialize($sender_ids);
375
-
376
  // Update the thread the message belongs to.
377
  $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_threads} SET message_ids = %s, sender_ids = %s, last_message_id = %d, last_sender_id = %d, last_post_date = FROM_UNIXTIME(%d) WHERE id = %d", $message_ids, $sender_ids, $wpdb->insert_id, $this->sender_id, $this->date_sent, $this->thread_id ) );
378
-
379
  // Find the recipients and update the unread counts for each
380
  if ( !$this->recipients )
381
  $this->recipients = $this->get_recipients();
382
-
383
  for ( $i = 0; $i < count($this->recipients); $i++ ) {
384
  if ( $this->recipients[$i]->user_id != $bp->loggedin_user->id )
385
  $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET unread_count = unread_count + 1, sender_only = 0, is_deleted = 0 WHERE thread_id = %d AND user_id = %d", $this->thread_id, $this->recipients[$i] ) );
@@ -389,74 +389,74 @@ Class BP_Messages_Message {
389
  $message_id = $wpdb->insert_id;
390
  $serialized_message_id = serialize( array( (int)$message_id ) );
391
  $serialized_sender_id = serialize( array( (int)$bp->loggedin_user->id ) );
392
-
393
- $sql = $wpdb->prepare( "INSERT INTO {$bp->messages->table_name_threads} ( message_ids, sender_ids, first_post_date, last_post_date, last_message_id, last_sender_id ) VALUES ( %s, %s, FROM_UNIXTIME(%d), FROM_UNIXTIME(%d), %d, %d )", $serialized_message_id, $serialized_sender_id, $this->date_sent, $this->date_sent, $message_id, $this->sender_id );
394
-
395
  if ( false === $wpdb->query($sql) )
396
  return false;
397
-
398
 
399
  $this->thread_id = $wpdb->insert_id;
400
-
401
  // Add a new entry for each recipient;
402
  for ( $i = 0; $i < count($this->recipients); $i++ ) {
403
  $wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->messages->table_name_recipients} ( user_id, thread_id, unread_count ) VALUES ( %d, %d, 1 )", $this->recipients[$i], $this->thread_id ) );
404
  }
405
-
406
  if ( !in_array( $this->sender_id, (array)$this->recipients ) ) {
407
  // Finally, add a recipient entry for the sender, as replies need to go to this person too.
408
  $wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->messages->table_name_recipients} ( user_id, thread_id, unread_count, sender_only ) VALUES ( %d, %d, 0, 0 )", $this->sender_id, $this->thread_id ) );
409
  }
410
  }
411
-
412
  $this->id = $message_id;
413
  messages_remove_callback_values();
414
 
415
  do_action( 'messages_message_after_save', $this );
416
-
417
  return $this->thread_id;
418
  }
419
-
420
  function get_recipients() {
421
  global $bp, $wpdb;
422
-
423
  return $wpdb->get_results( $wpdb->prepare( "SELECT user_id FROM {$bp->messages->table_name_recipients} WHERE thread_id = %d", $this->thread_id ) );
424
  }
425
-
426
  // Static Functions
427
-
428
  function get_recipient_ids( $recipient_usernames ) {
429
  if ( !$recipient_usernames )
430
  return false;
431
-
432
  if ( is_array($recipient_usernames) ) {
433
  for ( $i = 0; $i < count($recipient_usernames); $i++ ) {
434
  if ( $rid = bp_core_get_userid( trim($recipient_usernames[$i]) ) )
435
  $recipient_ids[] = $rid;
436
  }
437
  }
438
-
439
  return $recipient_ids;
440
  }
441
-
442
  function get_last_sent_for_user( $thread_id ) {
443
  global $wpdb, $bp;
444
-
445
  $message_ids = $wpdb->get_var( $wpdb->prepare( "SELECT message_ids FROM {$bp->messages->table_name_threads} WHERE id = %d", $thread_id ) );
446
  $message_ids = implode( ',', unserialize($message_ids));
447
 
448
  $sql = $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_messages} WHERE sender_id = %d AND id IN (" . $wpdb->escape($message_ids) . ") ORDER BY date_sent DESC LIMIT 1", $bp->loggedin_user->id );
449
  return $wpdb->get_var($sql);
450
- }
451
-
452
  function is_user_sender( $user_id, $message_id ) {
453
  global $wpdb, $bp;
454
  return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_messages} WHERE sender_id = %d AND id = %d", $user_id, $message_id ) );
455
  }
456
-
457
  function get_message_sender( $message_id ) {
458
  global $wpdb, $bp;
459
- return $wpdb->get_var( $wpdb->prepare( "SELECT sender_id FROM {$bp->messages->table_name_messages} WHERE id = %d", $message_id ) );
460
  }
461
  }
462
 
@@ -466,19 +466,19 @@ Class BP_Messages_Notice {
466
  var $message;
467
  var $date_sent;
468
  var $is_active;
469
-
470
  function bp_messages_notice($id = null) {
471
  if ( $id ) {
472
  $this->id = $id;
473
  $this->populate($id);
474
  }
475
  }
476
-
477
  function populate() {
478
  global $wpdb, $bp;
479
-
480
  $notice = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->messages->table_name_notices} WHERE id = %d", $this->id ) );
481
-
482
  if ( $notice ) {
483
  $this->subject = $notice->subject;
484
  $this->message = $notice->message;
@@ -486,83 +486,83 @@ Class BP_Messages_Notice {
486
  $this->is_active = $notice->is_active;
487
  }
488
  }
489
-
490
  function save() {
491
  global $wpdb, $bp;
492
-
493
  $this->subject = apply_filters( 'messages_notice_subject_before_save', $this->subject, $this->id );
494
  $this->message = apply_filters( 'messages_notice_message_before_save', $this->message, $this->id );
495
 
496
  do_action( 'messages_notice_before_save', $this );
497
-
498
  if ( !$this->id ) {
499
- $sql = $wpdb->prepare( "INSERT INTO {$bp->messages->table_name_notices} (subject, message, date_sent, is_active) VALUES (%s, %s, FROM_UNIXTIME(%d), %d)", $this->subject, $this->message, $this->date_sent, $this->is_active );
500
  } else {
501
- $sql = $wpdb->prepare( "UPDATE {$bp->messages->table_name_notices} SET subject = %s, message = %s, is_active = %d WHERE id = %d", $this->subject, $this->message, $this->is_active, $this->id );
502
  }
503
-
504
  if ( !$wpdb->query($sql) )
505
  return false;
506
-
507
  if ( !$id = $this->id )
508
  $id = $wpdb->insert_id;
509
-
510
  // Now deactivate all notices apart from the new one.
511
  $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_notices} SET is_active = 0 WHERE id != %d", $id ) );
512
-
513
- update_usermeta( $bp->loggedin_user->id, 'last_activity', date( 'Y-m-d H:i:s' ) );
514
 
515
  do_action( 'messages_notice_after_save', $this );
516
-
517
  return true;
518
  }
519
-
520
  function activate() {
521
  $this->is_active = 1;
522
  if ( !$this->save() )
523
  return false;
524
-
525
  return true;
526
  }
527
-
528
  function deactivate() {
529
  $this->is_active = 0;
530
  if ( !$this->save() )
531
  return false;
532
-
533
  return true;
534
  }
535
-
536
  function delete() {
537
  global $wpdb, $bp;
538
-
539
  $sql = $wpdb->prepare( "DELETE FROM {$bp->messages->table_name_notices} WHERE id = %d", $this->id );
540
-
541
  if ( !$wpdb->query($sql) )
542
  return false;
543
-
544
- return true;
545
  }
546
-
547
  // Static Functions
548
-
549
  function get_notices() {
550
  global $wpdb, $bp;
551
-
552
  $notices = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->messages->table_name_notices} ORDER BY date_sent DESC" ) );
553
  return $notices;
554
  }
555
-
556
  function get_total_notice_count() {
557
  global $wpdb, $bp;
558
-
559
- $notice_count = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM " . $bp->messages->table_name_notices ) );
560
  return $notice_count;
561
  }
562
-
563
  function get_active() {
564
  global $wpdb, $bp;
565
-
566
  $notice_id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_notices} WHERE is_active = 1") );
567
  return new BP_Messages_Notice($notice_id);
568
  }
1
  <?php
2
 
3
+ Class BP_Messages_Thread {
4
  var $thread_id;
5
  var $message_ids;
6
  var $first_post_date;
7
+
8
  var $last_post_date;
9
  var $last_sender_id;
10
  var $last_message_id;
11
  var $last_message_subject;
12
  var $last_message_message;
13
  var $last_message_date_sent;
14
+
15
  var $messages = null;
16
  var $has_access = false;
17
  var $unread_count = 0;
18
  var $recipients = null;
19
+
20
  var $box;
21
  var $get_all_messages;
22
+
23
  function bp_messages_thread( $id = null, $get_all_messages = false, $box = 'inbox' ) {
24
  $this->box = $box;
25
  $this->get_all_messages = $get_all_messages;
26
+
27
  if ( $id ) {
28
  $this->populate( $id );
29
  }
30
+
31
  if ( $this->get_all_messages ) {
32
  $this->messages = $this->get_messages();
33
  $this->recipients = $this->get_recipients();
34
  }
35
  }
36
+
37
+ function populate( $id ) {
38
  global $wpdb, $bp;
39
 
40
  $thread = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->messages->table_name_threads} WHERE id = %d", $id ) );
41
+
42
  if ( $thread ) {
43
+
44
  // If we're only viewing a thread in a list of threads, don't bother using
45
  // up resources checking if we have access. Only check if we're viewing the full
46
  // thread.
56
  // If we are viewing only the threads in a users inbox/sentbox we need to
57
  // filter the users messages out
58
  if ( !$this->get_all_messages ) {
59
+
60
  // Flip the array to start from the newest message
61
  $this->message_ids = array_reverse( $this->message_ids );
62
+
63
  foreach ( $this->message_ids as $key => $message_id ) {
64
  if ( 'sentbox' == $this->box ) {
65
  if ( !messages_is_user_sender( $bp->loggedin_user->id, $message_id ) ) {
66
  unset( $this->message_ids[$key] );
67
  } else {
68
  break;
69
+ }
70
  } else {
71
  if ( messages_is_user_sender( $bp->loggedin_user->id, $message_id ) ) {
72
  unset( $this->message_ids[$key] );
73
  } else {
74
  break;
75
+ }
76
  }
77
  }
78
 
85
 
86
  $this->first_post_date = $thread->first_post_date;
87
  $this->last_post_date = $thread->last_post_date;
88
+
89
  if ( !empty($this->message_ids) )
90
  $this->message_ids = implode( ',', $this->message_ids );
91
  else
92
  $this->message_ids = false;
93
+
94
  $this->unread_count = $this->get_unread();
95
 
96
+ $last_message = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->messages->table_name_messages} WHERE id = %d", $this->last_message_id ) );
97
+
98
  if ( $last_message ) {
99
  $this->last_message_subject = $last_message->subject;
100
  $this->last_message_message = $last_message->message;
101
  $this->last_message_date_sent = $last_message->date_sent;
102
  }
103
+
104
  $this->recipients = $this->get_recipients();
105
  }
106
  }
107
  }
108
+
109
  function get_messages() {
110
  global $wpdb, $bp;
111
+
112
  if ( $this->message_ids)
113
  return $wpdb->get_results( "SELECT * FROM {$bp->messages->table_name_messages} WHERE id IN (" . $wpdb->escape($this->message_ids) . ")" );
114
  else
120
 
121
  $sql = $wpdb->prepare( "SELECT unread_count FROM {$bp->messages->table_name_recipients} WHERE thread_id = %d AND user_id = %d", $this->thread_id, $bp->loggedin_user->id );
122
  $unread_count = $wpdb->get_var($sql);
123
+
124
  return $unread_count;
125
  }
126
+
127
  function mark_read() {
128
  BP_Messages_Thread::mark_as_read($this->thread_id);
129
  }
130
+
131
  function mark_unread() {
132
  BP_Messages_Thread::mark_as_unread($this->thread_id);
133
  }
134
+
135
  function get_recipients() {
136
  global $wpdb, $bp;
137
 
143
  if ( count($recipients) > 1 && $recipient != $bp->loggedin_user->id )
144
  $recipient_ids[] = $recipient;
145
  }
146
+
147
  return $recipient_ids;
148
  }
149
+
150
  /** Static Functions **/
151
+
152
  function delete( $thread_id ) {
153
  global $wpdb, $bp;
154
+
155
  $delete_for_user = $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET is_deleted = 1 WHERE thread_id = %d AND user_id = %d", $thread_id, $bp->loggedin_user->id ) );
156
+
157
  // Check to see if any more recipients remain for this message
158
  // if not, then delete the message from the database.
159
  $recipients = $wpdb->get_results( $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_recipients} WHERE thread_id = %d AND is_deleted = 0", $thread_id ) );
162
  // Get message ids:
163
  $message_ids = $wpdb->get_var( $wpdb->prepare( "SELECT message_ids FROM {$bp->messages->table_name_threads} WHERE id = %d", $thread_id ) );
164
  $message_ids = unserialize($message_ids);
165
+
166
  // delete thread:
167
  $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->messages->table_name_threads} WHERE id = %d", $thread_id ) );
168
+
169
  // delete messages:
170
  for ( $i = 0; $i < count($message_ids); $i++ ) {
171
  $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->messages->table_name_messages} WHERE id = %d", $message_ids[$i] ) );
172
  }
173
+
174
  // delete the recipients
175
  $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->messages->table_name_recipients} WHERE id = %d", $thread_id ) );
176
  }
177
 
178
  return true;
179
  }
180
+
181
  function get_current_threads_for_user( $user_id, $box = 'inbox', $limit = null, $page = null, $type = 'all' ) {
182
  global $wpdb, $bp;
183
 
184
  // If we have pagination values set we want to pass those to the query
185
  if ( $limit && $page )
186
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
187
+
188
  if ( $type == 'unread' )
189
  $type_sql = $wpdb->prepare( " AND r.unread_count != 0 " );
190
  else if ( $type == 'read' )
191
  $type_sql = $wpdb->prepare( " AND r.unread_count = 0 " );
192
+
193
  $sql = $wpdb->prepare( "SELECT r.thread_id FROM {$bp->messages->table_name_recipients} r, {$bp->messages->table_name_threads} t WHERE t.id = r.thread_id AND r.is_deleted = 0 AND r.user_id = %d$exclude_sender $type_sql ORDER BY t.last_post_date DESC$pag_sql", $bp->loggedin_user->id );
194
 
195
  if ( !$thread_ids = $wpdb->get_results($sql) )
196
  return false;
197
+
198
  $threads = false;
199
+
200
  for ( $i = 0; $i < count($thread_ids); $i++ ) {
201
  $threads[$i] = new BP_Messages_Thread( $thread_ids[$i]->thread_id, false, $box );
202
 
205
  }
206
 
207
  // reset keys
208
+ return array_reverse( array_reverse( $threads ) );
209
  }
210
+
211
  function mark_as_read( $thread_id ) {
212
  global $wpdb, $bp;
213
+
214
  $sql = $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET unread_count = 0 WHERE user_id = %d AND thread_id = %d", $bp->loggedin_user->id, $thread_id );
215
  $wpdb->query($sql);
216
  }
217
+
218
  function mark_as_unread( $thread_id ) {
219
  global $wpdb, $bp;
220
+
221
  $sql = $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET unread_count = 1 WHERE user_id = %d AND thread_id = %d", $bp->loggedin_user->id, $thread_id );
222
  $wpdb->query($sql);
223
  }
224
+
225
  function get_total_threads_for_user( $user_id, $box = 'inbox', $type = 'all' ) {
226
  global $wpdb, $bp;
227
 
228
  $exclude_sender = '';
229
  if ( $box != 'sentbox' )
230
  $exclude_sender = ' AND sender_only != 1';
231
+
232
  if ( $type == 'unread' )
233
  $type_sql = $wpdb->prepare( " AND unread_count != 0 " );
234
  else if ( $type == 'read' )
235
  $type_sql = $wpdb->prepare( " AND unread_count = 0 " );
236
 
237
+ return (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(thread_id) FROM {$bp->messages->table_name_recipients} WHERE user_id = %d AND is_deleted = 0$exclude_sender $type_sql", $user_id ) );
238
  }
239
+
240
  function user_is_sender($thread_id) {
241
  global $wpdb, $bp;
242
+
243
+ $sender_ids = $wpdb->get_var( $wpdb->prepare( "SELECT sender_ids FROM {$bp->messages->table_name_threads} WHERE id = %d", $thread_id ) );
244
+
245
  if ( !$sender_ids )
246
  return false;
247
+
248
  $sender_ids = unserialize($sender_ids);
249
+
250
  return in_array( $bp->loggedin_user->id, $sender_ids );
251
  }
252
 
254
  global $wpdb, $bp;
255
 
256
  $sql = $wpdb->prepare("SELECT last_sender_id FROM {$bp->messages->table_name_threads} WHERE id = %d", $thread_id);
257
+
258
  if ( !$sender_id = $wpdb->get_var($sql) )
259
  return false;
260
+
261
  return bp_core_get_userlink( $sender_id, true );
262
  }
263
+
264
  function get_inbox_count() {
265
  global $wpdb, $bp;
266
 
268
 
269
  if ( !$unread_counts = $wpdb->get_results($sql) )
270
  return false;
271
+
272
  $count = 0;
273
  for ( $i = 0; $i < count($unread_counts); $i++ ) {
274
  $count += $unread_counts[$i]->unread_count;
275
  }
276
+
277
  return $count;
278
  }
279
+
280
  function check_access( $thread_id, $user_id = false ) {
281
  global $wpdb, $bp;
282
+
283
  if ( !$user_id )
284
  $user_id = $bp->loggedin_user->id;
285
+
286
  return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_recipients} WHERE thread_id = %d AND user_id = %d", $thread_id, $user_id ) );
287
  }
288
 
289
  function is_valid( $thread_id ) {
290
  global $wpdb, $bp;
291
+
292
  return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_threads} WHERE id = %d", $thread_id ) );
293
  }
294
+
295
  function get_recipient_links($recipients) {
296
  if ( count($recipients) >= 5 )
297
  return count($recipients) . __(' Recipients', 'buddypress');
310
  var $subject;
311
  var $message;
312
  var $date_sent;
313
+
314
  var $thread_id;
315
  var $recipients = false;
316
 
324
  $this->populate($id);
325
  }
326
  }
327
+
328
  function populate( $id ) {
329
  global $wpdb, $bp;
330
+
331
  $sql = $wpdb->prepare("SELECT * FROM {$bp->messages->table_name_messages} WHERE id = %d", $id);
332
 
333
  if ( $message = $wpdb->get_row($sql) ) {
339
  }
340
 
341
  }
342
+
343
+ function send() {
344
  global $wpdb, $bp;
345
+
346
  $this->sender_id = apply_filters( 'messages_message_sender_id_before_save', $this->sender_id, $this->id );
347
  $this->subject = apply_filters( 'messages_message_subject_before_save', $this->subject, $this->id );
348
  $this->message = apply_filters( 'messages_message_content_before_save', $this->message, $this->id );
349
+ $this->date_sent = apply_filters( 'messages_message_date_sent_before_save', $this->date_sent, $this->id );
350
 
351
  do_action( 'messages_message_before_save', $this );
352
+
353
  // First insert the message into the messages table
354
  if ( !$wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->messages->table_name_messages} ( sender_id, subject, message, date_sent ) VALUES ( %d, %s, %s, FROM_UNIXTIME(%d) )", $this->sender_id, $this->subject, $this->message, $this->date_sent ) ) )
355
  return false;
356
+
357
  // Next, if thread_id is set, we are adding to an existing thread, if not, start a new one.
358
  if ( $this->thread_id ) {
359
  // Select and update the current message ids for the thread.
361
  $message_ids = unserialize($the_ids->message_ids);
362
  $message_ids[] = $wpdb->insert_id;
363
  $message_ids = serialize($message_ids);
364
+
365
  // We need this so we can return the new message ID.
366
  $message_id = $wpdb->insert_id;
367
+
368
  // Update the sender ids for the thread
369
  $sender_ids = unserialize($the_ids->sender_ids);
370
 
371
  if ( !in_array( $this->sender_id, $sender_ids ) || !$sender_ids )
372
  $sender_ids[] = $this->sender_id;
373
+
374
+ $sender_ids = serialize($sender_ids);
375
+
376
  // Update the thread the message belongs to.
377
  $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_threads} SET message_ids = %s, sender_ids = %s, last_message_id = %d, last_sender_id = %d, last_post_date = FROM_UNIXTIME(%d) WHERE id = %d", $message_ids, $sender_ids, $wpdb->insert_id, $this->sender_id, $this->date_sent, $this->thread_id ) );
378
+
379
  // Find the recipients and update the unread counts for each
380
  if ( !$this->recipients )
381
  $this->recipients = $this->get_recipients();
382
+
383
  for ( $i = 0; $i < count($this->recipients); $i++ ) {
384
  if ( $this->recipients[$i]->user_id != $bp->loggedin_user->id )
385
  $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET unread_count = unread_count + 1, sender_only = 0, is_deleted = 0 WHERE thread_id = %d AND user_id = %d", $this->thread_id, $this->recipients[$i] ) );
389
  $message_id = $wpdb->insert_id;
390
  $serialized_message_id = serialize( array( (int)$message_id ) );
391
  $serialized_sender_id = serialize( array( (int)$bp->loggedin_user->id ) );
392
+
393
+ $sql = $wpdb->prepare( "INSERT INTO {$bp->messages->table_name_threads} ( message_ids, sender_ids, first_post_date, last_post_date, last_message_id, last_sender_id ) VALUES ( %s, %s, FROM_UNIXTIME(%d), FROM_UNIXTIME(%d), %d, %d )", $serialized_message_id, $serialized_sender_id, $this->date_sent, $this->date_sent, $message_id, $this->sender_id );
394
+
395
  if ( false === $wpdb->query($sql) )
396
  return false;
397
+
398
 
399
  $this->thread_id = $wpdb->insert_id;
400
+
401
  // Add a new entry for each recipient;
402
  for ( $i = 0; $i < count($this->recipients); $i++ ) {
403
  $wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->messages->table_name_recipients} ( user_id, thread_id, unread_count ) VALUES ( %d, %d, 1 )", $this->recipients[$i], $this->thread_id ) );
404
  }
405
+
406
  if ( !in_array( $this->sender_id, (array)$this->recipients ) ) {
407
  // Finally, add a recipient entry for the sender, as replies need to go to this person too.
408
  $wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->messages->table_name_recipients} ( user_id, thread_id, unread_count, sender_only ) VALUES ( %d, %d, 0, 0 )", $this->sender_id, $this->thread_id ) );
409
  }
410
  }
411
+
412
  $this->id = $message_id;
413
  messages_remove_callback_values();
414
 
415
  do_action( 'messages_message_after_save', $this );
416
+
417
  return $this->thread_id;
418
  }
419
+
420
  function get_recipients() {
421
  global $bp, $wpdb;
422
+
423
  return $wpdb->get_results( $wpdb->prepare( "SELECT user_id FROM {$bp->messages->table_name_recipients} WHERE thread_id = %d", $this->thread_id ) );
424
  }
425
+
426
  // Static Functions
427
+
428
  function get_recipient_ids( $recipient_usernames ) {
429
  if ( !$recipient_usernames )
430
  return false;
431
+
432
  if ( is_array($recipient_usernames) ) {
433
  for ( $i = 0; $i < count($recipient_usernames); $i++ ) {
434
  if ( $rid = bp_core_get_userid( trim($recipient_usernames[$i]) ) )
435
  $recipient_ids[] = $rid;
436
  }
437
  }
438
+
439
  return $recipient_ids;
440
  }
441
+
442
  function get_last_sent_for_user( $thread_id ) {
443
  global $wpdb, $bp;
444
+
445
  $message_ids = $wpdb->get_var( $wpdb->prepare( "SELECT message_ids FROM {$bp->messages->table_name_threads} WHERE id = %d", $thread_id ) );
446
  $message_ids = implode( ',', unserialize($message_ids));
447
 
448
  $sql = $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_messages} WHERE sender_id = %d AND id IN (" . $wpdb->escape($message_ids) . ") ORDER BY date_sent DESC LIMIT 1", $bp->loggedin_user->id );
449
  return $wpdb->get_var($sql);
450
+ }
451
+
452
  function is_user_sender( $user_id, $message_id ) {
453
  global $wpdb, $bp;
454
  return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_messages} WHERE sender_id = %d AND id = %d", $user_id, $message_id ) );
455
  }
456
+
457
  function get_message_sender( $message_id ) {
458
  global $wpdb, $bp;
459
+ return $wpdb->get_var( $wpdb->prepare( "SELECT sender_id FROM {$bp->messages->table_name_messages} WHERE id = %d", $message_id ) );
460
  }
461
  }
462
 
466
  var $message;
467
  var $date_sent;
468
  var $is_active;
469
+
470
  function bp_messages_notice($id = null) {
471
  if ( $id ) {
472
  $this->id = $id;
473
  $this->populate($id);
474
  }
475
  }
476
+
477
  function populate() {
478
  global $wpdb, $bp;
479
+
480
  $notice = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->messages->table_name_notices} WHERE id = %d", $this->id ) );
481
+
482
  if ( $notice ) {
483
  $this->subject = $notice->subject;
484
  $this->message = $notice->message;
486
  $this->is_active = $notice->is_active;
487
  }
488
  }
489
+
490
  function save() {
491
  global $wpdb, $bp;
492
+
493
  $this->subject = apply_filters( 'messages_notice_subject_before_save', $this->subject, $this->id );
494
  $this->message = apply_filters( 'messages_notice_message_before_save', $this->message, $this->id );
495
 
496
  do_action( 'messages_notice_before_save', $this );
497
+
498
  if ( !$this->id ) {
499
+ $sql = $wpdb->prepare( "INSERT INTO {$bp->messages->table_name_notices} (subject, message, date_sent, is_active) VALUES (%s, %s, FROM_UNIXTIME(%d), %d)", $this->subject, $this->message, $this->date_sent, $this->is_active );
500
  } else {
501
+ $sql = $wpdb->prepare( "UPDATE {$bp->messages->table_name_notices} SET subject = %s, message = %s, is_active = %d WHERE id = %d", $this->subject, $this->message, $this->is_active, $this->id );
502
  }
503
+
504
  if ( !$wpdb->query($sql) )
505
  return false;
506
+
507
  if ( !$id = $this->id )
508
  $id = $wpdb->insert_id;
509
+
510
  // Now deactivate all notices apart from the new one.
511
  $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_notices} SET is_active = 0 WHERE id != %d", $id ) );
512
+
513
+ update_usermeta( $bp->loggedin_user->id, 'last_activity', date( 'Y-m-d H:i:s' ) );
514
 
515
  do_action( 'messages_notice_after_save', $this );
516
+
517
  return true;
518
  }
519
+
520
  function activate() {
521
  $this->is_active = 1;
522
  if ( !$this->save() )
523
  return false;
524
+
525
  return true;
526
  }
527
+
528
  function deactivate() {
529
  $this->is_active = 0;
530
  if ( !$this->save() )
531
  return false;
532
+
533
  return true;
534
  }
535
+
536
  function delete() {
537
  global $wpdb, $bp;
538
+
539
  $sql = $wpdb->prepare( "DELETE FROM {$bp->messages->table_name_notices} WHERE id = %d", $this->id );
540
+
541
  if ( !$wpdb->query($sql) )
542
  return false;
543
+
544
+ return true;
545
  }
546
+
547
  // Static Functions
548
+
549
  function get_notices() {
550
  global $wpdb, $bp;
551
+
552
  $notices = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->messages->table_name_notices} ORDER BY date_sent DESC" ) );
553
  return $notices;
554
  }
555
+
556
  function get_total_notice_count() {
557
  global $wpdb, $bp;
558
+
559
+ $notice_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM " . $bp->messages->table_name_notices ) );
560
  return $notice_count;
561
  }
562
+
563
  function get_active() {
564
  global $wpdb, $bp;
565
+
566
  $notice_id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_notices} WHERE is_active = 1") );
567
  return new BP_Messages_Notice($notice_id);
568
  }
bp-messages/bp-messages-cssjs.php CHANGED
@@ -2,15 +2,15 @@
2
 
3
  function messages_add_autocomplete_js() {
4
  global $bp;
5
-
6
  // Include the autocomplete JS for composing a message.
7
  if ( $bp->current_component == $bp->messages->slug && 'compose' == $bp->current_action ) {
8
  add_action( 'wp_head', 'messages_autocomplete_init_jsblock' );
9
-
10
  wp_enqueue_script( 'bp-jquery-autocomplete', BP_PLUGIN_URL . '/bp-messages/js/autocomplete/jquery.autocomplete.js', array( 'jquery' ) );
11
  wp_enqueue_script( 'bp-jquery-autocomplete-fb', BP_PLUGIN_URL . '/bp-messages/js/autocomplete/jquery.autocompletefb.js' );
12
  wp_enqueue_script( 'bp-jquery-bgiframe', BP_PLUGIN_URL . '/bp-messages/js/autocomplete/jquery.bgiframe.min.js' );
13
- wp_enqueue_script( 'bp-jquery-dimensions', BP_PLUGIN_URL . '/bp-messages/js/autocomplete/jquery.dimensions.js' );
14
  }
15
 
16
  }
@@ -20,7 +20,7 @@ function messages_add_autocomplete_css() {
20
  global $bp;
21
 
22
  if ( $bp->current_component == $bp->messages->slug && 'compose' == $bp->current_action ) {
23
- wp_enqueue_style( 'bp-messages-autocomplete', BP_PLUGIN_URL . '/bp-messages/css/autocomplete/jquery.autocompletefb.css' );
24
  wp_print_styles();
25
  }
26
  }
@@ -30,7 +30,7 @@ function messages_autocomplete_init_jsblock() {
30
  ?>
31
  <script type="text/javascript">
32
  jQuery(document).ready(function() {
33
- var acfb =
34
  jQuery("ul.first").autoCompletefb({urlLookup:'<?php echo $bp->root_domain . str_replace( 'index.php', 'wp-load.php', $_SERVER['SCRIPT_NAME'] ) ?>'});
35
 
36
  jQuery('#send_message_form').submit( function() {
2
 
3
  function messages_add_autocomplete_js() {
4
  global $bp;
5
+
6
  // Include the autocomplete JS for composing a message.
7
  if ( $bp->current_component == $bp->messages->slug && 'compose' == $bp->current_action ) {
8
  add_action( 'wp_head', 'messages_autocomplete_init_jsblock' );
9
+
10
  wp_enqueue_script( 'bp-jquery-autocomplete', BP_PLUGIN_URL . '/bp-messages/js/autocomplete/jquery.autocomplete.js', array( 'jquery' ) );
11
  wp_enqueue_script( 'bp-jquery-autocomplete-fb', BP_PLUGIN_URL . '/bp-messages/js/autocomplete/jquery.autocompletefb.js' );
12
  wp_enqueue_script( 'bp-jquery-bgiframe', BP_PLUGIN_URL . '/bp-messages/js/autocomplete/jquery.bgiframe.min.js' );
13
+ wp_enqueue_script( 'bp-jquery-dimensions', BP_PLUGIN_URL . '/bp-messages/js/autocomplete/jquery.dimensions.js' );
14
  }
15
 
16
  }
20
  global $bp;
21
 
22
  if ( $bp->current_component == $bp->messages->slug && 'compose' == $bp->current_action ) {
23
+ wp_enqueue_style( 'bp-messages-autocomplete', BP_PLUGIN_URL . '/bp-messages/css/autocomplete/jquery.autocompletefb.css' );
24
  wp_print_styles();
25
  }
26
  }
30
  ?>
31
  <script type="text/javascript">
32
  jQuery(document).ready(function() {
33
+ var acfb =
34
  jQuery("ul.first").autoCompletefb({urlLookup:'<?php echo $bp->root_domain . str_replace( 'index.php', 'wp-load.php', $_SERVER['SCRIPT_NAME'] ) ?>'});
35
 
36
  jQuery('#send_message_form').submit( function() {
bp-messages/bp-messages-filters.php CHANGED
File without changes
bp-messages/bp-messages-notifications.php CHANGED
@@ -3,23 +3,23 @@
3
  function messages_notification_new_message( $args ) {
4
  global $bp;
5
  extract($args);
6
-
7
  $message = new BP_Messages_Message( $item_id );
8
-
9
  $sender_name = bp_core_get_user_displayname( $message->sender_id );
10
 
11
  for ( $i = 0; $i < count($recipient_ids); $i++ ) {
12
  if ( $message->sender_id == $recipient_ids[$i] || 'no' == get_usermeta( $recipient_ids[$i], 'notification_messages_new_message' ) ) continue;
13
 
14
  $ud = get_userdata( $recipient_ids[$i] );
15
- $message_link = bp_core_get_user_domain( $recipient_ids[$i] ) . 'messages/view/' . $message->id;
16
- $settings_link = bp_core_get_user_domain( $recipient_ids[$i] ) . 'settings/notifications';
17
-
18
  // Set up and send the message
19
  $to = $ud->user_email;
20
  $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'New message from %s', 'buddypress' ), stripslashes( $sender_name ) );
21
 
22
- $content = sprintf( __(
23
  '%s sent you a new message:
24
 
25
  Subject: %s
@@ -44,18 +44,18 @@ function messages_notification_new_notice( $message_subject, $message ) {
44
  global $bp, $wpdb;
45
 
46
  $users = $wpdb->get_results( $wpdb->prepare( "SELECT ID as user_id, user_email, user_login FROM {$wpdb->base_prefix}users WHERE user_status = 0 AND spam = 0 AND deleted = 0" ) );
47
-
48
  for ( $i = 0; $i < count($users); $i++ ) {
49
  if ( get_usermeta( $users[$i]->user_id, 'notification_messages_new_notice' ) == 'no' ) continue;
50
 
51
- $message_link = bp_core_get_user_domain( $users[$i]->user_id ) . 'messages';
52
- $settings_link = bp_core_get_user_domain( $users[$i]->user_id ) . 'settings/notifications';
53
 
54
  // Set up and send the message
55
  $to = $users[$i]->user_email;
56
  $subject = __( 'New Site Notice', 'buddypress' );
57
 
58
- $message = sprintf( __(
59
  'A new site notice has been posted on %s:
60
 
61
  "%s: %s"
@@ -69,7 +69,7 @@ To view the notice: %s
69
 
70
  // Send it
71
  wp_mail( $to, $subject, $message );
72
-
73
  unset($message);
74
  unset($subject);
75
  unset($to);
3
  function messages_notification_new_message( $args ) {
4
  global $bp;
5
  extract($args);
6
+
7
  $message = new BP_Messages_Message( $item_id );
8
+
9
  $sender_name = bp_core_get_user_displayname( $message->sender_id );
10
 
11
  for ( $i = 0; $i < count($recipient_ids); $i++ ) {
12
  if ( $message->sender_id == $recipient_ids[$i] || 'no' == get_usermeta( $recipient_ids[$i], 'notification_messages_new_message' ) ) continue;
13
 
14
  $ud = get_userdata( $recipient_ids[$i] );
15
+ $message_link = bp_core_get_user_domain( $recipient_ids[$i] ) . $bp->messages->slug . '/view/' . $message->id;
16
+ $settings_link = bp_core_get_user_domain( $recipient_ids[$i] ) . $bp->settings->slug . '/notifications';
17
+
18
  // Set up and send the message
19
  $to = $ud->user_email;
20
  $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'New message from %s', 'buddypress' ), stripslashes( $sender_name ) );
21
 
22
+ $content = sprintf( __(
23
  '%s sent you a new message:
24
 
25
  Subject: %s
44
  global $bp, $wpdb;
45
 
46
  $users = $wpdb->get_results( $wpdb->prepare( "SELECT ID as user_id, user_email, user_login FROM {$wpdb->base_prefix}users WHERE user_status = 0 AND spam = 0 AND deleted = 0" ) );
47
+
48
  for ( $i = 0; $i < count($users); $i++ ) {
49
  if ( get_usermeta( $users[$i]->user_id, 'notification_messages_new_notice' ) == 'no' ) continue;
50
 
51
+ $message_link = bp_core_get_user_domain( $users[$i]->user_id ) . $bp->messages->slug;
52
+ $settings_link = bp_core_get_user_domain( $users[$i]->user_id ) . $bp->settings->slug . '/notifications';
53
 
54
  // Set up and send the message
55
  $to = $users[$i]->user_email;
56
  $subject = __( 'New Site Notice', 'buddypress' );
57
 
58
+ $message = sprintf( __(
59
  'A new site notice has been posted on %s:
60
 
61
  "%s: %s"
69
 
70
  // Send it
71
  wp_mail( $to, $subject, $message );
72
+
73
  unset($message);
74
  unset($subject);
75
  unset($to);
bp-messages/bp-messages-templatetags.php CHANGED
@@ -10,11 +10,11 @@ Class BP_Messages_Box_Template {
10
  var $total_thread_count;
11
  var $threads;
12
  var $thread;
13
-
14
  var $in_the_loop;
15
  var $user_id;
16
  var $box;
17
-
18
  var $pag_page;
19
  var $pag_num;
20
  var $pag_links;
@@ -24,18 +24,18 @@ Class BP_Messages_Box_Template {
24
  $this->pag_num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : $per_page;
25
  $this->user_id = $user_id;
26
  $this->box = $box;
27
-
28
  if ( 'notices' == $this->box )
29
  $this->threads = BP_Messages_Notice::get_notices();
30
  else
31
  $this->threads = BP_Messages_Thread::get_current_threads_for_user( $this->user_id, $this->box, $this->pag_num, $this->pag_page, $type );
32
-
33
  if ( !$this->threads ) {
34
  $this->thread_count = 0;
35
  $this->total_thread_count = 0;
36
- } else {
37
  $total_notice_count = BP_Messages_Notice::get_total_notice_count();
38
-
39
  if ( !$max || $max >= (int)$total_notice_count ) {
40
  if ( 'notices' == $this->box )
41
  $this->total_thread_count = (int)$total_notice_count;
@@ -44,7 +44,7 @@ Class BP_Messages_Box_Template {
44
  } else {
45
  $this->total_thread_count = (int)$max;
46
  }
47
-
48
  if ( $max ) {
49
  if ( $max >= count($this->threads) )
50
  $this->thread_count = count($this->threads);
@@ -65,29 +65,29 @@ Class BP_Messages_Box_Template {
65
  'mid_size' => 1
66
  ));
67
  }
68
-
69
  function has_threads() {
70
  if ( $this->thread_count )
71
  return true;
72
-
73
  return false;
74
  }
75
-
76
  function next_thread() {
77
  $this->current_thread++;
78
  $this->thread = $this->threads[$this->current_thread];
79
-
80
  return $this->thread;
81
  }
82
-
83
  function rewind_threads() {
84
  $this->current_thread = -1;
85
  if ( $this->thread_count > 0 ) {
86
  $this->thread = $this->threads[0];
87
  }
88
  }
89
-
90
- function message_threads() {
91
  if ( $this->current_thread + 1 < $this->thread_count ) {
92
  return true;
93
  } elseif ( $this->current_thread + 1 == $this->thread_count ) {
@@ -99,7 +99,7 @@ Class BP_Messages_Box_Template {
99
  $this->in_the_loop = false;
100
  return false;
101
  }
102
-
103
  function the_message_thread() {
104
  global $thread;
105
 
@@ -113,7 +113,7 @@ Class BP_Messages_Box_Template {
113
 
114
  function bp_has_message_threads( $args = '' ) {
115
  global $bp, $messages_template;
116
-
117
  $defaults = array(
118
  'user_id' => $bp->loggedin_user->id,
119
  'box' => 'inbox',
@@ -130,20 +130,20 @@ function bp_has_message_threads( $args = '' ) {
130
  } else {
131
  if ( 'inbox' == $bp->current_action )
132
  bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, 'messages', 'new_message' );
133
-
134
  if ( 'sentbox' == $bp->current_action )
135
  $box = 'sentbox';
136
 
137
  if ( 'notices' == $bp->current_action )
138
  $box = 'notices';
139
-
140
  $messages_template = new BP_Messages_Box_Template( $user_id, $box, $per_page, $max, $type );
141
  }
142
-
143
  return apply_filters( 'bp_has_message_threads', $messages_template->has_threads(), &$messages_template );
144
  }
145
 
146
- function bp_message_threads() {
147
  global $messages_template;
148
  return $messages_template->message_threads();
149
  }
@@ -201,7 +201,7 @@ function bp_message_thread_view_link() {
201
  global $messages_template, $bp;
202
  return apply_filters( 'bp_get_message_thread_view_link', $bp->loggedin_user->domain . $bp->messages->slug . '/view/' . $messages_template->thread->thread_id );
203
  }
204
-
205
  function bp_message_thread_delete_link() {
206
  echo bp_get_message_thread_delete_link();
207
  }
@@ -209,13 +209,13 @@ function bp_message_thread_delete_link() {
209
  global $messages_template, $bp;
210
  return apply_filters( 'bp_get_message_thread_delete_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->messages->slug . '/' . $bp->current_action . '/delete/' . $messages_template->thread->thread_id, 'messages_delete_thread' ) );
211
  }
212
-
213
  function bp_message_thread_has_unread() {
214
  global $messages_template;
215
 
216
  if ( $messages_template->thread->unread_count )
217
  return true;
218
-
219
  return false;
220
  }
221
 
@@ -224,10 +224,10 @@ function bp_message_thread_unread_count() {
224
  }
225
  function bp_get_message_thread_unread_count() {
226
  global $messages_template;
227
-
228
  if ( (int)$messages_template->thread->unread_count )
229
  return apply_filters( 'bp_get_message_thread_unread_count', $messages_template->thread->unread_count );
230
-
231
  return false;
232
  }
233
 
@@ -275,7 +275,7 @@ function bp_messages_pagination_count() {
275
  $to_num = ( $from_num + ( $messages_template->pag_num - 1 ) > $messages_template->total_thread_count ) ? $messages_template->total_thread_count : $from_num + ( $messages_template->pag_num - 1) ;
276
 
277
  echo sprintf( __( 'Viewing message %d to %d (of %d messages)', 'buddypress' ), $from_num, $to_num, $messages_template->total_thread_count ); ?> &nbsp;
278
- <span class="ajax-loader"></span><?php
279
  }
280
 
281
  function bp_messages_form_action() {
@@ -314,10 +314,10 @@ function bp_messages_content_value() {
314
 
315
  function bp_messages_options() {
316
  global $bp;
317
-
318
  if ( $bp->current_action != 'sentbox' ) {
319
  ?>
320
- <?php _e( 'Select:', 'buddypress' ) ?>
321
  <select name="message-type-select" id="message-type-select">
322
  <option value=""></option>
323
  <option value="read"><?php _e('Read', 'buddypress') ?></option>
@@ -328,12 +328,12 @@ function bp_messages_options() {
328
  <a href="#" id="mark_as_unread"><?php _e('Mark as Unread', 'buddypress') ?></a> &nbsp;
329
  <?php } ?>
330
  <a href="#" id="delete_<?php echo $bp->current_action ?>_messages"><?php _e('Delete Selected', 'buddypress') ?></a> &nbsp;
331
- <?php
332
  }
333
 
334
  function bp_message_is_active_notice() {
335
  global $messages_template;
336
-
337
  if ( $messages_template->thread->is_active ) {
338
  echo "<strong>";
339
  _e( 'Currently Active', 'buddypress' );
@@ -345,7 +345,7 @@ function bp_message_is_active_notice() {
345
 
346
  if ( $messages_template->thread->is_active )
347
  return true;
348
-
349
  return false;
350
  }
351
 
@@ -391,7 +391,7 @@ function bp_message_activate_deactivate_link() {
391
  if ( 1 == (int)$messages_template->thread->is_active ) {
392
  $link = wp_nonce_url( $bp->loggedin_user->domain . $bp->messages->slug . '/notices/deactivate/' . $messages_template->thread->id, 'messages_deactivate_notice' );
393
  } else {
394
- $link = wp_nonce_url( $bp->loggedin_user->domain . $bp->messages->slug . '/notices/activate/' . $messages_template->thread->id, 'messages_activate_notice' );
395
  }
396
  return apply_filters( 'bp_get_message_activate_deactivate_link', $link );
397
  }
@@ -405,14 +405,14 @@ function bp_message_activate_deactivate_text() {
405
  if ( 1 == (int)$messages_template->thread->is_active ) {
406
  $text = __('Deactivate', 'buddypress');
407
  } else {
408
- $text = __('Activate', 'buddypress');
409
  }
410
  return apply_filters( 'bp_message_activate_deactivate_text', $text );
411
  }
412
 
413
  function bp_message_get_notices() {
414
  global $userdata;
415
-
416
  $notice = BP_Messages_Notice::get_active();
417
  $closed_notices = get_usermeta( $userdata->ID, 'closed_notices');
418
 
@@ -428,7 +428,7 @@ function bp_message_get_notices() {
428
  <a href="#" id="close-notice"><?php _e( 'Close', 'buddypress' ) ?></a>
429
  </div>
430
  <?php
431
- }
432
  }
433
  }
434
 
@@ -437,12 +437,12 @@ function bp_send_message_button() {
437
  }
438
  function bp_get_send_message_button() {
439
  global $bp;
440
-
441
  if ( bp_is_home() || !is_user_logged_in() )
442
  return false;
443
-
444
- $ud = get_userdata( $bp->displayed_user->id );
445
-
446
  return apply_filters( 'bp_get_send_message_button', '<div class="generic-button"><a class="send-message" title="' . __( 'Send Message', 'buddypress' ) . '" href="' . $bp->loggedin_user->domain . $bp->messages->slug . '/compose/?r=' . $ud->user_login . '">' . __( 'Send Message', 'buddypress' ) . '</a></div>' );
447
  }
448
 
@@ -456,17 +456,17 @@ function bp_message_loading_image_src() {
456
 
457
  function bp_message_get_recipient_tabs() {
458
  global $bp;
459
-
460
  if ( isset( $_GET['r'] ) ) {
461
  $user_id = bp_core_get_userid( $_GET['r'] );
462
-
463
  if ( $user_id ) {
464
  ?>
465
  <li id="un-<?php echo $_GET['r'] ?>" class="friend-tab">
466
  <span>
467
  <?php echo bp_core_fetch_avatar( array( 'item_id' => $user_id, 'type' => 'thumb', 'width' => 15, 'height' => 15 ) ) ?>
468
  <?php echo bp_core_get_userlink( $user_id ) ?>
469
- </span>
470
  </li>
471
  <?php
472
  }
@@ -489,45 +489,45 @@ class BP_Messages_Thread_Template {
489
  var $current_message = -1;
490
  var $message_count;
491
  var $message;
492
-
493
  var $thread;
494
-
495
  var $in_the_loop;
496
-
497
  var $pag_page;
498
  var $pag_num;
499
  var $pag_links;
500
  var $total_message_count;
501
-
502
  function bp_messages_thread_template( $thread_id, $order ) {
503
  global $bp;
504
-
505
  $this->thread = new BP_Messages_Thread( $thread_id, true );
506
  $this->message_count = count( $this->thread->messages );
507
  }
508
-
509
  function has_messages() {
510
  if ( $this->message_count )
511
  return true;
512
-
513
  return false;
514
  }
515
-
516
  function next_message() {
517
  $this->current_message++;
518
  $this->message = $this->thread->messages[$this->current_message];
519
-
520
  return $this->message;
521
  }
522
-
523
  function rewind_messages() {
524
  $this->current_message = -1;
525
  if ( $this->message_count > 0 ) {
526
  $this->message = $this->thread->messages[0];
527
  }
528
  }
529
-
530
- function messages() {
531
  if ( $this->current_message + 1 < $this->message_count ) {
532
  return true;
533
  } elseif ( $this->current_message + 1 == $this->message_count ) {
@@ -539,7 +539,7 @@ class BP_Messages_Thread_Template {
539
  $this->in_the_loop = false;
540
  return false;
541
  }
542
-
543
  function the_message() {
544
  global $message;
545
 
@@ -553,7 +553,7 @@ class BP_Messages_Thread_Template {
553
 
554
  function bp_thread_has_messages( $args = '' ) {
555
  global $bp, $thread_template, $group_id;
556
-
557
  $defaults = array(
558
  'thread_id' => false,
559
  'order' => 'ASC'
@@ -571,13 +571,13 @@ function bp_thread_has_messages( $args = '' ) {
571
 
572
  function bp_thread_messages() {
573
  global $thread_template;
574
-
575
  return $thread_template->messages();
576
  }
577
 
578
  function bp_thread_the_message() {
579
  global $thread_template;
580
-
581
  return $thread_template->the_message();
582
  }
583
 
@@ -586,7 +586,7 @@ function bp_the_thread_id() {
586
  }
587
  function bp_get_the_thread_id() {
588
  global $thread_template;
589
-
590
  return apply_filters( 'bp_get_the_thread_id', $thread_template->thread->thread_id );
591
  }
592
 
@@ -604,10 +604,10 @@ function bp_the_thread_recipients() {
604
  }
605
  function bp_get_the_thread_recipients() {
606
  global $thread_template;
607
-
608
  if ( count($thread_template->thread->recipients) >= 5 )
609
  return apply_filters( 'bp_get_the_thread_recipients', sprintf( __( '%d Recipients', 'buddypress' ), count($thread_template->thread->recipients) ) );
610
-
611
  foreach( $thread_template->thread->recipients as $recipient )
612
  $recipient_links[] = bp_core_get_userlink( $recipient );
613
 
@@ -619,21 +619,21 @@ function bp_the_thread_message_alt_class() {
619
  }
620
  function bp_get_the_thread_message_alt_class() {
621
  global $thread_template;
622
-
623
  if ( $thread_template->current_message % 2 == 1 )
624
  $class = ' alt';
625
  else
626
  $class = '';
627
-
628
  return apply_filters( 'bp_get_the_thread_message_alt_class', $class );
629
  }
630
-
631
  function bp_the_thread_message_sender_avatar( $args = '' ) {
632
  echo bp_get_the_thread_message_sender_avatar_thumb( $args );
633
  }
634
  function bp_get_the_thread_message_sender_avatar_thumb( $args = '' ) {
635
- global $thread_template;
636
-
637
  $defaults = array(
638
  'type' => 'thumb',
639
  'width' => false,
@@ -651,17 +651,17 @@ function bp_the_thread_message_sender_link() {
651
  }
652
  function bp_get_the_thread_message_sender_link() {
653
  global $thread_template;
654
-
655
  return apply_filters( 'bp_get_the_thread_message_sender_link', bp_core_get_userlink( $thread_template->message->sender_id, false, true ) );
656
  }
657
-
658
  function bp_the_thread_message_sender_name() {
659
  echo bp_get_the_thread_message_sender_name();
660
  }
661
  function bp_get_the_thread_message_sender_name() {
662
  global $thread_template;
663
-
664
- return apply_filters( 'bp_get_the_thread_message_sender_name', bp_core_get_user_displayname( $thread_template->message->sender_id ) );
665
  }
666
 
667
  function bp_the_thread_message_time_since() {
@@ -669,7 +669,7 @@ function bp_the_thread_message_time_since() {
669
  }
670
  function bp_get_the_thread_message_time_since() {
671
  global $thread_template;
672
-
673
  return apply_filters( 'bp_get_the_thread_message_time_since', sprintf( __( 'Sent %s ago', 'buddypress' ), bp_core_time_since( strtotime( $thread_template->message->date_sent ) ) ) );
674
  }
675
 
@@ -678,29 +678,29 @@ function bp_the_thread_message_content() {
678
  }
679
  function bp_get_the_thread_message_content() {
680
  global $thread_template;
681
-
682
- return apply_filters( 'bp_get_the_thread_message_content', $thread_template->message->message );
683
  }
684
-
685
 
686
  /*** DEPRECATED FUNCTIONS (DO NOT USE) **********************************************************/
687
 
688
- /* DEPRECATED - please use the view message template loop. */
689
  function messages_view_thread( $thread_id ) {
690
  global $bp;
691
 
692
  $thread = new BP_Messages_Thread( $thread_id, true );
693
-
694
  if ( !$thread->has_access ) {
695
  unset($_GET['mode']); ?>
696
  <div id="message" class="error">
697
  <p><?php _e( 'There was an error when viewing that message', 'buddypress' ) ?></p>
698
  </div>
699
- <?php
700
  } else {
701
  if ( $thread->messages ) { ?>
702
  <?php $thread->mark_read() ?>
703
-
704
  <div class="wrap">
705
  <h2 id="message-subject"><?php echo $thread->subject; ?></h2>
706
  <table class="form-table">
@@ -708,16 +708,16 @@ function messages_view_thread( $thread_id ) {
708
  <tr>
709
  <td>
710
  <img src="<?php echo $bp->messages->image_base ?>/email_open.gif" alt="Message" style="vertical-align: top;" /> &nbsp;
711
- <?php _e('Sent between ', 'buddypress') ?> <?php echo BP_Messages_Thread::get_recipient_links($thread->recipients) ?>
712
- <?php _e('and', 'buddypress') ?> <?php echo bp_core_get_userlink($bp->loggedin_user->id) ?>.
713
  </td>
714
  </tr>
715
  </tbody>
716
  </table>
717
-
718
  <?php
719
  $counter = 0;
720
-
721
  foreach ( $thread->messages as $message ) {
722
  $alt = ( $counter % 2 == 1 ) ? ' alt' : '';
723
  ?>
@@ -728,26 +728,26 @@ function messages_view_thread( $thread_id ) {
728
  <h3><?php echo apply_filters( 'bp_get_message_sender_id', bp_core_get_userlink( $message->sender_id ) ) ?></h3>
729
  <small><?php echo apply_filters( 'bp_get_message_date_sent', bp_format_time( strtotime($message->date_sent ) ) ) ?></small>
730
  </div>
731
-
732
  <?php do_action( 'messages_custom_fields_output_before' ) ?>
733
-
734
  <?php echo apply_filters( 'bp_get_the_message_thread_content', stripslashes($message->message) ); ?>
735
-
736
  <?php do_action( 'messages_custom_fields_output_after' ) ?>
737
-
738
  <div class="clear"></div>
739
  </div>
740
  <?php
741
  $counter++;
742
  }
743
-
744
  ?>
745
  <form id="send-reply" action="<?php bp_messages_form_action() ?>" method="post">
746
  <div class="message-box">
747
  <div id="messagediv">
748
  <div class="avatar-box">
749
  <?php echo bp_core_fetch_avatar( array( 'item_id' => $bp->loggedin_user->id, 'type' => 'thumb' ) ); ?>
750
-
751
  <h3><?php _e("Reply: ", 'buddypress') ?></h3>
752
  </div>
753
  <label for="reply"></label>
@@ -761,7 +761,7 @@ function messages_view_thread( $thread_id ) {
761
  <input type="hidden" id="thread_id" name="thread_id" value="<?php echo attribute_escape( $thread->thread_id ); ?>" />
762
  <input type="hidden" name="subject" id="subject" value="<?php _e('Re: ', 'buddypress'); echo str_replace( 'Re: ', '', $thread->last_message_subject); ?>" />
763
  </div>
764
-
765
  <?php wp_nonce_field( 'messages_send_message', '_wpnonce_send_message' ) ?>
766
  </form>
767
  </div>
10
  var $total_thread_count;
11
  var $threads;
12
  var $thread;
13
+
14
  var $in_the_loop;
15
  var $user_id;
16
  var $box;
17
+
18
  var $pag_page;
19
  var $pag_num;
20
  var $pag_links;
24
  $this->pag_num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : $per_page;
25
  $this->user_id = $user_id;
26
  $this->box = $box;
27
+
28
  if ( 'notices' == $this->box )
29
  $this->threads = BP_Messages_Notice::get_notices();
30
  else
31
  $this->threads = BP_Messages_Thread::get_current_threads_for_user( $this->user_id, $this->box, $this->pag_num, $this->pag_page, $type );
32
+
33
  if ( !$this->threads ) {
34
  $this->thread_count = 0;
35
  $this->total_thread_count = 0;
36
+ } else {
37
  $total_notice_count = BP_Messages_Notice::get_total_notice_count();
38
+
39
  if ( !$max || $max >= (int)$total_notice_count ) {
40
  if ( 'notices' == $this->box )
41
  $this->total_thread_count = (int)$total_notice_count;
44
  } else {
45
  $this->total_thread_count = (int)$max;
46
  }
47
+
48
  if ( $max ) {
49
  if ( $max >= count($this->threads) )
50
  $this->thread_count = count($this->threads);
65
  'mid_size' => 1
66
  ));
67
  }
68
+
69
  function has_threads() {
70
  if ( $this->thread_count )
71
  return true;
72
+
73
  return false;
74
  }
75
+
76
  function next_thread() {
77
  $this->current_thread++;
78
  $this->thread = $this->threads[$this->current_thread];
79
+
80
  return $this->thread;
81
  }
82
+
83
  function rewind_threads() {
84
  $this->current_thread = -1;
85
  if ( $this->thread_count > 0 ) {
86
  $this->thread = $this->threads[0];
87
  }
88
  }
89
+
90
+ function message_threads() {
91
  if ( $this->current_thread + 1 < $this->thread_count ) {
92
  return true;
93
  } elseif ( $this->current_thread + 1 == $this->thread_count ) {
99
  $this->in_the_loop = false;
100
  return false;
101
  }
102
+
103
  function the_message_thread() {
104
  global $thread;
105
 
113
 
114
  function bp_has_message_threads( $args = '' ) {
115
  global $bp, $messages_template;
116
+
117
  $defaults = array(
118
  'user_id' => $bp->loggedin_user->id,
119
  'box' => 'inbox',
130
  } else {
131
  if ( 'inbox' == $bp->current_action )
132
  bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, 'messages', 'new_message' );
133
+
134
  if ( 'sentbox' == $bp->current_action )
135
  $box = 'sentbox';
136
 
137
  if ( 'notices' == $bp->current_action )
138
  $box = 'notices';
139
+
140
  $messages_template = new BP_Messages_Box_Template( $user_id, $box, $per_page, $max, $type );
141
  }
142
+
143
  return apply_filters( 'bp_has_message_threads', $messages_template->has_threads(), &$messages_template );
144
  }
145
 
146
+ function bp_message_threads() {
147
  global $messages_template;
148
  return $messages_template->message_threads();
149
  }
201
  global $messages_template, $bp;
202
  return apply_filters( 'bp_get_message_thread_view_link', $bp->loggedin_user->domain . $bp->messages->slug . '/view/' . $messages_template->thread->thread_id );
203
  }
204
+
205
  function bp_message_thread_delete_link() {
206
  echo bp_get_message_thread_delete_link();
207
  }
209
  global $messages_template, $bp;
210
  return apply_filters( 'bp_get_message_thread_delete_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->messages->slug . '/' . $bp->current_action . '/delete/' . $messages_template->thread->thread_id, 'messages_delete_thread' ) );
211
  }
212
+
213
  function bp_message_thread_has_unread() {
214
  global $messages_template;
215
 
216
  if ( $messages_template->thread->unread_count )
217
  return true;
218
+
219
  return false;
220
  }
221
 
224
  }
225
  function bp_get_message_thread_unread_count() {
226
  global $messages_template;
227
+
228
  if ( (int)$messages_template->thread->unread_count )
229
  return apply_filters( 'bp_get_message_thread_unread_count', $messages_template->thread->unread_count );
230
+
231
  return false;
232
  }
233
 
275
  $to_num = ( $from_num + ( $messages_template->pag_num - 1 ) > $messages_template->total_thread_count ) ? $messages_template->total_thread_count : $from_num + ( $messages_template->pag_num - 1) ;
276
 
277
  echo sprintf( __( 'Viewing message %d to %d (of %d messages)', 'buddypress' ), $from_num, $to_num, $messages_template->total_thread_count ); ?> &nbsp;
278
+ <span class="ajax-loader"></span><?php
279
  }
280
 
281
  function bp_messages_form_action() {
314
 
315
  function bp_messages_options() {
316
  global $bp;
317
+
318
  if ( $bp->current_action != 'sentbox' ) {
319
  ?>
320
+ <?php _e( 'Select:', 'buddypress' ) ?>
321
  <select name="message-type-select" id="message-type-select">
322
  <option value=""></option>
323
  <option value="read"><?php _e('Read', 'buddypress') ?></option>
328
  <a href="#" id="mark_as_unread"><?php _e('Mark as Unread', 'buddypress') ?></a> &nbsp;
329
  <?php } ?>
330
  <a href="#" id="delete_<?php echo $bp->current_action ?>_messages"><?php _e('Delete Selected', 'buddypress') ?></a> &nbsp;
331
+ <?php
332
  }
333
 
334
  function bp_message_is_active_notice() {
335
  global $messages_template;
336
+
337
  if ( $messages_template->thread->is_active ) {
338
  echo "<strong>";
339
  _e( 'Currently Active', 'buddypress' );
345
 
346
  if ( $messages_template->thread->is_active )
347
  return true;
348
+
349
  return false;
350
  }
351
 
391
  if ( 1 == (int)$messages_template->thread->is_active ) {
392
  $link = wp_nonce_url( $bp->loggedin_user->domain . $bp->messages->slug . '/notices/deactivate/' . $messages_template->thread->id, 'messages_deactivate_notice' );
393
  } else {
394
+ $link = wp_nonce_url( $bp->loggedin_user->domain . $bp->messages->slug . '/notices/activate/' . $messages_template->thread->id, 'messages_activate_notice' );
395
  }
396
  return apply_filters( 'bp_get_message_activate_deactivate_link', $link );
397
  }
405
  if ( 1 == (int)$messages_template->thread->is_active ) {
406
  $text = __('Deactivate', 'buddypress');
407
  } else {
408
+ $text = __('Activate', 'buddypress');
409
  }
410
  return apply_filters( 'bp_message_activate_deactivate_text', $text );
411
  }
412
 
413
  function bp_message_get_notices() {
414
  global $userdata;
415
+
416
  $notice = BP_Messages_Notice::get_active();
417
  $closed_notices = get_usermeta( $userdata->ID, 'closed_notices');
418
 
428
  <a href="#" id="close-notice"><?php _e( 'Close', 'buddypress' ) ?></a>
429
  </div>
430
  <?php
431
+ }
432
  }
433
  }
434
 
437
  }
438
  function bp_get_send_message_button() {
439
  global $bp;
440
+
441
  if ( bp_is_home() || !is_user_logged_in() )
442
  return false;
443
+
444
+ $ud = get_userdata( $bp->displayed_user->id );
445
+
446
  return apply_filters( 'bp_get_send_message_button', '<div class="generic-button"><a class="send-message" title="' . __( 'Send Message', 'buddypress' ) . '" href="' . $bp->loggedin_user->domain . $bp->messages->slug . '/compose/?r=' . $ud->user_login . '">' . __( 'Send Message', 'buddypress' ) . '</a></div>' );
447
  }
448
 
456
 
457
  function bp_message_get_recipient_tabs() {
458
  global $bp;
459
+
460
  if ( isset( $_GET['r'] ) ) {
461
  $user_id = bp_core_get_userid( $_GET['r'] );
462
+
463
  if ( $user_id ) {
464
  ?>
465
  <li id="un-<?php echo $_GET['r'] ?>" class="friend-tab">
466
  <span>
467
  <?php echo bp_core_fetch_avatar( array( 'item_id' => $user_id, 'type' => 'thumb', 'width' => 15, 'height' => 15 ) ) ?>
468
  <?php echo bp_core_get_userlink( $user_id ) ?>
469
+ </span>
470
  </li>
471
  <?php
472
  }
489
  var $current_message = -1;
490
  var $message_count;
491
  var $message;
492
+
493
  var $thread;
494
+
495
  var $in_the_loop;
496
+
497
  var $pag_page;
498
  var $pag_num;
499
  var $pag_links;
500
  var $total_message_count;
501
+
502
  function bp_messages_thread_template( $thread_id, $order ) {
503
  global $bp;
504
+
505
  $this->thread = new BP_Messages_Thread( $thread_id, true );
506
  $this->message_count = count( $this->thread->messages );
507
  }
508
+
509
  function has_messages() {
510
  if ( $this->message_count )
511
  return true;
512
+
513
  return false;
514
  }
515
+
516
  function next_message() {
517
  $this->current_message++;
518
  $this->message = $this->thread->messages[$this->current_message];
519
+
520
  return $this->message;
521
  }
522
+
523
  function rewind_messages() {
524
  $this->current_message = -1;
525
  if ( $this->message_count > 0 ) {
526
  $this->message = $this->thread->messages[0];
527
  }
528
  }
529
+
530
+ function messages() {
531
  if ( $this->current_message + 1 < $this->message_count ) {
532
  return true;
533
  } elseif ( $this->current_message + 1 == $this->message_count ) {
539
  $this->in_the_loop = false;
540
  return false;
541
  }
542
+
543
  function the_message() {
544
  global $message;
545
 
553
 
554
  function bp_thread_has_messages( $args = '' ) {
555
  global $bp, $thread_template, $group_id;
556
+
557
  $defaults = array(
558
  'thread_id' => false,
559
  'order' => 'ASC'
571
 
572
  function bp_thread_messages() {
573
  global $thread_template;
574
+
575
  return $thread_template->messages();
576
  }
577
 
578
  function bp_thread_the_message() {
579
  global $thread_template;
580
+
581
  return $thread_template->the_message();
582
  }
583
 
586
  }
587
  function bp_get_the_thread_id() {
588
  global $thread_template;
589
+
590
  return apply_filters( 'bp_get_the_thread_id', $thread_template->thread->thread_id );
591
  }
592
 
604
  }
605
  function bp_get_the_thread_recipients() {
606
  global $thread_template;
607
+
608
  if ( count($thread_template->thread->recipients) >= 5 )
609
  return apply_filters( 'bp_get_the_thread_recipients', sprintf( __( '%d Recipients', 'buddypress' ), count($thread_template->thread->recipients) ) );
610
+
611
  foreach( $thread_template->thread->recipients as $recipient )
612
  $recipient_links[] = bp_core_get_userlink( $recipient );
613
 
619
  }
620
  function bp_get_the_thread_message_alt_class() {
621
  global $thread_template;
622
+
623
  if ( $thread_template->current_message % 2 == 1 )
624
  $class = ' alt';
625
  else
626
  $class = '';
627
+
628
  return apply_filters( 'bp_get_the_thread_message_alt_class', $class );
629
  }
630
+
631
  function bp_the_thread_message_sender_avatar( $args = '' ) {
632
  echo bp_get_the_thread_message_sender_avatar_thumb( $args );
633
  }
634
  function bp_get_the_thread_message_sender_avatar_thumb( $args = '' ) {
635
+ global $thread_template;
636
+
637
  $defaults = array(
638
  'type' => 'thumb',
639
  'width' => false,
651
  }
652
  function bp_get_the_thread_message_sender_link() {
653
  global $thread_template;
654
+
655
  return apply_filters( 'bp_get_the_thread_message_sender_link', bp_core_get_userlink( $thread_template->message->sender_id, false, true ) );
656
  }
657
+
658
  function bp_the_thread_message_sender_name() {
659
  echo bp_get_the_thread_message_sender_name();
660
  }
661
  function bp_get_the_thread_message_sender_name() {
662
  global $thread_template;
663
+
664
+ return apply_filters( 'bp_get_the_thread_message_sender_name', bp_core_get_user_displayname( $thread_template->message->sender_id ) );
665
  }
666
 
667
  function bp_the_thread_message_time_since() {
669
  }
670
  function bp_get_the_thread_message_time_since() {
671
  global $thread_template;
672
+
673
  return apply_filters( 'bp_get_the_thread_message_time_since', sprintf( __( 'Sent %s ago', 'buddypress' ), bp_core_time_since( strtotime( $thread_template->message->date_sent ) ) ) );
674
  }
675
 
678
  }
679
  function bp_get_the_thread_message_content() {
680
  global $thread_template;
681
+
682
+ return apply_filters( 'bp_get_the_thread_message_content', $thread_template->message->message );
683
  }
684
+
685
 
686
  /*** DEPRECATED FUNCTIONS (DO NOT USE) **********************************************************/
687
 
688
+ /* DEPRECATED - please use the view message template loop. */
689
  function messages_view_thread( $thread_id ) {
690
  global $bp;
691
 
692
  $thread = new BP_Messages_Thread( $thread_id, true );
693
+
694
  if ( !$thread->has_access ) {
695
  unset($_GET['mode']); ?>
696
  <div id="message" class="error">
697
  <p><?php _e( 'There was an error when viewing that message', 'buddypress' ) ?></p>
698
  </div>
699
+ <?php
700
  } else {
701
  if ( $thread->messages ) { ?>
702
  <?php $thread->mark_read() ?>
703
+
704
  <div class="wrap">
705
  <h2 id="message-subject"><?php echo $thread->subject; ?></h2>
706
  <table class="form-table">
708
  <tr>
709
  <td>
710
  <img src="<?php echo $bp->messages->image_base ?>/email_open.gif" alt="Message" style="vertical-align: top;" /> &nbsp;
711
+ <?php _e('Sent between ', 'buddypress') ?> <?php echo BP_Messages_Thread::get_recipient_links($thread->recipients) ?>
712
+ <?php _e('and', 'buddypress') ?> <?php echo bp_core_get_userlink($bp->loggedin_user->id) ?>.
713
  </td>
714
  </tr>
715
  </tbody>
716
  </table>
717
+
718
  <?php
719
  $counter = 0;
720
+
721
  foreach ( $thread->messages as $message ) {
722
  $alt = ( $counter % 2 == 1 ) ? ' alt' : '';
723
  ?>
728
  <h3><?php echo apply_filters( 'bp_get_message_sender_id', bp_core_get_userlink( $message->sender_id ) ) ?></h3>
729
  <small><?php echo apply_filters( 'bp_get_message_date_sent', bp_format_time( strtotime($message->date_sent ) ) ) ?></small>
730
  </div>
731
+
732
  <?php do_action( 'messages_custom_fields_output_before' ) ?>
733
+
734
  <?php echo apply_filters( 'bp_get_the_message_thread_content', stripslashes($message->message) ); ?>
735
+
736
  <?php do_action( 'messages_custom_fields_output_after' ) ?>
737
+
738
  <div class="clear"></div>
739
  </div>
740
  <?php
741
  $counter++;
742
  }
743
+
744
  ?>
745
  <form id="send-reply" action="<?php bp_messages_form_action() ?>" method="post">
746
  <div class="message-box">
747
  <div id="messagediv">
748
  <div class="avatar-box">
749
  <?php echo bp_core_fetch_avatar( array( 'item_id' => $bp->loggedin_user->id, 'type' => 'thumb' ) ); ?>
750
+
751
  <h3><?php _e("Reply: ", 'buddypress') ?></h3>
752
  </div>
753
  <label for="reply"></label>
761
  <input type="hidden" id="thread_id" name="thread_id" value="<?php echo attribute_escape( $thread->thread_id ); ?>" />
762
  <input type="hidden" name="subject" id="subject" value="<?php _e('Re: ', 'buddypress'); echo str_replace( 'Re: ', '', $thread->last_message_subject); ?>" />
763
  </div>
764
+
765
  <?php wp_nonce_field( 'messages_send_message', '_wpnonce_send_message' ) ?>
766
  </form>
767
  </div>
bp-messages/css/autocomplete/jquery.autocompletefb.css CHANGED
File without changes
bp-messages/deprecated/bp-messages-deprecated.php CHANGED
@@ -3,7 +3,7 @@
3
  * Deprecated Messaging Functionality
4
  *
5
  * This file contains functions that are deprecated.
6
- * You should not under any circumstance use these functions as they are
7
  * either no longer valid, or have been replaced with something much more awesome.
8
  *
9
  * If you are using functions in this file you should slap the back of your head
@@ -12,9 +12,9 @@
12
  *
13
  * Of course, things will still work if you use these functions but you will
14
  * be the laughing stock of the BuddyPress community. We will all point and laugh at
15
- * you. You'll also be making things harder for yourself in the long run,
16
  * and you will miss out on lovely performance and functionality improvements.
17
- *
18
  * If you've checked you are not using any deprecated functions and finished your little
19
  * dance, you can add the following line to your wp-config.php file to prevent any of
20
  * these old functions from being loaded:
@@ -23,14 +23,14 @@
23
  */
24
  function messages_deprecated_globals() {
25
  global $bp;
26
-
27
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
28
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
29
  return $template;
30
 
31
  $bp->groups->image_base = BP_PLUGIN_URL . '/bp-messages/deprecated/images';
32
  }
33
- add_action( 'plugins_loaded', 'messages_deprecated_globals', 5 );
34
  add_action( 'admin_menu', 'messages_deprecated_globals', 2 );
35
 
36
  function messages_add_js() {
@@ -49,9 +49,9 @@ function messages_add_structure_css() {
49
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
50
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
51
  return $template;
52
-
53
  /* Enqueue the structure CSS file to give basic positional formatting for components */
54
- wp_enqueue_style( 'bp-messages-structure', BP_PLUGIN_URL . '/bp-messages/deprecated/css/structure.css' );
55
  }
56
  add_action( 'bp_styles', 'messages_add_structure_css' );
57
 
@@ -61,15 +61,15 @@ function messages_ajax_send_reply() {
61
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
62
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
63
  return false;
64
-
65
  check_ajax_referer( 'messages_send_message' );
66
-
67
- $result = messages_send_message($_REQUEST['send_to'], $_REQUEST['subject'], $_REQUEST['content'], $_REQUEST['thread_id'], true, false, true);
68
 
69
  if ( $result['status'] ) { ?>
70
  <div class="avatar-box">
71
  <?php echo bp_core_fetch_avatar( array( 'item_id' => $result['reply']->sender_id, 'type' => 'thumb' ) ); ?>
72
-
73
  <h3><?php echo bp_core_get_userlink($result['reply']->sender_id) ?></h3>
74
  <small><?php echo bp_format_time($result['reply']->date_sent) ?></small>
75
  </div>
@@ -89,12 +89,12 @@ function messages_ajax_markunread() {
89
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
90
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
91
  return false;
92
-
93
  if ( !isset($_POST['thread_ids']) ) {
94
  echo "-1[[split]]" . __('There was a problem marking messages as unread.', 'buddypress');
95
  } else {
96
  $thread_ids = explode( ',', $_POST['thread_ids'] );
97
-
98
  for ( $i = 0; $i < count($thread_ids); $i++ ) {
99
  BP_Messages_Thread::mark_as_unread($thread_ids[$i]);
100
  }
@@ -107,8 +107,8 @@ function messages_ajax_markread() {
107
 
108
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
109
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
110
- return false;
111
-
112
  if ( !isset($_POST['thread_ids']) ) {
113
  echo "-1[[split]]" . __('There was a problem marking messages as read.', 'buddypress');
114
  } else {
@@ -127,7 +127,7 @@ function messages_ajax_delete() {
127
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
128
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
129
  return false;
130
-
131
  if ( !isset($_POST['thread_ids']) ) {
132
  echo "-1[[split]]" . __( 'There was a problem deleting messages.', 'buddypress' );
133
  } else {
@@ -136,7 +136,7 @@ function messages_ajax_delete() {
136
  for ( $i = 0; $i < count($thread_ids); $i++ ) {
137
  BP_Messages_Thread::delete($thread_ids[$i]);
138
  }
139
-
140
  _e('Messages deleted.', 'buddypress');
141
  }
142
  }
@@ -148,14 +148,14 @@ function messages_ajax_close_notice() {
148
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
149
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
150
  return false;
151
-
152
  if ( !isset($_POST['notice_id']) ) {
153
  echo "-1[[split]]" . __('There was a problem closing the notice.', 'buddypress');
154
  } else {
155
  $notice_ids = get_usermeta( $userdata->ID, 'closed_notices' );
156
-
157
  $notice_ids[] = (int) $_POST['notice_id'];
158
-
159
  update_usermeta( $userdata->ID, 'closed_notices', $notice_ids );
160
  }
161
  }
@@ -167,7 +167,7 @@ function messages_ajax_autocomplete_results() {
167
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
168
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
169
  return false;
170
-
171
  $friends = false;
172
 
173
  // Get the friend ids based on the search terms
@@ -182,7 +182,7 @@ function messages_ajax_autocomplete_results() {
182
  $username = $ud->user_login;
183
  echo bp_core_fetch_avatar( array( 'item_id' => $user_id, 'type' => 'thumb', 'width' => 15, 'height' => 15 ) ) . ' ' . bp_core_get_user_displayname( $user_id ) . ' (' . $username . ')
184
  ';
185
- }
186
  }
187
  }
188
  add_action( 'wp_ajax_messages_autocomplete_results', 'messages_ajax_autocomplete_results' );
@@ -192,35 +192,35 @@ function messages_send_message( $recipients, $subject, $content, $thread_id, $fr
192
  global $pmessage;
193
  global $message, $type;
194
  global $bp, $current_user;
195
-
196
  messages_add_callback_values( $recipients, $subject, $content );
197
-
198
  if ( isset( $_POST['send-notice'] ) ) {
199
  if ( messages_send_notice( $subject, $content, $from_template ) ) {
200
  bp_core_add_message( __('Notice posted successfully.', 'buddypress') );
201
  } else {
202
- bp_core_add_message( __('There was an error posting that notice.', 'buddypress'), 'error' );
203
  }
204
  bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/notices' );
205
  return true;
206
  }
207
-
208
  $recipients = explode( ' ', $recipients );
209
-
210
  // If there are no recipients
211
  if ( count( $recipients ) < 1 ) {
212
- if ( !$from_ajax ) {
213
  bp_core_add_message( __('Please enter at least one valid user to send this message to.', 'buddypress'), 'error' );
214
  bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/compose' );
215
  } else {
216
  return array('status' => 0, 'message' => __('There was an error sending the reply, please try again.', 'buddypress'));
217
  }
218
-
219
  // If there is only 1 recipient and it is the logged in user.
220
  } else if ( 1 == count( $recipients ) && $recipients[0] == $current_user->user_login ) {
221
  bp_core_add_message( __('You must send your message to one or more users not including yourself.', 'buddypress'), 'error' );
222
- bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/compose' );
223
-
224
  // If the subject or content boxes are empty.
225
  } else if ( empty( $subject ) || empty( $content ) ) {
226
  if ( !$from_ajax ) {
@@ -229,14 +229,14 @@ function messages_send_message( $recipients, $subject, $content, $thread_id, $fr
229
  } else {
230
  return array('status' => 0, 'message' => __('Please make sure you have typed a message before sending a reply.', 'buddypress'));
231
  }
232
-
233
  // Passed validation continue.
234
  } else {
235
 
236
  // Strip the logged in user from the recipient list if they exist
237
  if ( $key = array_search( $current_user->user_login, $recipients ) )
238
  unset( $recipients[$key] );
239
-
240
  $pmessage = new BP_Messages_Message;
241
 
242
  $pmessage->sender_id = $bp->loggedin_user->id;
@@ -244,7 +244,7 @@ function messages_send_message( $recipients, $subject, $content, $thread_id, $fr
244
  $pmessage->message = $content;
245
  $pmessage->thread_id = $thread_id;
246
  $pmessage->date_sent = time();
247
-
248
  if ( $is_reply ) {
249
  $thread = new BP_Messages_Thread($thread_id);
250
  $pmessage->recipients = $thread->get_recipients();
@@ -256,30 +256,30 @@ function messages_send_message( $recipients, $subject, $content, $thread_id, $fr
256
  if ( !$pmessage->send() ) {
257
  $message = __('Message could not be sent, please try again.', 'buddypress');
258
  $type = 'error';
259
-
260
  if ( $from_ajax ) {
261
  return array('status' => 0, 'message' => $message);
262
  } else {
263
  bp_core_add_message( $message, $type );
264
  bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/compose' );
265
- }
266
  } else {
267
  $message = __('Message sent successfully!', 'buddypress');
268
  $type = 'success';
269
-
270
  // Send screen notifications to the recipients
271
  for ( $i = 0; $i < count($pmessage->recipients); $i++ ) {
272
  if ( $pmessage->recipients[$i] != $bp->loggedin_user->id ) {
273
- bp_core_add_notification( $pmessage->id, $pmessage->recipients[$i], 'messages', 'new_message' );
274
  }
275
  }
276
-
277
  // Send email notifications to the recipients
278
  require_once( BP_PLUGIN_DIR . '/bp-messages/bp-messages-notifications.php' );
279
  messages_notification_new_message( array( 'item_id' => $pmessage->id, 'recipient_ids' => $pmessage->recipients, 'thread_id' => $pmessage->thread_id, 'component_name' => $bp->messages->slug, 'component_action' => 'message_sent', 'is_private' => 1 ) );
280
 
281
  do_action( 'messages_send_message', array( 'item_id' => $pmessage->id, 'recipient_ids' => $pmessage->recipients, 'thread_id' => $pmessage->thread_id, 'component_name' => $bp->messages->slug, 'component_action' => 'message_sent', 'is_private' => 1 ) );
282
-
283
  if ( $from_ajax ) {
284
  return array('status' => 1, 'message' => $message, 'reply' => $pmessage);
285
  } else {
@@ -290,7 +290,7 @@ function messages_send_message( $recipients, $subject, $content, $thread_id, $fr
290
  } else {
291
  $message = __('Message could not be sent, please try again.', 'buddypress');
292
  $type = 'error';
293
-
294
  if ( $from_ajax ) {
295
  return array('status' => 0, 'message' => $message);
296
  } else {
3
  * Deprecated Messaging Functionality
4
  *
5
  * This file contains functions that are deprecated.
6
+ * You should not under any circumstance use these functions as they are
7
  * either no longer valid, or have been replaced with something much more awesome.
8
  *
9
  * If you are using functions in this file you should slap the back of your head
12
  *
13
  * Of course, things will still work if you use these functions but you will
14
  * be the laughing stock of the BuddyPress community. We will all point and laugh at
15
+ * you. You'll also be making things harder for yourself in the long run,
16
  * and you will miss out on lovely performance and functionality improvements.
17
+ *
18
  * If you've checked you are not using any deprecated functions and finished your little
19
  * dance, you can add the following line to your wp-config.php file to prevent any of
20
  * these old functions from being loaded:
23
  */
24
  function messages_deprecated_globals() {
25
  global $bp;
26
+
27
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
28
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
29
  return $template;
30
 
31
  $bp->groups->image_base = BP_PLUGIN_URL . '/bp-messages/deprecated/images';
32
  }
33
+ add_action( 'plugins_loaded', 'messages_deprecated_globals', 5 );
34
  add_action( 'admin_menu', 'messages_deprecated_globals', 2 );
35
 
36
  function messages_add_js() {
49
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
50
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
51
  return $template;
52
+
53
  /* Enqueue the structure CSS file to give basic positional formatting for components */
54
+ wp_enqueue_style( 'bp-messages-structure', BP_PLUGIN_URL . '/bp-messages/deprecated/css/structure.css' );
55
  }
56
  add_action( 'bp_styles', 'messages_add_structure_css' );
57
 
61
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
62
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
63
  return false;
64
+
65
  check_ajax_referer( 'messages_send_message' );
66
+
67
+ $result = messages_send_message($_REQUEST['send_to'], $_REQUEST['subject'], $_REQUEST['content'], $_REQUEST['thread_id'], true, false, true);
68
 
69
  if ( $result['status'] ) { ?>
70
  <div class="avatar-box">
71
  <?php echo bp_core_fetch_avatar( array( 'item_id' => $result['reply']->sender_id, 'type' => 'thumb' ) ); ?>
72
+
73
  <h3><?php echo bp_core_get_userlink($result['reply']->sender_id) ?></h3>
74
  <small><?php echo bp_format_time($result['reply']->date_sent) ?></small>
75
  </div>
89
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
90
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
91
  return false;
92
+
93
  if ( !isset($_POST['thread_ids']) ) {
94
  echo "-1[[split]]" . __('There was a problem marking messages as unread.', 'buddypress');
95
  } else {
96
  $thread_ids = explode( ',', $_POST['thread_ids'] );
97
+
98
  for ( $i = 0; $i < count($thread_ids); $i++ ) {
99
  BP_Messages_Thread::mark_as_unread($thread_ids[$i]);
100
  }
107
 
108
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
109
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
110
+ return false;
111
+
112
  if ( !isset($_POST['thread_ids']) ) {
113
  echo "-1[[split]]" . __('There was a problem marking messages as read.', 'buddypress');
114
  } else {
127
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
128
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
129
  return false;
130
+
131
  if ( !isset($_POST['thread_ids']) ) {
132
  echo "-1[[split]]" . __( 'There was a problem deleting messages.', 'buddypress' );
133
  } else {
136
  for ( $i = 0; $i < count($thread_ids); $i++ ) {
137
  BP_Messages_Thread::delete($thread_ids[$i]);
138
  }
139
+
140
  _e('Messages deleted.', 'buddypress');
141
  }
142
  }
148
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
149
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
150
  return false;
151
+
152
  if ( !isset($_POST['notice_id']) ) {
153
  echo "-1[[split]]" . __('There was a problem closing the notice.', 'buddypress');
154
  } else {
155
  $notice_ids = get_usermeta( $userdata->ID, 'closed_notices' );
156
+
157
  $notice_ids[] = (int) $_POST['notice_id'];
158
+
159
  update_usermeta( $userdata->ID, 'closed_notices', $notice_ids );
160
  }
161
  }
167
  /* If we are using a BuddyPress 1.1+ theme ignore this. */
168
  if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
169
  return false;
170
+
171
  $friends = false;
172
 
173
  // Get the friend ids based on the search terms
182
  $username = $ud->user_login;
183
  echo bp_core_fetch_avatar( array( 'item_id' => $user_id, 'type' => 'thumb', 'width' => 15, 'height' => 15 ) ) . ' ' . bp_core_get_user_displayname( $user_id ) . ' (' . $username . ')
184
  ';
185
+ }
186
  }
187
  }
188
  add_action( 'wp_ajax_messages_autocomplete_results', 'messages_ajax_autocomplete_results' );
192
  global $pmessage;
193
  global $message, $type;
194
  global $bp, $current_user;
195
+
196
  messages_add_callback_values( $recipients, $subject, $content );
197
+
198
  if ( isset( $_POST['send-notice'] ) ) {
199
  if ( messages_send_notice( $subject, $content, $from_template ) ) {
200
  bp_core_add_message( __('Notice posted successfully.', 'buddypress') );
201
  } else {
202
+ bp_core_add_message( __('There was an error posting that notice.', 'buddypress'), 'error' );
203
  }
204
  bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/notices' );
205
  return true;
206
  }
207
+
208
  $recipients = explode( ' ', $recipients );
209
+
210
  // If there are no recipients
211
  if ( count( $recipients ) < 1 ) {
212
+ if ( !$from_ajax ) {
213
  bp_core_add_message( __('Please enter at least one valid user to send this message to.', 'buddypress'), 'error' );
214
  bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/compose' );
215
  } else {
216
  return array('status' => 0, 'message' => __('There was an error sending the reply, please try again.', 'buddypress'));
217
  }
218
+
219
  // If there is only 1 recipient and it is the logged in user.
220
  } else if ( 1 == count( $recipients ) && $recipients[0] == $current_user->user_login ) {
221
  bp_core_add_message( __('You must send your message to one or more users not including yourself.', 'buddypress'), 'error' );
222
+ bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/compose' );
223
+
224
  // If the subject or content boxes are empty.
225
  } else if ( empty( $subject ) || empty( $content ) ) {
226
  if ( !$from_ajax ) {
229
  } else {
230
  return array('status' => 0, 'message' => __('Please make sure you have typed a message before sending a reply.', 'buddypress'));
231
  }
232
+
233
  // Passed validation continue.
234
  } else {
235
 
236
  // Strip the logged in user from the recipient list if they exist
237
  if ( $key = array_search( $current_user->user_login, $recipients ) )
238
  unset( $recipients[$key] );
239
+
240
  $pmessage = new BP_Messages_Message;
241
 
242
  $pmessage->sender_id = $bp->loggedin_user->id;
244
  $pmessage->message = $content;
245
  $pmessage->thread_id = $thread_id;
246
  $pmessage->date_sent = time();
247
+
248
  if ( $is_reply ) {
249
  $thread = new BP_Messages_Thread($thread_id);
250
  $pmessage->recipients = $thread->get_recipients();
256
  if ( !$pmessage->send() ) {
257
  $message = __('Message could not be sent, please try again.', 'buddypress');
258
  $type = 'error';
259
+
260
  if ( $from_ajax ) {
261
  return array('status' => 0, 'message' => $message);
262
  } else {
263
  bp_core_add_message( $message, $type );
264
  bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/compose' );
265
+ }
266
  } else {
267
  $message = __('Message sent successfully!', 'buddypress');
268
  $type = 'success';
269
+
270
  // Send screen notifications to the recipients
271
  for ( $i = 0; $i < count($pmessage->recipients); $i++ ) {
272
  if ( $pmessage->recipients[$i] != $bp->loggedin_user->id ) {
273
+ bp_core_add_notification( $pmessage->id, $pmessage->recipients[$i], 'messages', 'new_message' );
274
  }
275
  }
276
+
277
  // Send email notifications to the recipients
278
  require_once( BP_PLUGIN_DIR . '/bp-messages/bp-messages-notifications.php' );
279
  messages_notification_new_message( array( 'item_id' => $pmessage->id, 'recipient_ids' => $pmessage->recipients, 'thread_id' => $pmessage->thread_id, 'component_name' => $bp->messages->slug, 'component_action' => 'message_sent', 'is_private' => 1 ) );
280
 
281
  do_action( 'messages_send_message', array( 'item_id' => $pmessage->id, 'recipient_ids' => $pmessage->recipients, 'thread_id' => $pmessage->thread_id, 'component_name' => $bp->messages->slug, 'component_action' => 'message_sent', 'is_private' => 1 ) );
282
+
283
  if ( $from_ajax ) {
284
  return array('status' => 1, 'message' => $message, 'reply' => $pmessage);
285
  } else {
290
  } else {
291
  $message = __('Message could not be sent, please try again.', 'buddypress');
292
  $type = 'error';
293
+
294
  if ( $from_ajax ) {
295
  return array('status' => 0, 'message' => $message);
296
  } else {
bp-messages/deprecated/css/structure.css CHANGED
File without changes
bp-messages/deprecated/images/ajax-loader.gif CHANGED
File without changes
bp-messages/deprecated/images/email.gif CHANGED
File without changes
bp-messages/deprecated/images/email_draft.gif CHANGED
File without changes
bp-messages/deprecated/images/email_open.gif CHANGED
File without changes
bp-messages/deprecated/images/email_sent.gif CHANGED
File without changes
bp-messages/deprecated/images/loading.gif CHANGED
File without changes
bp-messages/deprecated/images/nav_bullet.gif CHANGED
File without changes
bp-messages/deprecated/images/warning.gif CHANGED
File without changes
bp-messages/deprecated/js/general.js CHANGED
File without changes
bp-messages/js/autocomplete/jquery.autocomplete.js CHANGED
File without changes
bp-messages/js/autocomplete/jquery.autocompletefb.js CHANGED
File without changes
bp-messages/js/autocomplete/jquery.bgiframe.min.js CHANGED
File without changes
bp-messages/js/autocomplete/jquery.dimensions.js CHANGED
File without changes
bp-status.php CHANGED
@@ -11,13 +11,13 @@ function bp_status_setup_globals() {
11
  /* For internal identification */
12
  $bp->status->id = 'status';
13
  $bp->status->slug = BP_STATUS_SLUG;
14
-
15
  /* Register this in the active components array */
16
  $bp->active_components[$bp->status->slug] = $bp->status->id;
17
 
18
  do_action( 'bp_status_setup_globals' );
19
  }
20
- add_action( 'plugins_loaded', 'bp_status_setup_globals', 5 );
21
  add_action( 'admin_menu', 'bp_status_setup_globals', 2 );
22
 
23
 
@@ -30,7 +30,7 @@ add_action( 'admin_menu', 'bp_status_setup_globals', 2 );
30
 
31
  function bp_status_register_activity_actions() {
32
  global $bp;
33
-
34
  if ( !function_exists( 'bp_activity_set_action' ) )
35
  return false;
36
 
@@ -43,14 +43,14 @@ add_action( 'plugins_loaded', 'bp_status_register_activity_actions' );
43
 
44
  function bp_status_record_activity( $user_id, $content, $primary_link, $component_action = 'new_status' ) {
45
  global $bp;
46
-
47
  if ( !function_exists( 'bp_activity_add' ) )
48
  return false;
49
-
50
- return bp_activity_add( array(
51
- 'user_id' => $user_id,
52
- 'content' => $content,
53
- 'primary_link' => $primary_link,
54
  'component_name' => $bp->status->id,
55
  'component_action' => $component_action
56
  ) );
@@ -65,10 +65,10 @@ function bp_status_delete_activity( $user_id, $content ) {
65
 
66
  function bp_status_register_activity_action( $key, $value ) {
67
  global $bp;
68
-
69
  if ( !function_exists( 'bp_activity_set_action' ) )
70
  return false;
71
-
72
  return apply_filters( 'bp_status_register_activity_action', bp_activity_set_action( $bp->status->id, $key, $value ), $key, $value );
73
  }
74
 
@@ -86,7 +86,7 @@ function bp_status_action_add() {
86
 
87
  if ( $bp->current_component != BP_STATUS_SLUG || 'add' != $bp->current_action )
88
  return false;
89
-
90
  if ( !check_admin_referer( 'bp_status_add_status', '_wpnonce_add_status' ) )
91
  return false;
92
 
@@ -94,7 +94,7 @@ function bp_status_action_add() {
94
  bp_core_add_message( __( 'Your status was updated successfully!', 'buddypress' ) );
95
  else
96
  bp_core_add_message( __( 'There was a problem updating your status. Please try again.', 'buddypress' ), 'error' );
97
-
98
  bp_core_redirect( $bp->loggedin_user->domain );
99
  }
100
  add_action( 'init', 'bp_status_action_add' );
@@ -111,17 +111,17 @@ add_action( 'init', 'bp_status_action_add' );
111
 
112
  function bp_status_add_status( $user_id, $content, $recorded_time = false ) {
113
  global $bp;
114
-
115
  $content = apply_filters( 'bp_status_content_before_save', $content );
116
-
117
- if ( !$recorded_time )
118
  $recorded_time = time();
119
-
120
  if ( !$content || empty($content) )
121
  return false;
122
-
123
  bp_status_clear_existing_activity( $user_id );
124
-
125
  /* Store the status in usermeta for easy access. */
126
  update_usermeta( $user_id, 'bp_status', array( 'content' => $content, 'recorded_time' => $recorded_time ) );
127
 
@@ -131,7 +131,7 @@ function bp_status_add_status( $user_id, $content, $recorded_time = false ) {
131
  $activity_content .= "<blockquote>$content</blockquote>";
132
 
133
  bp_status_record_activity( $user_id, apply_filters( 'bp_status_activity_new', $activity_content, $content, $user_link ), apply_filters( 'bp_status_activity_new_primary_link', $user_link, $user_id ) );
134
-
135
  do_action( 'bp_status_add_status', $user_id, $content );
136
 
137
  return true;
@@ -139,19 +139,19 @@ function bp_status_add_status( $user_id, $content, $recorded_time = false ) {
139
 
140
  function bp_status_clear_status( $user_id = false ) {
141
  global $bp;
142
-
143
  if ( !$user_id )
144
  $user_id = $bp->loggedin_user->id;
145
-
146
  bp_status_clear_existing_activity( $user_id );
147
-
148
  return delete_usermeta( $user_id, 'bp_status' );
149
  }
150
 
151
  function bp_status_clear_existing_activity( $user_id ) {
152
  /* Fetch existing status update if there is one. */
153
  $existing_status = get_usermeta( $user_id, 'bp_status' );
154
-
155
  if ( '' != $existing_status ) {
156
  if ( strtotime( '+5 minutes', $existing_status['recorded_time'] ) >= time() ) {
157
  /***
11
  /* For internal identification */
12
  $bp->status->id = 'status';
13
  $bp->status->slug = BP_STATUS_SLUG;
14
+
15
  /* Register this in the active components array */
16
  $bp->active_components[$bp->status->slug] = $bp->status->id;
17
 
18
  do_action( 'bp_status_setup_globals' );
19
  }
20
+ add_action( 'plugins_loaded', 'bp_status_setup_globals', 5 );
21
  add_action( 'admin_menu', 'bp_status_setup_globals', 2 );
22
 
23
 
30
 
31
  function bp_status_register_activity_actions() {
32
  global $bp;
33
+
34
  if ( !function_exists( 'bp_activity_set_action' ) )
35
  return false;
36
 
43
 
44
  function bp_status_record_activity( $user_id, $content, $primary_link, $component_action = 'new_status' ) {
45
  global $bp;
46
+
47
  if ( !function_exists( 'bp_activity_add' ) )
48
  return false;
49
+
50
+ return bp_activity_add( array(
51
+ 'user_id' => $user_id,
52
+ 'content' => $content,
53
+ 'primary_link' => $primary_link,
54
  'component_name' => $bp->status->id,
55
  'component_action' => $component_action
56
  ) );
65
 
66
  function bp_status_register_activity_action( $key, $value ) {
67
  global $bp;
68
+
69
  if ( !function_exists( 'bp_activity_set_action' ) )
70
  return false;
71
+
72
  return apply_filters( 'bp_status_register_activity_action', bp_activity_set_action( $bp->status->id, $key, $value ), $key, $value );
73
  }
74
 
86
 
87
  if ( $bp->current_component != BP_STATUS_SLUG || 'add' != $bp->current_action )
88
  return false;
89
+
90
  if ( !check_admin_referer( 'bp_status_add_status', '_wpnonce_add_status' ) )
91
  return false;
92
 
94
  bp_core_add_message( __( 'Your status was updated successfully!', 'buddypress' ) );
95
  else
96
  bp_core_add_message( __( 'There was a problem updating your status. Please try again.', 'buddypress' ), 'error' );
97
+
98
  bp_core_redirect( $bp->loggedin_user->domain );
99
  }
100
  add_action( 'init', 'bp_status_action_add' );
111
 
112
  function bp_status_add_status( $user_id, $content, $recorded_time = false ) {
113
  global $bp;
114
+
115
  $content = apply_filters( 'bp_status_content_before_save', $content );
116
+
117
+ if ( !$recorded_time )
118
  $recorded_time = time();
119
+
120
  if ( !$content || empty($content) )
121
  return false;
122
+
123
  bp_status_clear_existing_activity( $user_id );
124
+
125
  /* Store the status in usermeta for easy access. */
126
  update_usermeta( $user_id, 'bp_status', array( 'content' => $content, 'recorded_time' => $recorded_time ) );
127
 
131
  $activity_content .= "<blockquote>$content</blockquote>";
132
 
133
  bp_status_record_activity( $user_id, apply_filters( 'bp_status_activity_new', $activity_content, $content, $user_link ), apply_filters( 'bp_status_activity_new_primary_link', $user_link, $user_id ) );
134
+
135
  do_action( 'bp_status_add_status', $user_id, $content );
136
 
137
  return true;
139
 
140
  function bp_status_clear_status( $user_id = false ) {
141
  global $bp;
142
+
143
  if ( !$user_id )
144
  $user_id = $bp->loggedin_user->id;
145
+
146
  bp_status_clear_existing_activity( $user_id );
147
+
148
  return delete_usermeta( $user_id, 'bp_status' );
149
  }
150
 
151
  function bp_status_clear_existing_activity( $user_id ) {
152
  /* Fetch existing status update if there is one. */
153
  $existing_status = get_usermeta( $user_id, 'bp_status' );
154
+
155
  if ( '' != $existing_status ) {
156
  if ( strtotime( '+5 minutes', $existing_status['recorded_time'] ) >= time() ) {
157
  /***
bp-status/bp-status-filters.php CHANGED
File without changes
bp-status/bp-status-templatetags.php CHANGED
@@ -10,43 +10,43 @@ function bp_the_status( $args = false ) {
10
  } else {
11
  if ( 'clear' == $_GET['status'] && is_user_logged_in() )
12
  bp_status_clear_status();
13
-
14
  echo bp_get_the_status( $args );
15
  }
16
  }
17
  function bp_get_the_status( $args = false ) {
18
  global $bp;
19
-
20
  $defaults = array(
21
  'user_id' => $bp->displayed_user->id,
22
  'clear_button_text' => __( 'Clear', 'buddypress' ),
23
  'new_button_text' => __( 'Update Your Status', 'buddypress' ),
24
  'no_anchor' => false
25
  );
26
-
27
  $r = wp_parse_args( $args, $defaults );
28
  extract( $r, EXTR_SKIP );
29
-
30
  if ( !$user_id )
31
  $user_id = $bp->displayed_user->id;
32
-
33
- $status = apply_filters( 'bp_status_from_usermeta', get_usermeta( $user_id, 'bp_status' ) );
34
-
35
  if ( empty($status) )
36
  return bp_get_update_status_button( 'text=' . $new_button_text );
37
-
38
  $time_since = sprintf( __( '%s ago', 'buddypress' ), bp_core_time_since( $status['recorded_time'] ) );
39
  $content = apply_filters( 'the_status_content', $status['content'] );
40
-
41
  if ( !(int)$no_anchor && $user_id == $bp->loggedin_user->id )
42
  $content = '<a href="' . bp_core_get_user_domain( $user_id ) . '?status=new" id="status-new-status">' . $content . '</a>';
43
 
44
  $content .= ' <span class="time-since">' . $time_since . '</span>';
45
  $content .= ' ' . bp_get_clear_status_button( 'text=' . $clear_button_text );
46
-
47
  return apply_filters( 'bp_get_the_status', $content );
48
  }
49
-
50
  function bp_update_status_button( $args = false ) {
51
  echo bp_get_update_status_button( $args );
52
  }
@@ -57,16 +57,16 @@ function bp_update_status_button( $args = false ) {
57
  'user_id' => false,
58
  'text' => __( 'Update Your Status', 'buddypress' )
59
  );
60
-
61
  $r = wp_parse_args( $args, $defaults );
62
  extract( $r, EXTR_SKIP );
63
-
64
  if ( !$user_id )
65
  $user_id = $bp->displayed_user->id;
66
-
67
  if ( $user_id != $bp->loggedin_user->id )
68
  return false;
69
-
70
  return apply_filters( 'bp_get_update_status_button', '<div class="generic-button"><a href="' . bp_core_get_user_domain( $user_id ) . '?status=new" id="status-new-status">' . $text . '</a></div>' );
71
  }
72
 
@@ -80,25 +80,25 @@ function bp_clear_status_button( $args = false ) {
80
  'user_id' => false,
81
  'text' => __( 'Clear', 'buddypress' )
82
  );
83
-
84
  $r = wp_parse_args( $args, $defaults );
85
  extract( $r, EXTR_SKIP );
86
-
87
  if ( !$user_id )
88
  $user_id = $bp->displayed_user->id;
89
-
90
  if ( $user_id != $bp->loggedin_user->id )
91
  return false;
92
-
93
  return apply_filters( 'bp_get_clear_status_button', '<a href="' . bp_core_get_user_domain( $user_id ) . '?status=clear" id="status-clear-status">' . $text . '</a>' );
94
  }
95
 
96
  function bp_status_form_action( $user_id = false ) {
97
  global $bp;
98
-
99
  if ( !$user_id )
100
  $user_id = $bp->loggedin_user->id;
101
-
102
  echo apply_filters( 'bp_status_form_action', bp_core_get_user_domain( $user_id ) . BP_STATUS_SLUG . '/add' );
103
  }
104
 
10
  } else {
11
  if ( 'clear' == $_GET['status'] && is_user_logged_in() )
12
  bp_status_clear_status();
13
+
14
  echo bp_get_the_status( $args );
15
  }
16
  }
17
  function bp_get_the_status( $args = false ) {
18
  global $bp;
19
+
20
  $defaults = array(
21
  'user_id' => $bp->displayed_user->id,
22
  'clear_button_text' => __( 'Clear', 'buddypress' ),
23
  'new_button_text' => __( 'Update Your Status', 'buddypress' ),
24
  'no_anchor' => false
25
  );
26
+
27
  $r = wp_parse_args( $args, $defaults );
28
  extract( $r, EXTR_SKIP );
29
+
30
  if ( !$user_id )
31
  $user_id = $bp->displayed_user->id;
32
+
33
+ $status = apply_filters( 'bp_status_from_usermeta', get_usermeta( $user_id, 'bp_status' ) );
34
+
35
  if ( empty($status) )
36
  return bp_get_update_status_button( 'text=' . $new_button_text );
37
+
38
  $time_since = sprintf( __( '%s ago', 'buddypress' ), bp_core_time_since( $status['recorded_time'] ) );
39
  $content = apply_filters( 'the_status_content', $status['content'] );
40
+
41
  if ( !(int)$no_anchor && $user_id == $bp->loggedin_user->id )
42
  $content = '<a href="' . bp_core_get_user_domain( $user_id ) . '?status=new" id="status-new-status">' . $content . '</a>';
43
 
44
  $content .= ' <span class="time-since">' . $time_since . '</span>';
45
  $content .= ' ' . bp_get_clear_status_button( 'text=' . $clear_button_text );
46
+
47
  return apply_filters( 'bp_get_the_status', $content );
48
  }
49
+
50
  function bp_update_status_button( $args = false ) {
51
  echo bp_get_update_status_button( $args );
52
  }
57
  'user_id' => false,
58
  'text' => __( 'Update Your Status', 'buddypress' )
59
  );
60
+
61
  $r = wp_parse_args( $args, $defaults );
62
  extract( $r, EXTR_SKIP );
63
+
64
  if ( !$user_id )
65
  $user_id = $bp->displayed_user->id;
66
+
67
  if ( $user_id != $bp->loggedin_user->id )
68
  return false;
69
+
70
  return apply_filters( 'bp_get_update_status_button', '<div class="generic-button"><a href="' . bp_core_get_user_domain( $user_id ) . '?status=new" id="status-new-status">' . $text . '</a></div>' );
71
  }
72
 
80
  'user_id' => false,
81
  'text' => __( 'Clear', 'buddypress' )
82
  );
83
+
84
  $r = wp_parse_args( $args, $defaults );
85
  extract( $r, EXTR_SKIP );
86
+
87
  if ( !$user_id )
88
  $user_id = $bp->displayed_user->id;
89
+
90
  if ( $user_id != $bp->loggedin_user->id )
91
  return false;
92
+
93
  return apply_filters( 'bp_get_clear_status_button', '<a href="' . bp_core_get_user_domain( $user_id ) . '?status=clear" id="status-clear-status">' . $text . '</a>' );
94
  }
95
 
96
  function bp_status_form_action( $user_id = false ) {
97
  global $bp;
98
+
99
  if ( !$user_id )
100
  $user_id = $bp->loggedin_user->id;
101
+
102
  echo apply_filters( 'bp_status_form_action', bp_core_get_user_domain( $user_id ) . BP_STATUS_SLUG . '/add' );
103
  }
104
 
bp-status/bp-status-widgets.php CHANGED
File without changes
bp-themes/bp-default/_inc/css/adminbar.css CHANGED
@@ -26,7 +26,7 @@
26
  background: none;
27
  padding-right: 0;
28
  }
29
-
30
  #wp-admin-bar ul li ul a {
31
  color: #666 !important;
32
  text-decoration: none;
@@ -143,4 +143,4 @@
143
  -khtml-border-radius: 2px !important;
144
  -webkit-border-radius: 2px !important;
145
  margin-left: 2px !important;
146
- }
26
  background: none;
27
  padding-right: 0;
28
  }
29
+
30
  #wp-admin-bar ul li ul a {
31
  color: #666 !important;
32
  text-decoration: none;
143
  -khtml-border-radius: 2px !important;
144
  -webkit-border-radius: 2px !important;
145
  margin-left: 2px !important;
146
+ }
bp-themes/bp-default/_inc/css/screen.css CHANGED
@@ -7,18 +7,18 @@ body {
7
  background: #fff;
8
  }
9
 
10
- a {
11
- color: #f7740a;
12
  text-decoration: underline;
13
  }
14
 
15
  a:hover {
16
- color: #555;
17
  text-decoration: none;
18
  }
19
 
20
- a.selected {
21
- color: #555;
22
  text-decoration: none;
23
  }
24
 
@@ -64,11 +64,11 @@ h1, h2, h3 {
64
  float: right;
65
  padding: 7px 20px;
66
  }
67
-
68
  #logout-link img {
69
  vertical-align: middle;
70
  }
71
-
72
  #search-login-bar #rememberme { display: none; }
73
 
74
 
@@ -86,12 +86,12 @@ h1, h2, h3 {
86
  padding: 0;
87
  }
88
 
89
- #header h1#logo {
90
  float: left;
91
  margin: 20px 0 15px 20px;
92
  padding: 15px 0;
93
  }
94
-
95
  #header h1#logo a {
96
  font-size: 2em;
97
  color: #aaa;
@@ -99,8 +99,8 @@ h1, h2, h3 {
99
  font-family: Georgia, times, serif;
100
  display: block;
101
  text-decoration: none;
102
- }
103
-
104
  #header ul {
105
  float: right;
106
  margin: 0;
@@ -120,7 +120,7 @@ h1, h2, h3 {
120
  -webkit-border-radius: 3px;
121
  text-decoration: none;
122
  }
123
-
124
  #header ul li.selected a {
125
  background: #fff9df;
126
  color: #ff7900;
@@ -153,7 +153,7 @@ h1, h2, h3 {
153
  }
154
 
155
  /*** Content Header *************************************************************/
156
-
157
  div.content-header {
158
  font: normal 1em "Georgia", Times, serif;
159
  text-transform: uppercase;
@@ -185,11 +185,11 @@ div.content-header {
185
  color: #555;
186
  text-decoration: none;
187
  }
188
-
189
  ul.content-header-nav li span {
190
  color: #999;
191
  }
192
-
193
  ul.content-header-nav li.current {
194
  background: url(../images/topoption_selected_back.gif) top center no-repeat;
195
  }
@@ -212,7 +212,7 @@ div.content-header {
212
  margin-right: 0;
213
  list-style: none;
214
  }
215
-
216
  #userbar h3 {
217
  font: normal 1em "Georgia", Times, serif;
218
  text-transform: uppercase;
@@ -237,17 +237,17 @@ div.content-header {
237
  text-align: center;
238
  margin: 0.4em 0;
239
  float: none;
240
- }
241
-
242
  #userbar p#login-text {
243
  padding: 0.5em 1em 0 1em;
244
  }
245
-
246
  p.avatar img {
247
  border: 4px solid #fff;
248
  }
249
  img#avatar-to-crop { border: none !important; }
250
-
251
  #userbar form {
252
  padding: 1em 1.5em 1em 1em;
253
  }
@@ -256,7 +256,7 @@ div.content-header {
256
  }
257
  #userbar form input#userbar_rememberme { width: auto; }
258
  #userbar form input#wp-submit { width: auto; }
259
-
260
  #userbar ul#bp-nav {
261
  width: 149px;
262
  margin: 1.75em 0 0 0;
@@ -277,7 +277,7 @@ div.content-header {
277
  #userbar ul#bp-nav li.current a {
278
  color: #fff;
279
  }
280
-
281
  li a#user-profile, li a#my-profile {
282
  background: url(../images/profile_bullet.gif) 88% 52% no-repeat;
283
  padding: 0.55em 3em 0.55em 0 !important;
@@ -286,26 +286,26 @@ div.content-header {
286
 
287
  li a#user-messages, li a#my-messages {
288
  background: url(../images/messages_bullet.gif) 89% 52% no-repeat;
289
- }
290
-
291
  li a#user-blogs, li a#my-blogs {
292
  background: url(../images/blog_bullet.gif) 87% 52% no-repeat;
293
  padding: 0.55em 3em 0.55em 0 !important;
294
  margin-right: 0.85em !important;
295
  }
296
-
297
  li a#user-friends, li a#my-friends {
298
  background: url(../images/friends_bullet.gif) 87% 52% no-repeat;
299
  padding: 0.55em 3em 0.55em 0 !important;
300
  margin-right: 0.85em !important;
301
  }
302
-
303
  li a#user-groups, li a#my-groups {
304
  background: url(../images/groups_bullet.gif) 88% 52% no-repeat;
305
  padding: 0.55em 3em 0.55em 0 !important;
306
  margin-right: 0.85em !important;
307
  }
308
-
309
  li a#user-wire, li a#my-wire {
310
  background: url(../images/wire_bullet.gif) 88% 52% no-repeat;
311
  padding: 0.55em 3em 0.55em 0 !important;
@@ -317,15 +317,15 @@ div.content-header {
317
  padding: 0.55em 3em 0.55em 0 !important;
318
  margin-right: 0.85em !important;
319
  }
320
-
321
  li a#user-settings, li a#my-settings {
322
- background: url(../images/settings_bullet.gif) 88% 52% no-repeat;
323
  }
324
-
325
  li a#wp-logout {
326
  background: url(../images/logout_bullet.gif) 87% 52% no-repeat;
327
  }
328
-
329
  li a#group-home, li a#group-wire, li a#group-photos, li a#group-forum,
330
  li a#group-members, li a#group-invite, li a#group-leave, li a#group-admin
331
  li a#request-membership, li a#group-admin {
@@ -335,29 +335,29 @@ div.content-header {
335
  margin-right: 0.85em;
336
  }
337
  li a#group-forum {
338
- background: url(../images/forum_bullet.gif) 88% 52% no-repeat;
339
  }
340
 
341
  li a#group-members {
342
- background: url(../images/friends_bullet.gif) 87% 52% no-repeat;
343
  }
344
-
345
  li a#group-invite {
346
- background: url(../images/invite_bullet.gif) 89% 52% no-repeat;
347
  }
348
 
349
  li a#group-leave {
350
- background: url(../images/cross_bullet.gif) 88% 52% no-repeat;
351
  }
352
-
353
  li a#group-wire {
354
  background: url(../images/wire_bullet.gif) 88% 52% no-repeat;
355
- }
356
-
357
  li a#group-admin {
358
  background: url(../images/blogadmin_icon.gif) 87% 52% no-repeat;
359
  }
360
-
361
  li a#request-membership {
362
  background: url(../images/request_bullet.gif) 87% 25% no-repeat;
363
  }
@@ -372,18 +372,18 @@ div.content-header {
372
  background: #f0f0f0;
373
  }
374
  #optionsbar a { text-decoration: none; }
375
-
376
  #optionsbar ul {
377
  margin: 0;
378
  padding: 0;
379
  list-style: none;
380
  }
381
-
382
  #optionsbar ul li {
383
  float: none;
384
  margin-right: 0;
385
  }
386
-
387
  #optionsbar p.avatar {
388
  text-align: center !important;
389
  float: none;
@@ -394,7 +394,7 @@ div.content-header {
394
  margin: 0;
395
  float: none;
396
  }
397
-
398
  #optionsbar h3 {
399
  font: normal 1em "Georgia", Times, serif;
400
  text-transform: uppercase;
@@ -403,7 +403,7 @@ div.content-header {
403
  padding: 8px 0 17px 0;
404
  letter-spacing: 0.5px;
405
  }
406
-
407
  #optionsbar ul#options-nav {
408
  width: 148px;
409
  margin: 1.75em 0 0 0;
@@ -420,14 +420,14 @@ div.content-header {
420
  display: block;
421
  text-align: right;
422
  }
423
-
424
  #optionsbar ul.icons li a {
425
  padding-right: 3.1em !important;
426
  margin-right: 0.7em;
427
  }
428
 
429
  /*** Internal Page Left Menu / Main Column **************************************/
430
-
431
  .internal-page .left-menu {
432
  position: relative;
433
  float: left;
@@ -439,11 +439,11 @@ div.content-header {
439
  padding: 0;
440
  }
441
  .left-menu h5 { margin: 0; font-size: 1em; }
442
-
443
  .left-menu div.button-block {
444
  margin: 20px 0;
445
  }
446
-
447
  .left-menu input { width: 90%; }
448
 
449
  .internal-page .main-column {
@@ -474,17 +474,17 @@ div.bp-widget {
474
  }
475
  .left-menu div.bp-widget h4 {
476
  background: url(../images/leftmenu_group_header.gif) top left no-repeat;
477
- color: #555;
478
  }
479
 
480
  /* "See All" links in widget headers */
481
  div.bp-widget h4 span { position: absolute; right: 10px; }
482
-
483
  div.bp-widget h4 a {
484
  color: #fff;
485
  font-weight: normal;
486
  }
487
-
488
  ul.horiz-gallery {
489
  list-style: none;
490
  overflow: auto;
@@ -515,24 +515,24 @@ ul.item-list {
515
  padding: 10px 10px 10px 10px;
516
  overflow: hidden;
517
  }
518
-
519
  ul.item-list img.avatar {
520
  float: left;
521
  margin-right: 10px;
522
  }
523
-
524
- ul.item-list h4, ul.item-list h5, ul.item-list .item-title {
525
  font-size: 1em;
526
  margin: 0 0 4px 0;
527
  }
528
-
529
  ul.item-list li .field-data {
530
  margin-left: 68px;
531
  margin-top: 10px;
532
  font-size: 0.9em;
533
  color: #888;
534
  }
535
-
536
  ul.item-list li .desc {
537
  font-size: 0.9em;
538
  color: #888;
@@ -547,10 +547,6 @@ div.action {
547
  text-align: right;
548
  }
549
 
550
- div#avatar-crop-pane {
551
- display: none;
552
- }
553
-
554
  div#avatar-crop-submit {
555
  margin: 20px 0 0 0;
556
  }
@@ -566,7 +562,7 @@ div#avatar-crop-submit {
566
  position: absolute;
567
  top: 45px;
568
  }
569
-
570
  .pagination-links {
571
  text-align: right;
572
  margin-bottom: 5px;
@@ -586,7 +582,7 @@ a.page-numbers:hover { background: #e1e1e1; }
586
  background: #d5d5d5;
587
  border-bottom: 2px solid #f28935;
588
  }
589
-
590
  .pag-count {
591
  font-size: 0.9em;
592
  color: #888;
@@ -648,12 +644,12 @@ a.page-numbers:hover { background: #e1e1e1; }
648
  }
649
  .accept a { background-image: url(../images/accept_button_side.gif); }
650
  .reject a { background-image: url(../images/reject_button_side.gif); }
651
-
652
  .generic-button a:hover {
653
  color: #555;
654
  text-decoration: none;
655
  }
656
-
657
  .friendship-button a.add {
658
  background: url(../images/add_button_side.gif) top right no-repeat;
659
  }
@@ -665,23 +661,23 @@ a.page-numbers:hover { background: #e1e1e1; }
665
  .friendship-button a.requested {
666
  background: url(../images/check_button_side.gif) top right no-repeat;
667
  }
668
-
669
  .loading a {
670
- background: url(../images/loading_button_side.gif) top right no-repeat !important;
671
  }
672
 
673
  .group-button a.join-group, .group-button a.request-membership {
674
  background: url(../images/add_button_side.gif) top right no-repeat;
675
  }
676
-
677
  .group-button a.leave-group {
678
  background: url(../images/remove_button_side.gif) top right no-repeat;
679
  }
680
-
681
  .group-button a.membership-requested {
682
  background: url(../images/check_button_side.gif) top right no-repeat;
683
  }
684
-
685
  .main-column .button-block {
686
  overflow: hidden;
687
  width: 100%;
@@ -733,7 +729,7 @@ form.standard-form { }
733
  font-weight: bold;
734
  margin: 10px 0 5px 0;
735
  }
736
-
737
  form.standard-form input[type=text] {
738
  width: 65%;
739
  }
@@ -741,7 +737,7 @@ form.standard-form { }
741
  form.standard-form textarea {
742
  width: 65%;
743
  }
744
-
745
  form.standard-form .checkbox label, form.standard-form .radio label {
746
  font-weight: normal;
747
  display: inline;
@@ -787,39 +783,39 @@ h2.widgettitle, .directory h3, h2.pagetitle {
787
  .widget ul.item-list {
788
  margin-top: 5px !important;
789
  }
790
-
791
  .widget ul.item-list li .item-avatar img, img.avatar {
792
  border: 3px solid #ddd;
793
  }
794
-
795
  .widget ul.item-list li h4.item-title {
796
  font: normal 1.4em "Georgia", Times, serif;
797
- margin: 0 0 7px 0;
798
  }
799
-
800
  .widget_bp_blogs_widget_recent_posts img.avatar {
801
  width: 50px !important;
802
  height: 50px !important;
803
- }
804
-
805
  .widget ul.item-list li .item {
806
  margin-left: 71px;
807
  }
808
  .widget_bp_blogs_recent_posts_widget ul.item-list li .item {
809
  margin-left: 31px !important;
810
  }
811
-
812
  .widget ul.item-list li .item-meta {
813
  font: normal 1em "Georgia", Times, serif;
814
  margin: 10px 0;
815
  }
816
-
817
  .widget .item-options {
818
  text-align: right;
819
  font-size: 0.9em;
820
  margin: -15px 0 0 0;
821
  }
822
-
823
  .widget_bp_core_widget_whos_online .item-avatar {
824
  float: left;
825
  margin-right: 10px;
@@ -830,7 +826,7 @@ div.create-account {
830
  margin: 10px 0;
831
  text-align: right;
832
  }
833
-
834
  .widget-error {
835
  padding: 10px;
836
  background: #fff9df;
@@ -844,7 +840,7 @@ span.activity, .message-metadata small {
844
  border-bottom: 1px solid #FFE8C4;
845
  display: inline-block;
846
  font: normal 0.9em "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif !important;
847
- max-width: 60%;
848
  }
849
 
850
  div.avatar-block {
@@ -880,11 +876,11 @@ div.avatar-block {
880
  background: #ccc;
881
  cursor: pointer;
882
  }
883
-
884
  .widget table#wp-calendar td#today {
885
  background: #fff9df;
886
  }
887
-
888
  .widget table#wp-calendar td.pad {
889
  background: none;
890
  }
@@ -902,7 +898,7 @@ div.avatar-block {
902
  background: url(../images/rightcol_header_back.gif) top left no-repeat;
903
  color: #fff;
904
  }
905
-
906
  #second-section .widget h2 {
907
  background: url(../images/centercol_header_back.gif) top left no-repeat;
908
  color: #fff;
@@ -959,13 +955,13 @@ ul#letter-list {
959
  font-family: Georgia, Times, serif;
960
  padding: 3px 5px;
961
  }
962
-
963
  ul#letter-list li a:hover {
964
  font-weight: bold;
965
  background: #fff9df;
966
  color: #f7740a;
967
  }
968
-
969
  ul#letter-list li a.selected {
970
  font-weight: bold;
971
  background: #aaa;
@@ -985,14 +981,14 @@ ul#letter-list {
985
 
986
  .post, #comments-template, #compose-reply {
987
  background: url(../images/item_list_back.gif) top left repeat-x;
988
- padding: 20px 15px;
989
  }
990
  #comments-section, #compose-reply {
991
  background: none;
992
  }
993
-
994
- ol.commentlist {
995
- list-style: none;
996
  margin: 0;
997
  padding: 0;
998
  }
@@ -1030,7 +1026,7 @@ ul#letter-list {
1030
  .post .entry {
1031
  margin: 10px 0;
1032
  }
1033
-
1034
  .post span.tags {
1035
  background: url(../images/tag_icon.gif) center left no-repeat;
1036
  padding-left: 1.6em;
@@ -1178,15 +1174,15 @@ h4.archive {
1178
  }
1179
 
1180
  .commentlist li.alt { background: #f0f0f0; }
1181
- .commentlist li img.avatar {
1182
  padding: 0;
1183
  margin: 0 10px 10px 0;
1184
  float: left;
1185
-
1186
  }
1187
  .commentlist li.alt img.avatar { border-color: #fff !important; }
1188
 
1189
- .commentmetadata {
1190
  font-size: 0.9em;
1191
  border-bottom: 1px solid #ddd;
1192
  padding-bottom: 10px;
@@ -1228,7 +1224,7 @@ h4.archive {
1228
  margin: 5px 0 10px 0;
1229
  }
1230
 
1231
- #basic-details-section input, #basic-details-section textarea,
1232
  #profile-details-section input, #profile-details-section textarea,
1233
  input#signup_blog_title {
1234
  width: 90%;
@@ -1263,7 +1259,7 @@ input#signup_blog_title {
1263
  margin: 0;
1264
  font-size: 1.4em;
1265
  }
1266
-
1267
 
1268
  /*** Component Specific Styles ****************************************************/
1269
 
@@ -1281,9 +1277,9 @@ input#signup_blog_title {
1281
  background: none !important;
1282
  }
1283
  ul#activity-filter-links li#afilter-blogs a {
1284
- background: url(../images/blog_bullet.gif) 20px 4px no-repeat;
1285
  }
1286
-
1287
  ul#activity-filter-links li#afilter-profile a {
1288
  background: url(../images/profile_bullet.gif) 0 4px no-repeat;
1289
  }
@@ -1291,11 +1287,11 @@ input#signup_blog_title {
1291
  ul#activity-filter-links li#afilter-friends a {
1292
  background: url(../images/friends_bullet.gif) 0 4px no-repeat;
1293
  }
1294
-
1295
  ul#activity-filter-links li#afilter-groups a {
1296
  background: url(../images/groups_bullet.gif) 0 4px no-repeat;
1297
  }
1298
-
1299
  ul#activity-filter-links li#afilter-wire a {
1300
  background: url(../images/wire_bullet.gif) 0 4px no-repeat;
1301
  }
@@ -1303,7 +1299,7 @@ input#signup_blog_title {
1303
  ul#activity-filter-links li#afilter-status a {
1304
  background: url(../images/status_bullet.gif) 0 4px no-repeat;
1305
  }
1306
-
1307
  .activity-list li div.activity-avatar {
1308
  position: absolute;
1309
  margin: -1px 0 0 -35px;
@@ -1311,7 +1307,7 @@ input#signup_blog_title {
1311
  .widget .activity-list li div.activity-avatar img.avatar {
1312
  border-width: 2px;
1313
  }
1314
-
1315
  .internal-page .activity-list li div.activity-avatar img.avatar {
1316
  border-top-width: 3px !important;
1317
  border-right-width: 2px !important;
@@ -1327,7 +1323,10 @@ input#signup_blog_title {
1327
  -moz-border-radius: 5px;
1328
  -webkit-border-radius: 5px;
1329
  }
1330
- .activity-list li blockquote p { margin: 0; }
 
 
 
1331
 
1332
  .activity-list li span.time-since {
1333
  font-size: 0.8em;
@@ -1367,7 +1366,7 @@ ul#activity-filter-links li {
1367
  border: 1px solid #ccc;
1368
  font-weight: bold;
1369
  }
1370
-
1371
  ul#activity-filter-links li#afilter-clear a {
1372
  background: url(../images/error_icon.gif) 0 4px no-repeat;
1373
  border-color: #ffa6ac;
@@ -1386,10 +1385,13 @@ a.rss-image {
1386
  }
1387
 
1388
  #activity-rss p {
1389
- text-align: right;
1390
- font-size: 0.9em;
1391
- margin: -20px 0 5px 0;
1392
  }
 
 
 
1393
 
1394
  #activity-rss p a {
1395
  background: url(../images/rss.png) center left no-repeat;
@@ -1408,12 +1410,12 @@ a.rss-image {
1408
 
1409
  .widget_bp_core_recently_active_widget div.item-avatar {
1410
  display: inline;
1411
- margin: 0 5px 5x 0;
1412
  }
1413
 
1414
 
1415
  /**** BLOGS *****************/
1416
-
1417
  #blog-info {
1418
  border-bottom: 1px solid #e1e1e1;
1419
  }
@@ -1438,7 +1440,7 @@ a.rss-image {
1438
  color: #f7740a;
1439
  font: italic 1em Georgia, times, serif;
1440
  }
1441
-
1442
  .post span.tags {
1443
  background: url(../images/tag_icon.gif) center left no-repeat;
1444
  }
@@ -1456,8 +1458,8 @@ h4.archive {
1456
  text-transform: uppercase;
1457
  border-bottom: 1px solid #e1e1e1;
1458
  }
1459
-
1460
-
1461
  /*---- Blog Signup Form --------*/
1462
 
1463
  #setupform label {
@@ -1468,7 +1470,7 @@ h4.archive {
1468
  background-color: #ff3a3a;
1469
  color: #fff;
1470
  }
1471
-
1472
  .suffix_address, .prefix_address {
1473
  font-size: 1.4em;
1474
  }
@@ -1479,11 +1481,11 @@ h4.archive {
1479
  #setupform input#blogname {
1480
  text-align: right;
1481
  }
1482
-
1483
  #setupform input#submit {
1484
  font-size: 1.4em;
1485
  }
1486
-
1487
  /***** FORUMS ***************/
1488
 
1489
  ul#forum-topic-list li {
@@ -1494,17 +1496,17 @@ ul#forum-topic-list li {
1494
  .sticky {
1495
  background-image: url( ../images/message_thread_unread_back.gif ) !important;
1496
  }
1497
-
1498
  .closed a.topic-title {
1499
  background: url( ../images/closed.png ) no-repeat center left;
1500
  padding: 0 0 0 20px;
1501
  }
1502
-
1503
- ul#forum-topic-list li span.latest {
1504
  display: block;
1505
  margin-left: 50px;
1506
  }
1507
-
1508
  ul#forum-topic-list li div.admin-links, ul#topic-post-list li div.admin-links {
1509
  position: absolute;
1510
  top: 1em;
@@ -1579,7 +1581,7 @@ div#post-topic-reply textarea {
1579
  display: block;
1580
  margin: 10px 0 3px 0;
1581
  }
1582
-
1583
  div#edit-post textarea {
1584
  height: 150px;
1585
  width: 98%;
@@ -1634,7 +1636,7 @@ div#forum-dir-list {
1634
  position: absolute;
1635
  top: -25px;
1636
  }
1637
-
1638
  table#global-forum-topic-list {
1639
  width: 97%;
1640
  margin: 0 10px;
@@ -1642,7 +1644,7 @@ table#global-forum-topic-list {
1642
  table#global-forum-topic-list tr.alt {
1643
  background: url( ../images/message_thread_back.gif ) 0 -2px;
1644
  }
1645
-
1646
  table#global-forum-topic-list td {
1647
  border-top: 1px solid #eee;
1648
  position: relative;
@@ -1651,32 +1653,32 @@ table#global-forum-topic-list {
1651
  color: #888;
1652
  font-size: 0.9em;
1653
  }
1654
-
1655
  table#global-forum-topic-list tr th, table#global-forum-topic-list td.td-postcount,
1656
- table#global-forum-topic-list td.td-freshness {
1657
  text-align: center;
1658
  }
1659
 
1660
-
1661
  table#global-forum-topic-list tr th#th-title, table#global-forum-topic-list tr th#th-poster,
1662
  table#global-forum-topic-list tr th#th-group { text-align: left; }
1663
-
1664
  table#global-forum-topic-list tr td, table#global-forum-topic-list tr th {
1665
  padding: 5px 10px;
1666
  vertical-align: middle;
1667
  }
1668
-
1669
  table#global-forum-topic-list td.td-freshness {
1670
  font-size: 0.9em;
1671
  color: #888;
1672
  }
1673
-
1674
  table#global-forum-topic-list td.td-poster, table#global-forum-topic-list td.td-group {
1675
  min-width: 130px;
1676
  }
1677
-
1678
  table#global-forum-topic-list img.avatar { float:left; }
1679
-
1680
  table#global-forum-topic-list div.poster-name, table#global-forum-topic-list div.object-name {
1681
  margin-left: 35px;
1682
  }
@@ -1684,15 +1686,15 @@ table#global-forum-topic-list {
1684
  table#global-forum-topic-list th#th-title {
1685
  width: 40%;
1686
  }
1687
-
1688
  table#global-forum-topic-list th#th-postcount {
1689
  width: 1%;
1690
  }
1691
-
1692
  table#global-forum-topic-list td img {
1693
  vertical-align: middle;
1694
  margin-right: 4px;
1695
- border-width: 3px !important;
1696
  }
1697
 
1698
  div#popular-group-forum-listing {
@@ -1708,7 +1710,7 @@ div#popular-group-forum-listing {
1708
  div.group-forum div.item-avatar {
1709
  float: left;
1710
  }
1711
-
1712
  div.group-forum div.item {
1713
  margin-left: 70px;
1714
  }
@@ -1716,7 +1718,7 @@ div#popular-group-forum-listing {
1716
  font-size: 1.2em;
1717
  font-family: Georgia, times, serif;
1718
  }
1719
-
1720
  div.group-forum div.desc {
1721
  font-size: 0.95em;
1722
  color: #888;
@@ -1767,14 +1769,14 @@ div.sub-options {
1767
  #group-settings-form .bp-widget ul {
1768
  margin-left: 0;
1769
  }
1770
-
1771
  #invite-list { margin-bottom: 25px; }
1772
-
1773
  #invite-list ul, ul#friend-list {
1774
  margin: 0;
1775
  }
1776
  #invite-list input { width: auto !important; }
1777
-
1778
  #create-group-form textarea, #group-settings-form textarea {
1779
  height: 120px;
1780
  }
@@ -1805,7 +1807,7 @@ ul#group-list li, ul#member-list li, ul#blog-list li, ul#comment-list li, ul.ite
1805
  border-color: red !important;
1806
  }
1807
  ul.item-list li.banned-user a { color: red; }
1808
-
1809
  #group-list li span.small, #member-list li span.small, #comment-list li span.small, ul.item-list li span.small {
1810
  font-size: 0.95em;
1811
  color: #888;
@@ -1845,11 +1847,11 @@ ul#group-list li, ul#member-list li, ul#blog-list li, ul#comment-list li, ul.ite
1845
  #random-groups-list .desc, #random-groups-list .meta {
1846
  font-size: 0.9em;
1847
  }
1848
-
1849
  #random-groups-list .desc {
1850
- margin-left: 70px;
1851
  }
1852
-
1853
  #random-groups-list .action {
1854
  text-align: right;
1855
  margin-top: -20px;
@@ -1865,7 +1867,7 @@ ul#group-list li, ul#member-list li, ul#blog-list li, ul#comment-list li, ul.ite
1865
  #previous-next input#group-creation-previous {
1866
  width: auto;
1867
  }
1868
-
1869
  #previous-next input#group-creation-next, #previous-next input#group-creation-finish {
1870
  width: auto;
1871
  margin-left: 20px;
@@ -1909,18 +1911,18 @@ div.message-box {
1909
  width: 30px;
1910
  margin-bottom: 10px;
1911
  }
1912
-
1913
  div.message-box .message-metadata h3 {
1914
  font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Tahoma, Verdana, Arial, sans-serif;
1915
  font-size: 1em;
1916
  margin: 0 0 5px 0;
1917
  }
1918
-
1919
  div.message-box .message-metadata small {
1920
  font-size: 0.9em;
1921
  color: #888;
1922
  }
1923
-
1924
  div.message-box .message-metadata h3 {
1925
  font-size: 1.1em;
1926
  }
@@ -1943,25 +1945,25 @@ table#message-threads tr.unread {
1943
  color: #888;
1944
  font-size: 0.95em;
1945
  }
1946
-
1947
- .avatar-box {
1948
  border: none !important;
1949
  }
1950
 
1951
  #main #content .avatar-box h3 {
1952
  font: bold 1em "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Tahoma, Verdana, Arial, sans-serif;;
1953
  }
1954
-
1955
  .avatar-box small {
1956
  line-height: 1.5;
1957
  font-size: 0.9em;
1958
  color: #888;
1959
  }
1960
-
1961
  #message_content_tbl { border: 1px solid #ddd; }
1962
  .mceToolbar, .mceStatusbar { background: #eee; }
1963
  .mceToolbar a { color: #bbb !important; }
1964
-
1965
  div.ajax_reply, div.error-box {
1966
  text-align: center;
1967
  background: #EAF3FA;
@@ -1992,7 +1994,7 @@ div.error-box {
1992
  font-size: 1.2em;
1993
  font-weight: bold;
1994
  }
1995
-
1996
  form#send-reply textarea {
1997
  width: 98%;
1998
  }
@@ -2061,7 +2063,7 @@ table.profile-fields, table.wp-profile-fields {
2061
  table.profile-fields tr td, table.wp-profile-fields tr td {
2062
  padding: 0.5em 1em;
2063
  }
2064
-
2065
  table.profile-fields tr td.label, table.wp-profile-fields tr td.label {
2066
  width: 130px;
2067
  }
@@ -2090,7 +2092,7 @@ table.profile-fields, table.wp-profile-fields {
2090
  color: #888;
2091
  font-size: 0.9em;
2092
  }
2093
-
2094
  .wire-post-content {
2095
  margin-left: 68px;
2096
  }
@@ -2117,10 +2119,10 @@ div#wire-post-new {
2117
  margin: 0;
2118
  }
2119
 
2120
- div#wire-post-new-avatar {
2121
  float: left;
2122
  }
2123
-
2124
  div#wire-post-new-metadata {
2125
  position: absolute;
2126
  bottom: 11px;
@@ -2129,7 +2131,7 @@ div#wire-post-new {
2129
  span#wire-by-text {
2130
  display: none;
2131
  }
2132
-
2133
  div#wire-post-new-input {
2134
  margin-left: 70px;
2135
  }
@@ -2138,8 +2140,8 @@ div#wire-post-new {
2138
  width: 98%;
2139
  margin: 5px 0 0 0;
2140
  }
2141
-
2142
- input#wire-post-submit {
2143
  margin-top: 10px;
2144
  }
2145
 
@@ -2147,7 +2149,8 @@ div#wire-post-new {
2147
  /**** STATUS UPDATES *************/
2148
 
2149
  div#user-status {
2150
- margin: 0 0 20px 0;
 
2151
  font: normal 1.3em Georgia, times, serif;
2152
  }
2153
  div#user-status a#status-new-status {
@@ -2158,21 +2161,21 @@ div#user-status {
2158
  div#user-status div.generic-button a#status-new-status {
2159
  font: normal 11px "Lucida Grande", "Lucida Sans Unicode", Arial, Tahoma, sans-serif;
2160
  }
2161
-
2162
  input#status-update-input, textarea#status-update-input {
2163
  padding: 5px;
2164
  width: 98%;
2165
  font: normal 1em "Lucida Grande", "Lucida Sans Unicode", Arial, Tahoma, sans-serif;
2166
  color: #888;
2167
  }
2168
-
2169
  div#status-update-buttons {
2170
  margin: 10px 0 0 0;
2171
- }
2172
  div#status-update-buttons input {
2173
  width: auto;
2174
  }
2175
-
2176
  div#user-status label {
2177
  display: block;
2178
  font: normal 1em Georgia, times, serif;
@@ -2180,13 +2183,13 @@ div#user-status {
2180
  font-style: italic;
2181
  padding: 0 0 5px 0;
2182
  }
2183
-
2184
  a#status-new-status, a#status-clear-status {
2185
  padding-top: 2px;
2186
  font: normal 11px "Lucida Grande", "Lucida Sans Unicode", Arial, Tahoma, sans-serif;
2187
  }
2188
  a#status-clear-status { color: red; }
2189
-
2190
  div#user-status span.time-since {
2191
  color: #aaa;
2192
  font: normal 11px "Lucida Grande", "Lucida Sans Unicode", Arial, Tahoma, sans-serif;
@@ -2215,15 +2218,15 @@ table.notification-settings {
2215
  table.notification-settings td {
2216
  padding: 3px 0;
2217
  }
2218
-
2219
  table.notification-settings th.icon {
2220
  width: 35px;
2221
  }
2222
-
2223
  table.notification-settings th.title {
2224
  width: 80%;
2225
  }
2226
-
2227
  table.notification-settings .yes, table.notification-settings .no {
2228
  width: 40px;
2229
  }
@@ -2237,11 +2240,11 @@ input.settings-input {
2237
  table.notification-settings th {
2238
  font-weight: bold;
2239
  }
2240
-
2241
  table.notification-settings tr {
2242
  border-bottom: 1px solid #eee;
2243
  }
2244
-
2245
  table.notification-settings th.icon {
2246
  background: center center no-repeat;
2247
  }
7
  background: #fff;
8
  }
9
 
10
+ a {
11
+ color: #f7740a;
12
  text-decoration: underline;
13
  }
14
 
15
  a:hover {
16
+ color: #555;
17
  text-decoration: none;
18
  }
19
 
20
+ a.selected {
21
+ color: #555;
22
  text-decoration: none;
23
  }
24
 
64
  float: right;
65
  padding: 7px 20px;
66
  }
67
+
68
  #logout-link img {
69
  vertical-align: middle;
70
  }
71
+
72
  #search-login-bar #rememberme { display: none; }
73
 
74
 
86
  padding: 0;
87
  }
88
 
89
+ #header h1#logo {
90
  float: left;
91
  margin: 20px 0 15px 20px;
92
  padding: 15px 0;
93
  }
94
+
95
  #header h1#logo a {
96
  font-size: 2em;
97
  color: #aaa;
99
  font-family: Georgia, times, serif;
100
  display: block;
101
  text-decoration: none;
102
+ }
103
+
104
  #header ul {
105
  float: right;
106
  margin: 0;
120
  -webkit-border-radius: 3px;
121
  text-decoration: none;
122
  }
123
+
124
  #header ul li.selected a {
125
  background: #fff9df;
126
  color: #ff7900;
153
  }
154
 
155
  /*** Content Header *************************************************************/
156
+
157
  div.content-header {
158
  font: normal 1em "Georgia", Times, serif;
159
  text-transform: uppercase;
185
  color: #555;
186
  text-decoration: none;
187
  }
188
+
189
  ul.content-header-nav li span {
190
  color: #999;
191
  }
192
+
193
  ul.content-header-nav li.current {
194
  background: url(../images/topoption_selected_back.gif) top center no-repeat;
195
  }
212
  margin-right: 0;
213
  list-style: none;
214
  }
215
+
216
  #userbar h3 {
217
  font: normal 1em "Georgia", Times, serif;
218
  text-transform: uppercase;
237
  text-align: center;
238
  margin: 0.4em 0;
239
  float: none;
240
+ }
241
+
242
  #userbar p#login-text {
243
  padding: 0.5em 1em 0 1em;
244
  }
245
+
246
  p.avatar img {
247
  border: 4px solid #fff;
248
  }
249
  img#avatar-to-crop { border: none !important; }
250
+
251
  #userbar form {
252
  padding: 1em 1.5em 1em 1em;
253
  }
256
  }
257
  #userbar form input#userbar_rememberme { width: auto; }
258
  #userbar form input#wp-submit { width: auto; }
259
+
260
  #userbar ul#bp-nav {
261
  width: 149px;
262
  margin: 1.75em 0 0 0;
277
  #userbar ul#bp-nav li.current a {
278
  color: #fff;
279
  }
280
+
281
  li a#user-profile, li a#my-profile {
282
  background: url(../images/profile_bullet.gif) 88% 52% no-repeat;
283
  padding: 0.55em 3em 0.55em 0 !important;
286
 
287
  li a#user-messages, li a#my-messages {
288
  background: url(../images/messages_bullet.gif) 89% 52% no-repeat;
289
+ }
290
+
291
  li a#user-blogs, li a#my-blogs {
292
  background: url(../images/blog_bullet.gif) 87% 52% no-repeat;
293
  padding: 0.55em 3em 0.55em 0 !important;
294
  margin-right: 0.85em !important;
295
  }
296
+
297
  li a#user-friends, li a#my-friends {
298
  background: url(../images/friends_bullet.gif) 87% 52% no-repeat;
299
  padding: 0.55em 3em 0.55em 0 !important;
300
  margin-right: 0.85em !important;
301
  }
302
+
303
  li a#user-groups, li a#my-groups {
304
  background: url(../images/groups_bullet.gif) 88% 52% no-repeat;
305
  padding: 0.55em 3em 0.55em 0 !important;
306
  margin-right: 0.85em !important;
307
  }
308
+
309
  li a#user-wire, li a#my-wire {
310
  background: url(../images/wire_bullet.gif) 88% 52% no-repeat;
311
  padding: 0.55em 3em 0.55em 0 !important;
317
  padding: 0.55em 3em 0.55em 0 !important;
318
  margin-right: 0.85em !important;
319
  }
320
+
321
  li a#user-settings, li a#my-settings {
322
+ background: url(../images/settings_bullet.gif) 88% 52% no-repeat;
323
  }
324
+
325
  li a#wp-logout {
326
  background: url(../images/logout_bullet.gif) 87% 52% no-repeat;
327
  }
328
+
329
  li a#group-home, li a#group-wire, li a#group-photos, li a#group-forum,
330
  li a#group-members, li a#group-invite, li a#group-leave, li a#group-admin
331
  li a#request-membership, li a#group-admin {
335
  margin-right: 0.85em;
336
  }
337
  li a#group-forum {
338
+ background: url(../images/forum_bullet.gif) 88% 52% no-repeat;
339
  }
340
 
341
  li a#group-members {
342
+ background: url(../images/friends_bullet.gif) 87% 52% no-repeat;
343
  }
344
+
345
  li a#group-invite {
346
+ background: url(../images/invite_bullet.gif) 89% 52% no-repeat;
347
  }
348
 
349
  li a#group-leave {
350
+ background: url(../images/cross_bullet.gif) 88% 52% no-repeat;
351
  }
352
+
353
  li a#group-wire {
354
  background: url(../images/wire_bullet.gif) 88% 52% no-repeat;
355
+ }
356
+
357
  li a#group-admin {
358
  background: url(../images/blogadmin_icon.gif) 87% 52% no-repeat;
359
  }
360
+
361
  li a#request-membership {
362
  background: url(../images/request_bullet.gif) 87% 25% no-repeat;
363
  }
372
  background: #f0f0f0;
373
  }
374
  #optionsbar a { text-decoration: none; }
375
+
376
  #optionsbar ul {
377
  margin: 0;
378
  padding: 0;
379
  list-style: none;
380
  }
381
+
382
  #optionsbar ul li {
383
  float: none;
384
  margin-right: 0;
385
  }
386
+
387
  #optionsbar p.avatar {
388
  text-align: center !important;
389
  float: none;
394
  margin: 0;
395
  float: none;
396
  }
397
+
398
  #optionsbar h3 {
399
  font: normal 1em "Georgia", Times, serif;
400
  text-transform: uppercase;
403
  padding: 8px 0 17px 0;
404
  letter-spacing: 0.5px;
405
  }
406
+
407
  #optionsbar ul#options-nav {
408
  width: 148px;
409
  margin: 1.75em 0 0 0;
420
  display: block;
421
  text-align: right;
422
  }
423
+
424
  #optionsbar ul.icons li a {
425
  padding-right: 3.1em !important;
426
  margin-right: 0.7em;
427
  }
428
 
429
  /*** Internal Page Left Menu / Main Column **************************************/
430
+
431
  .internal-page .left-menu {
432
  position: relative;
433
  float: left;
439
  padding: 0;
440
  }
441
  .left-menu h5 { margin: 0; font-size: 1em; }
442
+
443
  .left-menu div.button-block {
444
  margin: 20px 0;
445
  }
446
+
447
  .left-menu input { width: 90%; }
448
 
449
  .internal-page .main-column {
474
  }
475
  .left-menu div.bp-widget h4 {
476
  background: url(../images/leftmenu_group_header.gif) top left no-repeat;
477
+ color: #555;
478
  }
479
 
480
  /* "See All" links in widget headers */
481
  div.bp-widget h4 span { position: absolute; right: 10px; }
482
+
483
  div.bp-widget h4 a {
484
  color: #fff;
485
  font-weight: normal;
486
  }
487
+
488
  ul.horiz-gallery {
489
  list-style: none;
490
  overflow: auto;
515
  padding: 10px 10px 10px 10px;
516
  overflow: hidden;
517
  }
518
+
519
  ul.item-list img.avatar {
520
  float: left;
521
  margin-right: 10px;
522
  }
523
+
524
+ ul.item-list h4, ul.item-list h5, ul.item-list .item-title {
525
  font-size: 1em;
526
  margin: 0 0 4px 0;
527
  }
528
+
529
  ul.item-list li .field-data {
530
  margin-left: 68px;
531
  margin-top: 10px;
532
  font-size: 0.9em;
533
  color: #888;
534
  }
535
+
536
  ul.item-list li .desc {
537
  font-size: 0.9em;
538
  color: #888;
547
  text-align: right;
548
  }
549
 
 
 
 
 
550
  div#avatar-crop-submit {
551
  margin: 20px 0 0 0;
552
  }
562
  position: absolute;
563
  top: 45px;
564
  }
565
+
566
  .pagination-links {
567
  text-align: right;
568
  margin-bottom: 5px;
582
  background: #d5d5d5;
583
  border-bottom: 2px solid #f28935;
584
  }
585
+
586
  .pag-count {
587
  font-size: 0.9em;
588
  color: #888;
644
  }
645
  .accept a { background-image: url(../images/accept_button_side.gif); }
646
  .reject a { background-image: url(../images/reject_button_side.gif); }
647
+
648
  .generic-button a:hover {
649
  color: #555;
650
  text-decoration: none;
651
  }
652
+
653
  .friendship-button a.add {
654
  background: url(../images/add_button_side.gif) top right no-repeat;
655
  }
661
  .friendship-button a.requested {
662
  background: url(../images/check_button_side.gif) top right no-repeat;
663
  }
664
+
665
  .loading a {
666
+ background: url(../images/loading_button_side.gif) top right no-repeat !important;
667
  }
668
 
669
  .group-button a.join-group, .group-button a.request-membership {
670
  background: url(../images/add_button_side.gif) top right no-repeat;
671
  }
672
+
673
  .group-button a.leave-group {
674
  background: url(../images/remove_button_side.gif) top right no-repeat;
675
  }
676
+
677
  .group-button a.membership-requested {
678
  background: url(../images/check_button_side.gif) top right no-repeat;
679
  }
680
+
681
  .main-column .button-block {
682
  overflow: hidden;
683
  width: 100%;
729
  font-weight: bold;
730
  margin: 10px 0 5px 0;
731
  }
732
+
733
  form.standard-form input[type=text] {
734
  width: 65%;
735
  }
737
  form.standard-form textarea {
738
  width: 65%;
739
  }
740
+
741
  form.standard-form .checkbox label, form.standard-form .radio label {
742
  font-weight: normal;
743
  display: inline;
783
  .widget ul.item-list {
784
  margin-top: 5px !important;
785
  }
786
+
787
  .widget ul.item-list li .item-avatar img, img.avatar {
788
  border: 3px solid #ddd;
789
  }
790
+
791
  .widget ul.item-list li h4.item-title {
792
  font: normal 1.4em "Georgia", Times, serif;
793
+ margin: 0 0 7px 0;
794
  }
795
+
796
  .widget_bp_blogs_widget_recent_posts img.avatar {
797
  width: 50px !important;
798
  height: 50px !important;
799
+ }
800
+
801
  .widget ul.item-list li .item {
802
  margin-left: 71px;
803
  }
804
  .widget_bp_blogs_recent_posts_widget ul.item-list li .item {
805
  margin-left: 31px !important;
806
  }
807
+
808
  .widget ul.item-list li .item-meta {
809
  font: normal 1em "Georgia", Times, serif;
810
  margin: 10px 0;
811
  }
812
+
813
  .widget .item-options {
814
  text-align: right;
815
  font-size: 0.9em;
816
  margin: -15px 0 0 0;
817
  }
818
+
819
  .widget_bp_core_widget_whos_online .item-avatar {
820
  float: left;
821
  margin-right: 10px;
826
  margin: 10px 0;
827
  text-align: right;
828
  }
829
+
830
  .widget-error {
831
  padding: 10px;
832
  background: #fff9df;
840
  border-bottom: 1px solid #FFE8C4;
841
  display: inline-block;
842
  font: normal 0.9em "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif !important;
843
+ max-width: 60%;
844
  }
845
 
846
  div.avatar-block {
876
  background: #ccc;
877
  cursor: pointer;
878
  }
879
+
880
  .widget table#wp-calendar td#today {
881
  background: #fff9df;
882
  }
883
+
884
  .widget table#wp-calendar td.pad {
885
  background: none;
886
  }
898
  background: url(../images/rightcol_header_back.gif) top left no-repeat;
899
  color: #fff;
900
  }
901
+
902
  #second-section .widget h2 {
903
  background: url(../images/centercol_header_back.gif) top left no-repeat;
904
  color: #fff;
955
  font-family: Georgia, Times, serif;
956
  padding: 3px 5px;
957
  }
958
+
959
  ul#letter-list li a:hover {
960
  font-weight: bold;
961
  background: #fff9df;
962
  color: #f7740a;
963
  }
964
+
965
  ul#letter-list li a.selected {
966
  font-weight: bold;
967
  background: #aaa;
981
 
982
  .post, #comments-template, #compose-reply {
983
  background: url(../images/item_list_back.gif) top left repeat-x;
984
+ padding: 20px 15px;
985
  }
986
  #comments-section, #compose-reply {
987
  background: none;
988
  }
989
+
990
+ ol.commentlist {
991
+ list-style: none;
992
  margin: 0;
993
  padding: 0;
994
  }
1026
  .post .entry {
1027
  margin: 10px 0;
1028
  }
1029
+
1030
  .post span.tags {
1031
  background: url(../images/tag_icon.gif) center left no-repeat;
1032
  padding-left: 1.6em;
1174
  }
1175
 
1176
  .commentlist li.alt { background: #f0f0f0; }
1177
+ .commentlist li img.avatar {
1178
  padding: 0;
1179
  margin: 0 10px 10px 0;
1180
  float: left;
1181
+
1182
  }
1183
  .commentlist li.alt img.avatar { border-color: #fff !important; }
1184
 
1185
+ .commentmetadata {
1186
  font-size: 0.9em;
1187
  border-bottom: 1px solid #ddd;
1188
  padding-bottom: 10px;
1224
  margin: 5px 0 10px 0;
1225
  }
1226
 
1227
+ #basic-details-section input, #basic-details-section textarea,
1228
  #profile-details-section input, #profile-details-section textarea,
1229
  input#signup_blog_title {
1230
  width: 90%;
1259
  margin: 0;
1260
  font-size: 1.4em;
1261
  }
1262
+
1263
 
1264
  /*** Component Specific Styles ****************************************************/
1265
 
1277
  background: none !important;
1278
  }
1279
  ul#activity-filter-links li#afilter-blogs a {
1280
+ background: url(../images/blog_bullet.gif) 20px 4px no-repeat;
1281
  }
1282
+
1283
  ul#activity-filter-links li#afilter-profile a {
1284
  background: url(../images/profile_bullet.gif) 0 4px no-repeat;
1285
  }
1287
  ul#activity-filter-links li#afilter-friends a {
1288
  background: url(../images/friends_bullet.gif) 0 4px no-repeat;
1289
  }
1290
+
1291
  ul#activity-filter-links li#afilter-groups a {
1292
  background: url(../images/groups_bullet.gif) 0 4px no-repeat;
1293
  }
1294
+
1295
  ul#activity-filter-links li#afilter-wire a {
1296
  background: url(../images/wire_bullet.gif) 0 4px no-repeat;
1297
  }
1299
  ul#activity-filter-links li#afilter-status a {
1300
  background: url(../images/status_bullet.gif) 0 4px no-repeat;
1301
  }
1302
+
1303
  .activity-list li div.activity-avatar {
1304
  position: absolute;
1305
  margin: -1px 0 0 -35px;
1307
  .widget .activity-list li div.activity-avatar img.avatar {
1308
  border-width: 2px;
1309
  }
1310
+
1311
  .internal-page .activity-list li div.activity-avatar img.avatar {
1312
  border-top-width: 3px !important;
1313
  border-right-width: 2px !important;
1323
  -moz-border-radius: 5px;
1324
  -webkit-border-radius: 5px;
1325
  }
1326
+ .activity-list li blockquote p {
1327
+ margin: 0;
1328
+ overflow: hidden;
1329
+ }
1330
 
1331
  .activity-list li span.time-since {
1332
  font-size: 0.8em;
1366
  border: 1px solid #ccc;
1367
  font-weight: bold;
1368
  }
1369
+
1370
  ul#activity-filter-links li#afilter-clear a {
1371
  background: url(../images/error_icon.gif) 0 4px no-repeat;
1372
  border-color: #ffa6ac;
1385
  }
1386
 
1387
  #activity-rss p {
1388
+ text-align: right;
1389
+ font-size: 0.9em;
1390
+ margin: -20px 0 5px 0;
1391
  }
1392
+ .profile #activity-rss p {
1393
+ margin-top: 0;
1394
+ }
1395
 
1396
  #activity-rss p a {
1397
  background: url(../images/rss.png) center left no-repeat;
1410
 
1411
  .widget_bp_core_recently_active_widget div.item-avatar {
1412
  display: inline;
1413
+ margin: 0 5px 5px 0;
1414
  }
1415
 
1416
 
1417
  /**** BLOGS *****************/
1418
+
1419
  #blog-info {
1420
  border-bottom: 1px solid #e1e1e1;
1421
  }
1440
  color: #f7740a;
1441
  font: italic 1em Georgia, times, serif;
1442
  }
1443
+
1444
  .post span.tags {
1445
  background: url(../images/tag_icon.gif) center left no-repeat;
1446
  }
1458
  text-transform: uppercase;
1459
  border-bottom: 1px solid #e1e1e1;
1460
  }
1461
+
1462
+
1463
  /*---- Blog Signup Form --------*/
1464
 
1465
  #setupform label {
1470
  background-color: #ff3a3a;
1471
  color: #fff;
1472
  }
1473
+
1474
  .suffix_address, .prefix_address {
1475
  font-size: 1.4em;
1476
  }
1481
  #setupform input#blogname {
1482
  text-align: right;
1483
  }
1484
+
1485
  #setupform input#submit {
1486
  font-size: 1.4em;
1487
  }
1488
+
1489
  /***** FORUMS ***************/
1490
 
1491
  ul#forum-topic-list li {
1496
  .sticky {
1497
  background-image: url( ../images/message_thread_unread_back.gif ) !important;
1498
  }
1499
+
1500
  .closed a.topic-title {
1501
  background: url( ../images/closed.png ) no-repeat center left;
1502
  padding: 0 0 0 20px;
1503
  }
1504
+
1505
+ ul#forum-topic-list li span.latest {
1506
  display: block;
1507
  margin-left: 50px;
1508
  }
1509
+
1510
  ul#forum-topic-list li div.admin-links, ul#topic-post-list li div.admin-links {
1511
  position: absolute;
1512
  top: 1em;
1581
  display: block;
1582
  margin: 10px 0 3px 0;
1583
  }
1584
+
1585
  div#edit-post textarea {
1586
  height: 150px;
1587
  width: 98%;
1636
  position: absolute;
1637
  top: -25px;
1638
  }
1639
+
1640
  table#global-forum-topic-list {
1641
  width: 97%;
1642
  margin: 0 10px;
1644
  table#global-forum-topic-list tr.alt {
1645
  background: url( ../images/message_thread_back.gif ) 0 -2px;
1646
  }
1647
+
1648
  table#global-forum-topic-list td {
1649
  border-top: 1px solid #eee;
1650
  position: relative;
1653
  color: #888;
1654
  font-size: 0.9em;
1655
  }
1656
+
1657
  table#global-forum-topic-list tr th, table#global-forum-topic-list td.td-postcount,
1658
+ table#global-forum-topic-list td.td-freshness {
1659
  text-align: center;
1660
  }
1661
 
1662
+
1663
  table#global-forum-topic-list tr th#th-title, table#global-forum-topic-list tr th#th-poster,
1664
  table#global-forum-topic-list tr th#th-group { text-align: left; }
1665
+
1666
  table#global-forum-topic-list tr td, table#global-forum-topic-list tr th {
1667
  padding: 5px 10px;
1668
  vertical-align: middle;
1669
  }
1670
+
1671
  table#global-forum-topic-list td.td-freshness {
1672
  font-size: 0.9em;
1673
  color: #888;
1674
  }
1675
+
1676
  table#global-forum-topic-list td.td-poster, table#global-forum-topic-list td.td-group {
1677
  min-width: 130px;
1678
  }
1679
+
1680
  table#global-forum-topic-list img.avatar { float:left; }
1681
+
1682
  table#global-forum-topic-list div.poster-name, table#global-forum-topic-list div.object-name {
1683
  margin-left: 35px;
1684
  }
1686
  table#global-forum-topic-list th#th-title {
1687
  width: 40%;
1688
  }
1689
+
1690
  table#global-forum-topic-list th#th-postcount {
1691
  width: 1%;
1692
  }
1693
+
1694
  table#global-forum-topic-list td img {
1695
  vertical-align: middle;
1696
  margin-right: 4px;
1697
+ border-width: 3px !important;
1698
  }
1699
 
1700
  div#popular-group-forum-listing {
1710
  div.group-forum div.item-avatar {
1711
  float: left;
1712
  }
1713
+
1714
  div.group-forum div.item {
1715
  margin-left: 70px;
1716
  }
1718
  font-size: 1.2em;
1719
  font-family: Georgia, times, serif;
1720
  }
1721
+
1722
  div.group-forum div.desc {
1723
  font-size: 0.95em;
1724
  color: #888;
1769
  #group-settings-form .bp-widget ul {
1770
  margin-left: 0;
1771
  }
1772
+
1773
  #invite-list { margin-bottom: 25px; }
1774
+
1775
  #invite-list ul, ul#friend-list {
1776
  margin: 0;
1777
  }
1778
  #invite-list input { width: auto !important; }
1779
+
1780
  #create-group-form textarea, #group-settings-form textarea {
1781
  height: 120px;
1782
  }
1807
  border-color: red !important;
1808
  }
1809
  ul.item-list li.banned-user a { color: red; }
1810
+
1811
  #group-list li span.small, #member-list li span.small, #comment-list li span.small, ul.item-list li span.small {
1812
  font-size: 0.95em;
1813
  color: #888;
1847
  #random-groups-list .desc, #random-groups-list .meta {
1848
  font-size: 0.9em;
1849
  }
1850
+
1851
  #random-groups-list .desc {
1852
+ margin-left: 70px;
1853
  }
1854
+
1855
  #random-groups-list .action {
1856
  text-align: right;
1857
  margin-top: -20px;
1867
  #previous-next input#group-creation-previous {
1868
  width: auto;
1869
  }
1870
+
1871
  #previous-next input#group-creation-next, #previous-next input#group-creation-finish {
1872
  width: auto;
1873
  margin-left: 20px;
1911
  width: 30px;
1912
  margin-bottom: 10px;
1913
  }
1914
+
1915
  div.message-box .message-metadata h3 {
1916
  font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Tahoma, Verdana, Arial, sans-serif;
1917
  font-size: 1em;
1918
  margin: 0 0 5px 0;
1919
  }
1920
+
1921
  div.message-box .message-metadata small {
1922
  font-size: 0.9em;
1923
  color: #888;
1924
  }
1925
+
1926
  div.message-box .message-metadata h3 {
1927
  font-size: 1.1em;
1928
  }
1945
  color: #888;
1946
  font-size: 0.95em;
1947
  }
1948
+
1949
+ .avatar-box {
1950
  border: none !important;
1951
  }
1952
 
1953
  #main #content .avatar-box h3 {
1954
  font: bold 1em "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Tahoma, Verdana, Arial, sans-serif;;
1955
  }
1956
+
1957
  .avatar-box small {
1958
  line-height: 1.5;
1959
  font-size: 0.9em;
1960
  color: #888;
1961
  }
1962
+
1963
  #message_content_tbl { border: 1px solid #ddd; }
1964
  .mceToolbar, .mceStatusbar { background: #eee; }
1965
  .mceToolbar a { color: #bbb !important; }
1966
+
1967
  div.ajax_reply, div.error-box {
1968
  text-align: center;
1969
  background: #EAF3FA;
1994
  font-size: 1.2em;
1995
  font-weight: bold;
1996
  }
1997
+
1998
  form#send-reply textarea {
1999
  width: 98%;
2000
  }
2063
  table.profile-fields tr td, table.wp-profile-fields tr td {
2064
  padding: 0.5em 1em;
2065
  }
2066
+
2067
  table.profile-fields tr td.label, table.wp-profile-fields tr td.label {
2068
  width: 130px;
2069
  }
2092
  color: #888;
2093
  font-size: 0.9em;
2094
  }
2095
+
2096
  .wire-post-content {
2097
  margin-left: 68px;
2098
  }
2119
  margin: 0;
2120
  }
2121
 
2122
+ div#wire-post-new-avatar {
2123
  float: left;
2124
  }
2125
+
2126
  div#wire-post-new-metadata {
2127
  position: absolute;
2128
  bottom: 11px;
2131
  span#wire-by-text {
2132
  display: none;
2133
  }
2134
+
2135
  div#wire-post-new-input {
2136
  margin-left: 70px;
2137
  }
2140
  width: 98%;
2141
  margin: 5px 0 0 0;
2142
  }
2143
+
2144
+ input#wire-post-submit {
2145
  margin-top: 10px;
2146
  }
2147
 
2149
  /**** STATUS UPDATES *************/
2150
 
2151
  div#user-status {
2152
+ margin: 0;
2153
+ padding-bottom: 20px;
2154
  font: normal 1.3em Georgia, times, serif;
2155
  }
2156
  div#user-status a#status-new-status {
2161
  div#user-status div.generic-button a#status-new-status {
2162
  font: normal 11px "Lucida Grande", "Lucida Sans Unicode", Arial, Tahoma, sans-serif;
2163
  }
2164
+
2165
  input#status-update-input, textarea#status-update-input {
2166
  padding: 5px;
2167
  width: 98%;
2168
  font: normal 1em "Lucida Grande", "Lucida Sans Unicode", Arial, Tahoma, sans-serif;
2169
  color: #888;
2170
  }
2171
+
2172
  div#status-update-buttons {
2173
  margin: 10px 0 0 0;
2174
+ }
2175
  div#status-update-buttons input {
2176
  width: auto;
2177
  }
2178
+
2179
  div#user-status label {
2180
  display: block;
2181
  font: normal 1em Georgia, times, serif;
2183
  font-style: italic;
2184
  padding: 0 0 5px 0;
2185
  }
2186
+
2187
  a#status-new-status, a#status-clear-status {
2188
  padding-top: 2px;
2189
  font: normal 11px "Lucida Grande", "Lucida Sans Unicode", Arial, Tahoma, sans-serif;
2190
  }
2191
  a#status-clear-status { color: red; }
2192
+
2193
  div#user-status span.time-since {
2194
  color: #aaa;
2195
  font: normal 11px "Lucida Grande", "Lucida Sans Unicode", Arial, Tahoma, sans-serif;
2218
  table.notification-settings td {
2219
  padding: 3px 0;
2220
  }
2221
+
2222
  table.notification-settings th.icon {
2223
  width: 35px;
2224
  }
2225
+
2226
  table.notification-settings th.title {
2227
  width: 80%;
2228
  }
2229
+
2230
  table.notification-settings .yes, table.notification-settings .no {
2231
  width: 40px;
2232
  }
2240
  table.notification-settings th {
2241
  font-weight: bold;
2242
  }
2243
+
2244
  table.notification-settings tr {
2245
  border-bottom: 1px solid #eee;
2246
  }
2247
+
2248
  table.notification-settings th.icon {
2249
  background: center center no-repeat;
2250
  }
bp-themes/bp-default/_inc/images/accept_button.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/accept_button_side.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/activity_bullet.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/add_button_side.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/add_friend_button.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/add_friend_icon.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/admin-menu-arrow.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/admin_bar_back.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/admin_bar_logo.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/admin_menu_icon.png CHANGED
File without changes
bp-themes/bp-default/_inc/images/ajax-loader.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/arrowback_icon.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/background.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/background_blog.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/blog.png CHANGED
File without changes
bp-themes/bp-default/_inc/images/blog_bullet.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/blogadmin_icon.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/bp_logo.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/button_back.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/centercol_header_back.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/check_button_side.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/closed.png CHANGED
File without changes
bp-themes/bp-default/_inc/images/comments_icon.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/content_back.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/content_header.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/create_account_button.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/cross_bullet.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/error_back.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/error_icon.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/forum_bullet.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/friends_bullet.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/group_header.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/groups_bullet.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/info_icon.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/invite_bullet.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/item_list_back.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/leftcol_header_back.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/leftmenu_group_header.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/loading_button_side.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/logo.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/logout_bullet.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/member.png CHANGED
File without changes
bp-themes/bp-default/_inc/images/message_thread_back.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/message_thread_unread_back.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/messages_bullet.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/mystery-man.jpg CHANGED
File without changes
bp-themes/bp-default/_inc/images/nav_bullet.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/navitem_selected_back.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/notice_back.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/optionnavitem_selected_back.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/optionsbar_header_arrow.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/optionsbar_header_noarrow.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/profile_bullet.gif CHANGED
File without changes
bp-themes/bp-default/_inc/images/quotes_background.gif → bp RENAMED
File without changes