BuddyPress - Version 1.0

Version Description

Download this release

Release Info

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

Version 1.0

Files changed (134) hide show
  1. bp-activity.php +307 -0
  2. bp-activity/bp-activity-classes.php +332 -0
  3. bp-activity/bp-activity-cssjs.php +10 -0
  4. bp-activity/bp-activity-filters.php +16 -0
  5. bp-activity/bp-activity-templatetags.php +347 -0
  6. bp-activity/bp-activity-widgets.php +84 -0
  7. bp-activity/css/structure.css +15 -0
  8. bp-activity/css/widget-activity.css +9 -0
  9. bp-activity/feeds/bp-activity-friends-feed.php +44 -0
  10. bp-activity/feeds/bp-activity-personal-feed.php +44 -0
  11. bp-activity/feeds/bp-activity-sitewide-feed.php +45 -0
  12. bp-activity/images/rss.png +0 -0
  13. bp-blogs.php +862 -0
  14. bp-blogs/admin-tabs/admin.css +56 -0
  15. bp-blogs/admin-tabs/bp-blogs-comments-tab.php +3 -0
  16. bp-blogs/admin-tabs/bp-blogs-posts-tab.php +3 -0
  17. bp-blogs/admin-tabs/bp-blogs-tab.php +3 -0
  18. bp-blogs/bp-blogs-ajax.php +12 -0
  19. bp-blogs/bp-blogs-classes.php +665 -0
  20. bp-blogs/bp-blogs-cssjs.php +10 -0
  21. bp-blogs/bp-blogs-templatetags.php +1322 -0
  22. bp-blogs/bp-blogs-widgets.php +85 -0
  23. bp-blogs/css/structure.css +84 -0
  24. bp-blogs/css/widget-blogs.css +29 -0
  25. bp-blogs/js/directory-blogs.js +104 -0
  26. bp-core.php +1349 -0
  27. bp-core/bp-core-activation.php +128 -0
  28. bp-core/bp-core-admin.php +275 -0
  29. bp-core/bp-core-adminbar.php +281 -0
  30. bp-core/bp-core-ajax-handler.php +11 -0
  31. bp-core/bp-core-ajax.php +76 -0
  32. bp-core/bp-core-avatars.php +498 -0
  33. bp-core/bp-core-catchuri.php +302 -0
  34. bp-core/bp-core-classes.php +363 -0
  35. bp-core/bp-core-cssjs.php +190 -0
  36. bp-core/bp-core-notifications.php +98 -0
  37. bp-core/bp-core-settings.php +201 -0
  38. bp-core/bp-core-signup.php +420 -0
  39. bp-core/bp-core-templatetags.php +1127 -0
  40. bp-core/bp-core-widgets.php +231 -0
  41. bp-core/css/admin-bar.css +234 -0
  42. bp-core/css/structure.css +321 -0
  43. bp-core/css/widget-members.css +22 -0
  44. bp-core/images/accept_button_side.gif +0 -0
  45. bp-core/images/add_button_side.gif +0 -0
  46. bp-core/images/add_friend_button.gif +0 -0
  47. bp-core/images/admin-menu-arrow.gif +0 -0
  48. bp-core/images/admin_bar_back.gif +0 -0
  49. bp-core/images/admin_bar_logo.gif +0 -0
  50. bp-core/images/ajax-loader.gif +0 -0
  51. bp-core/images/blog.png +0 -0
  52. bp-core/images/button_back.gif +0 -0
  53. bp-core/images/check_button_side.gif +0 -0
  54. bp-core/images/loading_button_side.gif +0 -0
  55. bp-core/images/logout_bullet.gif +0 -0
  56. bp-core/images/member.png +0 -0
  57. bp-core/images/mystery-man.jpg +0 -0
  58. bp-core/images/nav_bullet.gif +0 -0
  59. bp-core/images/reject_button_side.gif +0 -0
  60. bp-core/images/remove_button_side.gif +0 -0
  61. bp-core/images/remove_friend_button.gif +0 -0
  62. bp-core/images/requested_friend_button.gif +0 -0
  63. bp-core/images/view_button_side.gif +0 -0
  64. bp-core/js/account-admin.js +64 -0
  65. bp-core/js/directory-members.js +111 -0
  66. bp-core/js/general.js +112 -0
  67. bp-core/js/jquery/jquery.livequery.pack.js +9 -0
  68. bp-core/js/jquery/jquery.tablednd.js +314 -0
  69. bp-core/js/widget-members.js +49 -0
  70. bp-forums.php +198 -0
  71. bp-forums/bbpress-plugins/buddypress-enable.php +59 -0
  72. bp-forums/bp-forums-admin.php +121 -0
  73. bp-forums/bp-forums-bbpress-live.php +683 -0
  74. bp-forums/bp-forums-filters.php +61 -0
  75. bp-forums/bp-forums-templatetags.php +601 -0
  76. bp-forums/installation-readme.txt +73 -0
  77. bp-friends.php +664 -0
  78. bp-friends/bp-friends-ajax.php +41 -0
  79. bp-friends/bp-friends-classes.php +329 -0
  80. bp-friends/bp-friends-cssjs.php +22 -0
  81. bp-friends/bp-friends-notifications.php +75 -0
  82. bp-friends/bp-friends-templatetags.php +463 -0
  83. bp-friends/css/structure.css +28 -0
  84. bp-friends/images/ajax-loader.gif +0 -0
  85. bp-friends/js/general.js +73 -0
  86. bp-groups.php +2352 -0
  87. bp-groups/bp-groups-admin.php +129 -0
  88. bp-groups/bp-groups-ajax.php +271 -0
  89. bp-groups/bp-groups-classes.php +951 -0
  90. bp-groups/bp-groups-cssjs.php +36 -0
  91. bp-groups/bp-groups-filters.php +54 -0
  92. bp-groups/bp-groups-notifications.php +271 -0
  93. bp-groups/bp-groups-templatetags.php +2361 -0
  94. bp-groups/bp-groups-widgets.php +113 -0
  95. bp-groups/css/structure.css +38 -0
  96. bp-groups/css/widget-groups.css +22 -0
  97. bp-groups/images/ajax-loader.gif +0 -0
  98. bp-groups/images/none-thumbnail.gif +0 -0
  99. bp-groups/images/none.gif +0 -0
  100. bp-groups/js/directory-groups.js +138 -0
  101. bp-groups/js/general.js +197 -0
  102. bp-groups/js/widget-groups.js +49 -0
  103. bp-languages/buddypress.pot +4501 -0
  104. bp-loader.php +54 -0
  105. bp-messages.php +602 -0
  106. bp-messages/autocomplete/bp-messages-autocomplete.php +22 -0
  107. bp-messages/bp-messages-ajax.php +91 -0
  108. bp-messages/bp-messages-classes.php +563 -0
  109. bp-messages/bp-messages-cssjs.php +39 -0
  110. bp-messages/bp-messages-filters.php +48 -0
  111. bp-messages/bp-messages-notifications.php +81 -0
  112. bp-messages/bp-messages-templatetags.php +562 -0
  113. bp-messages/css/autocomplete/jquery.autocompletefb.css +83 -0
  114. bp-messages/css/structure.css +96 -0
  115. bp-messages/images/ajax-loader.gif +0 -0
  116. bp-messages/images/email.gif +0 -0
  117. bp-messages/images/email_draft.gif +0 -0
  118. bp-messages/images/email_open.gif +0 -0
  119. bp-messages/images/email_sent.gif +0 -0
  120. bp-messages/images/loading.gif +0 -0
  121. bp-messages/images/nav_bullet.gif +0 -0
  122. bp-messages/images/warning.gif +0 -0
  123. bp-messages/js/autocomplete/init.php +16 -0
  124. bp-messages/js/autocomplete/jquery.autocomplete.js +728 -0
  125. bp-messages/js/autocomplete/jquery.autocompletefb.js +68 -0
  126. bp-messages/js/autocomplete/jquery.bgiframe.min.js +10 -0
  127. bp-messages/js/autocomplete/jquery.dimensions.js +116 -0
  128. bp-messages/js/general.js +297 -0
  129. bp-themes/bphome/404.php +40 -0
  130. bp-themes/bphome/activate.php +25 -0
  131. bp-themes/bphome/archive.php +69 -0
  132. bp-themes/bphome/archives.php +25 -0
  133. bp-themes/bphome/attachment.php +33 -0
  134. bp-themes/bphome/comments-popup.php +87 -0
bp-activity.php ADDED
@@ -0,0 +1,307 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ define ( 'BP_ACTIVITY_VERSION', '1.0' );
4
+ define ( 'BP_ACTIVITY_DB_VERSION', '1300' );
5
+
6
+ /* Define the slug for the component */
7
+ if ( !defined( 'BP_ACTIVITY_SLUG' ) )
8
+ define ( 'BP_ACTIVITY_SLUG', 'activity' );
9
+
10
+ /* How long before activity items in streams are re-cached? */
11
+ if ( !defined( 'BP_ACTIVITY_CACHE_LENGTH' ) )
12
+ define ( 'BP_ACTIVITY_CACHE_LENGTH', '6 HOURS' );
13
+
14
+ require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-classes.php' );
15
+ require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-templatetags.php' );
16
+ require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-widgets.php' );
17
+ require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-cssjs.php' );
18
+ require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-filters.php' );
19
+
20
+
21
+ /**************************************************************************
22
+ bp_bp_activity_install()
23
+
24
+ Sets up the component ready for use on a site installation.
25
+ **************************************************************************/
26
+
27
+ function bp_activity_install() {
28
+ global $wpdb, $bp;
29
+
30
+ if ( !empty($wpdb->charset) )
31
+ $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
32
+
33
+ $sql[] = "CREATE TABLE {$bp->activity->table_name_user_activity} (
34
+ id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
35
+ user_id bigint(20) NOT NULL,
36
+ component_name varchar(75) NOT NULL,
37
+ component_action varchar(75) NOT NULL,
38
+ item_id bigint(20) NOT NULL,
39
+ secondary_item_id bigint(20) NOT NULL,
40
+ date_recorded datetime NOT NULL,
41
+ is_private tinyint(1) NOT NULL DEFAULT 0,
42
+ no_sitewide_cache tinyint(1) NOT NULL DEFAULT 0,
43
+ KEY item_id (item_id),
44
+ KEY user_id (user_id),
45
+ KEY is_private (is_private),
46
+ KEY component_name (component_name)
47
+ ) {$charset_collate};";
48
+
49
+ $sql[] = "CREATE TABLE {$bp->activity->table_name_user_activity_cached} (
50
+ id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
51
+ user_id bigint(20) NOT NULL,
52
+ component_name varchar(75) NOT NULL,
53
+ component_action varchar(75) NOT NULL,
54
+ content longtext NOT NULL,
55
+ primary_link varchar(150) NOT NULL,
56
+ item_id bigint(20) NOT NULL,
57
+ secondary_item_id bigint(20) NOT NULL,
58
+ date_cached datetime NOT NULL,
59
+ date_recorded datetime NOT NULL,
60
+ is_private tinyint(1) NOT NULL DEFAULT 0,
61
+ KEY date_cached (date_cached),
62
+ KEY date_recorded (date_recorded),
63
+ KEY is_private (is_private),
64
+ KEY user_id (user_id),
65
+ KEY item_id (item_id),
66
+ KEY component_name (component_name)
67
+ ) {$charset_collate};";
68
+
69
+ $sql[] = "CREATE TABLE {$bp->activity->table_name_sitewide} (
70
+ id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
71
+ user_id bigint(20) NOT NULL,
72
+ item_id bigint(20) NOT NULL,
73
+ secondary_item_id bigint(20),
74
+ content longtext NOT NULL,
75
+ primary_link varchar(150) NOT NULL,
76
+ component_name varchar(75) NOT NULL,
77
+ component_action varchar(75) NOT NULL,
78
+ date_cached datetime NOT NULL,
79
+ date_recorded datetime NOT NULL,
80
+ KEY date_cached (date_cached),
81
+ KEY date_recorded (date_recorded),
82
+ KEY user_id (user_id),
83
+ KEY item_id (item_id),
84
+ KEY component_name (component_name)
85
+ ) {$charset_collate};";
86
+
87
+ require_once( ABSPATH . 'wp-admin/upgrade-functions.php' );
88
+ dbDelta($sql);
89
+
90
+ if ( '' == get_site_option( 'bp-activity-db-merge' ) || !get_site_option( 'bp-activity-db-merge' ) ) {
91
+ $users = $wpdb->get_col( "SELECT ID FROM " . CUSTOM_USER_TABLE );
92
+
93
+ foreach ( $users as $user_id ) {
94
+ BP_Activity_Activity::convert_tables_for_user( $user_id );
95
+ BP_Activity_Activity::kill_tables_for_user( $user_id );
96
+ }
97
+
98
+ add_site_option( 'bp-activity-db-merge', 1 );
99
+ }
100
+
101
+ update_site_option( 'bp-activity-db-version', BP_ACTIVITY_DB_VERSION );
102
+ }
103
+
104
+ /**************************************************************************
105
+ bp_activity_setup_globals()
106
+
107
+ Set up and add all global variables for this component, and add them to
108
+ the $bp global variable array.
109
+ **************************************************************************/
110
+
111
+ function bp_activity_setup_globals() {
112
+ global $bp, $wpdb, $current_blog;
113
+
114
+ $bp->activity->table_name_user_activity = $wpdb->base_prefix . 'bp_activity_user_activity';
115
+ $bp->activity->table_name_user_activity_cached = $wpdb->base_prefix . 'bp_activity_user_activity_cached';
116
+ $bp->activity->table_name_sitewide = $wpdb->base_prefix . 'bp_activity_sitewide';
117
+
118
+ $bp->activity->image_base = BP_PLUGIN_URL . '/bp-activity/images';
119
+ $bp->activity->slug = BP_ACTIVITY_SLUG;
120
+
121
+ $bp->version_numbers->activity = BP_ACTIVITY_VERSION;
122
+
123
+ if ( is_site_admin() && get_site_option( 'bp-activity-db-version' ) < BP_ACTIVITY_DB_VERSION )
124
+ bp_activity_install();
125
+ }
126
+ add_action( 'plugins_loaded', 'bp_activity_setup_globals', 5 );
127
+ add_action( 'admin_menu', 'bp_activity_setup_globals', 1 );
128
+
129
+ function bp_activity_setup_root_component() {
130
+ /* Register 'groups' as a root component */
131
+ bp_core_add_root_component( BP_ACTIVITY_SLUG );
132
+ }
133
+ add_action( 'plugins_loaded', 'bp_activity_setup_root_component', 1 );
134
+
135
+
136
+ /**************************************************************************
137
+ bp_activity_setup_nav()
138
+
139
+ Set up front end navigation.
140
+ **************************************************************************/
141
+
142
+ function bp_activity_setup_nav() {
143
+ global $bp;
144
+
145
+ /* Add 'Activity' to the main navigation */
146
+ bp_core_add_nav_item( __('Activity', 'buddypress'), $bp->activity->slug );
147
+ bp_core_add_nav_default( $bp->activity->slug, 'bp_activity_screen_my_activity', 'just-me' );
148
+
149
+ $activity_link = $bp->loggedin_user->domain . $bp->activity->slug . '/';
150
+
151
+ /* Add the subnav items to the activity nav item */
152
+ bp_core_add_subnav_item( $bp->activity->slug, 'just-me', __('Just Me', 'buddypress'), $activity_link, 'bp_activity_screen_my_activity' );
153
+ bp_core_add_subnav_item( $bp->activity->slug, 'my-friends', __('My Friends', 'buddypress'), $activity_link, 'bp_activity_screen_friends_activity', 'activity-my-friends', bp_is_home() );
154
+
155
+ if ( $bp->current_component == $bp->activity->slug ) {
156
+ if ( bp_is_home() ) {
157
+ $bp->bp_options_title = __( 'My Activity', 'buddypress' );
158
+ } else {
159
+ $bp->bp_options_avatar = bp_core_get_avatar( $bp->displayed_user->id, 1 );
160
+ $bp->bp_options_title = $bp->displayed_user->fullname;
161
+ }
162
+ }
163
+ }
164
+ add_action( 'wp', 'bp_activity_setup_nav', 2 );
165
+ add_action( 'admin_menu', 'bp_activity_setup_nav', 2 );
166
+
167
+ /***** Screens **********/
168
+
169
+ function bp_activity_screen_my_activity() {
170
+ do_action( 'bp_activity_screen_my_activity' );
171
+ bp_core_load_template( apply_filters( 'bp_activity_template_my_activity', 'activity/just-me' ) );
172
+ }
173
+
174
+ function bp_activity_screen_friends_activity() {
175
+ do_action( 'bp_activity_screen_friends_activity' );
176
+ bp_core_load_template( apply_filters( 'bp_activity_template_friends_activity', 'activity/my-friends' ) );
177
+ }
178
+
179
+ /***** Actions **********/
180
+
181
+ 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 ) {
182
+ global $bp, $wpdb;
183
+
184
+ if ( !$user_id )
185
+ $user_id = $bp->loggedin_user->id;
186
+
187
+ if ( !$recorded_time )
188
+ $recorded_time = time();
189
+
190
+ $activity = new BP_Activity_Activity;
191
+ $activity->item_id = $item_id;
192
+ $activity->secondary_item_id = $secondary_item_id;
193
+ $activity->user_id = $user_id;
194
+ $activity->component_name = $component_name;
195
+ $activity->component_action = $component_action;
196
+ $activity->date_recorded = $recorded_time;
197
+ $activity->is_private = $is_private;
198
+
199
+ $loggedin_user_save = $activity->save();
200
+
201
+ /* Save an activity entry for both logged in and secondary user. For example for a new friend connection
202
+ you would want to show "X and Y are now friends" on both users activity stream */
203
+ if ( $secondary_user_id ) {
204
+ $activity = new BP_Activity_Activity;
205
+ $activity->item_id = $item_id;
206
+ $activity->user_id = $secondary_user_id;
207
+ $activity->component_name = $component_name;
208
+ $activity->component_action = $component_action;
209
+ $activity->date_recorded = $recorded_time;
210
+ $activity->is_private = $is_private;
211
+
212
+ // We don't want to record this on the sitewide stream, otherwise we will get duplicates.
213
+ $activity->no_sitewide_cache = true;
214
+
215
+ $secondary_user_save = $activity->save();
216
+ }
217
+
218
+ do_action( 'bp_activity_record', $item_id, $component_name, $component_action, $is_private, $secondary_item_id, $user_id, $secondary_user_id );
219
+
220
+ return true;
221
+ }
222
+
223
+ function bp_activity_action_sitewide_feed() {
224
+ global $bp, $wp_query;
225
+
226
+ if ( $bp->current_component != $bp->activity->slug || $bp->current_action != 'feed' || $bp->displayed_user->id )
227
+ return false;
228
+
229
+ $wp_query->is_404 = false;
230
+ status_header( 200 );
231
+
232
+ include_once( 'bp-activity/feeds/bp-activity-sitewide-feed.php' );
233
+ die;
234
+ }
235
+ add_action( 'wp', 'bp_activity_action_sitewide_feed', 3 );
236
+
237
+ function bp_activity_action_personal_feed() {
238
+ global $bp, $wp_query;
239
+
240
+ if ( $bp->current_component != $bp->activity->slug || !$bp->displayed_user->id || $bp->current_action != 'feed' )
241
+ return false;
242
+
243
+ $wp_query->is_404 = false;
244
+ status_header( 200 );
245
+
246
+ include_once( 'bp-activity/feeds/bp-activity-personal-feed.php' );
247
+ die;
248
+ }
249
+ add_action( 'wp', 'bp_activity_action_personal_feed', 3 );
250
+
251
+ function bp_activity_action_friends_feed() {
252
+ global $bp, $wp_query;
253
+
254
+ if ( $bp->current_component != $bp->activity->slug || !$bp->displayed_user->id || $bp->current_action != 'my-friends' || $bp->action_variables[0] != 'feed' )
255
+ return false;
256
+
257
+ $wp_query->is_404 = false;
258
+ status_header( 200 );
259
+
260
+ include_once( 'bp-activity/feeds/bp-activity-friends-feed.php' );
261
+ die;
262
+ }
263
+ add_action( 'wp', 'bp_activity_action_friends_feed', 3 );
264
+
265
+ function bp_activity_get_last_updated() {
266
+ return BP_Activity_Activity::get_last_updated();
267
+ }
268
+
269
+ function bp_activity_get_sitewide_activity( $max_items = 30, $pag_num = false, $pag_page = false ) {
270
+ return BP_Activity_Activity::get_sitewide_activity( $max_items, $pag_num, $pag_page );
271
+ }
272
+
273
+ function bp_activity_get_user_activity( $user_id, $max_items = 30, $since = '-4 weeks', $pag_num = false, $pag_page = false ) {
274
+ return BP_Activity_Activity::get_activity_for_user( $user_id, $max_items, $since, $pag_num, $pag_page );
275
+ }
276
+
277
+ function bp_activity_get_friends_activity( $user_id, $max_items = 30, $since = '-4 weeks', $max_items_per_friend = false, $pag_num = false, $pag_page = false ) {
278
+ return BP_Activity_Activity::get_activity_for_friends( $user_id, $max_items, $since, $max_items_per_friend, $pag_num, $pag_page );
279
+ }
280
+
281
+ function bp_activity_delete( $item_id, $component_name, $component_action, $user_id, $secondary_item_id ) {
282
+ if ( !BP_Activity_Activity::delete( $item_id, $component_name, $component_action, $user_id, $secondary_item_id ) )
283
+ return false;
284
+
285
+ do_action( 'bp_activity_delete', $item_id, $component_name, $component_action, $user_id, $secondary_item_id );
286
+
287
+ return true;
288
+ }
289
+
290
+ function bp_activity_order_by_date( $a, $b ) {
291
+ return strcasecmp( $b['date_recorded'], $a['date_recorded'] );
292
+ }
293
+
294
+ function bp_activity_remove_data( $user_id ) {
295
+ // Clear the user's activity from the sitewide stream and clear their activity tables
296
+ BP_Activity_Activity::delete_activity_for_user( $user_id );
297
+
298
+ // Remove the deleted users activity tables
299
+ BP_Activity_Activity::kill_tables_for_user( $user_id );
300
+
301
+ do_action( 'bp_activity_remove_data', $user_id );
302
+ }
303
+ add_action( 'wpmu_delete_user', 'bp_activity_remove_data' );
304
+ add_action( 'delete_user', 'bp_activity_remove_data' );
305
+
306
+
307
+ ?>
bp-activity/bp-activity-classes.php ADDED
@@ -0,0 +1,332 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ Class BP_Activity_Activity {
4
+ var $id;
5
+ var $item_id;
6
+ var $secondary_item_id;
7
+ var $user_id;
8
+ var $primary_link;
9
+ var $component_name;
10
+ var $component_action;
11
+ var $date_recorded;
12
+ var $is_private = false;
13
+ var $no_sitewide_cache = false;
14
+
15
+ var $table_name;
16
+ var $table_name_cached;
17
+ var $for_secondary_user = false;
18
+
19
+ function bp_activity_activity( $id = null, $populate = true ) {
20
+ global $bp;
21
+
22
+ if ( $id ) {
23
+ $this->id = $id;
24
+
25
+ if ( $populate )
26
+ $this->populate();
27
+ }
28
+ }
29
+
30
+ function populate() {
31
+ global $wpdb, $bp;
32
+
33
+ $activity = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$this->table_name} WHERE id = %d", $this->id ) );
34
+
35
+ $this->item_id = $activity->item_id;
36
+ $this->secondary_item_id = $activity->secondary_item_id;
37
+ $this->user_id = $activity->user_id;
38
+ $this->component_name = $activity->component_name;
39
+ $this->component_action = $activity->component_action;
40
+ $this->date_recorded = $activity->date_recorded;
41
+ $this->is_private = $activity->is_private;
42
+ $this->no_sitewide_cache = $activity->no_sitewide_cache;
43
+ }
44
+
45
+ function save() {
46
+ global $wpdb, $bp, $current_user;
47
+
48
+ do_action( 'bp_activity_before_save', $this );
49
+
50
+ if ( !$this->item_id || !$this->user_id || $this->is_private || !$this->component_name )
51
+ return false;
52
+
53
+ // Set the table names
54
+ $this->table_name = $bp->activity->table_name_user_activity;
55
+ $this->table_name_cached = $bp->activity->table_name_user_activity_cached;
56
+
57
+ if ( !$this->exists() ) {
58
+ // Insert the new activity into the activity table.
59
+ $activity = $wpdb->query( $wpdb->prepare( "INSERT INTO {$this->table_name} ( item_id, secondary_item_id, user_id, component_name, component_action, date_recorded, is_private, no_sitewide_cache ) VALUES ( %d, %d, %d, %s, %s, FROM_UNIXTIME(%d), %d, %d )", $this->item_id, $this->secondary_item_id, $this->user_id, $this->component_name, $this->component_action, $this->date_recorded, $this->is_private, $this->no_sitewide_cache ) );
60
+
61
+ // Fetch the formatted activity content so we can add it to the cache.
62
+ if ( function_exists( $bp->{$this->component_name}->format_activity_function ) ) {
63
+ if ( !$activity_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 ) )
64
+ return false;
65
+ }
66
+
67
+ // Add the cached version of the activity to the cached activity table.
68
+ $activity_cached = $wpdb->query( $wpdb->prepare( "INSERT INTO {$this->table_name_cached} ( user_id, item_id, secondary_item_id, content, primary_link, component_name, component_action, date_cached, date_recorded, is_private ) VALUES ( %d, %d, %d, %s, %s, %s, %s, FROM_UNIXTIME(%d), FROM_UNIXTIME(%d), %d )", $this->user_id, $this->item_id, $this->secondary_item_id, $activity_content['content'], $activity_content['primary_link'], $this->component_name, $this->component_action, time(), $this->date_recorded, $this->is_private ) );
69
+
70
+ // Add the cached version of the activity to the sitewide activity table.
71
+ if ( !$this->no_sitewide_cache )
72
+ $sitewide_cached = $wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->activity->table_name_sitewide} ( user_id, item_id, secondary_item_id, content, primary_link, component_name, component_action, date_cached, date_recorded ) VALUES ( %d, %d, %d, %s, %s, %s, %s, FROM_UNIXTIME(%d), FROM_UNIXTIME(%d) )", $this->user_id, $this->item_id, $this->secondary_item_id, $activity_content['content'], $activity_content['primary_link'], $this->component_name, $this->component_action, time(), $this->date_recorded ) );
73
+
74
+ if ( $activity && $activity_cached ) {
75
+ do_action( 'bp_activity_after_save', $this );
76
+ return true;
77
+ }
78
+
79
+ return false;
80
+ }
81
+ }
82
+
83
+ function exists() {
84
+ global $wpdb, $bp;
85
+ return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$this->table_name} WHERE item_id = %d AND secondary_item_id = %d AND user_id = %d AND component_name = %s AND component_action = %s", $this->item_id, $this->secondary_item_id, $this->user_id, $this->component_name, $this->component_action ) );
86
+ }
87
+
88
+ /* Static Functions */
89
+
90
+ function delete( $item_id, $component_name, $component_action, $user_id, $secondary_item_id = false ) {
91
+ global $wpdb, $bp;
92
+
93
+ if ( !$user_id )
94
+ return false;
95
+
96
+ if ( !$bp->activity )
97
+ bp_activity_setup_globals();
98
+
99
+ if ( $secondary_item_id )
100
+ $secondary_sql = $wpdb->prepare( "AND secondary_item_id = %d", $secondary_item_id );
101
+
102
+ if ( $component_action ) {
103
+ $component_action_sql = $wpdb->prepare( "AND component_action = %s AND user_id = %d", $component_action, $user_id );
104
+ $cached_component_action_sql = $wpdb->prepare( "AND component_action = %s", $component_action );
105
+ }
106
+
107
+ $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name_user_activity} WHERE item_id = %d {$secondary_sql} AND component_name = %s {$component_action_sql}", $item_id, $component_name ) );
108
+
109
+ // Delete this entry from the user activity cache table and the sitewide cache table
110
+ $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name_user_activity_cached} WHERE user_id = %d AND item_id = %d {$secondary_sql} AND component_name = %s {$cached_component_action_sql}", $user_id, $item_id, $component_name ) );
111
+ $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name_sitewide} WHERE item_id = %d {$secondary_sql} AND component_name = %s {$component_action_sql}", $item_id, $component_name ) );
112
+
113
+ return true;
114
+ }
115
+
116
+ function get_activity_for_user( $user_id, $max_items, $since, $limit, $page ) {
117
+ global $wpdb, $bp;
118
+
119
+ $since = strtotime($since);
120
+
121
+ if ( $limit && $page )
122
+ $pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
123
+
124
+ if ( $max )
125
+ $max_sql = $wpdb->prepare( "LIMIT %d", $max );
126
+
127
+ if ( !bp_is_home() )
128
+ $privacy_sql = " AND is_private = 0";
129
+
130
+ if ( $limit && $page && $max )
131
+ $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name_user_activity_cached} WHERE user_id = %d AND date_recorded >= FROM_UNIXTIME(%d) $privacy_sql ORDER BY date_recorded DESC $pag_sql", $user_id, $since ) );
132
+ else
133
+ $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name_user_activity_cached} WHERE user_id = %d AND date_recorded >= FROM_UNIXTIME(%d) $privacy_sql ORDER BY date_recorded DESC $pag_sql $max_sql", $user_id, $since ) );
134
+
135
+ $total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->activity->table_name_user_activity_cached} WHERE user_id = %d AND date_recorded >= FROM_UNIXTIME(%d) $privacy_sql ORDER BY date_recorded DESC $max_sql", $user_id, $since ) );
136
+
137
+ for ( $i = 0; $i < count( $activities ); $i++ ) {
138
+ if ( !$activities[$i]->is_private ) {
139
+ $activities_formatted[$i]['content'] = $activities[$i]->content;
140
+ $activities_formatted[$i]['primary_link'] = $activities[$i]->primary_link;
141
+ $activities_formatted[$i]['date_recorded'] = $activities[$i]->date_recorded;
142
+ $activities_formatted[$i]['component_name'] = $activities[$i]->component_name;
143
+ $activities_formatted[$i]['component_action'] = $activities[$i]->component_action;
144
+ $activities_formatted[$i]['is_private'] = $activities[$i]->is_private;
145
+ }
146
+ }
147
+
148
+ return array( 'activities' => $activities_formatted, 'total' => (int)$total_activities );
149
+ }
150
+
151
+ function get_activity_for_friends( $user_id, $max_items, $since, $max_items_per_friend, $limit, $page ) {
152
+ global $wpdb, $bp;
153
+
154
+ // TODO: Max items per friend not yet implemented.
155
+
156
+ if ( !function_exists('friends_get_friend_user_ids') )
157
+ return false;
158
+
159
+ if ( $limit && $page )
160
+ $pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
161
+
162
+ if ( $max )
163
+ $max_sql = $wpdb->prepare( "LIMIT %d", $max );
164
+
165
+ $since = strtotime($since);
166
+
167
+ $friend_ids = friends_get_friend_user_ids( $user_id );
168
+
169
+ if ( !$friend_ids )
170
+ return false;
171
+
172
+ $friend_ids = implode( ',', $friend_ids );
173
+
174
+ if ( $limit && $page && $max )
175
+ $activities = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT user_id, content, primary_link, date_recorded, component_name, component_action FROM {$bp->activity->table_name_sitewide} WHERE user_id IN ({$friend_ids}) AND date_recorded >= FROM_UNIXTIME(%d) ORDER BY date_recorded DESC $pag_sql", $since ) );
176
+ else
177
+ $activities = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT user_id, content, primary_link, date_recorded, component_name, component_action FROM {$bp->activity->table_name_sitewide} WHERE user_id IN ({$friend_ids}) AND date_recorded >= FROM_UNIXTIME(%d) ORDER BY date_recorded DESC $pag_sql $max_sql", $since ) );
178
+
179
+ $total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(user_id) FROM {$bp->activity->table_name_sitewide} WHERE user_id IN ({$friend_ids}) AND date_recorded >= FROM_UNIXTIME(%d) ORDER BY date_recorded DESC $max_sql", $since ) );
180
+
181
+ return array( 'activities' => $activities, 'total' => (int)$total_activities );
182
+ }
183
+
184
+ function get_sitewide_activity( $max, $limit, $page ) {
185
+ global $wpdb, $bp;
186
+
187
+ if ( $limit && $page )
188
+ $pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
189
+
190
+ if ( $max )
191
+ $max_sql = $wpdb->prepare( "LIMIT %d", $max );
192
+
193
+ /* Remove entries that are older than 6 months */
194
+ $wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp->activity->table_name_sitewide . " WHERE DATE_ADD(date_recorded, INTERVAL 6 MONTH) <= NOW()" ) );
195
+
196
+ if ( $limit && $page && $max )
197
+ $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name_sitewide} ORDER BY date_recorded DESC $pag_sql" ) );
198
+ else
199
+ $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name_sitewide} ORDER BY date_recorded DESC $pag_sql $max_sql" ) );
200
+
201
+ $total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->activity->table_name_sitewide} ORDER BY date_recorded DESC $max_sql" ) );
202
+
203
+ for ( $i = 0; $i < count( $activities ); $i++ ) {
204
+ $activities_formatted[$i]['content'] = $activities[$i]->content;
205
+ $activities_formatted[$i]['primary_link'] = $activities[$i]->primary_link;
206
+ $activities_formatted[$i]['date_recorded'] = $activities[$i]->date_recorded;
207
+ $activities_formatted[$i]['component_name'] = $activities[$i]->component_name;
208
+ $activities_formatted[$i]['component_action'] = $activities[$i]->component_action;
209
+ }
210
+
211
+ return array( 'activities' => $activities_formatted, 'total' => (int)$total_activities );
212
+ }
213
+
214
+ function get_sitewide_items_for_feed( $limit = 35 ) {
215
+ global $wpdb, $bp;
216
+
217
+ $activities = bp_activity_get_sitewide_activity( $limit );
218
+ for ( $i = 0; $i < count($activities); $i++ ) {
219
+ $title = explode( '<span', $activities[$i]['content'] );
220
+
221
+ $activity_feed[$i]['title'] = trim( strip_tags( $title[0] ) );
222
+ $activity_feed[$i]['link'] = $activities[$i]['primary_link'];
223
+ $activity_feed[$i]['description'] = @sprintf( $activities[$i]['content'], '' );
224
+ $activity_feed[$i]['pubdate'] = $activities[$i]['date_recorded'];
225
+ }
226
+
227
+ return $activity_feed;
228
+ }
229
+
230
+ function cache_friends_activities( $activity_array ) {
231
+ global $wpdb, $bp;
232
+
233
+ /* Empty the cache */
234
+ $wpdb->query( "TRUNCATE TABLE {$bp->activity->table_name_loggedin_user_friends_cached}" );
235
+
236
+ for ( $i = 0; $i < count($activity_array); $i++ ) {
237
+ // Cache that sucka...
238
+ $cached = $wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->activity->table_name_loggedin_user_friends_cached} ( user_id, content, primary_link, component_name, component_action, date_cached, date_recorded ) VALUES ( %d, %s, %s, %s, %s, FROM_UNIXTIME(%d), %s )", $activity_array[$i]['user_id'], $activity_array[$i]['content'], $activity_array[$i]['primary_link'], $activity_array[$i]['component_name'], $activity_array[$i]['component_action'], time(), $activity_array[$i]['date_recorded'] ) );
239
+ }
240
+
241
+ update_usermeta( $bp->loggedin_user->id, 'bp_activity_friends_last_cached', time() );
242
+ }
243
+
244
+ function cache_activities( $activity_array, $user_id ) {
245
+ global $wpdb, $bp;
246
+
247
+ /* Delete cached items older than 30 days for the user */
248
+ $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name_user_activity_cached} WHERE user_id = %d AND DATE_ADD(date_recorded, INTERVAL 30 DAY) <= NOW()", $user_id ) );
249
+ $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name_sitewide} WHERE user_id = %d AND DATE_ADD(date_recorded, INTERVAL 30 DAY) <= NOW()", $user_id ) );
250
+
251
+ for ( $i = 0; $i < count($activity_array); $i++ ) {
252
+ if ( empty( $activity_array[$i]['content'] ) ) continue;
253
+
254
+ // Cache that sucka...
255
+ $wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->activity->table_name_user_activity_cached} ( user_id, content, item_id, secondary_item_id, primary_link, component_name, component_action, date_cached, date_recorded, is_private ) VALUES ( %d, %s, %d, %d, %s, %s, %s, FROM_UNIXTIME(%d), %s, %d )", $user_id, $activity_array[$i]['content'], $activity_array[$i]['item_id'], $activity_array[$i]['secondary_item_id'], $activity_array[$i]['primary_link'], $activity_array[$i]['component_name'], $activity_array[$i]['component_action'], time(), $activity_array[$i]['date_recorded'], $activity_array[$i]['is_private'] ) );
256
+
257
+ // Add to the sitewide activity stream
258
+ if ( !$activity_array[$i]['is_private'] && !$activity_array[$i]['no_sitewide_cache'] )
259
+ $wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->activity->table_name_sitewide} ( user_id, content, item_id, secondary_item_id, primary_link, component_name, component_action, date_cached, date_recorded ) VALUES ( %d, %s, %d, %d, %s, %s, %s, FROM_UNIXTIME(%d), %s )", $user_id, $activity_array[$i]['content'], $activity_array[$i]['item_id'], $activity_array[$i]['secondary_item_id'], $activity_array[$i]['primary_link'], $activity_array[$i]['component_name'], $activity_array[$i]['component_action'], time(), $activity_array[$i]['date_recorded'] ) );
260
+ }
261
+
262
+ update_usermeta( $bp->displayed_user->id, 'bp_activity_last_cached', time() );
263
+ }
264
+
265
+ function delete_activity_for_user( $user_id ) {
266
+ global $wpdb, $bp;
267
+
268
+ /* Empty user's activities from the sitewide stream */
269
+ $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name_sitewide} WHERE user_id = %d", $user_id ) );
270
+
271
+ /* Empty the user's activity items and cached activity items */
272
+ $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name_user_activity} WHERE user_id = %d", $user_id ) );
273
+ $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name_user_activity_cached} WHERE user_id = %d", $user_id ) );
274
+
275
+ return true;
276
+ }
277
+
278
+ function get_last_updated() {
279
+ global $bp, $wpdb;
280
+
281
+ return $wpdb->get_var( $wpdb->prepare( "SELECT date_recorded FROM " . $bp->activity->table_name_sitewide . " ORDER BY date_recorded ASC LIMIT 1" ) );
282
+ }
283
+
284
+ function kill_tables_for_user( $user_id ) {
285
+ global $bp, $wpdb;
286
+
287
+ if ( !$wpdb->get_var( "SHOW TABLES LIKE 'wp_user_{$user_id}_activity'" ) )
288
+ return false;
289
+
290
+ $wpdb->query( $wpdb->prepare( "DROP TABLE wp_user_{$user_id}_activity" ) );
291
+ $wpdb->query( $wpdb->prepare( "DROP TABLE wp_user_{$user_id}_activity_cached" ) );
292
+ $wpdb->query( $wpdb->prepare( "DROP TABLE wp_user_{$user_id}_friends_activity_cached" ) );
293
+
294
+ return true;
295
+ }
296
+
297
+ function convert_tables_for_user( $user_id ) {
298
+ global $bp, $wpdb;
299
+
300
+ if ( !$wpdb->get_var( "SHOW TABLES LIKE 'wp_user_{$user_id}_activity'" ) )
301
+ return false;
302
+
303
+ $activity_items = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM wp_user_{$user_id}_activity" ) );
304
+ $activity_cached_items = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM wp_user_{$user_id}_activity_cached" ) );
305
+
306
+ if ( $activity_items ) {
307
+ foreach ( $activity_items as $activity_item ) {
308
+ $wpdb->query( $wpdb->prepare(
309
+ "INSERT INTO {$bp->activity->table_name_user_activity}
310
+ ( item_id, secondary_item_id, user_id, component_name, component_action, date_recorded, is_private, no_sitewide_cache )
311
+ VALUES
312
+ ( %d, %d, %d, %s, %s, %s, %d, %d )",
313
+ $activity_item->item_id, $activity_item->secondary_item_id, $user_id, $activity_item->component_name, $activity_item->component_action, $activity_item->date_recorded, $activity_item->is_private, $activity_item->no_sitewide_cache
314
+ ) );
315
+ }
316
+ }
317
+
318
+ if ( $activity_cached_items ) {
319
+ foreach ( $activity_cached_items as $activity_cached_item ) {
320
+ $wpdb->query( $wpdb->prepare(
321
+ "INSERT INTO {$bp->activity->table_name_user_activity_cached}
322
+ ( content, primary_link, item_id, secondary_item_id, user_id, component_name, component_action, date_recorded, date_cached, is_private )
323
+ VALUES
324
+ ( %s, %s, %d, %d, %d, %s, %s, %s, %s, %d )",
325
+ $activity_cached_item->content, $activity_cached_item->primary_link, $activity_cached_item->item_id, $activity_cached_item->secondary_item_id, $user_id, $activity_cached_item->component_name, $activity_cached_item->component_action, $activity_cached_item->date_recorded, $activity_cached_item->date_cached, $activity_cached_item->is_private
326
+ ) );
327
+ }
328
+ }
329
+ }
330
+ }
331
+
332
+ ?>
bp-activity/bp-activity-cssjs.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function bp_activity_add_structure_css() {
4
+ /* Enqueue the structure CSS file to give basic positional formatting for components */
5
+ wp_enqueue_style( 'bp-activity-structure', BP_PLUGIN_URL . '/bp-activity/css/structure.css' );
6
+ }
7
+ add_action( 'bp_styles', 'bp_activity_add_structure_css' );
8
+
9
+
10
+ ?>
bp-activity/bp-activity-filters.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /* Apply WordPress defined filters */
4
+ add_filter( 'bp_get_activity_content', 'wptexturize' );
5
+
6
+ add_filter( 'bp_get_activity_content', 'convert_smilies' );
7
+
8
+ add_filter( 'bp_get_activity_content', 'convert_chars' );
9
+
10
+ add_filter( 'bp_get_activity_content', 'wpautop' );
11
+
12
+ add_filter( 'bp_get_activity_content', 'stripslashes_deep' );
13
+
14
+ add_filter( 'bp_get_activity_content', 'make_clickable' );
15
+
16
+ ?>
bp-activity/bp-activity-templatetags.php ADDED
@@ -0,0 +1,347 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class BP_Activity_Template {
4
+ var $current_activity = -1;
5
+ var $activity_count;
6
+ var $total_activity_count;
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;
16
+
17
+ var $full_name;
18
+
19
+ function bp_activity_template( $type, $user_id, $per_page, $max, $timeframe ) {
20
+ global $bp;
21
+
22
+ $this->pag_page = isset( $_REQUEST['acpage'] ) ? intval( $_REQUEST['acpage'] ) : 1;
23
+ $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
24
+ $this->filter_content = false;
25
+ $this->activity_type = $type;
26
+
27
+ if ( $type == 'sitewide' )
28
+ $this->activities = bp_activity_get_sitewide_activity( $max, $this->pag_num, $this->pag_page );
29
+
30
+ if ( $type == 'personal' )
31
+ $this->activities = bp_activity_get_user_activity( $user_id, $timeframe, $this->page_num, $this->pag_page );
32
+
33
+ if ( $type == 'friends' && ( bp_is_home() || is_site_admin() || $bp->loggedin_user->id == $user_id ) )
34
+ $this->activities = bp_activity_get_friends_activity( $user_id, $timeframe, $this->pag_num, $this->pag_page );
35
+
36
+ if ( !$max )
37
+ $this->total_activity_count = (int)$this->activities['total'];
38
+ else
39
+ $this->total_activity_count = (int)$max;
40
+
41
+ $this->activities = $this->activities['activities'];
42
+
43
+ if ( $max ) {
44
+ if ( $max >= count($this->activities) )
45
+ $this->activity_count = count($this->activities);
46
+ else
47
+ $this->activity_count = (int)$max;
48
+ } else {
49
+ $this->activity_count = count($this->activities);
50
+ }
51
+
52
+ $this->full_name = $bp->displayed_user->fullname;
53
+
54
+ $this->pag_links = paginate_links( array(
55
+ 'base' => add_query_arg( 'acpage', '%#%' ),
56
+ 'format' => '',
57
+ 'total' => ceil( (int)$this->total_activity_count / (int)$this->pag_num ),
58
+ 'current' => (int)$this->pag_page,
59
+ 'prev_text' => '&laquo;',
60
+ 'next_text' => '&raquo;',
61
+ 'mid_size' => 1
62
+ ));
63
+ }
64
+
65
+ function has_activities() {
66
+ if ( $this->activity_count )
67
+ return true;
68
+
69
+ return false;
70
+ }
71
+
72
+ function next_activity() {
73
+ $this->current_activity++;
74
+ $this->activity = $this->activities[$this->current_activity];
75
+
76
+ return $this->activity;
77
+ }
78
+
79
+ function rewind_activities() {
80
+ $this->current_activity = -1;
81
+ if ( $this->activity_count > 0 ) {
82
+ $this->activity = $this->activities[0];
83
+ }
84
+ }
85
+
86
+ function user_activities() {
87
+ if ( $this->current_activity + 1 < $this->activity_count ) {
88
+ return true;
89
+ } elseif ( $this->current_activity + 1 == $this->activity_count ) {
90
+ do_action('loop_end');
91
+ // Do some cleaning up after the loop
92
+ $this->rewind_activities();
93
+ }
94
+
95
+ $this->in_the_loop = false;
96
+ return false;
97
+ }
98
+
99
+ function the_activity() {
100
+ global $activity;
101
+
102
+ $this->in_the_loop = true;
103
+ $this->activity = $this->next_activity();
104
+
105
+ if ( is_array( $this->activity ) )
106
+ $this->activity = (object) $this->activity;
107
+
108
+ if ( $this->current_activity == 0 ) // loop has just started
109
+ do_action('loop_start');
110
+ }
111
+ }
112
+
113
+ function bp_activity_get_list( $user_id, $title, $no_activity, $limit = false ) {
114
+ global $bp_activity_user_id, $bp_activity_limit, $bp_activity_title, $bp_activity_no_activity;
115
+
116
+ $bp_activity_user_id = $user_id;
117
+ $bp_activity_limit = $limit;
118
+ $bp_activity_title = $title;
119
+ $bp_activity_no_activity = $no_activity;
120
+
121
+ load_template( TEMPLATEPATH . '/activity/activity-list.php' );
122
+ }
123
+
124
+ function bp_has_activities( $args = '' ) {
125
+ global $bp, $activities_template, $bp_activity_user_id, $bp_activity_limit;
126
+
127
+ $defaults = array(
128
+ 'type' => 'sitewide',
129
+ 'user_id' => false,
130
+ 'per_page' => 25,
131
+ 'max' => false,
132
+ 'timeframe' => '-4 weeks'
133
+ );
134
+
135
+ $r = wp_parse_args( $args, $defaults );
136
+ extract( $r, EXTR_SKIP );
137
+
138
+ // The following lines are for backwards template compatibility.
139
+ if ( 'my-friends' == $bp->current_action && $bp->activity->slug == $bp->current_component )
140
+ $type = 'friends';
141
+
142
+ if ( $bp->displayed_user->id && $bp->activity->slug == $bp->current_component && ( !$bp->current_action || 'just-me' == $bp->current_action ) )
143
+ $type = 'personal';
144
+
145
+ if ( $bp->displayed_user->id && $bp->profile->slug == $bp->current_component )
146
+ $type = 'personal';
147
+
148
+ if ( $bp_activity_limit )
149
+ $max = $bp_activity_limit;
150
+
151
+ // END backwards compatibility ---
152
+
153
+ if ( ( 'personal' == $type || 'friends' == $type ) && !$user_id )
154
+ $user_id = (int)$bp->displayed_user->id;
155
+
156
+ if ( $max ) {
157
+ if ( $per_page > $max )
158
+ $per_page = $max;
159
+ }
160
+
161
+ $activities_template = new BP_Activity_Template( $type, $user_id, $per_page, $max, $timeframe );
162
+ return $activities_template->has_activities();
163
+ }
164
+
165
+ function bp_activities() {
166
+ global $activities_template;
167
+ return $activities_template->user_activities();
168
+ }
169
+
170
+ function bp_the_activity() {
171
+ global $activities_template;
172
+ return $activities_template->the_activity();
173
+ }
174
+
175
+ function bp_activity_pagination_count() {
176
+ global $bp, $activities_template;
177
+
178
+ $from_num = intval( ( $activities_template->pag_page - 1 ) * $activities_template->pag_num ) + 1;
179
+ $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) ;
180
+
181
+ echo sprintf( __( 'Viewing item %d to %d (of %d items)', 'buddypress' ), $from_num, $to_num, $activities_template->total_activity_count ); ?> &nbsp;
182
+ <img id="ajax-loader-activity" src="<?php echo $bp->core->image_base ?>/ajax-loader.gif" height="7" alt="<?php _e( "Loading", "buddypress" ) ?>" style="display: none;" /><?php
183
+ }
184
+
185
+ function bp_activity_pagination_links() {
186
+ echo bp_get_activity_pagination_links();
187
+ }
188
+ function bp_get_activity_pagination_links() {
189
+ global $activities_template;
190
+
191
+ return apply_filters( 'bp_get_activity_pagination_links', $activities_template->pag_links );
192
+ }
193
+
194
+ function bp_activities_title() {
195
+ global $bp_activity_title;
196
+
197
+ echo bp_get_activities_title();
198
+ }
199
+ function bp_get_activities_title() {
200
+ global $bp_activity_title;
201
+
202
+ return apply_filters( 'bp_get_activities_title', $bp_activity_title );
203
+ }
204
+
205
+ function bp_activities_no_activity() {
206
+ global $bp_activity_no_activity;
207
+
208
+ echo bp_get_activities_no_activity();
209
+ }
210
+ function bp_get_activities_no_activity() {
211
+ global $bp_activity_no_activity;
212
+
213
+ return apply_filters( 'bp_get_activities_no_activity', $bp_activity_no_activity );
214
+ }
215
+
216
+ function bp_activity_content() {
217
+ global $activities_template;
218
+
219
+ echo bp_get_activity_content();
220
+ }
221
+ function bp_get_activity_content() {
222
+ global $activities_template;
223
+
224
+ if ( bp_is_home() && $activities_template->activity_type == 'personal' ) {
225
+ return apply_filters( 'bp_get_activity_content', bp_activity_content_filter( $activities_template->activity->content, $activities_template->activity->date_recorded, $activities_template->full_name ) );
226
+ } else {
227
+ $activities_template->activity->content = bp_activity_insert_time_since( $activities_template->activity->content, $activities_template->activity->date_recorded );
228
+ return apply_filters( 'bp_get_activity_content', $activities_template->activity->content );
229
+ }
230
+ }
231
+
232
+ function bp_activity_content_filter( $content, $date_recorded, $full_name, $insert_time = true, $filter_words = true, $filter_you = true ) {
233
+ if ( !$content )
234
+ return false;
235
+
236
+ /* Split the content so we don't evaluate and replace text on content we don't want to */
237
+ $content = explode( '%s', $content );
238
+
239
+ /* Re-add the exploded %s */
240
+ $content[0] .= '%s';
241
+
242
+ /* Insert the time since */
243
+ if ( $insert_time )
244
+ $content[0] = bp_activity_insert_time_since( $content[0], $date_recorded );
245
+
246
+ // The "You" and "Your" conversion is only done in english, if a translation file is present
247
+ // then do not translate as it causes problems in other languages.
248
+ if ( '' == get_locale() ) {
249
+ /* Switch 'their/your' depending on whether the user is logged in or not and viewing their profile */
250
+ if ( $filter_words ) {
251
+ $content[0] = preg_replace( '/their\s/', 'your ', $content[0] );
252
+ }
253
+
254
+ /* Remove the 'You' and replace if with the persons name */
255
+ if ( $filter_you && $full_name != '' ) {
256
+ $content[0] = preg_replace( "/{$full_name}[<]/", 'You<', $content[0] );
257
+ }
258
+ }
259
+
260
+ $content_new = '';
261
+
262
+ for ( $i = 0; $i < count($content); $i++ )
263
+ $content_new .= $content[$i];
264
+
265
+ return apply_filters( 'bp_activity_content_filter', $content_new );
266
+ }
267
+
268
+ function bp_activity_insert_time_since( $content, $date ) {
269
+ if ( !$content || !$date )
270
+ return false;
271
+
272
+ // Make sure we don't have any URL encoding in links when trying to insert the time.
273
+ $content = urldecode($content);
274
+
275
+ return apply_filters( 'bp_activity_insert_time_since', @sprintf( $content, @sprintf( __( '&nbsp; %s ago', 'buddypress' ), bp_core_time_since( strtotime( $date ) ) ) ) );
276
+ }
277
+
278
+ function bp_activity_css_class() {
279
+ echo bp_get_activity_css_class();
280
+ }
281
+ function bp_get_activity_css_class() {
282
+ global $activities_template;
283
+
284
+ return apply_filters( 'bp_get_activity_css_class', $activities_template->activity->component_name );
285
+ }
286
+
287
+ function bp_sitewide_activity_feed_link() {
288
+ echo bp_get_sitewide_activity_feed_link();
289
+ }
290
+ function bp_get_sitewide_activity_feed_link() {
291
+ global $bp;
292
+
293
+ return apply_filters( 'bp_get_sitewide_activity_feed_link', site_url() . '/' . $bp->activity->slug . '/feed' );
294
+ }
295
+
296
+ function bp_activities_member_rss_link() {
297
+ echo bp_get_activities_member_rss_link();
298
+ }
299
+ function bp_get_activities_member_rss_link() {
300
+ global $bp;
301
+
302
+ if ( ( $bp->current_component == $bp->profile->slug ) || 'just-me' == $bp->current_action )
303
+ return apply_filters( 'bp_get_activities_member_rss_link', $bp->displayed_user->domain . $bp->activity->slug . '/feed' );
304
+ else
305
+ return apply_filters( 'bp_get_activities_member_rss_link', $bp->displayed_user->domain . $bp->activity->slug . '/my-friends/feed' );
306
+ }
307
+
308
+ /* Template tags for RSS feed output */
309
+
310
+ function bp_activity_feed_item_title() {
311
+ echo bp_get_activity_feed_item_title();
312
+ }
313
+ function bp_get_activity_feed_item_title() {
314
+ global $activities_template;
315
+
316
+ $title = explode( '<span', $activities_template->activity->content );
317
+ return apply_filters( 'bp_get_activity_feed_item_title', trim( strip_tags( html_entity_decode( $title[0] ) ) ) );
318
+ }
319
+
320
+ function bp_activity_feed_item_link() {
321
+ echo bp_get_activity_feed_item_link();
322
+ }
323
+ function bp_get_activity_feed_item_link() {
324
+ global $activities_template;
325
+
326
+ return apply_filters( 'bp_get_activity_feed_item_link', $activities_template->activity->primary_link );
327
+ }
328
+
329
+ function bp_activity_feed_item_date() {
330
+ echo bp_get_activity_feed_item_date();
331
+ }
332
+ function bp_get_activity_feed_item_date() {
333
+ global $activities_template;
334
+
335
+ return apply_filters( 'bp_get_activity_feed_item_date', $activities_template->activity->date_recorded );
336
+ }
337
+
338
+ function bp_activity_feed_item_description() {
339
+ echo bp_get_activity_feed_item_description();
340
+ }
341
+ function bp_get_activity_feed_item_description() {
342
+ global $activities_template;
343
+
344
+ return apply_filters( 'bp_get_activity_feed_item_description', html_entity_decode( str_replace( '%s', '', $activities_template->activity->content ), ENT_COMPAT, 'UTF-8' ) );
345
+ }
346
+
347
+ ?>
bp-activity/bp-activity-widgets.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /* Register widgets for blogs component */
4
+ function bp_activity_register_widgets() {
5
+ global $current_blog;
6
+
7
+ /* Site Wide Activity Widget */
8
+ wp_register_sidebar_widget( 'buddypress-activity', __('Site Wide Activity', 'buddypress'), 'bp_activity_widget_sitewide_activity');
9
+ wp_register_widget_control( 'buddypress-activity', __('Site Wide Activity', 'buddypress'), 'bp_activity_widget_sitewide_activity_control' );
10
+
11
+ if ( is_active_widget( 'bp_activity_widget_sitewide_activity' ) ) {
12
+ wp_enqueue_style( 'bp-activity-widget-activity-css', BP_PLUGIN_URL . '/bp-activity/css/widget-activity.css' );
13
+ }
14
+ }
15
+ add_action( 'plugins_loaded', 'bp_activity_register_widgets' );
16
+
17
+
18
+ function bp_activity_widget_sitewide_activity($args) {
19
+ global $bp, $current_blog;
20
+
21
+ extract($args);
22
+ $options = get_blog_option( $current_blog->blog_id, 'bp_activity_widget_sitewide_activity' );
23
+ ?>
24
+ <?php echo $before_widget; ?>
25
+ <?php echo $before_title
26
+ . $widget_name
27
+ . $after_title; ?>
28
+
29
+ <?php
30
+ if ( empty( $options['max_items'] ) ) {
31
+ $options['max_items'] = 20;
32
+ }
33
+ ?>
34
+
35
+ <?php
36
+ if ( !$activity = wp_cache_get( 'sitewide_activity', 'bp' ) ) {
37
+ $activity = bp_activity_get_sitewide_activity( $options['max_items'] );
38
+ wp_cache_set( 'sitewide_activity', $activity, 'bp' );
39
+ }
40
+ ?>
41
+
42
+ <?php if ( $activity['activities'] ) : ?>
43
+ <div class="item-options" id="activity-list-options">
44
+ <img src="<?php echo $bp->activity->image_base; ?>/rss.png" alt="<?php _e( 'RSS Feed', 'buddypress' ) ?>" /> <a href="<?php bp_sitewide_activity_feed_link() ?>" title="<?php _e( 'Site Wide Activity RSS Feed', 'buddypress' ) ?>"><?php _e( 'RSS Feed', 'buddypress' ) ?></a>
45
+ </div>
46
+ <ul id="site-wide-stream" class="activity-list">
47
+ <?php foreach( $activity['activities'] as $item ) : ?>
48
+ <li class="<?php echo $item['component_name'] ?>">
49
+ <?php echo apply_filters( 'bp_activity_content', bp_activity_content_filter( $item['content'], $item['date_recorded'], '', true, false, true ) ); ?>
50
+ </li>
51
+ <?php endforeach; ?>
52
+ </ul>
53
+ <?php else: ?>
54
+ <div class="widget-error">
55
+ <?php _e('There has been no recent site activity.', 'buddypress') ?>
56
+ </div>
57
+ <?php endif; ?>
58
+
59
+ <?php echo $after_widget; ?>
60
+ <?php
61
+ }
62
+
63
+ function bp_activity_widget_sitewide_activity_control() {
64
+ global $current_blog;
65
+
66
+ $options = $newoptions = get_blog_option( $current_blog->blog_id, 'bp_activity_widget_sitewide_activity');
67
+
68
+ if ( $_POST['bp-activity-widget-sitewide-submit'] ) {
69
+ $newoptions['max_items'] = strip_tags( stripslashes( $_POST['bp-activity-widget-sitewide-items-max'] ) );
70
+ }
71
+
72
+ if ( $options != $newoptions ) {
73
+ $options = $newoptions;
74
+ update_blog_option( $current_blog->blog_id, 'bp_activity_widget_sitewide_activity', $options );
75
+ }
76
+
77
+ $max_items = attribute_escape( $options['max_items'] );
78
+ ?>
79
+ <p><label for="bp-activity-widget-sitewide-items-max"><?php _e('Max Number of Items:', 'buddypress'); ?> <input class="widefat" id="bp-activity-widget-sitewide-items-max" name="bp-activity-widget-sitewide-items-max" type="text" value="<?php echo $max_items; ?>" style="width: 30%" /></label></p>
80
+ <input type="hidden" id="bp-activity-widget-sitewide-submit" name="bp-activity-widget-sitewide-submit" value="1" />
81
+ <?php
82
+ }
83
+
84
+ ?>
bp-activity/css/structure.css ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Basic layout structure styles for BuddyPress Activity Streams. Formats BuddyPress activity pages within any WordPress theme.
3
+ No colors, fonts or pretty stuff.
4
+
5
+ These structure styles can be overridden by the theme CSS file if needed.
6
+ */
7
+
8
+ #activity-list li {
9
+ margin: 15px 0;
10
+ }
11
+
12
+ #activity-list li blockquote {
13
+ padding: 7px 15px 7px 40px;
14
+ margin: 5px 0;
15
+ }
bp-activity/css/widget-activity.css ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ .bp_activity_widget_sitewide_activity span.time-since {
2
+ font-size: 11px;
3
+ }
4
+
5
+ .bp_activity_widget_sitewide_activity ul#site-wide-stream {
6
+ margin: 0;
7
+ padding: 0;
8
+ list-style: none;
9
+ }
bp-activity/feeds/bp-activity-friends-feed.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * RSS2 Feed Template for displaying the site wide activity stream.
4
+ *
5
+ * @package BuddyPress
6
+ */
7
+ header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
8
+ header('Status: 200 OK');
9
+ ?>
10
+ <?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
11
+
12
+ <rss version="2.0"
13
+ xmlns:content="http://purl.org/rss/1.0/modules/content/"
14
+ xmlns:wfw="http://wellformedweb.org/CommentAPI/"
15
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
16
+ xmlns:atom="http://www.w3.org/2005/Atom"
17
+ <?php do_action('bp_activity_friends_feed'); ?>
18
+ >
19
+
20
+ <channel>
21
+ <title><?php echo $bp->displayed_user->fullname; ?> - <?php _e( 'Friends Activity', 'buddypress' ) ?></title>
22
+ <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
23
+ <link><?php echo $bp->displayed_user->domain . $bp->activity->slug . '/my-friends/feed' ?></link>
24
+ <description><?php printf( __( '%s - Friends Activity Feed', 'buddypress' ), $bp->displayed_user->fullname ) ?></description>
25
+ <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', bp_activity_get_last_updated(), false); ?></pubDate>
26
+ <generator>http://buddypress.org/?bp-activity-version=<?php echo BP_ACTIVITY_VERSION ?></generator>
27
+ <language><?php echo get_option('rss_language'); ?></language>
28
+ <?php do_action('bp_activity_friends_feed_head'); ?>
29
+
30
+ <?php if ( bp_has_activities( 'type=friends&max=50' ) ) : ?>
31
+ <?php while ( bp_activities() ) : bp_the_activity(); ?>
32
+ <item>
33
+ <title><![CDATA[<?php bp_activity_feed_item_title() ?>]]></title>
34
+ <link><?php echo bp_activity_feed_item_link() ?></link>
35
+ <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', bp_activity_feed_item_date(), false); ?></pubDate>
36
+
37
+ <description><![CDATA[<?php bp_activity_feed_item_description() ?>]]></description>
38
+ <?php do_action('bp_activity_personal_feed_item'); ?>
39
+ </item>
40
+ <?php endwhile; ?>
41
+
42
+ <?php endif; ?>
43
+ </channel>
44
+ </rss>
bp-activity/feeds/bp-activity-personal-feed.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * RSS2 Feed Template for displaying the site wide activity stream.
4
+ *
5
+ * @package BuddyPress
6
+ */
7
+ header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
8
+ header('Status: 200 OK');
9
+ ?>
10
+ <?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
11
+
12
+ <rss version="2.0"
13
+ xmlns:content="http://purl.org/rss/1.0/modules/content/"
14
+ xmlns:wfw="http://wellformedweb.org/CommentAPI/"
15
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
16
+ xmlns:atom="http://www.w3.org/2005/Atom"
17
+ <?php do_action('bp_activity_personal_feed'); ?>
18
+ >
19
+
20
+ <channel>
21
+ <title><?php echo $bp->displayed_user->fullname; ?> - <?php _e( 'Activity', 'buddypress' ) ?></title>
22
+ <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
23
+ <link><?php echo $bp->displayed_user->domain . $bp->activity->slug . '/feed' ?></link>
24
+ <description><?php printf( __( '%s - Activity Feed', 'buddypress' ), $bp->displayed_user->fullname ) ?></description>
25
+ <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', bp_activity_get_last_updated(), false); ?></pubDate>
26
+ <generator>http://buddypress.org/?bp-activity-version=<?php echo BP_ACTIVITY_VERSION ?></generator>
27
+ <language><?php echo get_option('rss_language'); ?></language>
28
+ <?php do_action('bp_activity_personal_feed_head'); ?>
29
+
30
+ <?php if ( bp_has_activities( 'type=personal&max=50' ) ) : ?>
31
+ <?php while ( bp_activities() ) : bp_the_activity(); ?>
32
+ <item>
33
+ <title><![CDATA[<?php bp_activity_feed_item_title() ?>]]></title>
34
+ <link><?php echo bp_activity_feed_item_link() ?></link>
35
+ <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', bp_activity_feed_item_date(), false); ?></pubDate>
36
+
37
+ <description><![CDATA[<?php bp_activity_feed_item_description() ?>]]></description>
38
+ <?php do_action('bp_activity_personal_feed_item'); ?>
39
+ </item>
40
+ <?php endwhile; ?>
41
+
42
+ <?php endif; ?>
43
+ </channel>
44
+ </rss>
bp-activity/feeds/bp-activity-sitewide-feed.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * RSS2 Feed Template for displaying the site wide activity stream.
4
+ *
5
+ * @package BuddyPress
6
+ */
7
+
8
+ header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
9
+ header('Status: 200 OK');
10
+ ?>
11
+ <?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
12
+
13
+ <rss version="2.0"
14
+ xmlns:content="http://purl.org/rss/1.0/modules/content/"
15
+ xmlns:wfw="http://wellformedweb.org/CommentAPI/"
16
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
17
+ xmlns:atom="http://www.w3.org/2005/Atom"
18
+ <?php do_action('bp_activity_sitewide_feed'); ?>
19
+ >
20
+
21
+ <channel>
22
+ <title><?php echo get_site_option( 'site_name' ); ?> - <?php _e( 'Site Wide Activity', 'buddypress' ) ?></title>
23
+ <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
24
+ <link><?php echo site_url() . '/' . $bp->activity->slug . '/feed' ?></link>
25
+ <description><?php _e( 'Site Wide Activity Feed', 'buddypress' ) ?></description>
26
+ <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', bp_activity_get_last_updated(), false); ?></pubDate>
27
+ <generator>http://buddypress.org/?bp-activity-version=<?php echo BP_ACTIVITY_VERSION ?></generator>
28
+ <language><?php echo get_option('rss_language'); ?></language>
29
+ <?php do_action('bp_activity_sitewide_feed_head'); ?>
30
+
31
+ <?php if ( bp_has_activities( 'type=sitewide&max=50' ) ) : ?>
32
+ <?php while ( bp_activities() ) : bp_the_activity(); ?>
33
+ <item>
34
+ <title><![CDATA[<?php bp_activity_feed_item_title() ?>]]></title>
35
+ <link><?php echo bp_activity_feed_item_link() ?></link>
36
+ <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', bp_activity_feed_item_date(), false); ?></pubDate>
37
+
38
+ <description><![CDATA[<?php bp_activity_feed_item_description() ?>]]></description>
39
+ <?php do_action('bp_activity_personal_feed_item'); ?>
40
+ </item>
41
+ <?php endwhile; ?>
42
+
43
+ <?php endif; ?>
44
+ </channel>
45
+ </rss>
bp-activity/images/rss.png ADDED
Binary file
bp-blogs.php ADDED
@@ -0,0 +1,862 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ define ( 'BP_BLOGS_VERSION', '1.0' );
4
+ define ( 'BP_BLOGS_DB_VERSION', '1300' );
5
+
6
+ /* Define the slug for the component */
7
+ if ( !defined( 'BP_BLOGS_SLUG' ) )
8
+ define ( 'BP_BLOGS_SLUG', 'blogs' );
9
+
10
+ require ( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-classes.php' );
11
+ require ( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-cssjs.php' );
12
+ require ( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-templatetags.php' );
13
+ require ( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-widgets.php' );
14
+ require ( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-ajax.php' );
15
+
16
+
17
+ /**************************************************************************
18
+ bp_blogs_install()
19
+
20
+ Sets up the database tables ready for use on a site installation.
21
+ **************************************************************************/
22
+
23
+ function bp_blogs_install() {
24
+ global $wpdb, $bp;
25
+
26
+ if ( !empty($wpdb->charset) )
27
+ $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
28
+
29
+ $sql[] = "CREATE TABLE {$bp->blogs->table_name} (
30
+ id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
31
+ user_id bigint(20) NOT NULL,
32
+ blog_id bigint(20) NOT NULL,
33
+ KEY user_id (user_id),
34
+ KEY blog_id (blog_id)
35
+ ) {$charset_collate};";
36
+
37
+ $sql[] = "CREATE TABLE {$bp->blogs->table_name_blog_posts} (
38
+ id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
39
+ user_id bigint(20) NOT NULL,
40
+ blog_id bigint(20) NOT NULL,
41
+ post_id bigint(20) NOT NULL,
42
+ date_created datetime NOT NULL,
43
+ KEY user_id (user_id),
44
+ KEY blog_id (blog_id),
45
+ KEY post_id (post_id)
46
+ ) {$charset_collate};";
47
+
48
+ $sql[] = "CREATE TABLE {$bp->blogs->table_name_blog_comments} (
49
+ id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
50
+ user_id bigint(20) NOT NULL,
51
+ blog_id bigint(20) NOT NULL,
52
+ comment_id bigint(20) NOT NULL,
53
+ comment_post_id bigint(20) NOT NULL,
54
+ date_created datetime NOT NULL,
55
+ KEY user_id (user_id),
56
+ KEY blog_id (blog_id),
57
+ KEY comment_id (comment_id),
58
+ KEY comment_post_id (comment_post_id)
59
+ ) {$charset_collate};";
60
+
61
+ $sql[] = "CREATE TABLE {$bp->blogs->table_name_blogmeta} (
62
+ id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
63
+ blog_id bigint(20) NOT NULL,
64
+ meta_key varchar(255) DEFAULT NULL,
65
+ meta_value longtext DEFAULT NULL,
66
+ KEY blog_id (blog_id),
67
+ KEY meta_key (meta_key)
68
+ ) {$charset_collate};";
69
+
70
+
71
+ require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
72
+
73
+ dbDelta($sql);
74
+
75
+ // On first installation - record all existing blogs in the system.
76
+ if ( !(int)get_site_option( 'bp-blogs-first-install') ) {
77
+
78
+ bp_blogs_record_existing_blogs();
79
+ add_site_option( 'bp-blogs-first-install', 1 );
80
+
81
+ } else {
82
+
83
+ // Import blog titles and descriptions into the blogmeta table
84
+ if ( get_site_option( 'bp-blogs-version' ) <= '0.1.5' ) {
85
+ $blog_ids = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM " . $bp->blogs->table_name ) );
86
+
87
+ for ( $i = 0; $i < count($blog_ids); $i++ ) {
88
+ $name = get_blog_option( $blog_ids[$i], 'blogname' );
89
+ $desc = get_blog_option( $blog_ids[$i], 'blogdescription' );
90
+
91
+ bp_blogs_update_blogmeta( $blog_ids[$i], 'name', $name );
92
+ bp_blogs_update_blogmeta( $blog_ids[$i], 'description', $desc );
93
+ bp_blogs_update_blogmeta( $blog_ids[$i], 'last_activity', time() );
94
+ }
95
+ }
96
+
97
+ }
98
+
99
+ update_site_option( 'bp-blogs-db-version', BP_BLOGS_DB_VERSION );
100
+ }
101
+
102
+
103
+ function bp_blogs_check_installed() {
104
+ global $wpdb, $bp, $userdata;
105
+
106
+ if ( is_site_admin() ) {
107
+ /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
108
+ if ( get_site_option('bp-blogs-db-version') < BP_BLOGS_DB_VERSION )
109
+ bp_blogs_install();
110
+ }
111
+ }
112
+ add_action( 'admin_menu', 'bp_blogs_check_installed' );
113
+
114
+
115
+ /**************************************************************************
116
+ bp_blogs_setup_globals()
117
+
118
+ Set up and add all global variables for this component, and add them to
119
+ the $bp global variable array.
120
+ **************************************************************************/
121
+
122
+ function bp_blogs_setup_globals() {
123
+ global $bp, $wpdb;
124
+
125
+ $bp->blogs->table_name = $wpdb->base_prefix . 'bp_user_blogs';
126
+ $bp->blogs->table_name_blog_posts = $wpdb->base_prefix . 'bp_user_blogs_posts';
127
+ $bp->blogs->table_name_blog_comments = $wpdb->base_prefix . 'bp_user_blogs_comments';
128
+ $bp->blogs->table_name_blogmeta = $wpdb->base_prefix . 'bp_user_blogs_blogmeta';
129
+ $bp->blogs->format_activity_function = 'bp_blogs_format_activity';
130
+ $bp->blogs->format_notification_function = 'bp_blogs_format_notifications';
131
+ $bp->blogs->image_base = BP_PLUGIN_URL . '/bp-groups/images';
132
+ $bp->blogs->slug = BP_BLOGS_SLUG;
133
+
134
+ $bp->version_numbers->blogs = BP_BLOGS_VERSION;
135
+ }
136
+ add_action( 'plugins_loaded', 'bp_blogs_setup_globals', 5 );
137
+ add_action( 'admin_menu', 'bp_blogs_setup_globals', 1 );
138
+
139
+ function bp_blogs_setup_root_component() {
140
+ /* Register 'groups' as a root component */
141
+ bp_core_add_root_component( BP_BLOGS_SLUG );
142
+ }
143
+ add_action( 'plugins_loaded', 'bp_blogs_setup_root_component', 1 );
144
+
145
+ /**
146
+ * bp_blogs_setup_nav()
147
+ *
148
+ * Adds "Blog" to the navigation arrays for the current and logged in user.
149
+ *
150
+ * @package BuddyPress Blogs
151
+ * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
152
+ * @uses bp_is_home() Checks to see if the current user being viewed is the logged in user
153
+ */
154
+ function bp_blogs_setup_nav() {
155
+ global $bp;
156
+
157
+ /* Add 'Blogs' to the main navigation */
158
+ bp_core_add_nav_item( __( 'Blogs', 'buddypress' ), $bp->blogs->slug );
159
+
160
+ if ( $bp->displayed_user->id )
161
+ bp_core_add_nav_default( $bp->blogs->slug, 'bp_blogs_screen_my_blogs', 'my-blogs' );
162
+
163
+ $blogs_link = $bp->loggedin_user->domain . $bp->blogs->slug . '/';
164
+
165
+ /* Add the subnav items to the blogs nav item */
166
+ bp_core_add_subnav_item( $bp->blogs->slug, 'my-blogs', __('My Blogs', 'buddypress'), $blogs_link, 'bp_blogs_screen_my_blogs', 'my-blogs-list' );
167
+ bp_core_add_subnav_item( $bp->blogs->slug, 'recent-posts', __('Recent Posts', 'buddypress'), $blogs_link, 'bp_blogs_screen_recent_posts' );
168
+ bp_core_add_subnav_item( $bp->blogs->slug, 'recent-comments', __('Recent Comments', 'buddypress'), $blogs_link, 'bp_blogs_screen_recent_comments' );
169
+ bp_core_add_subnav_item( $bp->blogs->slug, 'create-a-blog', __('Create a Blog', 'buddypress'), $blogs_link, 'bp_blogs_screen_create_a_blog' );
170
+
171
+ /* Set up the component options navigation for Blog */
172
+ if ( 'blogs' == $bp->current_component ) {
173
+ if ( bp_is_home() ) {
174
+ if ( function_exists('xprofile_setup_nav') ) {
175
+ $bp->bp_options_title = __('My Blogs', 'buddypress');
176
+ }
177
+ } else {
178
+ /* If we are not viewing the logged in user, set up the current users avatar and name */
179
+ $bp->bp_options_avatar = bp_core_get_avatar( $bp->displayed_user->id, 1 );
180
+ $bp->bp_options_title = $bp->displayed_user->fullname;
181
+ }
182
+ }
183
+ }
184
+ add_action( 'wp', 'bp_blogs_setup_nav', 2 );
185
+ add_action( 'admin_menu', 'bp_blogs_setup_nav', 2 );
186
+
187
+ function bp_blogs_directory_blogs_setup() {
188
+ global $bp;
189
+
190
+ if ( $bp->current_component == $bp->blogs->slug && empty( $bp->current_action ) ) {
191
+ $bp->is_directory = true;
192
+
193
+ wp_enqueue_script( 'bp-blogs-directory-blogs', BP_PLUGIN_URL . '/bp-blogs/js/directory-blogs.js', array( 'jquery', 'jquery-livequery-pack' ) );
194
+ bp_core_load_template( apply_filters( 'bp_blogs_template_directory_blogs_setup', 'directories/blogs/index' ) );
195
+ }
196
+ }
197
+ add_action( 'wp', 'bp_blogs_directory_blogs_setup', 5 );
198
+
199
+ function bp_blogs_screen_my_blogs() {
200
+ do_action( 'bp_blogs_screen_my_blogs' );
201
+ bp_core_load_template( apply_filters( 'bp_blogs_template_my_blogs', 'blogs/my-blogs' ) );
202
+ }
203
+
204
+ function bp_blogs_screen_recent_posts() {
205
+ do_action( 'bp_blogs_screen_recent_posts' );
206
+ bp_core_load_template( apply_filters( 'bp_blogs_template_recent_posts', 'blogs/recent-posts' ) );
207
+ }
208
+
209
+ function bp_blogs_screen_recent_comments() {
210
+ do_action( 'bp_blogs_screen_recent_comments' );
211
+ bp_core_load_template( apply_filters( 'bp_blogs_template_recent_comments', 'blogs/recent-comments' ) );
212
+ }
213
+
214
+ function bp_blogs_screen_create_a_blog() {
215
+ do_action( 'bp_blogs_screen_create_a_blog' );
216
+ bp_core_load_template( apply_filters( 'bp_blogs_template_create_a_blog', 'blogs/create' ) );
217
+ }
218
+
219
+
220
+ /**************************************************************************
221
+ bp_blogs_record_activity()
222
+
223
+ Records activity for the logged in user within the friends component so that
224
+ it will show in the users activity stream (if installed)
225
+ **************************************************************************/
226
+
227
+ function bp_blogs_record_activity( $args = true ) {
228
+ global $bp;
229
+
230
+ /* Because blog, comment, and blog post code execution happens before anything else
231
+ we need to manually instantiate the activity component globals */
232
+ if ( !$bp->activity && function_exists('bp_activity_setup_globals') )
233
+ bp_activity_setup_globals();
234
+
235
+ if ( function_exists('bp_activity_record') ) {
236
+ extract($args);
237
+
238
+ bp_activity_record( $item_id, $component_name, $component_action, $is_private, $secondary_item_id, $user_id, $secondary_user_id, $recorded_time );
239
+ }
240
+ }
241
+
242
+ function bp_blogs_delete_activity( $args = true ) {
243
+ if ( function_exists('bp_activity_delete') ) {
244
+ extract($args);
245
+ bp_activity_delete( $item_id, $component_name, $component_action, $user_id, $secondary_item_id );
246
+ }
247
+ }
248
+
249
+ /**************************************************************************
250
+ bp_blogs_format_activity()
251
+
252
+ Selects and formats recorded blogs component activity.
253
+ **************************************************************************/
254
+
255
+ function bp_blogs_format_activity( $item_id, $user_id, $action, $secondary_item_id = false, $for_secondary_user = false ) {
256
+ global $bp;
257
+
258
+ switch( $action ) {
259
+ case 'new_blog':
260
+ $blog = new BP_Blogs_Blog($item_id);
261
+
262
+ if ( !$blog )
263
+ return false;
264
+
265
+ if ( !$user_id )
266
+ return false;
267
+
268
+ $blog_url = get_blog_option( $blog->blog_id, 'siteurl' );
269
+ $user_link = bp_core_get_userlink($user_id);
270
+ $blog_name = get_blog_option( $blog->blog_id, 'blogname' );
271
+
272
+ return array(
273
+ 'primary_link' => $blog_url,
274
+ 'content' => apply_filters( 'bp_blogs_new_blog_activity', sprintf( __( '%s created a new blog: %s', 'buddypress' ), $user_link, '<a href="' . $blog_url . '">' . $blog_name . '</a>' ) . ' <span class="time-since">%s</span>', $user_link, $blog_url, $blog_name )
275
+ );
276
+ break;
277
+ case 'new_blog_post':
278
+ $post = new BP_Blogs_Post( $item_id );
279
+
280
+ if ( !$post )
281
+ return false;
282
+
283
+ $post = BP_Blogs_Post::fetch_post_content($post);
284
+
285
+ if ( !$post || $post->post_type != 'post' )
286
+ return false;
287
+
288
+ $post_link = bp_post_get_permalink( $post, $post->blog_id );
289
+ $user_link = bp_core_get_userlink($user_id);
290
+
291
+ $content = sprintf( __( '%s wrote a new blog post: %s', 'buddypress' ), $user_link, '<a href="' . $post_link . '">' . $post->post_title . '</a>' ) . ' <span class="time-since">%s</span>';
292
+ $content .= '<blockquote>' . bp_create_excerpt($post->post_content) . '</blockquote>';
293
+
294
+ $content = apply_filters( 'bp_blogs_new_post_activity', $content, $user_link, $post );
295
+
296
+ return array(
297
+ 'primary_link' => $post_link,
298
+ 'content' => $content
299
+ );
300
+ break;
301
+ case 'new_blog_comment':
302
+
303
+ if ( !is_user_logged_in() )
304
+ return false;
305
+
306
+ $comment = new BP_Blogs_Comment($secondary_item_id);
307
+
308
+ if ( !$comment )
309
+ return false;
310
+
311
+ $comment = BP_Blogs_Comment::fetch_comment_content($comment);
312
+
313
+ if ( !$comment )
314
+ return false;
315
+
316
+ $comment_link = bp_post_get_permalink( $comment->post, $comment->blog_id );
317
+ $user_link = bp_core_get_userlink($user_id);
318
+
319
+ $content = sprintf( __( '%s commented on the blog post %s', 'buddypress' ), $user_link, '<a href="' . $comment_link . '#comment-' . $comment->comment_ID . '">' . $comment->post->post_title . '</a>' ) . ' <span class="time-since">%s</span>';
320
+ $content .= '<blockquote>' . bp_create_excerpt($comment->comment_content) . '</blockquote>';
321
+
322
+ $content = apply_filters( 'bp_blogs_new_comment_activity', $content, $user_link, $comment );
323
+
324
+ return array(
325
+ 'primary_link' => $post_link . '#comment-' . $comment->comment_ID,
326
+ 'content' => $content
327
+ );
328
+ break;
329
+ }
330
+
331
+ do_action( 'bp_blogs_format_activity', $action, $item_id, $user_id, $action, $secondary_item_id, $for_secondary_user );
332
+
333
+ return false;
334
+ }
335
+
336
+ function bp_blogs_record_existing_blogs() {
337
+ global $wpdb;
338
+
339
+ $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" ) );
340
+
341
+ if ( $blog_ids ) {
342
+ foreach( $blog_ids as $blog_id ) {
343
+ $users = get_users_of_blog( $blog_id );
344
+
345
+ if ( $users ) {
346
+ foreach ( $users as $user ) {
347
+ $role = unserialize( $user->meta_value );
348
+
349
+ if ( !isset( $role['subscriber'] ) )
350
+ bp_blogs_record_blog( $blog_id, $user->user_id );
351
+ }
352
+ }
353
+ }
354
+ }
355
+ }
356
+
357
+
358
+ function bp_blogs_record_blog( $blog_id, $user_id ) {
359
+ global $bp;
360
+
361
+ if ( !$user_id )
362
+ $user_id = $bp->loggedin_user->id;
363
+
364
+ $name = get_blog_option( $blog_id, 'blogname' );
365
+ $description = get_blog_option( $blog_id, 'blogdescription' );
366
+
367
+ $recorded_blog = new BP_Blogs_Blog;
368
+ $recorded_blog->user_id = $user_id;
369
+ $recorded_blog->blog_id = $blog_id;
370
+
371
+ $recorded_blog_id = $recorded_blog->save();
372
+
373
+ bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'name', $name );
374
+ bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'description', $description );
375
+ bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'last_activity', time() );
376
+
377
+ if ( (int)$_POST['blog_public'] )
378
+ $is_private = 0;
379
+ else
380
+ $is_private = 1;
381
+
382
+ // Record in activity streams
383
+ bp_blogs_record_activity( array( 'item_id' => $recorded_blog_id, 'component_name' => 'blogs', 'component_action' => 'new_blog', 'is_private' => $is_private, 'user_id' => $recorded_blog->user_id ) );
384
+
385
+ do_action( 'bp_blogs_new_blog', $recorded_blog, $is_private, $is_recorded );
386
+ }
387
+ add_action( 'wpmu_new_blog', 'bp_blogs_record_blog', 10, 2 );
388
+
389
+ function bp_blogs_record_post( $post_id, $blog_id = false, $user_id = false ) {
390
+ global $bp, $wpdb;
391
+
392
+ $post_id = (int)$post_id;
393
+ $post = get_post($post_id);
394
+
395
+ if ( !$user_id )
396
+ $user_id = (int)$post->post_author;
397
+
398
+ if ( !$blog_id )
399
+ $blog_id = (int)$wpdb->blogid;
400
+
401
+ /* This is to stop infinate loops with Donncha's sitewide tags plugin */
402
+ if ( (int)get_site_option('tags_blog_id') == (int)$blog_id )
403
+ return false;
404
+
405
+ /* Don't record this if it's not a post */
406
+ if ( $post->post_type != 'post' )
407
+ return false;
408
+
409
+ if ( !$is_recorded = BP_Blogs_Post::is_recorded( $post_id, $blog_id, $user_id ) ) {
410
+ if ( 'publish' == $post->post_status && '' == $post->post_password ) {
411
+
412
+ $recorded_post = new BP_Blogs_Post;
413
+ $recorded_post->user_id = $user_id;
414
+ $recorded_post->blog_id = $blog_id;
415
+ $recorded_post->post_id = $post_id;
416
+ $recorded_post->date_created = strtotime( $post->post_date );
417
+
418
+ $recorded_post_id = $recorded_post->save();
419
+
420
+ bp_blogs_update_blogmeta( $recorded_post->blog_id, 'last_activity', time() );
421
+ bp_blogs_record_activity( array( 'item_id' => $recorded_post->id, 'component_name' => 'blogs', 'component_action' => 'new_blog_post', 'is_private' => bp_blogs_is_blog_hidden( $recorded_post->blog_id ), 'user_id' => $recorded_post->user_id, 'recorded_time' => strtotime( $post->post_date ) ) );
422
+ }
423
+ } else {
424
+ $existing_post = new BP_Blogs_Post( null, $blog_id, $post_id );
425
+
426
+ /**
427
+ * Delete the recorded post if:
428
+ * - The status is no longer "published"
429
+ * - The post is password protected
430
+ */
431
+ if ( 'publish' != $post->post_status || '' != $post->post_password )
432
+ bp_blogs_remove_post( $post_id, $blog_id );
433
+
434
+ // Check to see if the post author has changed.
435
+ if ( (int)$existing_post->user_id != (int)$post->post_author ) {
436
+ // Delete the existing recorded post
437
+ bp_blogs_remove_post( $post_id, $blog_id );
438
+
439
+ // Re-record the post with the new author.
440
+ bp_blogs_record_post( $post_id );
441
+ }
442
+
443
+ $recorded_post = $existing_post;
444
+
445
+ /* Delete and re-add the activity stream item to reflect potential content changes. */
446
+ bp_blogs_delete_activity( array( 'item_id' => $recorded_post->id, 'component_name' => 'blogs', 'component_action' => 'new_blog_post', 'user_id' => $recorded_post->user_id ) );
447
+ bp_blogs_record_activity( array( 'item_id' => $recorded_post->id, 'component_name' => 'blogs', 'component_action' => 'new_blog_post', 'is_private' => bp_blogs_is_blog_hidden( $recorded_post->blog_id ), 'user_id' => $recorded_post->user_id, 'recorded_time' => strtotime( $post->post_date ) ) );
448
+ }
449
+
450
+ do_action( 'bp_blogs_new_blog_post', $recorded_post, $is_private, $is_recorded );
451
+ }
452
+ add_action( 'publish_post', 'bp_blogs_record_post' );
453
+ add_action( 'edit_post', 'bp_blogs_record_post' );
454
+
455
+
456
+ function bp_blogs_record_comment( $comment_id, $is_approved ) {
457
+ global $wpdb;
458
+
459
+ if ( !$is_approved )
460
+ return false;
461
+
462
+ $comment = get_comment($comment_id);
463
+
464
+ /* Get the user_id from the author email. */
465
+ $user = get_user_by_email( $comment->comment_author_email );
466
+ $user_id = (int)$user->ID;
467
+
468
+ if ( !$user_id )
469
+ return false;
470
+
471
+ $recorded_comment = new BP_Blogs_Comment;
472
+ $recorded_comment->user_id = $user_id;
473
+ $recorded_comment->blog_id = $wpdb->blogid;
474
+ $recorded_comment->comment_id = $comment_id;
475
+ $recorded_comment->comment_post_id = $comment->comment_post_ID;
476
+ $recorded_comment->date_created = strtotime( $comment->comment_date );
477
+
478
+ $recorded_commment_id = $recorded_comment->save();
479
+
480
+ bp_blogs_update_blogmeta( $recorded_comment->blog_id, 'last_activity', time() );
481
+ bp_blogs_record_activity( array( 'item_id' => $recorded_comment->blog_id, 'secondary_item_id' => $recorded_commment_id, 'component_name' => 'blogs', 'component_action' => 'new_blog_comment', 'is_private' => $is_private, 'user_id' => $recorded_comment->user_id, 'recorded_time' => $recorded_comment->date_created ) );
482
+ }
483
+ add_action( 'comment_post', 'bp_blogs_record_comment', 10, 2 );
484
+
485
+ function bp_blogs_approve_comment( $comment_id, $comment ) {
486
+ global $bp, $wpdb;
487
+
488
+ $recorded_comment = bp_blogs_record_comment( $comment_id, true );
489
+
490
+ bp_blogs_delete_activity( array( 'item_id' => $recorded_comment->blog_id, 'secondary_item_id' => $recorded_commment_id, 'component_name' => 'blogs', 'component_action' => 'new_blog_comment', 'user_id' => $recorded_comment->user_id ) );
491
+ bp_blogs_record_activity( array( 'item_id' => $recorded_comment->blog_id, 'secondary_item_id' => $recorded_commment_id, 'component_name' => 'blogs', 'component_action' => 'new_blog_comment', 'is_private' => $is_private, 'user_id' => $recorded_comment->user_id, 'recorded_time' => $recorded_comment->date_created ) );
492
+ }
493
+ add_action( 'comment_approved_', 'bp_blogs_approve_comment', 10, 2 );
494
+
495
+ function bp_blogs_unapprove_comment( $comment_id, $status = false ) {
496
+ if ( 'spam' == $status || !$status )
497
+ bp_blogs_remove_comment( $comment_id );
498
+ }
499
+ add_action( 'comment_unapproved_', 'bp_blogs_unapprove_comment' );
500
+ add_action( 'wp_set_comment_status', 'bp_blogs_unapprove_comment', 10, 2 );
501
+
502
+ function bp_blogs_add_user_to_blog( $user_id, $role, $blog_id ) {
503
+ if ( $role != 'subscriber' ) {
504
+ bp_blogs_record_blog( $blog_id, $user_id );
505
+ }
506
+ }
507
+ add_action( 'add_user_to_blog', 'bp_blogs_add_user_to_blog', 10, 3 );
508
+
509
+ function bp_blogs_remove_user_from_blog( $user_id, $blog_id ) {
510
+ bp_blogs_remove_blog_for_user( $user_id, $blog_id );
511
+ }
512
+ add_action( 'remove_user_from_blog', 'bp_blogs_remove_user_from_blog', 10, 2 );
513
+
514
+ function bp_blogs_remove_blog( $blog_id ) {
515
+ global $bp;
516
+
517
+ $blog_id = (int)$blog_id;
518
+
519
+ BP_Blogs_Blog::delete_blog_for_all( $blog_id );
520
+
521
+ // Delete activity stream item
522
+ bp_blogs_delete_activity( array( 'item_id' => $blog_id, 'component_name' => 'blogs', 'component_action' => 'new_blog', 'user_id' => $bp->loggedin_user->id ) );
523
+
524
+ do_action( 'bp_blogs_remove_blog', $blog_id );
525
+ }
526
+ add_action( 'delete_blog', 'bp_blogs_remove_blog' );
527
+
528
+ function bp_blogs_remove_blog_for_user( $user_id, $blog_id ) {
529
+ global $current_user;
530
+
531
+ $blog_id = (int)$blog_id;
532
+ $user_id = (int)$user_id;
533
+
534
+ BP_Blogs_Blog::delete_blog_for_user( $blog_id, $user_id );
535
+
536
+ // Delete activity stream item
537
+ bp_blogs_delete_activity( array( 'item_id' => $blog_id, 'component_name' => 'blogs', 'component_action' => 'new_blog', 'user_id' => $current_user->ID ) );
538
+
539
+ do_action( 'bp_blogs_remove_blog_for_user', $blog_id, $user_id );
540
+ }
541
+ add_action( 'remove_user_from_blog', 'bp_blogs_remove_blog_for_user', 10, 2 );
542
+
543
+ function bp_blogs_remove_post( $post_id ) {
544
+ global $current_blog, $bp;
545
+
546
+ $post_id = (int)$post_id;
547
+ $blog_id = (int)$current_blog->blog_id;
548
+
549
+ $post = new BP_Blogs_Post( null, $blog_id, $post_id );
550
+
551
+ // Delete post from the bp_blogs table
552
+ BP_Blogs_Post::delete( $post_id, $blog_id );
553
+
554
+ // Delete activity stream item
555
+ bp_blogs_delete_activity( array( 'item_id' => $post->id, 'component_name' => 'blogs', 'component_action' => 'new_blog_post', 'user_id' => $post->user_id ) );
556
+
557
+ do_action( 'bp_blogs_remove_post', $blog_id, $post_id, $post->user_id );
558
+ }
559
+ add_action( 'delete_post', 'bp_blogs_remove_post' );
560
+
561
+ function bp_blogs_remove_comment( $comment_id ) {
562
+ global $wpdb, $bp;
563
+
564
+ $recorded_comment = new BP_Blogs_Comment( false, $wpdb->blogid, $comment_id );
565
+ BP_Blogs_Comment::delete( $comment_id, $wpdb->blogid );
566
+
567
+ // Delete activity stream item
568
+ bp_blogs_delete_activity( array( 'item_id' => $recorded_comment->blog_id, 'secondary_item_id' => $recorded_comment->id, 'component_name' => 'blogs', 'component_action' => 'new_blog_comment', 'user_id' => $recorded_comment->user_id ) );
569
+
570
+ do_action( 'bp_blogs_remove_comment', $blog_id, $comment_id, $bp->loggedin_user->id );
571
+ }
572
+ add_action( 'delete_comment', 'bp_blogs_remove_comment' );
573
+
574
+ function bp_blogs_remove_data_for_blog( $blog_id ) {
575
+ global $bp;
576
+
577
+ /* If this is regular blog, delete all data for that blog. */
578
+ BP_Blogs_Blog::delete_blog_for_all( $blog_id );
579
+ BP_Blogs_Post::delete_posts_for_blog( $blog_id );
580
+ BP_Blogs_Comment::delete_comments_for_blog( $blog_id );
581
+
582
+ // Delete activity stream item
583
+ bp_blogs_delete_activity( array( 'item_id' => $blog_id, 'component_name' => 'blogs', 'component_action' => false, 'user_id' => $bp->loggedin_user->id ) );
584
+
585
+ do_action( 'bp_blogs_remove_data_for_blog', $blog_id );
586
+ }
587
+ add_action( 'delete_blog', 'bp_blogs_remove_data_for_blog', 1 );
588
+
589
+ function bp_blogs_get_blogs_for_user( $user_id ) {
590
+ return BP_Blogs_Blog::get_blogs_for_user( $user_id );
591
+ }
592
+
593
+ function bp_blogs_get_posts_for_user( $user_id ) {
594
+ return BP_Blogs_Post::get_posts_for_user( $user_id );
595
+ }
596
+
597
+ function bp_blogs_get_comments_for_user( $user_id ) {
598
+ return BP_Blogs_Comment::get_comments_for_user( $user_id );
599
+ }
600
+
601
+ function bp_blogs_get_latest_posts( $blog_id = null, $limit = 5 ) {
602
+ global $bp;
603
+
604
+ if ( !is_numeric( $limit ) )
605
+ $limit = 5;
606
+
607
+ return BP_Blogs_Post::get_latest_posts( $blog_id, $limit );
608
+ }
609
+
610
+ function bp_blogs_get_all_blogs( $limit = null, $page = null ) {
611
+ return BP_Blogs_Blog::get_all( $limit, $page );
612
+ }
613
+
614
+ function bp_blogs_get_random_blog( $limit = null, $page = null ) {
615
+ return BP_Blogs_Blog::get_random( $limit, $page );
616
+ }
617
+
618
+ function bp_blogs_get_all_posts( $limit = null, $page = null ) {
619
+ return BP_Blogs_Post::get_all( $limit, $page );
620
+ }
621
+
622
+ function bp_blogs_total_post_count( $blog_id ) {
623
+ return BP_Blogs_Post::total_post_count( $blog_id );
624
+ }
625
+
626
+ function bp_blogs_total_comment_count( $blog_id, $post_id = false ) {
627
+ return BP_Blogs_Post::total_comment_count( $blog_id, $post_id );
628
+ }
629
+
630
+ function bp_blogs_is_blog_hidden( $blog_id ) {
631
+ return BP_Blogs_Blog::is_hidden( $blog_id );
632
+ }
633
+
634
+ function bp_blogs_redirect_to_random_blog() {
635
+ global $bp, $wpdb;
636
+
637
+ if ( $bp->current_component == $bp->blogs->slug && isset( $_GET['random-blog'] ) ) {
638
+ $blog = bp_blogs_get_random_blog();
639
+
640
+ bp_core_redirect( get_blog_option( $blog['blogs'][0]->blog_id, 'siteurl') );
641
+ }
642
+ }
643
+ add_action( 'wp', 'bp_blogs_redirect_to_random_blog', 6 );
644
+
645
+
646
+ //
647
+ // Blog meta functions
648
+ // These functions are used to store specific blogmeta in one global table, rather than in each
649
+ // blog's options table. Significantly speeds up global blog queries.
650
+ // By default each blog's name, description and last updated time are stored and synced here.
651
+ //
652
+
653
+ function bp_blogs_delete_blogmeta( $blog_id, $meta_key = false, $meta_value = false ) {
654
+ global $wpdb, $bp;
655
+
656
+ if ( !is_numeric( $blog_id ) )
657
+ return false;
658
+
659
+ $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
660
+
661
+ if ( is_array($meta_value) || is_object($meta_value) )
662
+ $meta_value = serialize($meta_value);
663
+
664
+ $meta_value = trim( $meta_value );
665
+
666
+ if ( !$meta_key ) {
667
+ $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d", $blog_id ) );
668
+ } else if ( $meta_value ) {
669
+ $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 ) );
670
+ } else {
671
+ $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d AND meta_key = %s", $blog_id, $meta_key ) );
672
+ }
673
+
674
+ // TODO need to look into using this.
675
+ // wp_cache_delete($group_id, 'groups');
676
+
677
+ return true;
678
+ }
679
+
680
+ function bp_blogs_get_blogmeta( $blog_id, $meta_key = '') {
681
+ global $wpdb, $bp;
682
+
683
+ $blog_id = (int) $blog_id;
684
+
685
+ if ( !$blog_id )
686
+ return false;
687
+
688
+ if ( !empty($meta_key) ) {
689
+ $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
690
+
691
+ // TODO need to look into using this.
692
+ //$user = wp_cache_get($user_id, 'users');
693
+
694
+ // Check the cached user object
695
+ //if ( false !== $user && isset($user->$meta_key) )
696
+ // $metas = array($user->$meta_key);
697
+ //else
698
+ $metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d AND meta_key = %s", $blog_id, $meta_key) );
699
+ } else {
700
+ $metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d", $blog_id) );
701
+ }
702
+
703
+ if ( empty($metas) ) {
704
+ if ( empty($meta_key) )
705
+ return array();
706
+ else
707
+ return '';
708
+ }
709
+
710
+ $metas = array_map('maybe_unserialize', $metas);
711
+
712
+ if ( 1 == count($metas) )
713
+ return $metas[0];
714
+ else
715
+ return $metas;
716
+ }
717
+
718
+ function bp_blogs_update_blogmeta( $blog_id, $meta_key, $meta_value ) {
719
+ global $wpdb, $bp;
720
+
721
+ if ( !is_numeric( $blog_id ) )
722
+ return false;
723
+
724
+ $meta_key = preg_replace( '|[^a-z0-9_]|i', '', $meta_key );
725
+
726
+ if ( is_string($meta_value) )
727
+ $meta_value = stripslashes($wpdb->escape($meta_value));
728
+
729
+ $meta_value = maybe_serialize($meta_value);
730
+
731
+ if (empty($meta_value)) {
732
+ return bp_blogs_delete_blogmeta( $blog_id, $meta_key );
733
+ }
734
+
735
+ $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 ) );
736
+
737
+ if ( !$cur ) {
738
+ $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 ) );
739
+ } else if ( $cur->meta_value != $meta_value ) {
740
+ $wpdb->query( $wpdb->prepare( "UPDATE {$bp->blogs->table_name_blogmeta} SET meta_value = %s WHERE blog_id = %d AND meta_key = %s", $meta_value, $blog_id, $meta_key ) );
741
+ } else {
742
+ return false;
743
+ }
744
+
745
+ // TODO need to look into using this.
746
+ // wp_cache_delete($user_id, 'users');
747
+
748
+ return true;
749
+ }
750
+
751
+ function bp_blogs_force_buddypress_theme( $template ) {
752
+ global $bp;
753
+
754
+ if ( $bp->current_component == $bp->blogs->slug && empty( $bp->current_action ) ) {
755
+ $member_theme = get_site_option( 'active-member-theme' );
756
+
757
+ if ( empty( $member_theme ) )
758
+ $member_theme = 'bpmember';
759
+
760
+ add_filter( 'theme_root', 'bp_core_set_member_theme_root' );
761
+ add_filter( 'theme_root_uri', 'bp_core_set_member_theme_root_uri' );
762
+
763
+ return $member_theme;
764
+ } else {
765
+ return $template;
766
+ }
767
+ }
768
+ add_filter( 'template', 'bp_blogs_force_buddypress_theme', 1, 1 );
769
+
770
+ function bp_blogs_force_buddypress_stylesheet( $stylesheet ) {
771
+ global $bp;
772
+
773
+ if ( $bp->current_component == $bp->blogs->slug && empty( $bp->current_action ) ) {
774
+ $member_theme = get_site_option( 'active-member-theme' );
775
+
776
+ if ( empty( $member_theme ) )
777
+ $member_theme = 'bpmember';
778
+
779
+ add_filter( 'theme_root', 'bp_core_set_member_theme_root' );
780
+ add_filter( 'theme_root_uri', 'bp_core_set_member_theme_root_uri' );
781
+
782
+ return $member_theme;
783
+ } else {
784
+ return $stylesheet;
785
+ }
786
+ }
787
+ add_filter( 'stylesheet', 'bp_blogs_force_buddypress_stylesheet', 1, 1 );
788
+
789
+
790
+
791
+ function bp_blogs_remove_data( $user_id ) {
792
+ /* If this is regular blog, delete all data for that blog. */
793
+ BP_Blogs_Blog::delete_blogs_for_user( $user_id );
794
+ BP_Blogs_Post::delete_posts_for_user( $user_id );
795
+ BP_Blogs_Comment::delete_comments_for_user( $user_id );
796
+
797
+ do_action( 'bp_blogs_remove_data', $user_id );
798
+ }
799
+ add_action( 'wpmu_delete_user', 'bp_blogs_remove_data', 1 );
800
+ add_action( 'delete_user', 'bp_blogs_remove_data', 1 );
801
+
802
+
803
+ function bp_blogs_clear_blog_object_cache( $blog_id, $user_id ) {
804
+ wp_cache_delete( 'bp_blogs_of_user_' . $user_id, 'bp' );
805
+ wp_cache_delete( 'bp_blogs_for_user_' . $user_id, 'bp' );
806
+
807
+ /* Clear the sitewide activity cache */
808
+ wp_cache_delete( 'sitewide_activity', 'bp' );
809
+ }
810
+
811
+ function bp_blogs_format_clear_blog_cache( $recorded_blog_obj ) {
812
+ bp_blogs_clear_blog_object_cache( false, $recorded_blog_obj->user_id );
813
+
814
+ /* Clear the sitewide activity cache */
815
+ wp_cache_delete( 'sitewide_activity', 'bp' );
816
+ }
817
+
818
+ function bp_blogs_clear_post_object_cache( $blog_id, $post_id, $user_id ) {
819
+ wp_cache_delete( 'bp_user_posts_' . $user_id, 'bp' );
820
+ }
821
+
822
+ function bp_blogs_format_clear_post_cache( $recorded_post_obj ) {
823
+ bp_blogs_clear_post_object_cache( false, false, $recorded_post_obj->user_id );
824
+
825
+ /* Clear the sitewide activity cache */
826
+ wp_cache_delete( 'sitewide_activity', 'bp' );
827
+ }
828
+
829
+ function bp_blogs_clear_comment_object_cache( $blog_id, $comment_id, $user_id ) {
830
+ wp_cache_delete( 'bp_user_comments_' . $user_id, 'bp' );
831
+ }
832
+
833
+ function bp_blogs_format_clear_comment_cache( $recorded_comment_obj ) {
834
+ bp_blogs_clear_comment_object_cache( false, false, $recorded_comment_obj->user_id );
835
+
836
+ /* Clear the sitewide activity cache */
837
+ wp_cache_delete( 'sitewide_activity', 'bp' );
838
+ }
839
+
840
+ // List actions to clear object caches on
841
+ add_action( 'bp_blogs_remove_blog_for_user', 'bp_blogs_clear_blog_object_cache', 10, 2 );
842
+ add_action( 'bp_blogs_remove_post', 'bp_blogs_clear_post_object_cache', 10, 3 );
843
+ add_action( 'bp_blogs_remove_comment', 'bp_blogs_clear_comment_object_cache', 10, 3 );
844
+
845
+ add_action( 'bp_blogs_new_blog', 'bp_blogs_format_clear_blog_cache', 10, 2 );
846
+ add_action( 'bp_blogs_new_blog_post', 'bp_blogs_format_clear_post_cache', 10, 2 );
847
+ add_action( 'bp_blogs_new_blog_comment', 'bp_blogs_format_clear_comment_cache', 10, 2 );
848
+
849
+ // List actions to clear super cached pages on, if super cache is installed
850
+ add_action( 'bp_blogs_remove_data_for_blog', 'bp_core_clear_cache' );
851
+ add_action( 'bp_blogs_remove_comment', 'bp_core_clear_cache' );
852
+ add_action( 'bp_blogs_remove_post', 'bp_core_clear_cache' );
853
+ add_action( 'bp_blogs_remove_blog_for_user', 'bp_core_clear_cache' );
854
+ add_action( 'bp_blogs_remove_blog', 'bp_core_clear_cache' );
855
+ add_action( 'bp_blogs_new_blog_comment', 'bp_core_clear_cache' );
856
+ add_action( 'bp_blogs_new_blog_post', 'bp_core_clear_cache' );
857
+ add_action( 'bp_blogs_new_blog', 'bp_core_clear_cache' );
858
+ add_action( 'bp_blogs_remove_data', 'bp_core_clear_cache' );
859
+
860
+
861
+
862
+ ?>
bp-blogs/admin-tabs/admin.css ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ul#blog-list, ul#comment-list {
2
+ margin: 0;
3
+ padding: 0;
4
+ list-style: none;
5
+ }
6
+ ul#blog-list h4 {
7
+ font: normal 1.6em georgia, times, serif;
8
+ margin: 0.8em 0 0.2em 0;
9
+ }
10
+
11
+ ul#blog-list li, ul#comment-list li {
12
+ border-bottom: 1px solid #ddd;
13
+ }
14
+
15
+ .post {
16
+ border-bottom: 1px solid #ddd;
17
+ padding: 0.5em;
18
+ }
19
+
20
+ .post h2 {
21
+ font: normal 1.4em georgia, times, serif !important;
22
+ border: none !important;
23
+ margin: 0.5em 0 0.2em 0 !important;
24
+ }
25
+
26
+ .post hr {
27
+ visibility: hidden;
28
+ clear: both;
29
+ }
30
+
31
+ .post p.date {
32
+ margin: 0;
33
+ font-size: 0.9em;
34
+ }
35
+
36
+ .post p.date, .small, h2 span {
37
+ font: italic 1em Georgia, times, serif;
38
+ color: #888;
39
+ font-size: 0.95em;
40
+ }
41
+
42
+ .post span.tags {
43
+ background: url(/wp-content/themes/buddypress/images/tag_icon.gif) center left no-repeat;
44
+ padding-left: 1.6em;
45
+ float: left;
46
+ }
47
+
48
+ .post span.comments {
49
+ float: right;
50
+ background: url(/wp-content/themes/buddypress/images/comments_icon.gif) center right no-repeat;
51
+ padding-right: 1.8em;
52
+ }
53
+
54
+ ul#comment-list li {
55
+ padding: 0.8em;
56
+ }
bp-blogs/admin-tabs/bp-blogs-comments-tab.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <div class="wrap">
2
+ <?php require( TEMPLATEPATH . "/blogs/recent-comments.php" ); ?>
3
+ </div>
bp-blogs/admin-tabs/bp-blogs-posts-tab.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <div class="wrap">
2
+ <?php require( TEMPLATEPATH . "/blogs/recent-posts.php" ); ?>
3
+ </div>
bp-blogs/admin-tabs/bp-blogs-tab.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <div class="wrap">
2
+ <?php require( TEMPLATEPATH . "/blogs/my-blogs.php" ); ?>
3
+ </div>
bp-blogs/bp-blogs-ajax.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ function bp_blogs_ajax_directory_blogs() {
3
+ global $bp;
4
+
5
+ check_ajax_referer('directory_blogs');
6
+
7
+ load_template( TEMPLATEPATH . '/directories/blogs/blogs-loop.php' );
8
+ }
9
+ add_action( 'wp_ajax_directory_blogs', 'bp_blogs_ajax_directory_blogs' );
10
+
11
+
12
+ ?>
bp-blogs/bp-blogs-classes.php ADDED
@@ -0,0 +1,665 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ Class BP_Blogs_Blog {
4
+ var $id;
5
+ var $user_id;
6
+ var $blog_id;
7
+
8
+ function bp_blogs_blog( $id = null ) {
9
+ global $bp, $wpdb;
10
+
11
+ if ( !$user_id )
12
+ $user_id = $bp->displayed_user->id;
13
+
14
+ if ( $id ) {
15
+ $this->id = $id;
16
+ $this->populate();
17
+ }
18
+ }
19
+
20
+ function populate() {
21
+ global $wpdb, $bp;
22
+
23
+ $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name} WHERE id = %d", $this->id ) );
24
+
25
+ $this->user_id = $blog->user_id;
26
+ $this->blog_id = $blog->blog_id;
27
+ }
28
+
29
+ function save() {
30
+ global $wpdb, $bp;
31
+
32
+ $this->user_id = apply_filters( 'bp_blogs_blog_user_id_before_save', $this->user_id, $this->id );
33
+ $this->blog_id = apply_filters( 'bp_blogs_blog_id_before_save', $this->blog_id, $this->id );
34
+
35
+ do_action( 'bp_blogs_blog_before_save', $this );
36
+
37
+ // Don't try and save if there is no user ID or blog ID set.
38
+ if ( !$this->user_id || !$this->blog_id )
39
+ return false;
40
+
41
+ // Don't save if this blog has already been recorded for the user.
42
+ if ( !$this->id && $this->exists() )
43
+ return false;
44
+
45
+ if ( $this->id ) {
46
+ // Update
47
+ $sql = $wpdb->prepare( "UPDATE {$bp->blogs->table_name} SET user_id = %d, blog_id = %d WHERE id = %d", $this->user_id, $this->blog_id, $this->id );
48
+ } else {
49
+ // Save
50
+ $sql = $wpdb->prepare( "INSERT INTO {$bp->blogs->table_name} ( user_id, blog_id ) VALUES ( %d, %d )", $this->user_id, $this->blog_id );
51
+ }
52
+
53
+ if ( !$wpdb->query($sql) )
54
+ return false;
55
+
56
+ do_action( 'bp_blogs_blog_after_save', $this );
57
+
58
+ if ( $this->id )
59
+ return $this->id;
60
+ else
61
+ return $wpdb->insert_id;
62
+ }
63
+
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 */
71
+
72
+ function delete_blog_for_all( $blog_id ) {
73
+ global $wpdb, $bp;
74
+
75
+ if ( !$bp->blogs )
76
+ bp_blogs_setup_globals();
77
+
78
+ bp_blogs_delete_blogmeta( $blog_id );
79
+
80
+ return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name} WHERE blog_id = %d", $blog_id ) );
81
+ }
82
+
83
+ function delete_blog_for_user( $blog_id, $user_id = null ) {
84
+ global $wpdb, $bp;
85
+
86
+ if ( !$bp->blogs )
87
+ bp_blogs_setup_globals();
88
+
89
+ if ( !$user_id )
90
+ $user_id = $bp->loggedin_user->id;
91
+
92
+ return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name} WHERE user_id = %d AND blog_id = %d", $user_id, $blog_id ) );
93
+ }
94
+
95
+ function delete_blogs_for_user( $user_id = null ) {
96
+ global $wpdb, $bp;
97
+
98
+ if ( !$bp->blogs )
99
+ bp_blogs_setup_globals();
100
+
101
+ if ( !$user_id )
102
+ $user_id = $bp->loggedin_user->id;
103
+
104
+ return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name} WHERE user_id = %d", $user_id ) );
105
+ }
106
+
107
+ function get_blogs_for_user( $user_id = null ) {
108
+ global $bp, $wpdb;
109
+
110
+ if ( !$bp->blogs )
111
+ bp_blogs_setup_globals();
112
+
113
+ if ( !$user_id )
114
+ $user_id = $bp->displayed_user->id;
115
+
116
+ // Show logged in users their hidden blogs.
117
+ if ( !bp_is_home() )
118
+ $blog_ids = $wpdb->get_col( $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.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND b.user_id = %d ", $user_id) );
119
+ else
120
+ $blog_ids = $wpdb->get_col( $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.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND b.user_id = %d ", $user_id) );
121
+
122
+ $total_blog_count = BP_Blogs_Blog::total_blog_count( $user_id );
123
+
124
+ for ( $i = 0; $i < count($blog_ids); $i++ ) {
125
+ $blogs[] = array(
126
+ 'id' => $blog_ids[$i],
127
+ 'siteurl' => get_blog_option($blog_ids[$i], 'siteurl'),
128
+ 'title' => get_blog_option($blog_ids[$i], 'blogname'),
129
+ 'description' => get_blog_option($blog_ids[$i], 'blogdescription')
130
+ );
131
+ }
132
+
133
+ return array( 'blogs' => $blogs, 'count' => $total_blog_count );
134
+ }
135
+
136
+ function is_recorded( $blog_id ) {
137
+ global $bp, $wpdb;
138
+
139
+ if ( !$bp->blogs )
140
+ bp_blogs_setup_globals();
141
+
142
+ return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->blogs->table_name} WHERE blog_id = %d", $blog_id ) );
143
+ }
144
+
145
+ function total_blog_count( $user_id = null ) {
146
+ global $bp, $wpdb;
147
+
148
+ if ( !$bp->blogs )
149
+ bp_blogs_setup_globals();
150
+
151
+ if ( !$user_id )
152
+ $user_id = $bp->displayed_user->id;
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 ) {
162
+ global $bp, $wpdb;
163
+
164
+ if ( !$bp->blogs )
165
+ bp_blogs_setup_globals();
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}" ) );
173
+
174
+ return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
175
+ }
176
+
177
+ function get_by_letter( $letter, $limit = null, $page = null ) {
178
+ global $bp, $wpdb;
179
+
180
+ if ( !$bp->blogs )
181
+ bp_blogs_setup_globals();
182
+
183
+ like_escape($letter);
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}" ) );
191
+
192
+ return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
193
+ }
194
+
195
+ function search_blogs( $filter, $limit = null, $page = null ) {
196
+ global $wpdb, $bp;
197
+
198
+ if ( !$bp->blogs )
199
+ bp_blogs_setup_globals();
200
+
201
+ like_escape($filter);
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}" ) );
209
+
210
+ return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
211
+ }
212
+
213
+ function get_random( $limit = null, $page = null ) {
214
+ global $bp, $wpdb;
215
+
216
+ if ( !$bp->blogs )
217
+ bp_blogs_setup_globals();
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}" ) );
225
+
226
+ return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
227
+ }
228
+
229
+ function get_active( $limit = null, $page = null ) {
230
+ global $bp, $wpdb;
231
+
232
+ if ( !$bp->blogs )
233
+ bp_blogs_setup_globals();
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}" ) );
241
+
242
+ return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
243
+ }
244
+
245
+ function get_newest( $limit = null, $page = null ) {
246
+ global $bp, $wpdb;
247
+
248
+ if ( !$bp->blogs )
249
+ bp_blogs_setup_globals();
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}" ) );
257
+
258
+ return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
259
+ }
260
+
261
+ function is_hidden( $blog_id ) {
262
+ global $wpdb;
263
+
264
+ if ( !$bp->blogs )
265
+ bp_blogs_setup_globals();
266
+
267
+ if ( !(int)$wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT public FROM {$wpdb->base_prefix}blogs WHERE blog_id = %d", $blog_id ) ) )
268
+ return true;
269
+
270
+ return false;
271
+ }
272
+ }
273
+
274
+ Class BP_Blogs_Post {
275
+ var $id;
276
+ var $user_id;
277
+ var $blog_id;
278
+ var $post_id;
279
+ var $date_created;
280
+
281
+ function bp_blogs_post( $id = null, $blog_id = null, $post_id = null ) {
282
+ global $bp, $wpdb;
283
+
284
+ if ( $id || ( !$id && $blog_id && $post_id ) ) {
285
+ $this->id = $id;
286
+ $this->blog_id = $blog_id;
287
+ $this->post_id = $post_id;
288
+ $this->populate();
289
+ }
290
+ }
291
+
292
+ function populate() {
293
+ global $wpdb, $bp;
294
+
295
+ if ( $this->id )
296
+ $post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name_blog_posts} WHERE id = %d", $this->id ) );
297
+ else
298
+ $post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name_blog_posts} WHERE blog_id = %d AND post_id = %d", $this->blog_id, $this->post_id ) );
299
+
300
+ $this->id = $post->id;
301
+ $this->user_id = $post->user_id;
302
+ $this->blog_id = $post->blog_id;
303
+ $this->post_id = $post->post_id;
304
+ $this->date_created = $post->date_created;
305
+ }
306
+
307
+ function save() {
308
+ global $wpdb, $bp;
309
+
310
+ $this->post_id = apply_filters( 'bp_blogs_post_id_before_save', $this->post_id, $this->id );
311
+ $this->blog_id = apply_filters( 'bp_blogs_post_blog_id_before_save', $this->blog_id, $this->id );
312
+ $this->user_id = apply_filters( 'bp_blogs_post_user_id_before_save', $this->user_id, $this->id );
313
+ $this->date_created = apply_filters( 'bp_blogs_post_date_created_before_save', $this->date_created, $this->id );
314
+
315
+ do_action( 'bp_blogs_post_before_save', $this );
316
+
317
+ if ( $this->id ) {
318
+ // Update
319
+ $sql = $wpdb->prepare( "UPDATE {$bp->blogs->table_name_blog_posts} SET post_id = %d, blog_id = %d, user_id = %d, date_created = FROM_UNIXTIME(%d) WHERE id = %d", $this->post_id, $this->blog_id, $this->user_id, $this->date_created, $this->id );
320
+ } else {
321
+ // Save
322
+ $sql = $wpdb->prepare( "INSERT INTO {$bp->blogs->table_name_blog_posts} ( post_id, blog_id, user_id, date_created ) VALUES ( %d, %d, %d, FROM_UNIXTIME(%d) )", $this->post_id, $this->blog_id, $this->user_id, $this->date_created );
323
+ }
324
+
325
+ if ( !$wpdb->query($sql) )
326
+ return false;
327
+
328
+ do_action( 'bp_blogs_post_after_save', $this );
329
+
330
+ if ( $this->id )
331
+ return $this->id;
332
+ else
333
+ return $wpdb->insert_id;
334
+ }
335
+
336
+ /* Static Functions */
337
+
338
+ function delete( $post_id, $blog_id ) {
339
+ global $wpdb, $bp, $current_user;
340
+
341
+ if ( !$bp->blogs )
342
+ bp_blogs_setup_globals();
343
+
344
+ return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_posts} WHERE blog_id = %d AND post_id = %d", $blog_id, $post_id ) );
345
+ }
346
+
347
+ function delete_oldest( $user_id = null ) {
348
+ global $wpdb, $bp;
349
+
350
+ if ( !$bp->blogs )
351
+ bp_blogs_setup_globals();
352
+
353
+ if ( !$user_id )
354
+ $user_id = $current_user->ID;
355
+
356
+ return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_posts} WHERE user_id = %d ORDER BY date_created ASC LIMIT 1", $user_id ) );
357
+ }
358
+
359
+ function delete_posts_for_user( $user_id = null ) {
360
+ global $wpdb, $bp;
361
+
362
+ if ( !$bp->blogs )
363
+ bp_blogs_setup_globals();
364
+
365
+ if ( !$user_id )
366
+ $user_id = $bp->loggedin_user->id;
367
+
368
+ return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_posts} WHERE user_id = %d", $user_id ) );
369
+ }
370
+
371
+ function delete_posts_for_blog( $blog_id ) {
372
+ global $wpdb, $bp;
373
+
374
+ if ( !$bp->blogs )
375
+ bp_blogs_setup_globals();
376
+
377
+ return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_posts} WHERE blog_id = %d", $blog_id ) );
378
+ }
379
+
380
+ function get_latest_posts( $blog_id = null, $limit = 5 ) {
381
+ global $wpdb, $bp;
382
+
383
+ if ( !$bp->blogs )
384
+ bp_blogs_setup_globals();
385
+
386
+ if ( $blog_id )
387
+ $blog_sql = $wpdb->prepare( " AND p.blog_id = %d", $blog_id );
388
+
389
+ $post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT 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 $blog_sql ORDER BY p.date_created DESC LIMIT $limit" ) );
390
+
391
+ for ( $i = 0; $i < count($post_ids); $i++ ) {
392
+ $posts[$i] = BP_Blogs_Post::fetch_post_content($post_ids[$i]);
393
+ }
394
+
395
+ return $posts;
396
+ }
397
+
398
+ function get_posts_for_user( $user_id = null ) {
399
+ global $bp, $wpdb;
400
+
401
+ if ( !$bp->blogs )
402
+ bp_blogs_setup_globals();
403
+
404
+ if ( !$user_id )
405
+ $user_id = $bp->displayed_user->id;
406
+
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++ ) {
417
+ $posts[$i] = BP_Blogs_Post::fetch_post_content($post_ids[$i]);
418
+ }
419
+
420
+ return array( 'posts' => $posts, 'count' => $total_post_count );
421
+ }
422
+
423
+ function fetch_post_content( $post_object ) {
424
+ // TODO: switch_to_blog() calls are expensive and this needs to be changed.
425
+ switch_to_blog( $post_object->blog_id );
426
+ $post = get_post($post_object->post_id);
427
+ $post->blog_id = $post_object->blog_id;
428
+ restore_current_blog();
429
+
430
+ return $post;
431
+ }
432
+
433
+ function get_total_recorded_for_user( $user_id = null ) {
434
+ global $bp, $wpdb;
435
+
436
+ if ( !$bp->blogs )
437
+ bp_blogs_setup_globals();
438
+
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 ) {
446
+ global $bp, $wpdb, $current_user;
447
+
448
+ if ( !$bp->blogs )
449
+ bp_blogs_setup_globals();
450
+
451
+ if ( !$user_id )
452
+ $user_id = $current_user->ID;
453
+
454
+ return $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM {$bp->blogs->table_name_blog_posts} WHERE post_id = %d AND blog_id = %d AND user_id = %d", $post_id, $blog_id, $user_id ) );
455
+ }
456
+
457
+ function total_post_count( $blog_id ) {
458
+ global $bp, $wpdb;
459
+
460
+ if ( !$bp->blogs )
461
+ bp_blogs_setup_globals();
462
+
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() {
470
+ global $bp, $wpdb;
471
+
472
+ if ( !$bp->blogs )
473
+ bp_blogs_setup_globals();
474
+
475
+ return $wpdb->get_col( $wpdb->prepare( "SELECT post_id, blog_id FROM " . $bp->blogs->table_name_blog_posts ) );
476
+ }
477
+
478
+ }
479
+
480
+ Class BP_Blogs_Comment {
481
+ var $id;
482
+ var $user_id;
483
+ var $blog_id;
484
+ var $comment_id;
485
+ var $comment_post_id;
486
+ var $date_created;
487
+
488
+ function bp_blogs_comment( $id = false, $blog_id = false, $comment_id = false ) {
489
+ global $bp, $wpdb;
490
+
491
+ if ( !$user_id )
492
+ $user_id = $bp->displayed_user->id;
493
+
494
+ if ( $id || ( !$id && $blog_id && $comment_id ) ) {
495
+ $this->id = $id;
496
+ $this->blog_id = $blog_id;
497
+ $this->comment_id = $comment_id;
498
+ $this->populate();
499
+ }
500
+ }
501
+
502
+ function populate() {
503
+ global $wpdb, $bp;
504
+
505
+ if ( $this->id )
506
+ $comment = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name_blog_comments} WHERE id = %d", $this->id ) );
507
+ else
508
+ $comment = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name_blog_comments} WHERE blog_id = %d AND comment_id = %d", (int)$this->blog_id, (int)$this->comment_id ) );
509
+
510
+ $this->comment_id = $comment->comment_id;
511
+ $this->user_id = $comment->user_id;
512
+ $this->blog_id = $comment->blog_id;
513
+ $this->comment_post_id = $comment->comment_post_id;
514
+ $this->date_created = $comment->date_created;
515
+ }
516
+
517
+ function save() {
518
+ global $wpdb, $bp;
519
+
520
+ $this->comment_id = apply_filters( 'bp_blogs_comment_id_before_save', $this->comment_id, $this->id );
521
+ $this->comment_post_id = apply_filters( 'bp_blogs_comment_post_id_before_save', $this->comment_post_id, $this->id );
522
+ $this->blog_id = apply_filters( 'bp_blogs_comment_blog_id_before_save', $this->blog_id, $this->id );
523
+ $this->user_id = apply_filters( 'bp_blogs_comment_user_id_before_save', $this->user_id, $this->id );
524
+ $this->date_created = apply_filters( 'bp_blogs_comment_date_created_before_save', $this->date_created, $this->id );
525
+
526
+ do_action( 'bp_blogs_comment_before_save', $this );
527
+
528
+ if ( $this->id ) {
529
+ // Update
530
+ $sql = $wpdb->prepare( "UPDATE {$bp->blogs->table_name_blog_comments} SET comment_id = %d, comment_post_id = %d, blog_id = %d, user_id = %d, date_created = FROM_UNIXTIME(%d) WHERE id = %d", $this->comment_id, $this->comment_post_id, $this->blog_id, $this->user_id, $this->date_created, $this->id );
531
+ } else {
532
+ // Save
533
+ $sql = $wpdb->prepare( "INSERT INTO {$bp->blogs->table_name_blog_comments} ( comment_id, comment_post_id, blog_id, user_id, date_created ) VALUES ( %d, %d, %d, %d, FROM_UNIXTIME(%d) )", $this->comment_id, $this->comment_post_id, $this->blog_id, $this->user_id, $this->date_created );
534
+ }
535
+
536
+ if ( !$wpdb->query($sql) )
537
+ return false;
538
+
539
+ do_action( 'bp_blogs_comment_after_save', $this );
540
+
541
+ if ( $this->id )
542
+ return $this->id;
543
+ else
544
+ return $wpdb->insert_id;
545
+ }
546
+
547
+ /* Static Functions */
548
+
549
+ function delete( $comment_id, $blog_id ) {
550
+ global $wpdb, $bp, $current_user;
551
+
552
+ if ( !$bp->blogs )
553
+ bp_blogs_setup_globals();
554
+
555
+ return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_comments} WHERE comment_id = %d AND blog_id = %d", $comment_id, $blog_id ) );
556
+ }
557
+
558
+ function delete_oldest( $user_id = null ) {
559
+ global $wpdb, $bp, $current_user;
560
+
561
+ if ( !$bp->blogs )
562
+ bp_blogs_setup_globals();
563
+
564
+ if ( !$user_id )
565
+ $user_id = $current_user->ID;
566
+
567
+ return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_comments} WHERE user_id = %d ORDER BY date_created ASC LIMIT 1", $user_id ) );
568
+ }
569
+
570
+ function delete_comments_for_user( $user_id = null ) {
571
+ global $wpdb, $bp;
572
+
573
+ if ( !$bp->blogs )
574
+ bp_blogs_setup_globals();
575
+
576
+ if ( !$user_id )
577
+ $user_id = $bp->loggedin_user->id;
578
+
579
+ return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_comments} WHERE user_id = %d", $user_id ) );
580
+ }
581
+
582
+ function delete_comments_for_blog( $blog_id ) {
583
+ global $wpdb, $bp;
584
+
585
+ if ( !$bp->blogs )
586
+ bp_blogs_setup_globals();
587
+
588
+ return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_comments} WHERE blog_id = %d", $blog_id ) );
589
+ }
590
+
591
+ function get_comments_for_user( $user_id = null ) {
592
+ global $bp, $wpdb;
593
+
594
+ if ( !$bp->blogs )
595
+ bp_blogs_setup_globals();
596
+
597
+ if ( !$user_id )
598
+ $user_id = $bp->displayed_user->id;
599
+
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++ ) {
610
+ $comments[$i] = BP_Blogs_Comment::fetch_comment_content($comment_ids[$i]);
611
+ }
612
+
613
+ return array( 'comments' => $comments, 'count' => $total_comment_count );
614
+ }
615
+
616
+ function fetch_comment_content( $comment_object ) {
617
+ switch_to_blog($comment_object->blog_id);
618
+ $comment = get_comment($comment_object->comment_id);
619
+ $comment->blog_id = $comment_object->blog_id;
620
+ $comment->post = &get_post( $comment->comment_post_ID );
621
+ restore_current_blog();
622
+
623
+ return $comment;
624
+ }
625
+
626
+ function get_total_recorded_for_user( $user_id = null ) {
627
+ global $bp, $wpdb, $current_user;
628
+
629
+ if ( !$bp->blogs )
630
+ bp_blogs_setup_globals();
631
+
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 ) {
639
+ global $bp, $wpdb;
640
+
641
+ if ( !$bp->blogs )
642
+ bp_blogs_setup_globals();
643
+
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
+
651
+ function is_recorded( $comment_id, $comment_post_id, $blog_id, $user_id = null ) {
652
+ global $bp, $wpdb, $current_user;
653
+
654
+ if ( !$bp->blogs )
655
+ bp_blogs_setup_globals();
656
+
657
+ if ( !$user_id )
658
+ $user_id = $current_user->ID;
659
+
660
+ return $wpdb->get_var( $wpdb->prepare( "SELECT comment_id FROM {$bp->blogs->table_name_blog_comments} WHERE comment_id = %d AND blog_id = %d AND comment_post_id = %d AND user_id = %d", $comment_id, $blog_id, $comment_post_id, $user_id ) );
661
+ }
662
+
663
+ }
664
+
665
+ ?>
bp-blogs/bp-blogs-cssjs.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function bp_blogs_add_structure_css() {
4
+ /* Enqueue the structure CSS file to give basic positional formatting for components */
5
+ wp_enqueue_style( 'bp-blogs-structure', BP_PLUGIN_URL . '/bp-blogs/css/structure.css' );
6
+ }
7
+ add_action( 'bp_styles', 'bp_blogs_add_structure_css' );
8
+
9
+
10
+ ?>
bp-blogs/bp-blogs-templatetags.php ADDED
@@ -0,0 +1,1322 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /* Blog registration template tags */
4
+
5
+ function bp_blog_signup_enabled() {
6
+ $active_signup = get_site_option( 'registration' );
7
+
8
+ if ( !$active_signup )
9
+ $active_signup = 'all';
10
+
11
+ $active_signup = apply_filters( 'wpmu_active_signup', $active_signup ); // return "all", "none", "blog" or "user"
12
+
13
+ if ( 'none' == $active_signup || 'user' == $active_signup )
14
+ return false;
15
+
16
+ return true;
17
+ }
18
+
19
+ function bp_show_blog_signup_form($blogname = '', $blog_title = '', $errors = '') {
20
+ global $current_user, $current_site;
21
+ global $bp;
22
+
23
+ require_once( ABSPATH . WPINC . '/registration.php' );
24
+
25
+ if ( isset($_POST['submit']) ) {
26
+ bp_blogs_validate_blog_signup();
27
+ } else {
28
+ if ( ! is_wp_error($errors) ) {
29
+ $errors = new WP_Error();
30
+ }
31
+
32
+ // allow definition of default variables
33
+ $filtered_results = apply_filters('signup_another_blog_init', array('blogname' => $blogname, 'blog_title' => $blog_title, 'errors' => $errors ));
34
+ $blogname = $filtered_results['blogname'];
35
+ $blog_title = $filtered_results['blog_title'];
36
+ $errors = $filtered_results['errors'];
37
+
38
+ if ( $errors->get_error_code() ) {
39
+ echo "<p>" . __('There was a problem, please correct the form below and try again.', 'buddypress') . "</p>";
40
+ }
41
+ ?>
42
+ <p><?php printf(__("By filling out the form below, you can <strong>add a blog to your account</strong>. There is no limit to the number of blogs you can have, so create to your heart's content, but blog responsibly.", 'buddypress'), $current_user->display_name) ?></p>
43
+
44
+ <p><?php _e("If you&#8217;re not going to use a great blog domain, leave it for a new user. Now have at it!", 'buddypress') ?></p>
45
+
46
+ <form id="setupform" method="post" action="<?php echo $bp->loggedin_user->domain . $bp->blogs->slug . '/create-a-blog' ?>">
47
+
48
+ <input type="hidden" name="stage" value="gimmeanotherblog" />
49
+ <?php do_action( "signup_hidden_fields" ); ?>
50
+ <?php bp_blogs_signup_blog($blogname, $blog_title, $errors); ?>
51
+ <p>
52
+ <input id="submit" type="submit" name="submit" class="submit" value="<?php _e('Create Blog &raquo;', 'buddypress') ?>" />
53
+ </p>
54
+
55
+ <?php wp_nonce_field( 'bp_blog_signup_form' ) ?>
56
+ </form>
57
+ <?php
58
+ }
59
+ }
60
+
61
+ function bp_blogs_signup_blog( $blogname = '', $blog_title = '', $errors = '' ) {
62
+ global $current_site;
63
+
64
+ // Blog name
65
+ if( 'no' == constant( "VHOST" ) )
66
+ echo '<label for="blogname">' . __('Blog Name:', 'buddypress') . '</label>';
67
+ else
68
+ echo '<label for="blogname">' . __('Blog Domain:', 'buddypress') . '</label>';
69
+
70
+ if ( $errmsg = $errors->get_error_message('blogname') ) { ?>
71
+ <p class="error"><?php echo $errmsg ?></p>
72
+ <?php }
73
+
74
+ if( 'no' == constant( "VHOST" ) ) {
75
+ echo '<span class="prefix_address">' . $current_site->domain . $current_site->path . '</span><input name="blogname" type="text" id="blogname" value="'.$blogname.'" maxlength="50" /><br />';
76
+ } else {
77
+ echo '<input name="blogname" type="text" id="blogname" value="'.$blogname.'" maxlength="50" /><span class="suffix_address">.' . $current_site->domain . $current_site->path . '</span><br />';
78
+ }
79
+ if ( !is_user_logged_in() ) {
80
+ print '(<strong>' . __( 'Your address will be ' , 'buddypress');
81
+ if( 'no' == constant( "VHOST" ) ) {
82
+ print $current_site->domain . $current_site->path . __( 'blogname' , 'buddypress');
83
+ } else {
84
+ print __( 'domain.' , 'buddypress') . $current_site->domain . $current_site->path;
85
+ }
86
+ echo '.</strong> ' . __( 'Must be at least 4 characters, letters and numbers only. It cannot be changed so choose carefully!)' , 'buddypress') . '</p>';
87
+ }
88
+
89
+ // Blog Title
90
+ ?>
91
+ <label for="blog_title"><?php _e('Blog Title:', 'buddypress') ?></label>
92
+ <?php if ( $errmsg = $errors->get_error_message('blog_title') ) { ?>
93
+ <p class="error"><?php echo $errmsg ?></p>
94
+ <?php }
95
+ echo '<input name="blog_title" type="text" id="blog_title" value="'.wp_specialchars($blog_title, 1).'" /></p>';
96
+ ?>
97
+
98
+ <p>
99
+ <label for="blog_public_on"><?php _e('Privacy:', 'buddypress') ?></label>
100
+ <?php _e('I would like my blog to appear in search engines like Google and Technorati, and in public listings around this site.', 'buddypress'); ?>
101
+ <div style="clear:both;"></div>
102
+ <label class="checkbox" for="blog_public_on">
103
+ <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 } ?> />
104
+ <strong><?php _e( 'Yes' , 'buddypress'); ?></strong>
105
+ </label>
106
+ <label class="checkbox" for="blog_public_off">
107
+ <input type="radio" id="blog_public_off" name="blog_public" value="0" <?php if( isset( $_POST['blog_public'] ) && '0' == $_POST['blog_public'] ) { ?>checked="checked"<?php } ?> />
108
+ <strong><?php _e( 'No' , 'buddypress'); ?></strong>
109
+ </label>
110
+ </p>
111
+
112
+ <?php
113
+ do_action('signup_blogform', $errors);
114
+ }
115
+
116
+ function bp_blogs_validate_blog_signup() {
117
+ global $wpdb, $current_user, $blogname, $blog_title, $errors, $domain, $path;
118
+
119
+ if ( !check_admin_referer( 'bp_blog_signup_form' ) )
120
+ return false;
121
+
122
+ $current_user = wp_get_current_user();
123
+
124
+ if( !is_user_logged_in() )
125
+ die();
126
+
127
+ $result = bp_blogs_validate_blog_form();
128
+ extract($result);
129
+
130
+ if ( $errors->get_error_code() ) {
131
+ unset($_POST['submit']);
132
+ bp_show_blog_signup_form( $blogname, $blog_title, $errors );
133
+ return false;
134
+ }
135
+
136
+ $public = (int) $_POST['blog_public'];
137
+
138
+ $meta = apply_filters( 'signup_create_blog_meta', array( 'lang_id' => 1, 'public' => $public ) ); // depreciated
139
+ $meta = apply_filters( 'add_signup_meta', $meta );
140
+
141
+ /* If this is a VHOST install, remove the username from the domain as we are setting this blog
142
+ up inside a user domain, not the root domain. */
143
+
144
+ wpmu_create_blog( $domain, $path, $blog_title, $current_user->id, $meta, $wpdb->siteid );
145
+ bp_blogs_confirm_blog_signup($domain, $path, $blog_title, $current_user->user_login, $current_user->user_email, $meta);
146
+ return true;
147
+ }
148
+
149
+ function bp_blogs_validate_blog_form() {
150
+ $user = '';
151
+ if ( is_user_logged_in() )
152
+ $user = wp_get_current_user();
153
+
154
+ return wpmu_validate_blog_signup($_POST['blogname'], $_POST['blog_title'], $user);
155
+ }
156
+
157
+ function bp_blogs_confirm_blog_signup( $domain, $path, $blog_title, $user_name, $user_email = '', $meta = '' ) {
158
+ ?>
159
+ <p><?php _e('Congratulations! You have successfully registered a new blog.', 'buddypress') ?></p>
160
+ <p>
161
+ <?php printf(__('<a href="http://%1$s">http://%2$s</a> is your new blog. <a href="%3$s">Login</a> as "%4$s" using your existing password.', 'buddypress'), $domain.$path, $domain.$path, "http://" . $domain.$path . "wp-login.php", $user_name) ?>
162
+ </p>
163
+ <?php
164
+ do_action('signup_finished');
165
+ }
166
+
167
+ function bp_create_blog_link() {
168
+ global $bp;
169
+
170
+ if ( bp_is_home() ) {
171
+ echo apply_filters( 'bp_create_blog_link', '<a href="' . $bp->loggedin_user->domain . $bp->blogs->slug . '/create-a-blog">' . __('Create a Blog', 'buddypress') . '</a>' );
172
+ }
173
+ }
174
+
175
+ function bp_blogs_blog_tabs() {
176
+ global $bp, $groups_template;
177
+
178
+ // Don't show these tabs on a user's own profile
179
+ if ( bp_is_home() )
180
+ return false;
181
+
182
+ $current_tab = $bp->current_action
183
+ ?>
184
+ <ul class="content-header-nav">
185
+ <li<?php if ( 'my-blogs' == $current_tab || empty( $current_tab ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->blogs->slug ?>/my-blogs"><?php printf( __( "%s's Blogs", 'buddypress' ), $bp->displayed_user->fullname ) ?></a></li>
186
+ <li<?php if ( 'recent-posts' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->blogs->slug ?>/recent-posts"><?php printf( __( "%s's Recent Posts", 'buddypress' ), $bp->displayed_user->fullname ) ?></a></li>
187
+ <li<?php if ( 'recent-comments' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->blogs->slug ?>/recent-comments"><?php printf( __( "%s's Recent Comments", 'buddypress' ), $bp->displayed_user->fullname ) ?></a></li>
188
+ </ul>
189
+ <?php
190
+ do_action( 'bp_blogs_blog_tabs', $current_tab );
191
+ }
192
+
193
+ /**********************************************************************
194
+ * User Blog listing template class
195
+ */
196
+
197
+ class BP_Blogs_User_Blogs_Template {
198
+ var $current_blog = -1;
199
+ var $blog_count;
200
+ var $blogs;
201
+ var $blog;
202
+
203
+ var $in_the_loop;
204
+
205
+ var $pag_page;
206
+ var $pag_num;
207
+ var $pag_links;
208
+ var $total_blog_count;
209
+
210
+ function bp_blogs_user_blogs_template( $user_id, $per_page, $max ) {
211
+ global $bp;
212
+
213
+ if ( !$user_id )
214
+ $user_id = $bp->displayed_user->id;
215
+
216
+ $this->pag_page = isset( $_GET['fpage'] ) ? intval( $_GET['fpage'] ) : 1;
217
+ $this->pag_num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : $per_page;
218
+
219
+ if ( !$this->blogs = wp_cache_get( 'bp_blogs_for_user_' . $user_id, 'bp' ) ) {
220
+ $this->blogs = bp_blogs_get_blogs_for_user( $user_id );
221
+ wp_cache_set( 'bp_blogs_for_user_' . $user_id, $this->blogs, 'bp' );
222
+ }
223
+
224
+ if ( !$max )
225
+ $this->total_blog_count = (int)$this->blogs['count'];
226
+ else
227
+ $this->total_blog_count = (int)$max;
228
+
229
+ $this->blogs = array_slice( (array)$this->blogs['blogs'], intval( ( $this->pag_page - 1 ) * $this->pag_num), intval( $this->pag_num ) );
230
+
231
+ if ( $max ) {
232
+ if ( $max >= count($this->blogs) )
233
+ $this->blog_count = count($this->blogs);
234
+ else
235
+ $this->blog_count = (int)$max;
236
+ } else {
237
+ $this->blog_count = count($this->blogs);
238
+ }
239
+
240
+ $this->pag_links = paginate_links( array(
241
+ 'base' => add_query_arg( 'fpage', '%#%' ),
242
+ 'format' => '',
243
+ 'total' => ceil($this->total_blog_count / $this->pag_num),
244
+ 'current' => $this->pag_page,
245
+ 'prev_text' => '&laquo;',
246
+ 'next_text' => '&raquo;',
247
+ 'mid_size' => 1
248
+ ));
249
+ }
250
+
251
+ function has_blogs() {
252
+ if ( $this->blog_count )
253
+ return true;
254
+
255
+ return false;
256
+ }
257
+
258
+ function next_blog() {
259
+ $this->current_blog++;
260
+ $this->blog = $this->blogs[$this->current_blog];
261
+
262
+ return $this->blog;
263
+ }
264
+
265
+ function rewind_blogs() {
266
+ $this->current_blog = -1;
267
+ if ( $this->blog_count > 0 ) {
268
+ $this->blog = $this->blogs[0];
269
+ }
270
+ }
271
+
272
+ function user_blogs() {
273
+ if ( $this->current_blog + 1 < $this->blog_count ) {
274
+ return true;
275
+ } elseif ( $this->current_blog + 1 == $this->blog_count ) {
276
+ do_action('loop_end');
277
+ // Do some cleaning up after the loop
278
+ $this->rewind_blogs();
279
+ }
280
+
281
+ $this->in_the_loop = false;
282
+ return false;
283
+ }
284
+
285
+ function the_blog() {
286
+ global $blog;
287
+
288
+ $this->in_the_loop = true;
289
+ $blog = $this->next_blog();
290
+
291
+ if ( 0 == $this->current_blog ) // loop has just started
292
+ do_action('loop_start');
293
+ }
294
+ }
295
+
296
+ function bp_has_blogs( $args = '' ) {
297
+ global $blogs_template;
298
+
299
+ $defaults = array(
300
+ 'user_id' => false,
301
+ 'per_page' => 10,
302
+ 'max' => false
303
+ );
304
+
305
+ $r = wp_parse_args( $args, $defaults );
306
+ extract( $r, EXTR_SKIP );
307
+
308
+ $blogs_template = new BP_Blogs_User_Blogs_Template( $user_id, $per_page, $max );
309
+ return $blogs_template->has_blogs();
310
+ }
311
+
312
+ function bp_blogs() {
313
+ global $blogs_template;
314
+ return $blogs_template->user_blogs();
315
+ }
316
+
317
+ function bp_the_blog() {
318
+ global $blogs_template;
319
+ return $blogs_template->the_blog();
320
+ }
321
+
322
+ function bp_blogs_pagination_count() {
323
+ global $bp, $blogs_template;
324
+
325
+ $from_num = intval( ( $blogs_template->pag_page - 1 ) * $blogs_template->pag_num ) + 1;
326
+ $to_num = ( $from_num + ( $blogs_template->pag_num - 1 ) > $blogs_template->total_blog_count ) ? $blogs_template->total_blog_count : $from_num + ( $blogs_template->pag_num - 1 ) ;
327
+
328
+ echo sprintf( __( 'Viewing blog %d to %d (of %d blogs)', 'buddypress' ), $from_num, $to_num, $blogs_template->total_blog_count ); ?> &nbsp;
329
+ <img id="ajax-loader-blogs" src="<?php echo $bp->core->image_base ?>/ajax-loader.gif" height="7" alt="<?php _e( "Loading", "buddypress" ) ?>" style="display: none;" /><?php
330
+ }
331
+
332
+ function bp_blogs_pagination_links() {
333
+ echo bp_get_blogs_pagination_links();
334
+ }
335
+ function bp_get_blogs_pagination_links() {
336
+ global $blogs_template;
337
+
338
+ return apply_filters( 'bp_get_blogs_pagination_links', $blogs_template->pag_links );
339
+ }
340
+
341
+ function bp_blog_title() {
342
+ echo bp_get_blog_title();
343
+ }
344
+ function bp_get_blog_title() {
345
+ global $blogs_template;
346
+
347
+ return apply_filters( 'bp_get_blog_title', $blogs_template->blog['title'] );
348
+ }
349
+
350
+ function bp_blog_description() {
351
+ echo bp_get_blog_description();
352
+ }
353
+ function bp_get_blog_description() {
354
+ global $blogs_template;
355
+
356
+ return apply_filters( 'bp_get_blog_description', $blogs_template->blog['description'] );
357
+ }
358
+
359
+ function bp_blog_permalink() {
360
+ echo bp_get_blog_permalink();
361
+ }
362
+ function bp_get_blog_permalink() {
363
+ global $blogs_template;
364
+
365
+ return apply_filters( 'bp_get_blog_permalink', $blogs_template->blog['siteurl'] );
366
+ }
367
+
368
+
369
+ /**********************************************************************
370
+ * User Blog Posts listing template class
371
+ */
372
+
373
+ class BP_Blogs_Blog_Post_Template {
374
+ var $current_post = -1;
375
+ var $post_count;
376
+ var $posts;
377
+ var $post;
378
+
379
+ var $in_the_loop;
380
+
381
+ var $pag_page;
382
+ var $pag_num;
383
+ var $pag_links;
384
+ var $total_post_count;
385
+
386
+ function bp_blogs_blog_post_template( $user_id, $per_page, $max ) {
387
+ global $bp;
388
+
389
+ if ( !$user_id )
390
+ $user_id = $bp->displayed_user->id;
391
+
392
+ $this->pag_page = isset( $_GET['fpage'] ) ? intval( $_GET['fpage'] ) : 1;
393
+ $this->pag_num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : $per_page;
394
+
395
+ if ( !$this->posts = wp_cache_get( 'bp_user_posts_' . $user_id, 'bp' ) ) {
396
+ $this->posts = bp_blogs_get_posts_for_user( $user_id );
397
+ wp_cache_set( 'bp_user_posts_' . $user_id, $this->posts, 'bp' );
398
+ }
399
+
400
+ if ( !$max )
401
+ $this->total_post_count = (int)$this->posts['count'];
402
+ else
403
+ $this->total_post_count = (int)$max;
404
+
405
+ $this->posts = array_slice( (array)$this->posts['posts'], intval( ( $this->pag_page - 1 ) * $this->pag_num), intval( $this->pag_num ) );
406
+
407
+ if ( $max ) {
408
+ if ( $max >= count($this->posts) )
409
+ $this->post_count = count($this->posts);
410
+ else
411
+ $this->post_count = (int)$max;
412
+ } else {
413
+ $this->post_count = count($this->posts);
414
+ }
415
+
416
+ $this->pag_links = paginate_links( array(
417
+ 'base' => add_query_arg( 'fpage', '%#%' ),
418
+ 'format' => '',
419
+ 'total' => ceil($this->total_post_count / $this->pag_num),
420
+ 'current' => $this->pag_page,
421
+ 'prev_text' => '&laquo;',
422
+ 'next_text' => '&raquo;',
423
+ 'mid_size' => 1
424
+ ));
425
+ }
426
+
427
+ function has_posts() {
428
+ if ( $this->post_count )
429
+ return true;
430
+
431
+ return false;
432
+ }
433
+
434
+ function next_post() {
435
+ $this->current_post++;
436
+ $this->post = $this->posts[$this->current_post];
437
+
438
+ return $this->post;
439
+ }
440
+
441
+ function rewind_posts() {
442
+ $this->current_post = -1;
443
+ if ( $this->post_count > 0 ) {
444
+ $this->post = $this->posts[0];
445
+ }
446
+ }
447
+
448
+ function user_posts() {
449
+ if ( $this->current_post + 1 < $this->post_count ) {
450
+ return true;
451
+ } elseif ( $this->current_post + 1 == $this->post_count ) {
452
+ do_action('loop_end');
453
+ // Do some cleaning up after the loop
454
+ $this->rewind_posts();
455
+ }
456
+
457
+ $this->in_the_loop = false;
458
+ return false;
459
+ }
460
+
461
+ function the_post() {
462
+ global $post;
463
+
464
+ $this->in_the_loop = true;
465
+ $post = $this->next_post();
466
+
467
+ if ( 0 == $this->current_post ) // loop has just started
468
+ do_action('loop_start');
469
+ }
470
+ }
471
+
472
+ function bp_has_posts( $args = '' ) {
473
+ global $posts_template;
474
+
475
+ $defaults = array(
476
+ 'user_id' => false,
477
+ 'per_page' => 10,
478
+ 'max' => false
479
+ );
480
+
481
+ $r = wp_parse_args( $args, $defaults );
482
+ extract( $r, EXTR_SKIP );
483
+
484
+ $posts_template = new BP_Blogs_Blog_Post_Template( $user_id, $per_page, $max );
485
+ return $posts_template->has_posts();
486
+ }
487
+
488
+ function bp_posts() {
489
+ global $posts_template;
490
+ return $posts_template->user_posts();
491
+ }
492
+
493
+ function bp_the_post() {
494
+ global $posts_template;
495
+ return $posts_template->the_post();
496
+ }
497
+
498
+ function bp_post_pagination_count() {
499
+ global $bp, $posts_template;
500
+
501
+ $from_num = intval( ( $posts_template->pag_page - 1 ) * $posts_template->pag_num ) + 1;
502
+ $to_num = ( $from_num + ( $posts_template->pag_num - 1 ) > $posts_template->total_post_count ) ? $posts_template->total_post_count : $from_num + ( $posts_template->pag_num - 1 ) ;
503
+
504
+ echo sprintf( __( 'Viewing post %d to %d (of %d posts)', 'buddypress' ), $from_num, $to_num, $posts_template->total_post_count ); ?> &nbsp;
505
+ <img id="ajax-loader-blogs" src="<?php echo $bp->core->image_base ?>/ajax-loader.gif" height="7" alt="<?php _e( "Loading", "buddypress" ) ?>" style="display: none;" /><?php
506
+ }
507
+
508
+ function bp_post_pagination_links() {
509
+ echo bp_get_post_pagination_links();
510
+ }
511
+ function bp_get_post_pagination_links() {
512
+ global $posts_template;
513
+
514
+ return apply_filters( 'bp_get_post_pagination_links', $posts_template->pag_links );
515
+ }
516
+
517
+ function bp_post_id() {
518
+ echo bp_get_post_id();
519
+ }
520
+ function bp_get_post_id() {
521
+ global $posts_template;
522
+ echo apply_filters( 'bp_get_post_id', $posts_template->post->ID );
523
+ }
524
+
525
+ function bp_post_title( $deprecated = true ) {
526
+ if ( !$deprecated )
527
+ bp_get_post_title();
528
+ else
529
+ echo bp_get_post_title();
530
+ }
531
+ function bp_get_post_title() {
532
+ global $posts_template;
533
+
534
+ return apply_filters( 'bp_get_post_title', $posts_template->post->post_title );
535
+ }
536
+
537
+ function bp_post_permalink() {
538
+ global $posts_template;
539
+
540
+ echo bp_post_get_permalink();
541
+ }
542
+
543
+ function bp_post_excerpt() {
544
+ echo bp_get_post_excerpt();
545
+ }
546
+ function bp_get_post_excerpt() {
547
+ global $posts_template;
548
+ echo apply_filters( 'bp_get_post_excerpt', $posts_template->post->post_excerpt );
549
+ }
550
+
551
+ function bp_post_content() {
552
+ echo bp_get_post_content();
553
+ }
554
+ function bp_get_post_content() {
555
+ global $posts_template;
556
+ $content = $posts_template->post->post_content;
557
+ $content = apply_filters('the_content', $content);
558
+ $content = str_replace(']]>', ']]&gt;', $content);
559
+ return apply_filters( 'bp_get_post_content', $content );
560
+ }
561
+
562
+ function bp_post_status() {
563
+ echo bp_get_post_status();
564
+ }
565
+ function bp_get_post_status() {
566
+ global $posts_template;
567
+ return apply_filters( 'bp_get_post_status', $posts_template->post->post_status );
568
+ }
569
+
570
+ function bp_post_date( $date_format = null, $deprecated = true ) {
571
+ if ( !$date_format )
572
+ $date_format = get_option('date_format');
573
+
574
+ if ( !$deprecated )
575
+ return bp_get_post_date( $date_format );
576
+ else
577
+ echo bp_get_post_date();
578
+ }
579
+ function bp_get_post_date( $date_format = null ) {
580
+ global $posts_template;
581
+
582
+ if ( !$date_format )
583
+ $date_format = get_option('date_format');
584
+
585
+ echo apply_filters( 'bp_get_post_date', mysql2date( $date_format, $posts_template->post->post_date ) );
586
+ }
587
+
588
+ function bp_post_comment_count() {
589
+ echo bp_get_post_comment_count();
590
+ }
591
+ function bp_get_post_comment_count() {
592
+ global $posts_template;
593
+ return apply_filters( 'bp_get_post_comment_count', $posts_template->post->comment_count );
594
+ }
595
+
596
+ function bp_post_comments( $zero = 'No Comments', $one = '1 Comment', $more = '% Comments', $css_class = '', $none = 'Comments Off' ) {
597
+ global $posts_template, $wpdb;
598
+
599
+ $number = get_comments_number( $posts_template->post->ID );
600
+
601
+ if ( 0 == $number && 'closed' == $posts_template->postcomment_status && 'closed' == $posts_template->postping_status ) {
602
+ echo '<span' . ((!empty($css_class)) ? ' class="' . $css_class . '"' : '') . '>' . $none . '</span>';
603
+ return;
604
+ }
605
+
606
+ if ( !empty($posts_template->postpost_password) ) { // if there's a password
607
+ if ( !isset($_COOKIE['wp-postpass_' . COOKIEHASH]) || $_COOKIE['wp-postpass_' . COOKIEHASH] != $posts_template->postpost_password ) { // and it doesn't match the cookie
608
+ echo __('Enter your password to view comments', 'buddypress');
609
+ return;
610
+ }
611
+ }
612
+
613
+ echo '<a href="';
614
+
615
+ if ( 0 == $number )
616
+ echo bp_post_get_permalink() . '#respond';
617
+ else
618
+ echo bp_post_get_permalink() . '#comments';
619
+ echo '"';
620
+
621
+ if ( !empty( $css_class ) ) {
622
+ echo ' class="'.$css_class.'" ';
623
+ }
624
+ $title = attribute_escape( $posts_template->post->post_title );
625
+
626
+ echo apply_filters( 'comments_popup_link_attributes', '' );
627
+
628
+ echo ' title="' . sprintf( __('Comment on %s', 'buddypress'), $title ) . '">';
629
+ comments_number( $zero, $one, $more, $number );
630
+ echo '</a>';
631
+ }
632
+
633
+ function bp_post_author( $deprecated = true ) {
634
+ if ( !$deprecated )
635
+ return bp_get_post_author();
636
+ else
637
+ echo bp_get_post_author();
638
+ }
639
+ function bp_get_post_author() {
640
+ global $posts_template;
641
+
642
+ return apply_filters( 'bp_get_post_author', bp_core_get_userlink( $posts_template->post->post_author ) );
643
+ }
644
+
645
+ function bp_post_category( $separator = '', $parents = '', $post_id = false, $deprecated = true ) {
646
+ global $posts_template;
647
+
648
+ if ( !$deprecated )
649
+ return bp_get_post_category( $separator, $parents, $post_id );
650
+ else
651
+ echo bp_get_post_category();
652
+ }
653
+ function bp_get_post_category( $separator = '', $parents = '', $post_id = false ) {
654
+ global $posts_template;
655
+
656
+ if ( !$post_id )
657
+ $post_id = $posts_template->post->ID;
658
+
659
+ return apply_filters( 'bp_get_post_category', get_the_category_list( $separator, $parents, $post_id ) );
660
+ }
661
+
662
+ function bp_post_tags( $before = '', $sep = ', ', $after = '' ) {
663
+ global $posts_template, $wpdb;
664
+
665
+ switch_to_blog( $posts_template->post->blog_id );
666
+ $terms = bp_post_get_term_list( $before, $sep, $after );
667
+ restore_current_blog();
668
+ }
669
+
670
+ function bp_post_blog_id() {
671
+ echo bp_get_post_blog_id();
672
+ }
673
+ function bp_get_post_blog_id() {
674
+ global $posts_template;
675
+
676
+ return apply_filters( 'bp_get_post_blog_id', $posts_template->post->blog_id );
677
+ }
678
+
679
+ function bp_post_blog_name() {
680
+ echo bp_get_post_blog_name();
681
+ }
682
+ function bp_get_post_blog_name() {
683
+ global $posts_template;
684
+ return apply_filters( 'bp_get_post_blog_name', get_blog_option( $posts_template->post->blog_id, 'blogname' ) );
685
+ }
686
+
687
+ function bp_post_blog_permalink() {
688
+ echo bp_get_post_blog_permalink();
689
+ }
690
+ function bp_get_post_blog_permalink() {
691
+ global $posts_template;
692
+ return apply_filters( 'bp_get_post_blog_permalink', get_blog_option( $posts_template->post->blog_id, 'siteurl' ) );
693
+ }
694
+
695
+ function bp_post_get_permalink( $post = null, $blog_id = null ) {
696
+ global $current_blog, $posts_template;
697
+
698
+ if ( !$post )
699
+ $post = $posts_template->post;
700
+
701
+ if ( !$blog_id )
702
+ $blog_id = $posts_template->post->blog_id;
703
+
704
+ if ( !$post || !$blog_id )
705
+ return false;
706
+
707
+ $rewritecode = array(
708
+ '%year%',
709
+ '%monthnum%',
710
+ '%day%',
711
+ '%hour%',
712
+ '%minute%',
713
+ '%second%',
714
+ $leavename? '' : '%postname%',
715
+ '%post_id%',
716
+ '%category%',
717
+ '%author%',
718
+ $leavename? '' : '%pagename%',
719
+ );
720
+
721
+ if ( 'page' == $post->post_type )
722
+ return get_page_link($post->ID, $leavename);
723
+ else if ( 'attachment' == $post->post_type )
724
+ return get_attachment_link($post->ID);
725
+
726
+ $permalink = get_blog_option( $blog_id, 'permalink_structure' );
727
+ $site_url = get_blog_option( $blog_id, 'siteurl' );
728
+
729
+ if ( '' != $permalink && !in_array($post->post_status, array('draft', 'pending')) ) {
730
+ $unixtime = strtotime($post->post_date);
731
+
732
+ $category = '';
733
+ if ( false !== strpos($permalink, '%category%') ) {
734
+ $cats = get_the_category($post->ID);
735
+ if ( $cats )
736
+ usort($cats, '_usort_terms_by_ID'); // order by ID
737
+ $category = $cats[0]->slug;
738
+ if ( $parent=$cats[0]->parent )
739
+ $category = get_category_parents($parent, FALSE, '/', TRUE) . $category;
740
+
741
+ // show default category in permalinks, without
742
+ // having to assign it explicitly
743
+ if ( empty($category) ) {
744
+ $default_category = get_category( get_option( 'default_category' ) );
745
+ $category = is_wp_error( $default_category ) ? '' : $default_category->slug;
746
+ }
747
+ }
748
+
749
+ $author = '';
750
+ if ( false !== strpos($permalink, '%author%') ) {
751
+ $authordata = get_userdata($post->post_author);
752
+ $author = $authordata->user_nicename;
753
+ }
754
+
755
+ $date = explode(" ",date('Y m d H i s', $unixtime));
756
+ $rewritereplace =
757
+ array(
758
+ $date[0],
759
+ $date[1],
760
+ $date[2],
761
+ $date[3],
762
+ $date[4],
763
+ $date[5],
764
+ $post->post_name,
765
+ $post->ID,
766
+ $category,
767
+ $author,
768
+ $post->post_name,
769
+ );
770
+ $permalink = $site_url . str_replace($rewritecode, $rewritereplace, $permalink);
771
+ $permalink = user_trailingslashit($permalink, 'single');
772
+ return apply_filters('post_link', $permalink, $post);
773
+ } else { // if they're not using the fancy permalink option
774
+ $permalink = $site_url . '/?p=' . $post->ID;
775
+ return apply_filters('post_link', $permalink, $post);
776
+ }
777
+ }
778
+
779
+ function bp_post_get_term_list( $before = '', $sep = '', $after = '' ) {
780
+ global $posts_template;
781
+
782
+ $terms = get_the_terms( $posts_template->post->ID, 'post_tag' );
783
+
784
+ if ( is_wp_error($terms) )
785
+ return $terms;
786
+
787
+ if ( empty( $terms ) )
788
+ return false;
789
+
790
+ foreach ( $terms as $term ) {
791
+ $link = get_blog_option( 1, 'siteurl') . '/tag/' . $term->slug;
792
+ $link = apply_filters('term_link', $link);
793
+
794
+ $term_links[] = '<a href="' . $link . '" rel="tag">' . $term->name . '</a>';
795
+ }
796
+
797
+ $term_links = apply_filters( "term_links-$taxonomy", $term_links );
798
+
799
+ echo $before . join($sep, $term_links) . $after;
800
+ }
801
+
802
+
803
+ /**********************************************************************
804
+ * User Blog Comments listing template class
805
+ */
806
+
807
+ class BP_Blogs_Post_Comment_Template {
808
+ var $current_comment = -1;
809
+ var $comment_count;
810
+ var $comments;
811
+ var $comment;
812
+
813
+ var $in_the_loop;
814
+
815
+ var $pag_page;
816
+ var $pag_num;
817
+ var $pag_links;
818
+ var $total_comment_count;
819
+
820
+ function bp_blogs_post_comment_template( $user_id, $per_page, $max ) {
821
+ global $bp;
822
+
823
+ if ( !$user_id )
824
+ $user_id = $bp->displayed_user->id;
825
+
826
+ $this->pag_page = isset( $_GET['compage'] ) ? intval( $_GET['compage'] ) : 1;
827
+ $this->pag_num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : $per_page;
828
+
829
+ if ( !$this->comments = wp_cache_get( 'bp_user_comments_' . $user_id, 'bp' ) ) {
830
+ $this->comments = bp_blogs_get_comments_for_user( $user_id );
831
+ wp_cache_set( 'bp_user_comments_' . $user_id, $this->comments, 'bp' );
832
+ }
833
+
834
+ if ( !$max )
835
+ $this->total_comment_count = (int)$this->comments['count'];
836
+ else
837
+ $this->total_comment_count = (int)$max;
838
+
839
+ $this->comments = array_slice( (array)$this->comments['comments'], intval( ( $this->pag_page - 1 ) * $this->pag_num), intval( $this->pag_num ) );
840
+
841
+ if ( $max ) {
842
+ if ( $max >= count($this->comments) )
843
+ $this->comment_count = count($this->comments);
844
+ else
845
+ $this->comment_count = (int)$max;
846
+ } else {
847
+ $this->comment_count = count($this->comments);
848
+ }
849
+
850
+ $this->pag_links = paginate_links( array(
851
+ 'base' => add_query_arg( 'compage', '%#%' ),
852
+ 'format' => '',
853
+ 'total' => ceil($this->total_comment_count / $this->pag_num),
854
+ 'current' => $this->pag_page,
855
+ 'prev_text' => '&laquo;',
856
+ 'next_text' => '&raquo;',
857
+ 'mid_size' => 1
858
+ ));
859
+
860
+ }
861
+
862
+ function has_comments() {
863
+ if ( $this->comment_count )
864
+ return true;
865
+
866
+ return false;
867
+ }
868
+
869
+ function next_comment() {
870
+ $this->current_comment++;
871
+ $this->comment = $this->comments[$this->current_comment];
872
+
873
+ return $this->comment;
874
+ }
875
+
876
+ function rewind_comments() {
877
+ $this->current_comment = -1;
878
+ if ( $this->comment_count > 0 ) {
879
+ $this->comment = $this->comments[0];
880
+ }
881
+ }
882
+
883
+ function user_comments() {
884
+ if ( $this->current_comment + 1 < $this->comment_count ) {
885
+ return true;
886
+ } elseif ( $this->current_comment + 1 == $this->comment_count ) {
887
+ do_action('loop_end');
888
+ // Do some cleaning up after the loop
889
+ $this->rewind_comments();
890
+ }
891
+
892
+ $this->in_the_loop = false;
893
+ return false;
894
+ }
895
+
896
+ function the_comment() {
897
+ global $comment;
898
+
899
+ $this->in_the_loop = true;
900
+ $comment = $this->next_comment();
901
+
902
+ if ( 0 == $this->current_comment ) // loop has just started
903
+ do_action('loop_start');
904
+ }
905
+ }
906
+
907
+ function bp_has_comments( $args = '' ) {
908
+ global $comments_template;
909
+
910
+ $defaults = array(
911
+ 'user_id' => false,
912
+ 'per_page' => 10,
913
+ 'max' => false
914
+ );
915
+
916
+ $r = wp_parse_args( $args, $defaults );
917
+ extract( $r, EXTR_SKIP );
918
+
919
+ $comments_template = new BP_Blogs_Post_Comment_Template( $user_id, $per_page, $max );
920
+
921
+ return $comments_template->has_comments();
922
+ }
923
+
924
+ function bp_comments() {
925
+ global $comments_template;
926
+ return $comments_template->user_comments();
927
+ }
928
+
929
+ function bp_the_comment() {
930
+ global $comments_template;
931
+ return $comments_template->the_comment();
932
+ }
933
+
934
+ function bp_comments_pagination() {
935
+ echo bp_get_comments_pagination();
936
+ }
937
+ function bp_get_comments_pagination() {
938
+ global $comments_template;
939
+
940
+ return apply_filters( 'bp_get_comments_pagination', $comments_template->pag_links );
941
+ }
942
+
943
+ function bp_comment_id() {
944
+ echo bp_get_comment_id();
945
+ }
946
+ function bp_get_comment_id() {
947
+ global $comments_template;
948
+ echo apply_filters( 'bp_get_comment_id', $comments_template->comment->comment_ID );
949
+ }
950
+
951
+ function bp_comment_post_permalink( $depricated = true ) {
952
+ if ( !$depricated )
953
+ return bp_get_comment_post_permalink();
954
+ else
955
+ echo bp_get_comment_post_permalink();
956
+ }
957
+ function bp_get_comment_post_permalink() {
958
+ global $comments_template;
959
+
960
+ return apply_filters( 'bp_get_comment_post_permalink', bp_post_get_permalink( $comments_template->comment->post, $comments_template->comment->blog_id ) . '#comment-' . $comments_template->comment->comment_ID );
961
+ }
962
+
963
+ function bp_comment_post_title( $deprecated = true ) {
964
+ if ( !$deprecated )
965
+ return bp_get_comment_post_title();
966
+ else
967
+ echo bp_get_comment_post_title();
968
+ }
969
+ function bp_get_comment_post_title( $deprecated = true ) {
970
+ global $comments_template;
971
+
972
+ return apply_filters( 'bp_get_comment_post_title', $comments_template->comment->post->post_title );
973
+ }
974
+
975
+ function bp_comment_author( $deprecated = true ) {
976
+ global $comments_template;
977
+
978
+ if ( !$deprecated )
979
+ return bp_get_comment_author();
980
+ else
981
+ echo bp_get_comment_author();
982
+ }
983
+ function bp_get_comment_author() {
984
+ global $comments_template;
985
+
986
+ return apply_filters( 'bp_get_comment_author', bp_core_get_userlink( $comments_template->comment->user_id ) );
987
+ }
988
+
989
+ function bp_comment_content() {
990
+ echo bp_get_comment_content();
991
+ }
992
+ function bp_get_comment_content() {
993
+ global $comments_template;
994
+ $content = $comments_template->comment->comment_content;
995
+ $content = apply_filters('the_content', $content);
996
+ $content = str_replace(']]>', ']]&gt;', $content);
997
+ echo apply_filters( 'bp_get_comment_content', $content );
998
+ }
999
+
1000
+ function bp_comment_date( $date_format = null, $deprecated = true ) {
1001
+ if ( !$date_format )
1002
+ $date_format = get_option('date_format');
1003
+
1004
+ if ( !$deprecated )
1005
+ return bp_get_comment_date( $date_format );
1006
+ else
1007
+ echo bp_get_comment_date( $date_format );
1008
+ }
1009
+ function bp_get_comment_date( $date_format = null ) {
1010
+ global $comments_template;
1011
+
1012
+ if ( !$date_format )
1013
+ $date_format = get_option('date_format');
1014
+
1015
+ return apply_filters( 'bp_get_comment_date', mysql2date( $date_format, $comments_template->comment->comment_date ) );
1016
+ }
1017
+
1018
+ function bp_comment_blog_permalink( $deprecated = true ) {
1019
+ if ( !$deprecated )
1020
+ return bp_get_comment_blog_permalink();
1021
+ else
1022
+ echo bp_get_comment_blog_permalink();
1023
+ }
1024
+ function bp_get_comment_blog_permalink() {
1025
+ global $comments_template;
1026
+
1027
+ return apply_filters( 'bp_get_comment_blog_permalink', get_blog_option( $comments_template->comment->blog_id, 'siteurl' ) );
1028
+ }
1029
+
1030
+ function bp_comment_blog_name( $deprecated = true ) {
1031
+ global $comments_template;
1032
+
1033
+ if ( !$deprecated )
1034
+ return bp_get_comment_blog_permalink();
1035
+ else
1036
+ echo bp_get_comment_blog_permalink();
1037
+ }
1038
+ function bp_get_comment_blog_name( $deprecated = true ) {
1039
+ global $comments_template;
1040
+
1041
+ return apply_filters( 'bp_get_comment_blog_name', get_blog_option( $comments_template->comment->blog_id, 'blogname' ) );
1042
+ }
1043
+
1044
+ /**********************************************************************
1045
+ * Site Wide Blog listing template class
1046
+ */
1047
+
1048
+ class BP_Blogs_Site_Blogs_Template {
1049
+ var $current_blog = -1;
1050
+ var $blog_count;
1051
+ var $blogs;
1052
+ var $blog;
1053
+
1054
+ var $in_the_loop;
1055
+
1056
+ var $pag_page;
1057
+ var $pag_num;
1058
+ var $pag_links;
1059
+ var $total_blog_count;
1060
+
1061
+ function bp_blogs_site_blogs_template( $type, $per_page, $max ) {
1062
+ global $bp;
1063
+
1064
+ $this->pag_page = isset( $_REQUEST['bpage'] ) ? intval( $_REQUEST['bpage'] ) : 1;
1065
+ $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
1066
+
1067
+ if ( isset( $_REQUEST['s'] ) && '' != $_REQUEST['s'] && $type != 'random' ) {
1068
+ $this->blogs = BP_Blogs_Blog::search_blogs( $_REQUEST['s'], $this->pag_num, $this->pag_page );
1069
+ } else if ( isset( $_REQUEST['letter'] ) && '' != $_REQUEST['letter'] ) {
1070
+ $this->blogs = BP_Blogs_Blog::get_by_letter( $_REQUEST['letter'], $this->pag_num, $this->pag_page );
1071
+ } else {
1072
+ switch ( $type ) {
1073
+ case 'random':
1074
+ $this->blogs = BP_Blogs_Blog::get_random( $this->pag_num, $this->pag_page );
1075
+ break;
1076
+
1077
+ case 'newest':
1078
+ $this->blogs = BP_Blogs_Blog::get_newest( $this->pag_num, $this->pag_page );
1079
+ break;
1080
+
1081
+ case 'active': default:
1082
+ $this->blogs = BP_Blogs_Blog::get_active( $this->pag_num, $this->pag_page );
1083
+ break;
1084
+ }
1085
+ }
1086
+
1087
+ if ( !$max )
1088
+ $this->total_blog_count = (int)$this->blogs['total'];
1089
+ else
1090
+ $this->total_blog_count = (int)$max;
1091
+
1092
+ $this->blogs = $this->blogs['blogs'];
1093
+
1094
+ if ( $max ) {
1095
+ if ( $max >= count($this->blogs) )
1096
+ $this->blog_count = count($this->blogs);
1097
+ else
1098
+ $this->blog_count = (int)$max;
1099
+ } else {
1100
+ $this->blog_count = count($this->blogs);
1101
+ }
1102
+
1103
+ $this->pag_links = paginate_links( array(
1104
+ 'base' => add_query_arg( 'bpage', '%#%' ),
1105
+ 'format' => '',
1106
+ 'total' => ceil( (int) $this->total_blog_count / (int) $this->pag_num ),
1107
+ 'current' => (int) $this->pag_page,
1108
+ 'prev_text' => '&laquo;',
1109
+ 'next_text' => '&raquo;',
1110
+ 'mid_size' => 1
1111
+ ));
1112
+ }
1113
+
1114
+ function has_blogs() {
1115
+ if ( $this->blog_count )
1116
+ return true;
1117
+
1118
+ return false;
1119
+ }
1120
+
1121
+ function next_blog() {
1122
+ $this->current_blog++;
1123
+ $this->blog = $this->blogs[$this->current_blog];
1124
+
1125
+ return $this->blog;
1126
+ }
1127
+
1128
+ function rewind_blogs() {
1129
+ $this->current_blog = -1;
1130
+ if ( $this->blog_count > 0 ) {
1131
+ $this->blog = $this->blogs[0];
1132
+ }
1133
+ }
1134
+
1135
+ function blogs() {
1136
+ if ( $this->current_blog + 1 < $this->blog_count ) {
1137
+ return true;
1138
+ } elseif ( $this->current_blog + 1 == $this->blog_count ) {
1139
+ do_action('loop_end');
1140
+ // Do some cleaning up after the loop
1141
+ $this->rewind_blogs();
1142
+ }
1143
+
1144
+ $this->in_the_loop = false;
1145
+ return false;
1146
+ }
1147
+
1148
+ function the_blog() {
1149
+ global $blog;
1150
+
1151
+ $this->in_the_loop = true;
1152
+ $this->blog = $this->next_blog();
1153
+
1154
+ if ( 0 == $this->current_blog ) // loop has just started
1155
+ do_action('loop_start');
1156
+ }
1157
+ }
1158
+
1159
+ function bp_rewind_site_blogs() {
1160
+ global $site_blogs_template;
1161
+
1162
+ $site_blogs_template->rewind_blogs();
1163
+ }
1164
+
1165
+ function bp_has_site_blogs( $args = '' ) {
1166
+ global $site_blogs_template;
1167
+
1168
+ $defaults = array(
1169
+ 'type' => 'active',
1170
+ 'per_page' => 10,
1171
+ 'max' => false
1172
+ );
1173
+
1174
+ $r = wp_parse_args( $args, $defaults );
1175
+ extract( $r, EXTR_SKIP );
1176
+
1177
+ // type: active ( default ) | random | newest | popular
1178
+
1179
+ if ( $max ) {
1180
+ if ( $per_page > $max )
1181
+ $per_page = $max;
1182
+ }
1183
+
1184
+ $site_blogs_template = new BP_Blogs_Site_Blogs_Template( $type, $per_page, $max );
1185
+
1186
+ return $site_blogs_template->has_blogs();
1187
+ }
1188
+
1189
+ function bp_site_blogs() {
1190
+ global $site_blogs_template;
1191
+
1192
+ return $site_blogs_template->blogs();
1193
+ }
1194
+
1195
+ function bp_the_site_blog() {
1196
+ global $site_blogs_template;
1197
+
1198
+ return $site_blogs_template->the_blog();
1199
+ }
1200
+
1201
+ function bp_site_blogs_pagination_count() {
1202
+ global $bp, $site_blogs_template;
1203
+
1204
+ $from_num = intval( ( $site_blogs_template->pag_page - 1 ) * $site_blogs_template->pag_num ) + 1;
1205
+ $to_num = ( $from_num + ( $site_blogs_template->pag_num - 1 ) > $site_blogs_template->total_blog_count ) ? $site_blogs_template->total_blog_count : $from_num + ( $site_blogs_template->pag_num - 1 ) ;
1206
+
1207
+ echo sprintf( __( 'Viewing blog %d to %d (of %d blogs)', 'buddypress' ), $from_num, $to_num, $site_blogs_template->total_blog_count ); ?> &nbsp;
1208
+ <img id="ajax-loader-blogs" src="<?php echo $bp->core->image_base ?>/ajax-loader.gif" height="7" alt="<?php _e( "Loading", "buddypress" ) ?>" style="display: none;" /><?php
1209
+ }
1210
+
1211
+ function bp_site_blogs_pagination_links() {
1212
+ echo bp_get_site_blogs_pagination_links();
1213
+ }
1214
+ function bp_get_site_blogs_pagination_links() {
1215
+ global $site_blogs_template;
1216
+
1217
+ return apply_filters( 'bp_get_site_blogs_pagination_links', $site_blogs_template->pag_links );
1218
+ }
1219
+
1220
+ function bp_the_site_blog_avatar() {
1221
+ echo bp_get_the_site_blog_avatar();
1222
+ }
1223
+ function bp_get_the_site_blog_avatar() {
1224
+ global $site_blogs_template, $bp;
1225
+
1226
+ /***
1227
+ * In future BuddyPress versions you will be able to set the avatar for a blog.
1228
+ * Right now you can use a filter with the ID of the blog to change it if you wish.
1229
+ */
1230
+ return apply_filters( 'bp_get_blogs_blog_avatar_' . $site_blogs_template->blog->blog_id, '<img src="http://www.gravatar.com/avatar/' . md5( $site_blogs_template->blog->blog_id . '.blogs@' . $bp->root_domain ) . '?d=identicon&amp;s=150" class="avatar blog-avatar" alt="' . __( 'Blog Avatar', 'buddypress' ) . '" />', $site_blogs_template->blog->blog_id );
1231
+ }
1232
+
1233
+ function bp_the_site_blog_avatar_thumb() {
1234
+ echo bp_get_the_site_blog_avatar_thumb();
1235
+ }
1236
+ function bp_get_the_site_blog_avatar_thumb() {
1237
+ global $site_blogs_template, $bp;
1238
+
1239
+ return apply_filters( 'bp_get_blogs_blog_avatar_thumb_' . $site_blogs_template->blog->blog_id, '<img src="http://www.gravatar.com/avatar/' . md5( $site_blogs_template->blog->blog_id . '.blogs@' . $bp->root_domain ) . '?d=identicon&amp;s=50" class="avatar blog-avatar thumb" alt="' . __( 'Blog Avatar', 'buddypress' ) . '" />', $site_blogs_template->blog->blog_id );
1240
+ }
1241
+
1242
+ function bp_the_site_blog_avatar_mini() {
1243
+ echo bp_get_the_site_blog_avatar_mini();
1244
+ }
1245
+ function bp_get_the_site_blog_avatar_mini() {
1246
+ global $site_blogs_template, $bp;
1247
+
1248
+ return apply_filters( 'bp_get_blogs_blog_avatar_mini_' . $site_blogs_template->blog->blog_id, '<img src="http://www.gravatar.com/avatar/' . md5( $site_blogs_template->blog->blog_id . '.blogs@' . $bp->root_domain ) . '?d=identicon&amp;s=25" class="avatar blog-avatar mini" alt="' . __( 'Blog Avatar', 'buddypress' ) . '" />', $site_blogs_template->blog->blog_id );
1249
+ }
1250
+
1251
+ function bp_the_site_blog_link() {
1252
+ echo bp_get_the_site_blog_link();
1253
+ }
1254
+ function bp_get_the_site_blog_link() {
1255
+ global $site_blogs_template;
1256
+
1257
+ return apply_filters( 'bp_get_the_site_blog_link', get_blog_option( $site_blogs_template->blog->blog_id, 'siteurl' ) );
1258
+ }
1259
+
1260
+ function bp_the_site_blog_name() {
1261
+ echo bp_get_the_site_blog_name();
1262
+ }
1263
+ function bp_get_the_site_blog_name() {
1264
+ global $site_blogs_template;
1265
+
1266
+ return apply_filters( 'bp_get_the_site_blog_name', get_blog_option( $site_blogs_template->blog->blog_id, 'blogname' ) );
1267
+ }
1268
+
1269
+ function bp_the_site_blog_description() {
1270
+ echo apply_filters( 'bp_the_site_blog_description', bp_get_the_site_blog_description() );
1271
+ }
1272
+ function bp_get_the_site_blog_description() {
1273
+ global $site_blogs_template;
1274
+
1275
+ return apply_filters( 'bp_get_the_site_blog_description', get_blog_option( $site_blogs_template->blog->blog_id, 'blogdescription' ) );
1276
+ }
1277
+
1278
+ function bp_the_site_blog_last_active() {
1279
+ echo bp_get_the_site_blog_last_active();
1280
+ }
1281
+ function bp_get_the_site_blog_last_active() {
1282
+ global $site_blogs_template;
1283
+
1284
+ return apply_filters( 'bp_the_site_blog_last_active', bp_core_get_last_activity( bp_blogs_get_blogmeta( $site_blogs_template->blog->blog_id, 'last_activity' ), __( 'active %s ago', 'buddypress' ) ) );
1285
+ }
1286
+
1287
+ function bp_the_site_blog_latest_post() {
1288
+ echo bp_get_the_site_blog_latest_post();
1289
+ }
1290
+ function bp_get_the_site_blog_latest_post() {
1291
+ global $site_blogs_template;
1292
+
1293
+ if ( $post = bp_blogs_get_latest_posts( $site_blogs_template->blog->blog_id, 1 ) ) {
1294
+ return apply_filters( 'bp_get_the_site_blog_latest_post', sprintf( __( 'Latest Post: %s', 'buddypress' ), '<a href="' . bp_post_get_permalink( $post[0], $site_blogs_template->blog->blog_id ) . '">' . apply_filters( 'the_title', $post[0]->post_title ) . '</a>' ) );
1295
+ }
1296
+ }
1297
+
1298
+ function bp_the_site_blog_hidden_fields() {
1299
+ if ( isset( $_REQUEST['s'] ) ) {
1300
+ echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['s'] ). '" name="search_terms" />';
1301
+ }
1302
+
1303
+ if ( isset( $_REQUEST['letter'] ) ) {
1304
+ echo '<input type="hidden" id="selected_letter" value="' . attribute_escape( $_REQUEST['letter'] ) . '" name="selected_letter" />';
1305
+ }
1306
+
1307
+ if ( isset( $_REQUEST['blogs_search'] ) ) {
1308
+ echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['blogs_search'] ) . '" name="search_terms" />';
1309
+ }
1310
+ }
1311
+
1312
+ function bp_directory_blogs_search_form() {
1313
+ global $bp; ?>
1314
+ <form action="<?php echo $bp->root_domain . '/' . blogs_SLUG . '/search/' ?>" method="post" id="search-blogs-form">
1315
+ <label><input type="text" name="blogs_search" id="blogs_search" value="<?php if ( isset( $_GET['s'] ) ) { echo $_GET['s']; } else { _e( 'Search anything...', 'buddypress' ); } ?>" onfocus="if (this.value == '<?php _e( 'Search anything...', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Search anything...', 'buddypress' ) ?>';}" /></label>
1316
+ <input type="submit" id="blogs_search_submit" name="blogs_search_submit" value="<?php _e( 'Search', 'buddypress' ) ?>" />
1317
+ </form>
1318
+ <?php
1319
+ }
1320
+
1321
+
1322
+ ?>
bp-blogs/bp-blogs-widgets.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /* Register widgets for blogs component */
4
+ function bp_blogs_register_widgets() {
5
+ global $current_blog;
6
+
7
+ /* Latest Posts Widget */
8
+ wp_register_sidebar_widget( 'buddypress-blogs', __('Recent Blog Posts', 'buddypress'), 'bp_blogs_widget_recent_posts');
9
+ wp_register_widget_control( 'buddypress-blogs', __('Recent Blog Posts', 'buddypress'), 'bp_blogs_widget_recent_posts_control' );
10
+
11
+ if ( is_active_widget( 'bp_blogs_widget_recent_posts' ) ) {
12
+ wp_enqueue_style( 'bp-blogs-widget-posts-css', BP_PLUGIN_URL . '/bp-blogs/css/widget-blogs.css' );
13
+ }
14
+ }
15
+ add_action( 'plugins_loaded', 'bp_blogs_register_widgets' );
16
+
17
+
18
+ function bp_blogs_widget_recent_posts($args) {
19
+ global $current_blog;
20
+
21
+ extract($args);
22
+ $options = get_blog_option( $current_blog->blog_id, 'bp_blogs_widget_recent_posts' );
23
+ ?>
24
+ <?php echo $before_widget; ?>
25
+ <?php echo $before_title
26
+ . $widget_name
27
+ . $after_title; ?>
28
+
29
+ <?php $posts = bp_blogs_get_latest_posts( null, $options['max_posts'] ) ?>
30
+ <?php $counter = 0; ?>
31
+
32
+ <?php if ( $posts ) : ?>
33
+ <div class="item-options" id="recent-posts-options">
34
+ <?php _e("Site Wide", 'buddypress') ?>
35
+ </div>
36
+ <ul id="recent-posts" class="item-list">
37
+ <?php foreach ( $posts as $post ) : ?>
38
+ <li>
39
+ <div class="item-avatar">
40
+ <a href="<?php echo bp_post_get_permalink( $post, $post->blog_id ) ?>" title="<?php echo apply_filters( 'the_title', $post->post_title ) ?>"><?php echo bp_core_get_avatar( $post->post_author, 1 ) ?></a>
41
+ </div>
42
+
43
+ <div class="item">
44
+ <h4 class="item-title"><a href="<?php echo bp_post_get_permalink( $post, $post->blog_id ) ?>" title="<?php echo apply_filters( 'the_title', $post->post_title ) ?>"><?php echo apply_filters( 'the_title', $post->post_title ) ?></a></h4>
45
+ <?php if ( !$counter ) : ?>
46
+ <div class="item-content"><?php echo bp_create_excerpt($post->post_content) ?></div>
47
+ <?php endif; ?>
48
+ <div class="item-meta"><em><?php printf( __( 'by %s from the blog <a href="%s">%s</a>', 'buddypress' ), bp_core_get_userlink( $post->post_author ), get_blog_option( $post->blog_id, 'siteurl' ), get_blog_option( $post->blog_id, 'blogname' ) ) ?></em></div>
49
+ </div>
50
+ </li>
51
+ <?php $counter++; ?>
52
+ <?php endforeach; ?>
53
+ </ul>
54
+ <?php else: ?>
55
+ <div class="widget-error">
56
+ <?php _e('There are no recent blog posts, why not write one?', 'buddypress') ?>
57
+ </div>
58
+ <?php endif; ?>
59
+
60
+ <?php echo $after_widget; ?>
61
+ <?php
62
+ }
63
+
64
+ function bp_blogs_widget_recent_posts_control() {
65
+ global $current_blog;
66
+
67
+ $options = $newoptions = get_blog_option( $current_blog->blog_id, 'bp_blogs_widget_recent_posts');
68
+
69
+ if ( $_POST['bp-blogs-widget-recent-posts-submit'] ) {
70
+ $newoptions['max_posts'] = strip_tags( stripslashes( $_POST['bp-blogs-widget-recent-posts-max'] ) );
71
+ }
72
+
73
+ if ( $options != $newoptions ) {
74
+ $options = $newoptions;
75
+ update_blog_option( $current_blog->blog_id, 'bp_blogs_widget_recent_posts', $options );
76
+ }
77
+
78
+ $max_posts = attribute_escape( $options['max_posts'] );
79
+ ?>
80
+ <p><label for="bp-blogs-widget-recent-posts-max"><?php _e('Max Number of Posts:', 'buddypress'); ?> <input class="widefat" id="bp-blogs-widget-recent-posts-max" name="bp-blogs-widget-recent-posts-max" type="text" value="<?php echo $max_posts; ?>" style="width: 30%" /></label></p>
81
+ <input type="hidden" id="bp-blogs-widget-recent-posts-submit" name="bp-blogs-widget-recent-posts-submit" value="1" />
82
+ <?php
83
+ }
84
+
85
+ ?>
bp-blogs/css/structure.css ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Basic layout structure styles for BuddyPress Blogs. Formats BuddyPress blog pages within any WordPress theme.
3
+ No colors, fonts or pretty stuff.
4
+
5
+ These structure styles can be overridden by the theme CSS file if needed.
6
+ */
7
+
8
+ #blog-info {
9
+ margin: -1em 0 2em 0;
10
+ }
11
+
12
+ .post {
13
+ padding-bottom: 2em;
14
+ margin-bottom: 2em;
15
+ float: left;
16
+ width: 100%;
17
+ }
18
+
19
+ #main #content .post h2 {
20
+ border: none;
21
+ padding: 0;
22
+ margin: 0;
23
+ }
24
+
25
+ .post span.tags {
26
+ padding-left: 1.6em;
27
+ float: left;
28
+ }
29
+
30
+ .post span.comments {
31
+ float: right;
32
+ padding-right: 1.8em;
33
+ }
34
+
35
+ .postmetadata {
36
+ padding: 0.5em 0;
37
+ }
38
+
39
+ .post-details {
40
+ padding: 1em 1.5em;
41
+ margin: 0 0 2em 0;
42
+ }
43
+
44
+ h4.archive {
45
+ padding-bottom: 0.5em;
46
+ margin: -1em 0 1em 0;
47
+ }
48
+
49
+
50
+ /**** BLOG SIGNUP FORM **********/
51
+
52
+ #setupform label {
53
+ display: block;
54
+ padding-bottom: 3px;
55
+ }
56
+ #setupform label.checkbox {
57
+ display: inline;
58
+ margin-right: 1em;
59
+ }
60
+
61
+ #setupform label.checkbox input {
62
+ display: inline;
63
+ }
64
+
65
+ #setupform p.error {
66
+ padding: 5px 10px;
67
+ width: 40%;
68
+ }
69
+
70
+ #setupform input#blog_title, #setupform input#blogname {
71
+ width: 25%;
72
+ padding: 5px;
73
+ margin-bottom: 1.5em;
74
+ margin-right: 5px;
75
+ }
76
+ #setupform input#blog_title {
77
+ width: 65%;
78
+ }
79
+
80
+ #setupform input#submit {
81
+ width: auto;
82
+ margin-top: 1.5em;
83
+ padding: 3px 10px;
84
+ }
bp-blogs/css/widget-blogs.css ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .bp_blogs_widget_recent_posts ul.item-list {
2
+ margin: 15px 0 0 0;
3
+ padding: 0;
4
+ list-style: none;
5
+ }
6
+
7
+ .bp_blogs_widget_recent_posts ul.item-list li {
8
+ min-height: 60px;
9
+ }
10
+
11
+ .bp_blogs_widget_recent_posts ul.item-list li .item-meta {
12
+ margin-left: 35px;
13
+ }
14
+ .bp_blogs_widget_recent_posts ul.item-list li .item h4.item-title {
15
+ clear: none !important;
16
+ }
17
+
18
+ .bp_blogs_widget_recent_posts ul.item-list li .item-avatar {
19
+ float: left;
20
+ margin: 0 10px 0 0;
21
+ }
22
+ .bp_blogs_widget_recent_posts ul.item-list li .item-avatar img.avatar {
23
+ width: 25px;
24
+ height: 25px;
25
+ }
26
+
27
+ .bp_blogs_widget_recent_posts ul li em {
28
+ font-size: 11px;
29
+ }
bp-blogs/js/directory-blogs.js ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready( function() {
2
+ jQuery("ul#letter-list li a").livequery('click',
3
+ function() {
4
+ jQuery('#ajax-loader-blogs').toggle();
5
+
6
+ jQuery("div#blogs-list-options a").removeClass("selected");
7
+ jQuery(this).addClass('selected');
8
+ jQuery("input#blogs_search").val('');
9
+
10
+ var letter = jQuery(this).attr('id')
11
+ letter = letter.split('-');
12
+
13
+ jQuery.post( ajaxurl, {
14
+ action: 'directory_blogs',
15
+ 'cookie': encodeURIComponent(document.cookie),
16
+ '_wpnonce': jQuery("input#_wpnonce-blog-filter").val(),
17
+ 'letter': letter[1],
18
+ 'page': 1
19
+ },
20
+ function(response)
21
+ {
22
+ response = response.substr(0, response.length-1);
23
+ jQuery("#blog-dir-list").fadeOut(200,
24
+ function() {
25
+ jQuery('#ajax-loader-blogs').toggle();
26
+ jQuery("#blog-dir-list").html(response);
27
+ jQuery("#blog-dir-list").fadeIn(200);
28
+ }
29
+ );
30
+ });
31
+
32
+ return false;
33
+ }
34
+ );
35
+
36
+ jQuery("form#search-blogs-form").submit( function() {
37
+ jQuery('#ajax-loader-blogs').toggle();
38
+
39
+ jQuery.post( ajaxurl, {
40
+ action: 'directory_blogs',
41
+ 'cookie': encodeURIComponent(document.cookie),
42
+ '_wpnonce': jQuery("input#_wpnonce-blog-filter").val(),
43
+ 's': jQuery("input#blogs_search").val(),
44
+ 'page': 1
45
+ },
46
+ function(response)
47
+ {
48
+ response = response.substr(0, response.length-1);
49
+ jQuery("#blog-dir-list").fadeOut(200,
50
+ function() {
51
+ jQuery('#ajax-loader-blogs').toggle();
52
+ jQuery("#blog-dir-list").html(response);
53
+ jQuery("#blog-dir-list").fadeIn(200);
54
+ }
55
+ );
56
+ });
57
+
58
+ return false;
59
+ }
60
+ );
61
+
62
+ jQuery("div#blog-dir-pag a").livequery('click',
63
+ function() {
64
+ jQuery('#ajax-loader-blogs').toggle();
65
+
66
+ var page = jQuery(this).attr('href');
67
+ page = page.split('bpage=');
68
+
69
+ if ( !jQuery("input#selected_letter").val() )
70
+ var letter = '';
71
+ else
72
+ var letter = jQuery("input#selected_letter").val();
73
+
74
+ if ( !jQuery("input#search_terms").val() )
75
+ var search_terms = '';
76
+ else
77
+ var search_terms = jQuery("input#search_terms").val();
78
+
79
+ jQuery.post( ajaxurl, {
80
+ action: 'directory_blogs',
81
+ 'cookie': encodeURIComponent(document.cookie),
82
+ '_wpnonce': jQuery("input#_wpnonce").val(),
83
+ 'bpage': page[1],
84
+ '_wpnonce': jQuery("input#_wpnonce-blog-filter").val(),
85
+
86
+ 'letter': letter,
87
+ 's': search_terms
88
+ },
89
+ function(response)
90
+ {
91
+ response = response.substr(0, response.length-1);
92
+ jQuery("#blog-dir-list").fadeOut(200,
93
+ function() {
94
+ jQuery('#ajax-loader-blogs').toggle();
95
+ jQuery("#blog-dir-list").html(response);
96
+ jQuery("#blog-dir-list").fadeIn(200);
97
+ }
98
+ );
99
+ });
100
+
101
+ return false;
102
+ }
103
+ );
104
+ });
bp-core.php ADDED
@@ -0,0 +1,1349 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /* Define the current version number for checking if DB tables are up to date. */
4
+ define( 'BP_CORE_VERSION', '1.0' );
5
+ define( 'BP_CORE_DB_VERSION', '1300' );
6
+
7
+ /* Define the path and url of the BuddyPress plugins directory */
8
+ define( 'BP_PLUGIN_DIR', WP_PLUGIN_DIR . '/buddypress' );
9
+ define( 'BP_PLUGIN_URL', WP_PLUGIN_URL . '/buddypress' );
10
+
11
+ /* Place your custom code (actions/filters) in a file called /plugins/bp-custom.php and it will be loaded before anything else. */
12
+ if ( file_exists( WP_PLUGIN_DIR . '/bp-custom.php' ) )
13
+ require( WP_PLUGIN_DIR . '/bp-custom.php' );
14
+
15
+ /* Define on which blog ID BuddyPress should run */
16
+ if ( !defined( 'BP_ROOT_BLOG' ) )
17
+ define( 'BP_ROOT_BLOG', 1 );
18
+
19
+ /* Define the user and usermeta table names, useful if you are using custom or shared tables */
20
+ if ( !defined( 'CUSTOM_USER_TABLE' ) )
21
+ define( 'CUSTOM_USER_TABLE', $wpdb->base_prefix . 'users' );
22
+
23
+ if ( !defined( 'CUSTOM_USER_META_TABLE' ) )
24
+ define( 'CUSTOM_USER_META_TABLE', $wpdb->base_prefix . 'usermeta' );
25
+
26
+ /* Load the language file */
27
+ if ( file_exists( BP_PLUGIN_DIR . '/bp-languages/buddypress-' . get_locale() . '.mo' ) )
28
+ load_textdomain( 'buddypress', BP_PLUGIN_DIR . '/bp-languages/buddypress-' . get_locale() . '.mo' );
29
+
30
+ /* Load the files containing functions that we globally will need. */
31
+ require ( BP_PLUGIN_DIR . '/bp-core/bp-core-catchuri.php' );
32
+ require ( BP_PLUGIN_DIR . '/bp-core/bp-core-classes.php' );
33
+ require ( BP_PLUGIN_DIR . '/bp-core/bp-core-cssjs.php' );
34
+ require ( BP_PLUGIN_DIR . '/bp-core/bp-core-avatars.php' );
35
+ require ( BP_PLUGIN_DIR . '/bp-core/bp-core-templatetags.php' );
36
+ require ( BP_PLUGIN_DIR . '/bp-core/bp-core-settings.php' );
37
+ require ( BP_PLUGIN_DIR . '/bp-core/bp-core-widgets.php' );
38
+ require ( BP_PLUGIN_DIR . '/bp-core/bp-core-ajax.php' );
39
+ require ( BP_PLUGIN_DIR . '/bp-core/bp-core-notifications.php' );
40
+
41
+ if ( !defined( 'BP_DISABLE_ADMIN_BAR') )
42
+ require ( 'bp-core/bp-core-adminbar.php' );
43
+
44
+ /* Define the slug for member pages and the members directory (e.g. domain.com/[members] ) */
45
+ if ( !defined( 'BP_MEMBERS_SLUG' ) )
46
+ define( 'BP_MEMBERS_SLUG', 'members' );
47
+
48
+ /* Define the slug for the register/signup page */
49
+ if ( !defined( 'BP_REGISTER_SLUG' ) )
50
+ define( 'BP_REGISTER_SLUG', 'register' );
51
+
52
+ /* Define the slug for the activation page */
53
+ if ( !defined( 'BP_ACTIVATION_SLUG' ) )
54
+ define( 'BP_ACTIVATION_SLUG', 'activate' );
55
+
56
+ /* Define the slug for the search page */
57
+ if ( !defined( 'BP_SEARCH_SLUG' ) )
58
+ define( 'BP_SEARCH_SLUG', 'search' );
59
+
60
+ /* Define the slug for the search page */
61
+ if ( !defined( 'BP_HOME_BLOG_SLUG' ) )
62
+ define( 'BP_HOME_BLOG_SLUG', 'blog' );
63
+
64
+
65
+ /* "And now for something completely different" .... */
66
+
67
+
68
+ /**
69
+ * bp_core_setup_globals()
70
+ *
71
+ * Sets up default global BuddyPress configuration settings and stores
72
+ * them in a $bp variable.
73
+ *
74
+ * @package BuddyPress Core Core
75
+ * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
76
+ * @global $current_user A WordPress global containing current user information
77
+ * @global $current_component Which is set up in /bp-core/bp-core-catch-uri.php
78
+ * @global $current_action Which is set up in /bp-core/bp-core-catch-uri.php
79
+ * @global $action_variables Which is set up in /bp-core/bp-core-catch-uri.php
80
+ * @uses bp_core_get_user_domain() Returns the domain for a user
81
+ */
82
+ function bp_core_setup_globals() {
83
+ global $bp, $wpdb;
84
+ global $current_user, $current_component, $current_action, $current_blog;
85
+ global $displayed_user_id;
86
+ global $action_variables;
87
+
88
+ $current_user = wp_get_current_user();
89
+
90
+ /* The domain for the root of the site where the main blog resides */
91
+ $bp->root_domain = bp_core_get_root_domain();
92
+
93
+ /* The user ID of the user who is currently logged in. */
94
+ $bp->loggedin_user->id = $current_user->ID;
95
+
96
+ /* The domain for the user currently logged in. eg: http://domain.com/members/andy */
97
+ $bp->loggedin_user->domain = bp_core_get_user_domain($current_user->ID);
98
+
99
+ /* The user id of the user currently being viewed, set in /bp-core/bp-core-catchuri.php */
100
+ $bp->displayed_user->id = $displayed_user_id;
101
+
102
+ /* The domain for the user currently being displayed */
103
+ $bp->displayed_user->domain = bp_core_get_user_domain($displayed_user_id);
104
+
105
+ /* The component being used eg: http://domain.com/members/andy/ [profile] */
106
+ $bp->current_component = $current_component; // type: string
107
+
108
+ /* The current action for the component eg: http://domain.com/members/andy/profile/ [edit] */
109
+ $bp->current_action = $current_action; // type: string
110
+
111
+ /* The action variables for the current action eg: http://domain.com/members/andy/profile/edit/ [group] / [6] */
112
+ $bp->action_variables = $action_variables; // type: array
113
+
114
+ /* 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.*/
115
+ $bp->current_item = ''; // type: string
116
+
117
+ /* Used for overriding the 2nd level navigation menu so it can be used to display custom navigation for an item (for example a group) */
118
+ $bp->is_single_item = false;
119
+
120
+ /* The default component to use if none are set and someone visits: http://domain.com/members/andy */
121
+ $bp->default_component = 'profile';
122
+
123
+ /* Sets up the array container for the component navigation rendered by bp_get_nav() */
124
+ $bp->bp_nav = array();
125
+
126
+ /* Sets up the array container for the user navigation rendered by bp_get_user_nav() */
127
+ $bp->bp_users_nav = array();
128
+
129
+ /* Sets up the array container for the component options navigation rendered by bp_get_options_nav() */
130
+ $bp->bp_options_nav = array();
131
+
132
+ /* Sets up container used for the title of the current component option and rendered by bp_get_options_title() */
133
+ $bp->bp_options_title = '';
134
+
135
+ /* Sets up container used for the avatar of the current component being viewed. Rendered by bp_get_options_avatar() */
136
+ $bp->bp_options_avatar = '';
137
+
138
+ /* Fetches the default Gravatar image to use if the user has no avatar or gravatar */
139
+ $bp->grav_default = get_site_option( 'user-avatar-default' );
140
+
141
+ /* Fetch the full name for the logged in and current user */
142
+ $bp->loggedin_user->fullname = bp_core_global_user_fullname( $bp->loggedin_user->id );
143
+ $bp->displayed_user->fullname = bp_core_global_user_fullname( $bp->displayed_user->id );
144
+
145
+ /* Used to determine if user has admin rights on current content. If the logged in user is viewing
146
+ their own profile and wants to delete a post on their wire, is_item_admin is used. This is a
147
+ generic variable so it can be used in other components. It can also be modified, so when viewing a group
148
+ 'is_item_admin' would be 1 if they are a group admin, 0 if they are not. */
149
+ $bp->is_item_admin = bp_is_home();
150
+
151
+ /* Used to determine if the logged in user is a moderator for the current content. */
152
+ $bp->is_item_mod = false;
153
+
154
+ $bp->core->image_base = BP_PLUGIN_URL . '/bp-core/images';
155
+ $bp->core->table_name_notifications = $wpdb->base_prefix . 'bp_notifications';
156
+
157
+ if ( !$bp->current_component )
158
+ $bp->current_component = $bp->default_component;
159
+ }
160
+ add_action( 'plugins_loaded', 'bp_core_setup_globals', 3 );
161
+ add_action( '_admin_menu', 'bp_core_setup_globals', 1 ); // must be _admin_menu hook.
162
+
163
+ function bp_core_setup_root_components() {
164
+ /* Add core root components */
165
+ bp_core_add_root_component( BP_MEMBERS_SLUG );
166
+ bp_core_add_root_component( BP_REGISTER_SLUG );
167
+ bp_core_add_root_component( BP_ACTIVATION_SLUG );
168
+ bp_core_add_root_component( BP_SEARCH_SLUG );
169
+ bp_core_add_root_component( BP_HOME_BLOG_SLUG );
170
+ }
171
+ add_action( 'plugins_loaded', 'bp_core_setup_root_components', 1 );
172
+
173
+ function bp_core_setup_session() {
174
+ // Start a session for error/success feedback on redirect and for signup functions.
175
+ @session_start();
176
+
177
+ // Render any error/success feedback on the template
178
+ if ( $_SESSION['message'] != '' )
179
+ add_action( 'template_notices', 'bp_core_render_notice' );
180
+ }
181
+ add_action( 'wp', 'bp_core_setup_session', 3 );
182
+
183
+ function bp_core_install() {
184
+ global $wpdb, $bp;
185
+
186
+ if ( !empty($wpdb->charset) )
187
+ $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
188
+
189
+ $sql[] = "CREATE TABLE {$bp->core->table_name_notifications} (
190
+ id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
191
+ user_id bigint(20) NOT NULL,
192
+ item_id bigint(20) NOT NULL,
193
+ secondary_item_id bigint(20),
194
+ component_name varchar(75) NOT NULL,
195
+ component_action varchar(75) NOT NULL,
196
+ date_notified datetime NOT NULL,
197
+ is_new bool NOT NULL DEFAULT 0,
198
+ KEY item_id (item_id),
199
+ KEY secondary_item_id (secondary_item_id),
200
+ KEY user_id (user_id),
201
+ KEY is_new (is_new),
202
+ KEY component_name (component_name),
203
+ KEY component_action (component_action),
204
+ KEY useritem (user_id, is_new)
205
+ ) {$charset_collate};";
206
+
207
+ require_once( ABSPATH . 'wp-admin/upgrade-functions.php' );
208
+ dbDelta( $sql );
209
+
210
+ /* Add names of root components to the banned blog list to avoid conflicts */
211
+ bp_core_add_illegal_names();
212
+
213
+ // dbDelta won't change character sets, so we need to do this seperately.
214
+ // This will only be in here pre v1.0
215
+ $wpdb->query( $wpdb->prepare( "ALTER TABLE {$bp->core->table_name_notifications} DEFAULT CHARACTER SET %s", $wpdb->charset ) );
216
+
217
+ update_site_option( 'bp-core-db-version', BP_CORE_DB_VERSION );
218
+ }
219
+
220
+ /**
221
+ * bp_core_check_installed()
222
+ *
223
+ * Checks to make sure the database tables are set up for the core component.
224
+ *
225
+ * @package BuddyPress Core
226
+ * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
227
+ * @global $wpdb WordPress DB access object.
228
+ * @global $current_user WordPress global variable containing current logged in user information
229
+ * @uses is_site_admin() returns true if the current user is a site admin, false if not
230
+ * @uses get_site_option() fetches the value for a meta_key in the wp_sitemeta table
231
+ * @uses bp_core_install() runs the installation of DB tables for the core component
232
+ */
233
+ function bp_core_check_installed() {
234
+ global $wpdb, $bp;
235
+
236
+ if ( !is_site_admin() )
237
+ return false;
238
+
239
+ require ( BP_PLUGIN_DIR . '/bp-core/bp-core-admin.php' );
240
+
241
+ /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
242
+ if ( get_site_option('bp-core-db-version') < BP_CORE_DB_VERSION )
243
+ bp_core_install();
244
+ }
245
+ add_action( 'admin_menu', 'bp_core_check_installed' );
246
+
247
+ /**
248
+ * bp_core_add_admin_menu()
249
+ *
250
+ * Adds the "BuddyPress" admin submenu item to the Site Admin tab.
251
+ *
252
+ * @package BuddyPress Core
253
+ * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
254
+ * @global $wpdb WordPress DB access object.
255
+ * @uses is_site_admin() returns true if the current user is a site admin, false if not
256
+ * @uses add_submenu_page() WP function to add a submenu item
257
+ */
258
+ function bp_core_add_admin_menu() {
259
+ global $wpdb, $bp;
260
+
261
+ if ( !is_site_admin() )
262
+ return false;
263
+
264
+ /* Add the administration tab under the "Site Admin" tab for site administrators */
265
+ add_menu_page( __("BuddyPress", 'buddypress'), __("BuddyPress", 'buddypress'), 2, 'bp-core.php', "bp_core_admin_settings" );
266
+ add_submenu_page( 'bp-core.php', __("General Settings", 'buddypress'), __("General Settings", 'buddypress'), 1, 'bp-core.php', "bp_core_admin_settings" );
267
+ add_submenu_page( 'bp-core.php', __("Component Setup", 'buddypress'), __("Component Setup", 'buddypress'), 2, __FILE__, "bp_core_admin_component_setup" );
268
+ }
269
+ add_action( 'admin_menu', 'bp_core_add_admin_menu' );
270
+
271
+ /**
272
+ * bp_core_is_root_component()
273
+ *
274
+ * Checks to see if a component's URL should be in the root, not under a member page:
275
+ * eg: http://domain.com/groups/the-group NOT http://domain.com/members/andy/groups/the-group
276
+ *
277
+ * @package BuddyPress Core
278
+ * @return true if root component, else false.
279
+ */
280
+ function bp_core_is_root_component( $component_name ) {
281
+ global $bp;
282
+
283
+ return in_array( $component_name, $bp->root_components );
284
+ }
285
+
286
+ /**
287
+ * bp_core_setup_nav()
288
+ *
289
+ * Sets up the profile navigation item if the Xprofile component is not installed.
290
+ *
291
+ * @package BuddyPress Core
292
+ * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
293
+ * @uses bp_core_add_nav_item() Adds a navigation item to the top level buddypress navigation
294
+ * @uses bp_core_add_nav_default() Sets which sub navigation item is selected by default
295
+ * @uses bp_core_add_subnav_item() Adds a sub navigation item to a nav item
296
+ * @uses bp_is_home() Returns true if the current user being viewed is equal the logged in user
297
+ * @uses bp_core_get_avatar() Returns the either the thumb (1) or full (2) avatar URL for the user_id passed
298
+ */
299
+ function bp_core_setup_nav() {
300
+ global $bp;
301
+
302
+ if ( !function_exists('xprofile_install') ) {
303
+ /* Add 'Profile' to the main navigation */
304
+ bp_core_add_nav_item( __('Profile', 'buddypress'), 'profile' );
305
+ bp_core_add_nav_default( 'profile', 'bp_core_catch_profile_uri', 'public' );
306
+
307
+ $profile_link = $bp->loggedin_user->domain . '/profile/';
308
+
309
+ /* Add the subnav items to the profile */
310
+ bp_core_add_subnav_item( 'profile', 'public', __('Public', 'buddypress'), $profile_link, 'xprofile_screen_display_profile' );
311
+
312
+ if ( 'profile' == $bp->current_component ) {
313
+ if ( bp_is_home() ) {
314
+ $bp->bp_options_title = __('My Profile', 'buddypress');
315
+ } else {
316
+ $bp->bp_options_avatar = bp_core_get_avatar( $bp->displayed_user->id, 1 );
317
+ $bp->bp_options_title = $bp->displayed_user->fullname;
318
+ }
319
+ }
320
+ }
321
+ }
322
+ add_action( 'wp', 'bp_core_setup_nav', 2 );
323
+ add_action( 'admin_menu', 'bp_core_setup_nav', 2 );
324
+
325
+ function bp_core_directory_members() {
326
+ global $bp;
327
+
328
+ if ( !is_home() && is_null( $bp->displayed_user->id ) && $bp->current_component == $bp->default_component ) {
329
+ $bp->is_directory = true;
330
+ $bp->current_component = false;
331
+
332
+ wp_enqueue_script( 'bp-core-directory-members', BP_PLUGIN_URL . '/bp-core/js/directory-members.js', array( 'jquery', 'jquery-livequery-pack' ) );
333
+ bp_core_load_template( apply_filters( 'bp_core_template_directory_members', 'directories/members/index' ) );
334
+ }
335
+ }
336
+ add_action( 'wp', 'bp_core_directory_members', 5 );
337
+
338
+ /**
339
+ * bp_core_get_user_domain()
340
+ *
341
+ * Returns the domain for the passed user:
342
+ * e.g. http://domain.com/members/andy/
343
+ *
344
+ * @package BuddyPress Core
345
+ * @global $current_user WordPress global variable containing current logged in user information
346
+ * @param user_id The ID of the user.
347
+ * @uses get_usermeta() WordPress function to get the usermeta for a user.
348
+ */
349
+ function bp_core_get_user_domain( $user_id ) {
350
+ global $bp;
351
+
352
+ if ( !$user_id ) return;
353
+
354
+ $ud = get_userdata($user_id);
355
+
356
+ return $bp->root_domain . '/' . BP_MEMBERS_SLUG . '/' . $ud->user_login . '/';
357
+ }
358
+
359
+ /**
360
+ * bp_core_get_root_domain()
361
+ *
362
+ * Returns the domain for the root blog.
363
+ * eg: http://domain.com/ OR https://domain.com
364
+ *
365
+ * @package BuddyPress Core
366
+ * @uses get_blog_option() WordPress function to fetch blog meta.
367
+ * @return $domain The domain URL for the blog.
368
+ */
369
+ function bp_core_get_root_domain() {
370
+ return get_blog_option( BP_ROOT_BLOG, 'siteurl' );
371
+ }
372
+
373
+ /**
374
+ * bp_core_get_displayed_userid()
375
+ *
376
+ * Returns the user id for the user that is currently being displayed.
377
+ * eg: http://andy.domain.com/ or http://domain.com/andy/
378
+ *
379
+ * @package BuddyPress Core
380
+ * @global $current_blog WordPress global containing information and settings for the current blog being viewed.
381
+ * @uses bp_core_get_userid_from_user_login() Returns the user id for the username passed
382
+ * @return The user id for the user that is currently being displayed, return zero if this is not a user home and just a normal blog.
383
+ */
384
+ function bp_core_get_displayed_userid( $user_login ) {
385
+ return bp_core_get_userid_from_user_login( $user_login );
386
+ }
387
+
388
+ /**
389
+ * bp_core_add_nav_item()
390
+ *
391
+ * Adds a navigation item to the main navigation array used in BuddyPress themes.
392
+ *
393
+ * @package BuddyPress Core
394
+ * @param $id A unique id for the navigation item.
395
+ * @param $name The display name for the navigation item, e.g. 'Profile' or 'Messages'
396
+ * @param $slug The slug for the navigation item, e.g. 'profile' or 'messages'
397
+ * @param $function The function to run when this sub nav item is selected.
398
+ * @param $css_id The id to give the nav item in the HTML (for css highlighting)
399
+ * @param $add_to_usernav Should this navigation item show up on the users home when not logged in? Or when another user views the user's page?
400
+ * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
401
+ */
402
+ function bp_core_add_nav_item( $name, $slug, $css_id = false, $add_to_usernav = true ) {
403
+ global $bp;
404
+
405
+ $nav_key = count($bp->bp_nav) + 1;
406
+ $user_nav_key = count($bp->bp_users_nav) + 1;
407
+
408
+ if ( !$css_id )
409
+ $css_id = $slug;
410
+
411
+ $bp->bp_nav[$nav_key] = array(
412
+ 'name' => $name,
413
+ 'link' => $bp->loggedin_user->domain . $slug,
414
+ 'css_id' => $css_id
415
+ );
416
+
417
+ if ( $add_to_usernav ) {
418
+ $bp->bp_users_nav[$user_nav_key] = array(
419
+ 'name' => $name,
420
+ 'link' => $bp->displayed_user->domain . $slug,
421
+ 'css_id' => $css_id
422
+ );
423
+ }
424
+ }
425
+
426
+ /**
427
+ * bp_core_remove_nav_item()
428
+ *
429
+ * Removes a navigation item from the navigation array used in BuddyPress themes.
430
+ *
431
+ * @package BuddyPress Core
432
+ * @param $parent_id The id of the parent navigation item.
433
+ * @param $slug The slug of the sub navigation item.
434
+ */
435
+ function bp_core_remove_nav_item( $name ) {
436
+ global $bp;
437
+
438
+ foreach( (array) $bp->bp_nav as $item_key => $item_value ) {
439
+ if ( $item_value['name'] == $name ) {
440
+ unset( $bp->bp_nav[$item_key] );
441
+ }
442
+ }
443
+
444
+ foreach( (array) $bp->bp_users_nav as $item_key => $item_value ) {
445
+ if ( $item_value['name'] == $name ) {
446
+ unset( $bp->bp_nav[$item_key] );
447
+ }
448
+ }
449
+ }
450
+
451
+ /**
452
+ * bp_core_add_subnav_item()
453
+ *
454
+ * Adds a navigation item to the sub navigation array used in BuddyPress themes.
455
+ *
456
+ * @package BuddyPress Core
457
+ * @param $parent_id The id of the parent navigation item.
458
+ * @param $slug The slug of the sub navigation item.
459
+ * @param $name The display name for the sub navigation item, e.g. 'Public' or 'Change Avatar'
460
+ * @param $link The url for the sub navigation item.
461
+ * @param $function The function to run when this sub nav item is selected.
462
+ * @param $css_id The id to give the nav item in the HTML (for css highlighting)
463
+ * @param $user_has_access Should the logged in user be able to access this page?
464
+ * @param $admin_only Should this sub nav item only be visible/accessible to the site admin?
465
+ * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
466
+ */
467
+ function bp_core_add_subnav_item( $parent_id, $slug, $name, $link, $function, $css_id = false, $user_has_access = true, $admin_only = false ) {
468
+ global $bp;
469
+
470
+ if ( $admin_only && !is_site_admin() )
471
+ return false;
472
+
473
+ if ( !$css_id )
474
+ $css_id = $slug;
475
+
476
+ $bp->bp_options_nav[$parent_id][$slug] = array(
477
+ 'name' => $name,
478
+ 'link' => $link . $slug,
479
+ 'css_id' => $css_id
480
+ );
481
+
482
+ if ( function_exists($function) && $user_has_access && $bp->current_action == $slug && $bp->current_component == $parent_id )
483
+ add_action( 'wp', $function, 3 );
484
+ }
485
+
486
+ /**
487
+ * bp_core_remove_subnav_item()
488
+ *
489
+ * Removes a navigation item from the sub navigation array used in BuddyPress themes.
490
+ *
491
+ * @package BuddyPress Core
492
+ * @param $parent_id The id of the parent navigation item.
493
+ * @param $slug The slug of the sub navigation item.
494
+ */
495
+ function bp_core_remove_subnav_item( $parent_id, $slug ) {
496
+ global $bp;
497
+
498
+ unset( $bp->bp_options_nav[$parent_id][$slug] );
499
+ }
500
+
501
+ /**
502
+ * bp_core_reset_subnav_items()
503
+ *
504
+ * Clear the subnav items for a specific nav item.
505
+ *
506
+ * @package BuddyPress Core
507
+ * @param $parent_id The id of the parent navigation item.
508
+ * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
509
+ */
510
+ function bp_core_reset_subnav_items($parent_id) {
511
+ global $bp;
512
+
513
+ unset($bp->bp_options_nav[$parent_id]);
514
+ }
515
+
516
+ /**
517
+ * bp_core_add_nav_default()
518
+ *
519
+ * Set a default action for a nav item, when a sub nav item has not yet been selected.
520
+ *
521
+ * @package BuddyPress Core
522
+ * @param $parent_id The id of the parent navigation item.
523
+ * @param $function The function to run when this sub nav item is selected.
524
+ * @param $slug The slug of the sub nav item to highlight.
525
+ * @uses is_site_admin() returns true if the current user is a site admin, false if not
526
+ * @uses bp_is_home() Returns true if the current user being viewed is equal the logged in user
527
+ * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
528
+ */
529
+ function bp_core_add_nav_default( $parent_id, $function, $slug = false, $user_has_access = true, $admin_only = false ) {
530
+ global $bp;
531
+
532
+ if ( !$user_has_access && !bp_is_home() )
533
+ return false;
534
+
535
+ if ( $admin_only && !is_site_admin() )
536
+ return false;
537
+
538
+ if ( $bp->current_component == $parent_id && !$bp->current_action ) {
539
+ if ( function_exists($function) ) {
540
+ add_action( 'wp', $function, 3 );
541
+ }
542
+
543
+ if ( $slug )
544
+ $bp->current_action = $slug;
545
+ }
546
+ }
547
+
548
+ /**
549
+ * bp_core_load_template()
550
+ *
551
+ * Uses the bp_catch_uri function to load a specific template file with fallback support.
552
+ *
553
+ * Example:
554
+ * bp_core_load_template( 'profile/edit-profile' );
555
+ * Loads:
556
+ * wp-content/member-themes/[activated_theme]/profile/edit-profile.php
557
+ *
558
+ * @package BuddyPress Core
559
+ * @param $username str Username to check.
560
+ * @global $wpdb WordPress DB access object.
561
+ * @return false on no match
562
+ * @return int the user ID of the matched user.
563
+ */
564
+ function bp_core_load_template( $template, $skip_blog_check = false ) {
565
+ return bp_catch_uri( $template, $skip_blog_check );
566
+ }
567
+
568
+ /**
569
+ * bp_core_add_root_component()
570
+ *
571
+ * Adds a component to the $bp->root_components global.
572
+ * Any component that runs in the "root" of an install should be added.
573
+ * The "root" as in, it can or always runs outside of the /members/username/ path.
574
+ *
575
+ * Example of a root component:
576
+ * Groups: http://domain.com/groups/group-name
577
+ * http://community.domain.com/groups/group-name
578
+ * http://domain.com/wpmu/groups/group-name
579
+ *
580
+ * Example of a component that is NOT a root component:
581
+ * Friends: http://domain.com/members/andy/friends
582
+ * http://community.domain.com/members/andy/friends
583
+ * http://domain.com/wpmu/members/andy/friends
584
+ *
585
+ * @package BuddyPress Core
586
+ * @param $slug str The slug of the component
587
+ * @global $bp BuddyPress global settings
588
+ */
589
+ function bp_core_add_root_component( $slug ) {
590
+ global $bp;
591
+
592
+ $bp->root_components[] = $slug;
593
+ }
594
+
595
+ /**
596
+ * bp_core_get_random_member()
597
+ *
598
+ * Returns the user_id for a user based on their username.
599
+ *
600
+ * @package BuddyPress Core
601
+ * @param $username str Username to check.
602
+ * @global $wpdb WordPress DB access object.
603
+ * @return false on no match
604
+ * @return int the user ID of the matched user.
605
+ */
606
+ function bp_core_get_random_member() {
607
+ global $bp, $wpdb;
608
+
609
+ if ( $bp->current_component == BP_MEMBERS_SLUG && isset( $_GET['random'] ) ) {
610
+ $user = BP_Core_User::get_random_users(1);
611
+
612
+ $ud = get_userdata( $user['users'][0]->user_id );
613
+ bp_core_redirect( $bp->root_domain . '/' . BP_MEMBERS_SLUG . '/' . $ud->user_login );
614
+ }
615
+ }
616
+ add_action( 'wp', 'bp_core_get_random_member', 6 );
617
+
618
+ /**
619
+ * bp_core_get_userid()
620
+ *
621
+ * Returns the user_id for a user based on their username.
622
+ *
623
+ * @package BuddyPress Core
624
+ * @param $username str Username to check.
625
+ * @global $wpdb WordPress DB access object.
626
+ * @return false on no match
627
+ * @return int the user ID of the matched user.
628
+ */
629
+ function bp_core_get_userid( $username ) {
630
+ global $wpdb;
631
+
632
+ $sql = $wpdb->prepare( "SELECT ID FROM " . CUSTOM_USER_TABLE . " WHERE user_login = %s", $username );
633
+ return $wpdb->get_var($sql);
634
+ }
635
+
636
+ /**
637
+ * bp_core_get_userid_from_user_login()
638
+ *
639
+ * Returns the user_id from a user login
640
+ * @package BuddyPress Core
641
+ * @param $path str Path to check.
642
+ * @global $wpdb WordPress DB access object.
643
+ * @return false on no match
644
+ * @return int the user ID of the matched user.
645
+ */
646
+ function bp_core_get_userid_from_user_login( $user_login ) {
647
+ global $wpdb;
648
+
649
+ if ( !empty( $user_login ) )
650
+ return $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . CUSTOM_USER_TABLE . " WHERE user_login = %s", $user_login ) );
651
+ }
652
+
653
+ /**
654
+ * bp_core_get_username()
655
+ *
656
+ * Returns the username for a user based on their user id.
657
+ *
658
+ * @package BuddyPress Core
659
+ * @param $uid int User ID to check.
660
+ * @global $userdata WordPress user data for the current logged in user.
661
+ * @uses get_userdata() WordPress function to fetch the userdata for a user ID
662
+ * @return false on no match
663
+ * @return str the username of the matched user.
664
+ */
665
+ function bp_core_get_username( $uid ) {
666
+ global $userdata;
667
+
668
+ if ( $uid == $userdata->ID )
669
+ return __( 'You', 'buddypress' );
670
+
671
+ if ( !$ud = get_userdata($uid) )
672
+ return false;
673
+
674
+ return $ud->user_login;
675
+ }
676
+
677
+ /**
678
+ * bp_core_get_userurl()
679
+ *
680
+ * Returns the URL with no HTML markup for a user based on their user id.
681
+ *
682
+ * @package BuddyPress Core
683
+ * @param $uid int User ID to check.
684
+ * @global $userdata WordPress user data for the current logged in user.
685
+ * @uses get_userdata() WordPress function to fetch the userdata for a user ID
686
+ * @return false on no match
687
+ * @return str The URL for the user with no HTML formatting.
688
+ */
689
+ function bp_core_get_userurl( $uid ) {
690
+ global $bp;
691
+
692
+ if ( !is_numeric($uid) )
693
+ return false;
694
+
695
+ $ud = get_userdata($uid);
696
+
697
+ return $bp->root_domain . '/' . BP_MEMBERS_SLUG . '/' . $ud->user_login . '/';
698
+ }
699
+
700
+ /**
701
+ * bp_core_get_user_email()
702
+ *
703
+ * Returns the email address for the user based on user ID
704
+ *
705
+ * @package BuddyPress Core
706
+ * @param $uid int User ID to check.
707
+ * @uses get_userdata() WordPress function to fetch the userdata for a user ID
708
+ * @return false on no match
709
+ * @return str The email for the matched user.
710
+ */
711
+ function bp_core_get_user_email( $uid ) {
712
+ $ud = get_userdata($uid);
713
+ return $ud->user_email;
714
+ }
715
+
716
+ /**
717
+ * bp_core_get_userlink()
718
+ *
719
+ * Returns a HTML formatted link for a user with the user's full name as the link text.
720
+ * eg: <a href="http://andy.domain.com/">Andy Peatling</a>
721
+ * Optional parameters will return just the name, or just the URL, or disable "You" text when
722
+ * user matches the logged in user.
723
+ *
724
+ * [NOTES: This function needs to be cleaned up or split into separate functions]
725
+ *
726
+ * @package BuddyPress Core
727
+ * @param $uid int User ID to check.
728
+ * @param $no_anchor bool Disable URL and HTML and just return full name. Default false.
729
+ * @param $just_link bool Disable full name and HTML and just return the URL text. Default false.
730
+ * @param $no_you bool Disable replacing full name with "You" when logged in user is equal to the current user. Default false.
731
+ * @global $userdata WordPress user data for the current logged in user.
732
+ * @uses get_userdata() WordPress function to fetch the userdata for a user ID
733
+ * @uses bp_fetch_user_fullname() Returns the full name for a user based on user ID.
734
+ * @uses bp_core_get_userurl() Returns the URL for the user with no anchor tag based on user ID
735
+ * @return false on no match
736
+ * @return str The link text based on passed parameters.
737
+ */
738
+ function bp_core_get_userlink( $user_id, $no_anchor = false, $just_link = false, $deprecated = false, $with_s = false ) {
739
+ global $userdata;
740
+
741
+ $ud = get_userdata($user_id);
742
+
743
+ if ( !$ud )
744
+ return false;
745
+
746
+ if ( function_exists('bp_fetch_user_fullname') ) {
747
+ $display_name = bp_fetch_user_fullname( $user_id, false );
748
+
749
+ if ( $with_s )
750
+ $display_name = sprintf( __( "%s's", 'buddypress' ), $display_name );
751
+
752
+ } else {
753
+ $display_name = $ud->display_name;
754
+ }
755
+
756
+ // if ( $user_id == $userdata->ID && !$no_you )
757
+ // $display_name = 'You';
758
+
759
+ if ( $no_anchor )
760
+ return $display_name;
761
+
762
+ if ( !$url = bp_core_get_userurl($user_id) )
763
+ return false;
764
+
765
+ if ( $just_link )
766
+ return $url;
767
+
768
+ return '<a href="' . $url . '">' . $display_name . '</a>';
769
+ }
770
+
771
+ /**
772
+ * bp_core_global_user_fullname()
773
+ *
774
+ * Returns the full name for the user, or the display name if Xprofile component is not installed.
775
+ *
776
+ * @package BuddyPress Core
777
+ * @param $user_id string The user ID of the user.
778
+ * @param
779
+ * @uses bp_fetch_user_fullname() Returns the full name for a user based on user ID.
780
+ * @uses get_userdata() Fetches a new userdata object for the user ID passed.
781
+ * @return Either the users full name, or the display name.
782
+ */
783
+ function bp_core_global_user_fullname( $user_id ) {
784
+ if ( function_exists('bp_fetch_user_fullname') ) {
785
+ return bp_fetch_user_fullname( $user_id, false );
786
+ } else {
787
+ $ud = get_userdata($user_id);
788
+ return $current_user->display_name;
789
+ }
790
+ }
791
+
792
+ /**
793
+ * bp_core_get_userlink_by_email()
794
+ *
795
+ * Returns the user link for the user based on user email address
796
+ *
797
+ * @package BuddyPress Core
798
+ * @param $email str The email address for the user.
799
+ * @uses bp_core_get_userlink() BuddyPress function to get a userlink by user ID.
800
+ * @uses get_user_by_email() WordPress function to get userdata via an email address
801
+ * @return str The link to the users home base. False on no match.
802
+ */
803
+ function bp_core_get_userlink_by_email( $email ) {
804
+ $user = get_user_by_email( $email );
805
+ return bp_core_get_userlink( $user->ID, false, false, true );
806
+ }
807
+
808
+ /**
809
+ * bp_core_get_userlink_by_username()
810
+ *
811
+ * Returns the user link for the user based on user's username
812
+ *
813
+ * @package BuddyPress Core
814
+ * @param $username str The username for the user.
815
+ * @uses bp_core_get_userlink() BuddyPress function to get a userlink by user ID.
816
+ * @return str The link to the users home base. False on no match.
817
+ */
818
+ function bp_core_get_userlink_by_username( $username ) {
819
+ global $wpdb;
820
+
821
+ $user_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . CUSTOM_USER_TABLE . " WHERE user_login = %s", $username ) );
822
+ return bp_core_get_userlink( $user_id, false, false, true );
823
+ }
824
+
825
+ /**
826
+ * bp_core_get_user_email()
827
+ *
828
+ * Returns the email address for the user based on user ID
829
+ *
830
+ * @package BuddyPress Core
831
+ * @param $uid int User ID to check.
832
+ * @uses get_userdata() WordPress function to fetch the userdata for a user ID
833
+ * @return false on no match
834
+ * @return str The email for the matched user.
835
+ */
836
+ function bp_core_format_time( $time, $just_date = false ) {
837
+ $date = date( "F j, Y ", $time );
838
+
839
+ if ( !$just_date ) {
840
+ $date .= __('at', 'buddypress') . date( ' g:iA', $time );
841
+ }
842
+
843
+ return $date;
844
+ }
845
+
846
+ function bp_core_add_message( $message, $type = false ) {
847
+ if ( !$type )
848
+ $type = 'success';
849
+
850
+ $_SESSION['message'] = $message;
851
+ $_SESSION['message_type'] = $type;
852
+ }
853
+
854
+ /**
855
+ * bp_core_render_notice()
856
+ *
857
+ * Renders a feedback notice (either error or success message) to the theme template.
858
+ * The hook action 'template_notices' is used to call this function, it is not called directly.
859
+ *
860
+ * @package BuddyPress Core
861
+ * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
862
+ */
863
+ function bp_core_render_notice() {
864
+ if ( $_SESSION['message'] ) {
865
+ $type = ( 'success' == $_SESSION['message_type'] ) ? 'updated' : 'error';
866
+ ?>
867
+ <div id="message" class="<?php echo $type; ?>">
868
+ <p><?php echo $_SESSION['message']; ?></p>
869
+ </div>
870
+ <?php
871
+ unset( $_SESSION['message'] );
872
+ unset( $_SESSION['message_type'] );
873
+
874
+ do_action( 'bp_core_render_notice' );
875
+ }
876
+ }
877
+
878
+ /**
879
+ * bp_core_time_since()
880
+ *
881
+ * Based on function created by Dunstan Orchard - http://1976design.com
882
+ *
883
+ * This function will return an English representation of the time elapsed
884
+ * since a given date.
885
+ * eg: 2 hours and 50 minutes
886
+ * eg: 4 days
887
+ * eg: 4 weeks and 6 days
888
+ *
889
+ * @package BuddyPress Core
890
+ * @param $older_date int Unix timestamp of date you want to calculate the time since for
891
+ * @param $newer_date int Unix timestamp of date to compare older date to. Default false (current time).
892
+ * @return str The time since.
893
+ */
894
+ function bp_core_time_since( $older_date, $newer_date = false ) {
895
+ // array of time period chunks
896
+
897
+ $chunks = array(
898
+ array( 60 * 60 * 24 * 365 , __( 'year', 'buddypress' ), __( 'years', 'buddypress' ) ),
899
+ array( 60 * 60 * 24 * 30 , __( 'month', 'buddypress' ), __( 'months', 'buddypress' ) ),
900
+ array( 60 * 60 * 24 * 7, __( 'week', 'buddypress' ), __( 'weeks', 'buddypress' ) ),
901
+ array( 60 * 60 * 24 , __( 'day', 'buddypress' ), __( 'days', 'buddypress' ) ),
902
+ array( 60 * 60 , __( 'hour', 'buddypress' ), __( 'hours', 'buddypress' ) ),
903
+ array( 60 , __( 'minute', 'buddypress' ), __( 'minutes', 'buddypress' ) ),
904
+ array( 1, __( 'second', 'buddypress' ), __( 'seconds', 'buddypress' ) )
905
+ );
906
+
907
+ /* $newer_date will equal false if we want to know the time elapsed between a date and the current time */
908
+ /* $newer_date will have a value if we want to work out time elapsed between two known dates */
909
+ $newer_date = ( !$newer_date ) ? ( time() + ( 60*60*0 ) ) : $newer_date;
910
+
911
+ /* Difference in seconds */
912
+ $since = $newer_date - $older_date;
913
+
914
+ if ( 0 > $since )
915
+ return __( '[Adjust Time Zone]', 'buddypress' );
916
+
917
+ /**
918
+ * We only want to output two chunks of time here, eg:
919
+ * x years, xx months
920
+ * x days, xx hours
921
+ * so there's only two bits of calculation below:
922
+ */
923
+
924
+ /* Step one: the first chunk */
925
+ for ( $i = 0, $j = count($chunks); $i < $j; $i++) {
926
+ $seconds = $chunks[$i][0];
927
+
928
+ /* Finding the biggest chunk (if the chunk fits, break) */
929
+ if ( ( $count = floor($since / $seconds) ) != 0 )
930
+ break;
931
+ }
932
+
933
+ /* Set output var */
934
+ $output = ( 1 == $count ) ? '1 '. $chunks[$i][1] : $count . ' ' . $chunks[$i][2];
935
+
936
+ /* Step two: the second chunk */
937
+ if ( $i + 2 < $j ) {
938
+ $seconds2 = $chunks[$i + 1][0];
939
+ $name2 = $chunks[$i + 1][1];
940
+
941
+ //if ( $chunks[$i + 1][1] == __( 'second', 'buddypress' ) ) return $output;
942
+
943
+ if ( ( $count2 = floor( ( $since - ( $seconds * $count ) ) / $seconds2 ) ) != 0 ) {
944
+ /* Add to output var */
945
+ $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];
946
+ }
947
+ }
948
+
949
+ if ( !(int)trim($output) )
950
+ $output = '0 ' . __( 'seconds', 'buddypress' );
951
+
952
+ return $output;
953
+ }
954
+
955
+ /**
956
+ * bp_core_record_activity()
957
+ *
958
+ * Record user activity to the database. Many functions use a "last active" feature to
959
+ * show the length of time since the user was last active.
960
+ * This function will update that time as a usermeta setting for the user every 5 minutes.
961
+ *
962
+ * @package BuddyPress Core
963
+ * @global $userdata WordPress user data for the current logged in user.
964
+ * @uses update_usermeta() WordPress function to update user metadata in the usermeta table.
965
+ */
966
+ function bp_core_record_activity() {
967
+ global $bp;
968
+
969
+ if ( !is_user_logged_in() )
970
+ return false;
971
+
972
+ $activity = get_usermeta( $bp->loggedin_user->id, 'last_activity' );
973
+
974
+ if ( '' == $activity || time() >= strtotime( '+5 minutes', $activity ) )
975
+ update_usermeta( $bp->loggedin_user->id, 'last_activity', time() );
976
+ }
977
+ add_action( 'wp_head', 'bp_core_record_activity' );
978
+
979
+
980
+ /**
981
+ * bp_core_get_last_activity()
982
+ *
983
+ * Formats last activity based on time since date given.
984
+ *
985
+ * @package BuddyPress Core
986
+ * @param last_activity_date The date of last activity.
987
+ * @param $before The text to prepend to the activity time since figure.
988
+ * @param $after The text to append to the activity time since figure.
989
+ * @uses bp_core_time_since() This function will return an English representation of the time elapsed.
990
+ */
991
+ function bp_core_get_last_activity( $last_activity_date, $string ) {
992
+ if ( !$last_activity_date || empty( $last_activity_date ) ) {
993
+ $last_active = __( 'not recently active', 'buddypress' );
994
+ } else {
995
+ if ( strstr( $last_activity_date, '-' ) ) {
996
+ $last_active = bp_core_time_since( strtotime( $last_activity_date ) );
997
+ } else {
998
+ $last_active = bp_core_time_since( $last_activity_date );
999
+ }
1000
+
1001
+ $last_active = sprintf( $string, $last_active );
1002
+ }
1003
+
1004
+ return $last_active;
1005
+ }
1006
+
1007
+ /**
1008
+ * bp_core_get_all_posts_for_user()
1009
+ *
1010
+ * Fetch every post that is authored by the given user for the current blog.
1011
+ *
1012
+ * @package BuddyPress Core
1013
+ * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
1014
+ * @global $wpdb WordPress user data for the current logged in user.
1015
+ * @return array of post ids.
1016
+ */
1017
+ function bp_core_get_all_posts_for_user( $user_id = null ) {
1018
+ global $bp, $wpdb;
1019
+
1020
+ if ( !$user_id )
1021
+ $user_id = $bp->displayed_user->id;
1022
+
1023
+ 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 ) );
1024
+ }
1025
+
1026
+ /**
1027
+ * bp_core_get_site_path()
1028
+ *
1029
+ * Get the path of of the current site.
1030
+ *
1031
+ * @package BuddyPress Core
1032
+ * @global $comment WordPress comment global for the current comment.
1033
+ * @uses bp_core_get_userlink_by_email() Fetches a userlink via email address.
1034
+ */
1035
+ function bp_core_get_site_path() {
1036
+ global $current_site;
1037
+
1038
+ return $current_site->path;
1039
+ }
1040
+
1041
+ function bp_core_redirect( $location, $status = 302 ) {
1042
+ global $bp_no_status_set;
1043
+
1044
+ // Make sure we don't call status_header() in bp_core_do_catch_uri()
1045
+ // as this conflicts with wp_redirect()
1046
+ $bp_no_status_set = true;
1047
+
1048
+ wp_redirect( $location, $status );
1049
+ die;
1050
+ }
1051
+
1052
+ /**
1053
+ * bp_core_sort_nav_items()
1054
+ *
1055
+ * Reorder the core component navigation array items into the desired order.
1056
+ * This is done this way because we cannot assume that any one component is present.
1057
+ *
1058
+ * @package BuddyPress Core
1059
+ * @param $nav_array the navigation array variable
1060
+ * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
1061
+ * @uses ksort() Sort an array by key
1062
+ * @return $new_nav array reordered navigation array
1063
+ */
1064
+ function bp_core_sort_nav_items( $nav_array ) {
1065
+ global $bp;
1066
+
1067
+ foreach ( (array)$nav_array as $key => $value ) {
1068
+ switch ( $nav_array[$key]['css_id'] ) {
1069
+ case $bp->activity->slug:
1070
+ $new_nav[0] = $nav_array[$key];
1071
+ unset($nav_array[$key]);
1072
+ break;
1073
+ case $bp->profile->slug:
1074
+ $new_nav[1] = $nav_array[$key];
1075
+ unset($nav_array[$key]);
1076
+ break;
1077
+ case 'profile': // For profiles without bp-xprofile installed
1078
+ $new_nav[1] = $nav_array[$key];
1079
+ unset($nav_array[$key]);
1080
+ break;
1081
+ case $bp->blogs->slug:
1082
+ $new_nav[2] = $nav_array[$key];
1083
+ unset($nav_array[$key]);
1084
+ break;
1085
+ case $bp->wire->slug:
1086
+ $new_nav[3] = $nav_array[$key];
1087
+ unset($nav_array[$key]);
1088
+ break;
1089
+ case $bp->messages->slug:
1090
+ $new_nav[4] = $nav_array[$key];
1091
+ unset($nav_array[$key]);
1092
+ break;
1093
+ case $bp->friends->slug:
1094
+ $new_nav[5] = $nav_array[$key];
1095
+ unset($nav_array[$key]);
1096
+ break;
1097
+ case $bp->groups->slug:
1098
+ $new_nav[6] = $nav_array[$key];
1099
+ unset($nav_array[$key]);
1100
+ break;
1101
+ }
1102
+ }
1103
+
1104
+ if ( is_array( $new_nav ) ) {
1105
+ /* Sort the navigation array by key */
1106
+ ksort($new_nav);
1107
+
1108
+ /* Merge the remaining nav items, so they can be appended on the end */
1109
+ $new_nav = array_merge( $new_nav, $nav_array );
1110
+ }
1111
+
1112
+ return $new_nav;
1113
+ }
1114
+
1115
+ /**
1116
+ * bp_core_referrer()
1117
+ *
1118
+ * Returns the referrer URL without the http(s)://
1119
+ *
1120
+ * @package BuddyPress Core
1121
+ * @return The referrer URL
1122
+ */
1123
+ function bp_core_referrer() {
1124
+ $referer = explode( '/', wp_get_referer() );
1125
+ unset( $referer[0], $referer[1], $referer[2] );
1126
+ return implode( '/', $referer );
1127
+ }
1128
+
1129
+ function bp_core_get_member_themes() {
1130
+ add_filter( 'theme_root', 'bp_core_set_member_theme_root' );
1131
+ $themes = get_themes();
1132
+
1133
+ if ( $themes ) {
1134
+ foreach ( $themes as $name => $values ) {
1135
+ if ( $name == 'BuddyPress Default Home Theme' )
1136
+ continue;
1137
+
1138
+ $member_themes[] = array(
1139
+ 'name' => $name,
1140
+ 'template' => $values['Template'],
1141
+ 'version' => $values['Version']
1142
+ );
1143
+ }
1144
+ }
1145
+
1146
+ return $member_themes;
1147
+ }
1148
+
1149
+ function bp_core_set_member_theme_root() {
1150
+ return apply_filters( 'bp_core_set_member_theme_root', WP_CONTENT_DIR . "/bp-themes" );
1151
+ }
1152
+
1153
+ function bp_core_set_member_theme_root_uri() {
1154
+ return apply_filters( 'bp_core_set_member_theme_root_uri', WP_CONTENT_URL . '/bp-themes' );
1155
+ }
1156
+
1157
+ function bp_core_add_illegal_names() {
1158
+ global $bp;
1159
+
1160
+ $current = maybe_unserialize( get_site_option( 'illegal_names' ) );
1161
+ $bp_illegal_names = $bp->root_components;
1162
+
1163
+ if ( is_array( $current ) ) {
1164
+ foreach( $bp_illegal_names as $bp_illegal_name ) {
1165
+ if ( !in_array( $bp_illegal_name, $current ) )
1166
+ $current[] = $bp_illegal_name;
1167
+ }
1168
+ $new = $current;
1169
+ } else {
1170
+ $bp_illegal_names[] = $current;
1171
+ $new = $bp_illegal_names;
1172
+ }
1173
+
1174
+ update_site_option( 'illegal_names', $new );
1175
+ }
1176
+
1177
+
1178
+ /**
1179
+ * bp_core_email_from_name_filter()
1180
+ *
1181
+ * Sets the "From" name in emails sent to the name of the site and not "WordPress"
1182
+ *
1183
+ * @package BuddyPress Core
1184
+ * @uses get_blog_option() fetches the value for a meta_key in the wp_X_options table
1185
+ * @return The blog name for the root blog
1186
+ */
1187
+ function bp_core_email_from_name_filter() {
1188
+ return get_blog_option( 1, 'blogname' );
1189
+ }
1190
+ add_filter( 'wp_mail_from_name', 'bp_core_email_from_name_filter' );
1191
+
1192
+ /**
1193
+ * bp_core_email_from_name_filter()
1194
+ *
1195
+ * Sets the "From" address in emails sent
1196
+ *
1197
+ * @package BuddyPress Core
1198
+ * @global $current_site Object containing current site metadata
1199
+ * @return noreply@sitedomain email address
1200
+ */
1201
+ function bp_core_email_from_address_filter() {
1202
+ global $current_site;
1203
+ return 'noreply@' . $current_site->domain;
1204
+ }
1205
+ add_filter( 'wp_mail_from', 'bp_core_email_from_address_filter' );
1206
+
1207
+
1208
+ function bp_core_delete_account() {
1209
+ global $bp;
1210
+
1211
+ // Be careful with this function!
1212
+
1213
+ require_once( ABSPATH . '/wp-admin/includes/mu.php' );
1214
+ require_once( ABSPATH . '/wp-admin/includes/user.php' );
1215
+
1216
+ return wpmu_delete_user( $bp->loggedin_user->id );
1217
+ }
1218
+
1219
+ function bp_core_search_site() {
1220
+ global $bp;
1221
+
1222
+ if ( $bp->current_component == BP_SEARCH_SLUG ) {
1223
+ $search_terms = $_POST['search-terms'];
1224
+ $search_which = $_POST['search-which'];
1225
+
1226
+ switch ( $search_which ) {
1227
+ case 'members': default:
1228
+ $search = BP_MEMBERS_SLUG;
1229
+ break;
1230
+ case 'groups':
1231
+ $search = BP_GROUPS_SLUG;
1232
+ break;
1233
+ case 'blogs':
1234
+ $search = BP_BLOGS_SLUG;
1235
+ break;
1236
+ }
1237
+
1238
+ $search_url = apply_filters( 'bp_core_search_site', site_url( $search . '/?s=' . urlencode($search_terms) ), $search_terms );
1239
+
1240
+ bp_core_redirect( $search_url );
1241
+ }
1242
+ }
1243
+ add_action( 'wp', 'bp_core_search_site', 5 );
1244
+
1245
+ /**
1246
+ * bp_core_ucfirst()
1247
+ *
1248
+ * Localization save ucfirst() support.
1249
+ *
1250
+ * @package BuddyPress Core
1251
+ */
1252
+ function bp_core_ucfirst( $str ) {
1253
+ if ( function_exists( 'mb_strtoupper' ) && function_exists( 'mb_substr' ) ) {
1254
+ $fc = mb_strtoupper( mb_substr( $str, 0, 1 ) );
1255
+ return $fc.mb_substr( $str, 1 );
1256
+ } else {
1257
+ return ucfirst( $str );
1258
+ }
1259
+ }
1260
+
1261
+ /**
1262
+ * bp_core_strip_username_spaces()
1263
+ *
1264
+ * Strips spaces from usernames that are created using add_user() and wp_insert_user()
1265
+ *
1266
+ * @package BuddyPress Core
1267
+ */
1268
+ function bp_core_strip_username_spaces( $username ) {
1269
+ return str_replace( ' ', '-', $username );
1270
+ }
1271
+ add_action( 'pre_user_login', 'bp_core_strip_username_spaces' );
1272
+
1273
+ /**
1274
+ * bp_core_clear_cache()
1275
+ * REQUIRES WP-SUPER-CACHE
1276
+ *
1277
+ * When wp-super-cache is installed this function will clear cached pages
1278
+ * so that success/error messages are not cached, or time sensitive content.
1279
+ *
1280
+ * @package BuddyPress Core
1281
+ */
1282
+ function bp_core_clear_cache() {
1283
+ global $cache_path, $cache_filename;
1284
+
1285
+ if ( function_exists( 'prune_super_cache' ) ) {
1286
+ do_action( 'bp_core_clear_cache' );
1287
+
1288
+ return prune_super_cache( $cache_path, true );
1289
+ }
1290
+ }
1291
+
1292
+ function bp_core_print_version_numbers() {
1293
+ global $bp;
1294
+
1295
+ foreach ( $bp->version_numbers as $name => $version ) {
1296
+ echo ucwords($name) . ': <b>' . $version . '</b> / ';
1297
+ }
1298
+ }
1299
+
1300
+ function bp_core_print_generation_time() {
1301
+ global $wpdb;
1302
+ ?>
1303
+ <!-- Generated in <?php timer_stop(1); ?> seconds. -->
1304
+ <?php
1305
+ }
1306
+ add_action( 'wp_footer', 'bp_core_print_generation_time' );
1307
+
1308
+
1309
+ /**
1310
+ * bp_core_remove_data()
1311
+ *
1312
+ * Deletes usermeta for the user when the user is deleted.
1313
+ *
1314
+ * @package BuddyPress Core
1315
+ * @param $user_id The user id for the user to delete usermeta for
1316
+ * @uses delete_usermeta() deletes a row from the wp_usermeta table based on meta_key
1317
+ */
1318
+ function bp_core_remove_data( $user_id ) {
1319
+ /* Remove usermeta */
1320
+ delete_usermeta( $user_id, 'last_activity' );
1321
+
1322
+ /* Flush the cache to remove the user from all cached objects */
1323
+ wp_cache_flush();
1324
+ }
1325
+ add_action( 'wpmu_delete_user', 'bp_core_remove_data', 1 );
1326
+ add_action( 'delete_user', 'bp_core_remove_data', 1 );
1327
+
1328
+ function bp_core_clear_user_object_cache( $user_id ) {
1329
+ wp_cache_delete( 'bp_user_' . $user_id, 'bp' );
1330
+ wp_cache_delete( 'bp_core_avatar_v1_u' . $user_id, 'bp' );
1331
+ wp_cache_delete( 'bp_core_avatar_v2_u' . $user_id, 'bp' );
1332
+ wp_cache_delete( 'online_users' );
1333
+ wp_cache_delete( 'newest_users' );
1334
+ }
1335
+
1336
+ // List actions to clear object caches on
1337
+ add_action( 'bp_core_delete_avatar', 'bp_core_clear_user_object_cache' );
1338
+ add_action( 'bp_core_avatar_save', 'bp_core_clear_user_object_cache' );
1339
+
1340
+ // List actions to clear super cached pages on, if super cache is installed
1341
+ add_action( 'wp_login', 'bp_core_clear_cache' );
1342
+ add_action( 'bp_core_delete_avatar', 'bp_core_clear_cache' );
1343
+ add_action( 'bp_core_avatar_save', 'bp_core_clear_cache' );
1344
+ add_action( 'bp_core_render_notice', 'bp_core_clear_cache' );
1345
+
1346
+ // Remove the catch non existent blogs hook so WPMU doesn't think BuddyPress pages are non existing blogs
1347
+ remove_action( 'plugins_loaded', 'catch_nonexistant_blogs' );
1348
+
1349
+ ?>
bp-core/bp-core-activation.php ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function bp_core_activation_set_headers() {
4
+ global $wp_object_cache;
5
+
6
+ define( "WP_INSTALLING", true );
7
+
8
+ require_once( ABSPATH . WPINC . '/registration.php');
9
+
10
+ if( is_object( $wp_object_cache ) )
11
+ $wp_object_cache->cache_enabled = false;
12
+
13
+ do_action("activate_header");
14
+ }
15
+
16
+ function bp_core_activation_do_activation() {
17
+ global $current_site, $blog_id, $user_id; ?>
18
+
19
+ <?php if ( empty( $_GET['key'] ) && empty( $_POST['key'] ) ) { ?>
20
+
21
+ <h3><?php _e( 'Activation Key Required', 'buddypress' ) ?></h3>
22
+
23
+ <p id="intro-text"><?php _e( 'This is the key contained in the email you were sent after registering for this site.', 'buddypress' ) ?></p>
24
+
25
+ <div class="field-box">
26
+ <form name="activateform" id="activateform" method="post" action="<?php echo 'http://' . $current_site->domain . $current_site->path ?>wp-activate.php">
27
+ <p>
28
+ <label for="key"><?php _e('Activation Key:', 'buddypress' ) ?></label>
29
+ <br /><input type="text" name="key" id="key" value="" size="50" />
30
+ </p>
31
+ <p class="submit">
32
+ <input id="submit" type="submit" name="Submit" class="submit" value="<?php _e('Activate &raquo;', 'buddypress' ) ?>"/>
33
+ </p>
34
+ </form>
35
+ </div>
36
+
37
+ <?php } else {
38
+
39
+ $key = !empty($_GET['key']) ? $_GET['key'] : $_POST['key'];
40
+ $result = wpmu_activate_signup($key);
41
+
42
+ if ( is_wp_error($result) ) {
43
+ if ( 'already_active' == $result->get_error_code() || 'blog_taken' == $result->get_error_code() ) {
44
+ $signup = $result->get_error_data();
45
+ ?>
46
+
47
+ <h3><?php _e('Your account is now active!', 'buddypress' ); ?></h3>
48
+
49
+ <?php
50
+ _e( 'Your account has already been activated. You can now log in with the account details that were emailed to you.' );
51
+
52
+ } else {
53
+ ?>
54
+ <h2><?php _e('An error occurred during the activation', 'buddypress' ); ?></h2>
55
+ <?php
56
+ echo '<p>'.$result->get_error_message().'</p>';
57
+ }
58
+ } else {
59
+ extract($result);
60
+
61
+ $user = new WP_User( (int) $user_id);
62
+
63
+ ?>
64
+
65
+ <h3><?php _e('Your account is now active!', 'buddypress' ); ?></h3>
66
+
67
+ <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>
68
+
69
+ <div class="field-box" id="signup-welcome">
70
+ <p><span class="label"><?php _e( 'Username:', 'buddypress' ); ?></span> <?php echo $user->user_login ?></p>
71
+ <p><span class="label"><?php _e( 'Password:', 'buddypress' ); ?></span> <?php echo $password; ?></p>
72
+ </div>
73
+
74
+ <?php
75
+ do_action( 'bp_activation_extras', $user_id, $meta );
76
+ }
77
+ }
78
+ }
79
+
80
+ // Notify user of signup success.
81
+ function bp_core_activation_signup_blog_notification( $domain, $path, $title, $user, $user_email, $key, $meta ) {
82
+ global $current_site;
83
+
84
+ // Send email with activation link.
85
+ if ( 'no' == constant( "VHOST" ) ) {
86
+ $activate_url = bp_activation_page( false ) . "?key=$key";
87
+ } else {
88
+ $activate_url = bp_activation_page( false ) ."?key=$key";
89
+ }
90
+
91
+ $activate_url = clean_url($activate_url);
92
+ $admin_email = get_site_option( "admin_email" );
93
+
94
+ if ( empty( $admin_email ) )
95
+ $admin_email = 'support@' . $_SERVER['SERVER_NAME'];
96
+
97
+ $from_name = ( '' == get_site_option( "site_name" ) ) ? 'WordPress' : wp_specialchars( get_site_option( "site_name" ) );
98
+ $message_headers = "MIME-Version: 1.0\n" . "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
99
+ $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}" ) );
100
+ $subject = '[' . $from_name . '] ' . sprintf(__('Activate %s', 'buddypress' ), clean_url('http://' . $domain . $path));
101
+
102
+ wp_mail($user_email, $subject, $message, $message_headers);
103
+
104
+ // Return false to stop the original WPMU function from continuing
105
+ return false;
106
+ }
107
+ add_filter( 'wpmu_signup_blog_notification', 'bp_core_activation_signup_blog_notification', 1, 7 );
108
+
109
+ function bp_core_activation_signup_user_notification( $user, $user_email, $key, $meta ) {
110
+ global $current_site;
111
+
112
+ // Send email with activation link.
113
+ $admin_email = get_site_option( "admin_email" );
114
+
115
+ if ( empty( $admin_email ) )
116
+ $admin_email = 'support@' . $_SERVER['SERVER_NAME'];
117
+
118
+ $from_name = ( '' == get_site_option( "site_name" ) ) ? 'WordPress' : wp_specialchars( get_site_option( "site_name" ) );
119
+ $message_headers = "MIME-Version: 1.0\n" . "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
120
+ $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" ) ) );
121
+ $subject = apply_filters( 'wpmu_signup_user_notification_subject', sprintf( __( 'Activate %s', 'buddypress' ), $user ) );
122
+
123
+ wp_mail( $user_email, $subject, $message, $message_headers );
124
+
125
+ // Return false to stop the original WPMU function from continuing
126
+ return false;
127
+ }
128
+ add_filter( 'wpmu_signup_user_notification', 'bp_core_activation_signup_user_notification', 1, 4 );
bp-core/bp-core-admin.php ADDED
@@ -0,0 +1,275 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function bp_core_admin_settings() {
4
+ global $wpdb, $bp;
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'] ) ) : ?>
35
+ <div id="message" class="updated fade">
36
+ <p><?php _e( 'Settings Saved', 'buddypress' ) ?></p>
37
+ </div>
38
+ <?php endif; ?>
39
+
40
+ <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post" id="bp-admin-form">
41
+
42
+ <table class="form-table">
43
+ <tbody>
44
+ <?php if ( function_exists( 'xprofile_install' ) ) :?>
45
+ <tr>
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>
53
+ <td>
54
+ <input name="bp-admin[bp-xprofile-fullname-field-name]" id="bp-xprofile-fullname-field-name" value="<?php echo get_site_option('bp-xprofile-fullname-field-name') ?>" />
55
+ </td>
56
+ </tr>
57
+ <tr>
58
+ <th scope="row"><?php _e( 'Disable BuddyPress to WordPress profile syncing?', '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>
66
+ <th scope="row"><?php _e( 'Hide admin bar for logged out users?', 'buddypress' ) ?>:</th>
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>
74
+ <td>
75
+ <input type="radio" name="bp-admin[bp-disable-avatar-uploads]"<?php if ( (int)get_site_option( 'bp-disable-avatar-uploads' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-disable-avatar-uploads-yes" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
76
+ <input type="radio" name="bp-admin[bp-disable-avatar-uploads]"<?php if ( !(int)get_site_option( 'bp-disable-avatar-uploads' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-disable-avatar-uploads-no" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
77
+ </td>
78
+ </tr>
79
+ <?php if ( function_exists('bp_wire_install') ) { ?>
80
+ <tr>
81
+ <th scope="row"><?php _e( 'Allow non-friends to post on profile wires?', '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('Select theme to use for BuddyPress generated pages', 'buddypress' ) ?>:</th>
90
+ <td>
91
+ <?php $themes = bp_core_get_member_themes() ?>
92
+ <?php if ( $themes ) : ?>
93
+ <select name="bp-admin[active-member-theme]" id="active-member-theme">
94
+ <?php
95
+ for ( $i = 0; $i < count($themes); $i++ ) {
96
+ if ( $themes[$i]['template'] == get_site_option( 'active-member-theme' ) ) {
97
+ $selected = ' selected="selected"';
98
+ } else {
99
+ $selected = '';
100
+ }
101
+ ?>
102
+ <option<?php echo $selected ?> value="<?php echo $themes[$i]['template'] ?>"><?php echo $themes[$i]['name'] ?> (<?php echo $themes[$i]['version'] ?>)</option>
103
+ <?php } ?>
104
+ </select>
105
+ <?php else : ?>
106
+ <div class="error">
107
+ <p><?php printf( __( '<strong>You do not have any BuddyPress themes installed.</strong><p style="line-height: 150%%">Please move the default BuddyPress themes to their correct location (move %s to %s) and reload this page. You can <a href="http://buddypress.org/extend/themes" title="Download">download more themes here</a>.</p>', 'buddypress' ), BP_PLUGIN_DIR . '/bp-themes/', WP_CONTENT_DIR . '/bp-themes/' ) ?></p>
108
+ </div>
109
+ <p><?php _e( 'No Themes Installed.', 'buddypress' ) ?></p>
110
+ <?php endif; ?>
111
+ </td>
112
+ </tr>
113
+ <tr>
114
+ <th scope="row"><?php _e( 'Default User Avatar', 'buddypress' ) ?></th>
115
+ <td>
116
+ <p><?php _e( 'For users without a custom avatar of their own, you can either display a generic logo or a generated one based on their email address', 'buddypress' ) ?></p>
117
+
118
+ <label><input name="bp-admin[user-avatar-default]" id="avatar_mystery" value="mystery" type="radio" <?php if ( get_site_option( 'user-avatar-default' ) == 'mystery' ) : ?> checked="checked"<?php endif; ?> /> &nbsp;<img alt="" src="http://www.gravatar.com/avatar/<?php md5( $ud->user_email ) ?>&amp;?s=32&amp;d=<?php echo BP_PLUGIN_URL . '/bp-core/images/mystery-man.jpg' ?>&amp;r=PG&amp;forcedefault=1" class="avatar avatar-32" height="32" width="32"> &nbsp;<?php _e( 'Mystery Man', 'buddypress' ) ?></label><br>
119
+ <label><input name="bp-admin[user-avatar-default]" id="avatar_identicon" value="identicon" type="radio" <?php if ( get_site_option( 'user-avatar-default' ) == 'identicon' ) : ?> checked="checked"<?php endif; ?> /> &nbsp;<img alt="" src="http://www.gravatar.com/avatar/<?php md5( $ud->user_email ) ?>?s=32&amp;d=identicon&amp;r=PG&amp;forcedefault=1" class="avatar avatar-32" height="32" width="32"> &nbsp;<?php _e( 'Identicon (Generated)', 'buddypress' ) ?></label><br>
120
+ <label><input name="bp-admin[user-avatar-default]" id="avatar_wavatar" value="wavatar" type="radio" <?php if ( get_site_option( 'user-avatar-default' ) == 'wavatar' ) : ?> checked="checked"<?php endif; ?> /> &nbsp;<img alt="" src="http://www.gravatar.com/avatar/<?php md5( $ud->user_email ) ?>?s=32&amp;d=wavatar&amp;r=PG&amp;forcedefault=1" class="avatar avatar-32" height="32" width="32"> &nbsp;<?php _e( 'Wavatar (Generated)', 'buddypress' ) ?> </label><br>
121
+ <label><input name="bp-admin[user-avatar-default]" id="avatar_monsterid" value="monsterid" type="radio" <?php if ( get_site_option( 'user-avatar-default' ) == 'monsterid' ) : ?> checked="checked"<?php endif; ?> /> &nbsp;<img alt="" src="http://www.gravatar.com/avatar/<?php md5( $ud->user_email ) ?>?s=32&amp;d=monsterid&amp;r=PG&amp;forcedefault=1" class="avatar avatar-32" height="32" width="32"> &nbsp;<?php _e( 'MonsterID (Generated)', 'buddypress' ) ?></label>
122
+ </td>
123
+ </tr>
124
+
125
+ <?php do_action( 'bp_core_admin_screen_fields' ) ?>
126
+ </tbody>
127
+ </table>
128
+
129
+ <?php do_action( 'bp_core_admin_screen' ) ?>
130
+
131
+ <p class="submit">
132
+ <input class="button-primary" type="submit" name="bp-admin-submit" id="bp-admin-submit" value="<?php _e( 'Save Settings', 'buddypress' ) ?>"/>
133
+ </p>
134
+
135
+ <?php wp_nonce_field( 'bp-admin' ) ?>
136
+
137
+ </form>
138
+
139
+ </div>
140
+
141
+ <?php
142
+ }
143
+
144
+ function bp_core_admin_component_setup() {
145
+ global $wpdb, $bp;
146
+ ?>
147
+
148
+ <?php
149
+ if ( isset( $_POST['bp-admin-component-submit'] ) && isset( $_POST['bp_components'] ) ) {
150
+ if ( !check_admin_referer('bp-admin-component-setup') )
151
+ return false;
152
+
153
+ // Settings form submitted, now save the settings.
154
+ foreach ( $_POST['bp_components'] as $key => $value ) {
155
+ if ( !(int) $value )
156
+ $disabled[$key] = 1;
157
+ }
158
+ update_site_option( 'bp-deactivated-components', $disabled );
159
+ }
160
+ ?>
161
+
162
+ <div class="wrap">
163
+
164
+ <h2><?php _e( 'BuddyPress Component Setup', 'buddypress' ) ?></h2>
165
+
166
+ <?php if ( isset( $_POST['bp-admin-component-submit'] ) ) : ?>
167
+ <div id="message" class="updated fade">
168
+ <p><?php _e( 'Settings Saved', 'buddypress' ) ?></p>
169
+ </div>
170
+ <?php endif; ?>
171
+
172
+ <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post" id="bp-admin-component-form">
173
+
174
+ <p>
175
+ <?php _e(
176
+ 'By default, all BuddyPress components are enabled. You can selectively disable any of the
177
+ components by using the form below. Your BuddyPress installation will continue to function, however
178
+ the features of the disabled components will no longer be accessible to
179
+ anyone using the site.
180
+ ', 'buddypress' )?>
181
+ </p>
182
+
183
+ <?php $disabled_components = get_site_option( 'bp-deactivated-components' ); ?>
184
+
185
+ <table class="form-table" style="width: 80%">
186
+ <tbody>
187
+ <?php if ( file_exists( BP_PLUGIN_DIR . '/bp-activity.php') ) : ?>
188
+ <tr>
189
+ <td><h3><?php _e( 'Activity Streams', 'buddypress' ) ?></h3><p><?php _e( 'Tracks user activity across the entire site.', 'buddypress' ) ?></p></td>
190
+ <td>
191
+ <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;
192
+ <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' ) ?>
193
+ </td>
194
+ </tr>
195
+ <?php endif; ?>
196
+ <?php if ( file_exists( BP_PLUGIN_DIR . '/bp-blogs.php') ) : ?>
197
+ <tr>
198
+ <td><h3><?php _e( 'Blog Tracking', 'buddypress' ) ?></h3><p><?php _e( 'Tracks blogs, blog posts and blogs comments for a user across a WPMU installation.', 'buddypress' ) ?></p></td>
199
+ <td>
200
+ <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;
201
+ <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' ) ?>
202
+ </td>
203
+ </tr>
204
+ <?php endif; ?>
205
+ <?php if ( file_exists( BP_PLUGIN_DIR . '/bp-forums.php') ) : ?>
206
+ <tr>
207
+ <td><h3><?php _e( 'bbPress Forums', 'buddypress' ) ?></h3><p><?php _e( 'Activates bbPress forum support within BuddyPress groups or any other custom component.', 'buddypress' ) ?></p></td>
208
+ <td>
209
+ <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;
210
+ <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' ) ?>
211
+ </td>
212
+ </tr>
213
+ <?php endif; ?>
214
+ <?php if ( file_exists( BP_PLUGIN_DIR . '/bp-friends.php') ) : ?>
215
+ <tr>
216
+ <td><h3><?php _e( 'Friends', 'buddypress' ) ?></h3><p><?php _e( 'Allows the creation of friend connections between users.', 'buddypress' ) ?></p></td>
217
+ <td>
218
+ <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;
219
+ <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' ) ?>
220
+ </td>
221
+ </tr>
222
+ <?php endif; ?>
223
+ <?php if ( file_exists( BP_PLUGIN_DIR . '/bp-groups.php') ) : ?>
224
+ <tr>
225
+ <td><h3><?php _e( 'Groups', 'buddypress' ) ?></h3><p><?php _e( 'Let users create, join and participate in groups.', 'buddypress' ) ?></p></td>
226
+ <td>
227
+ <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;
228
+ <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' ) ?>
229
+ </td>
230
+ </tr>
231
+ <?php endif; ?>
232
+ <?php if ( file_exists( BP_PLUGIN_DIR . '/bp-messages.php') ) : ?>
233
+ <tr>
234
+ <td><h3><?php _e( 'Private Messaging', 'buddypress' ) ?></h3><p><?php _e( 'Let users send private messages to one another. Site admins can also send site-wide notices.', 'buddypress' ) ?></p></td>
235
+ <td>
236
+ <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;
237
+ <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' ) ?>
238
+ </td>
239
+ </tr>
240
+ <?php endif; ?>
241
+ <?php if ( file_exists( BP_PLUGIN_DIR . '/bp-wire.php') ) : ?>
242
+ <tr>
243
+ <td><h3><?php _e( 'Comment Wire', 'buddypress' ) ?></h3><p><?php _e( 'Let users leave a comment on groups, profiles and custom components.', 'buddypress' ) ?></p></td>
244
+ <td>
245
+ <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;
246
+ <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' ) ?>
247
+ </td>
248
+ </tr>
249
+ <?php endif; ?>
250
+ <?php if ( file_exists( BP_PLUGIN_DIR . '/bp-xprofile.php') ) : ?>
251
+ <tr>
252
+ <td><h3><?php _e( 'Extended Profiles', 'buddypress' ) ?></h3><p><?php _e( 'Activates customizable profiles and avatars for site users.', 'buddypress' ) ?></p></td>
253
+ <td width="45%">
254
+ <input type="radio" name="bp_components[bp-xprofile.php]" value="1"<?php if ( !isset( $disabled_components['bp-xprofile.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> &nbsp;
255
+ <input type="radio" name="bp_components[bp-xprofile.php]" value="0"<?php if ( isset( $disabled_components['bp-xprofile.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
256
+ </td>
257
+ </tr>
258
+ <?php endif; ?>
259
+ </tbody>
260
+ </table>
261
+
262
+ <p class="submit">
263
+ <input class="button-primary" type="submit" name="bp-admin-component-submit" id="bp-admin-component-submit" value="<?php _e( 'Save Settings', 'buddypress' ) ?>"/>
264
+ </p>
265
+
266
+ <?php wp_nonce_field( 'bp-admin-component-setup' ) ?>
267
+
268
+ </form>
269
+
270
+ </div>
271
+
272
+ <?php
273
+ }
274
+
275
+ ?>
bp-core/bp-core-adminbar.php ADDED
@@ -0,0 +1,281 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function bp_core_admin_bar() {
4
+ global $bp, $wpdb, $current_blog, $doing_admin_bar;
5
+
6
+ $doing_admin_bar = true;
7
+
8
+ if ( (int)get_site_option( 'hide-loggedout-adminbar' ) && !is_user_logged_in() )
9
+ return false;
10
+
11
+ echo '<div id="wp-admin-bar">';
12
+
13
+ // **** Do bp-adminbar-logo Actions ********
14
+ do_action( 'bp_adminbar_logo' );
15
+
16
+ echo '<ul class="main-nav">';
17
+
18
+ // **** Do bp-adminbar-menus Actions ********
19
+ do_action( 'bp_adminbar_menus' );
20
+
21
+ echo '</ul>';
22
+ echo '</div>';
23
+ }
24
+
25
+ // **** Default BuddyPress admin bar logo ********
26
+ function bp_adminbar_logo() {
27
+ global $bp;
28
+
29
+ echo '<a href="' . $bp->root_domain . '"><img id="admin-bar-logo" src="' . apply_filters( 'bp_admin_bar_logo_src', BP_PLUGIN_URL . '/bp-core/images/admin_bar_logo.gif' ) . '" alt="' . apply_filters( 'bp_admin_bar_logo_alt_text', __( 'BuddyPress', 'buddypress' ) ) . '" /></a>';
30
+ }
31
+
32
+ // **** "Log In" and "Sign Up" links (Visible when not logged in) ********
33
+ function bp_adminbar_login_menu() {
34
+ global $bp;
35
+
36
+ if ( !is_user_logged_in() ) {
37
+ 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>';
38
+
39
+ // Show "Sign Up" link if registrations are allowed
40
+ if ( get_site_option( 'registration' ) != 'none' ) {
41
+ echo '<li class="bp-signup no-arrow"><a href="' . bp_signup_page(false) . '">' . __( 'Sign Up', 'buddypress' ) . '</a></li>';
42
+ }
43
+ }
44
+ }
45
+
46
+ // **** "My Account" Menu ******
47
+ function bp_adminbar_account_menu() {
48
+ global $bp;
49
+
50
+ if ( !$bp->bp_nav )
51
+ return false;
52
+
53
+ /* Sort the nav by key as the array has been put together in different locations */
54
+ $bp->bp_nav = bp_core_sort_nav_items( $bp->bp_nav );
55
+
56
+ if ( is_user_logged_in() ) {
57
+
58
+ echo '<li id="bp-adminbar-account-menu"><a href="">';
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
+ foreach( $bp->bp_options_nav[$nav_item['css_id']] as $subnav_item ) {
75
+ $alt = ( 0 == $sub_counter % 2 ) ? ' class="alt"' : '';
76
+ echo '<li' . $alt . '><a id="bp-admin-' . $subnav_item['css_id'] . '" href="' . $subnav_item['link'] . '">' . $subnav_item['name'] . '</a></li>';
77
+ $sub_counter++;
78
+ }
79
+ echo '</ul>';
80
+ }
81
+
82
+ echo '</li>';
83
+
84
+ $counter++;
85
+ }
86
+
87
+ $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
88
+
89
+ if ( function_exists('wp_logout_url') ) {
90
+ echo '<li' . $alt . '><a id="bp-admin-logout" href="' . wp_logout_url(site_url()) . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>';
91
+ } else {
92
+ 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>';
93
+ }
94
+
95
+ echo '</ul>';
96
+ echo '</li>';
97
+ }
98
+ }
99
+
100
+ // return a string indicating user's role in that blog
101
+ function get_blog_role_for_user( $user, $blog ) {
102
+
103
+ // If the user is a site admin, just display admin.
104
+ if ( is_site_admin() )
105
+ return __( 'Admin', 'buddypress');
106
+
107
+ $roles = get_usermeta( $user, 'wp_' . $blog . '_capabilities' );
108
+
109
+ if ( isset( $roles['subscriber'] ) )
110
+ $role = __( 'Subscriber', 'buddypress' );
111
+ elseif ( isset( $roles['contributor'] ) )
112
+ $role = __( 'Contributor', 'buddypress' );
113
+ elseif ( isset( $roles['author'] ) )
114
+ $role = __( 'Author', 'buddypress' );
115
+ elseif ( isset( $roles['editor'] ) )
116
+ $role = __( 'Editor', 'buddypress' );
117
+ elseif ( isset( $roles['administrator'] ) )
118
+ $role = __( 'Admin', 'buddypress' );
119
+ else
120
+ return false;
121
+
122
+ return $role;
123
+ }
124
+
125
+ // *** "My Blogs" Menu ********
126
+ function bp_adminbar_blogs_menu() {
127
+ if ( is_user_logged_in() ) {
128
+ global $bp;
129
+
130
+ if ( function_exists('bp_blogs_install') ) {
131
+
132
+ if ( !$blogs = wp_cache_get( 'bp_blogs_of_user_' . $bp->loggedin_user->id, 'bp' ) ) {
133
+ $blogs = get_blogs_of_user( $bp->loggedin_user->id );
134
+ wp_cache_set( 'bp_blogs_of_user_' . $bp->loggedin_user->id, $blogs, 'bp' );
135
+ }
136
+
137
+ echo '<li id="bp-adminbar-blogs-menu"><a href="' . $bp->loggedin_user->domain . $bp->blogs->slug . '/my-blogs">';
138
+
139
+ _e( 'My Blogs', 'buddypress' );
140
+
141
+ echo '</a>';
142
+
143
+ echo '<ul>';
144
+ if ( is_array( $blogs )) {
145
+
146
+ $counter = 0;
147
+ foreach( $blogs as $blog ) {
148
+ $role = get_blog_role_for_user( $bp->loggedin_user->id, $blog->userblog_id );
149
+
150
+ $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
151
+ echo '<li' . $alt . '>';
152
+ echo '<a href="' . $blog->siteurl . '">' . $blog->blogname . ' (' . $role . ')</a>';
153
+ if ( !( 'Subscriber' == $role ) ) { // then they have something to display on the flyout menu
154
+ echo '<ul>';
155
+ echo '<li class="alt"><a href="' . $blog->siteurl . '/wp-admin/">' . __('Dashboard', 'buddypress') . '</a></li>';
156
+ echo '<li><a href="' . $blog->siteurl . '/wp-admin/post-new.php">' . __('New Post', 'buddypress') . '</a></li>';
157
+ echo '<li class="alt"><a href="' . $blog->siteurl . '/wp-admin/edit.php">' . __('Manage Posts', 'buddypress') . '</a></li>';
158
+ echo '<li><a href="' . $blog->siteurl . '/wp-admin/edit-comments.php">' . __('Manage Comments', 'buddypress') . '</a></li>';
159
+ if ( 'Admin' == $role ) {
160
+ echo '<li class="alt"><a href="' . $blog->siteurl . '/wp-admin/themes.php">' . __('Switch Theme', 'buddypress') . '</a></li>';
161
+ }
162
+ echo '</ul>';
163
+ }
164
+ echo '</li>';
165
+ $counter++;
166
+ }
167
+ }
168
+
169
+ $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
170
+
171
+ echo '<li' . $alt . '>';
172
+ echo '<a href="' . $bp->loggedin_user->domain . $bp->blogs->slug . '/create-a-blog">' . __('Create a Blog!', 'buddypress') . '</a>';
173
+ echo '</li>';
174
+
175
+ echo '</ul>';
176
+ echo '</li>';
177
+ }
178
+ }
179
+ }
180
+
181
+ // **** "Notifications" Menu *********
182
+ function bp_adminbar_notifications_menu() {
183
+ if ( is_user_logged_in() ) {
184
+ global $bp;
185
+
186
+ echo '<li id="bp-adminbar-notifications-menu"><a href="' . $bp->loggedin_user->domain . '">';
187
+ _e( 'Notifications', 'buddypress' );
188
+
189
+ if ( $notifications = bp_core_get_notifications_for_user( $bp->loggedin_user->id ) ) { ?>
190
+ <span><?php echo count($notifications) ?></span>
191
+ <?php
192
+ }
193
+
194
+ echo '</a>';
195
+ echo '<ul>';
196
+
197
+ if ( $notifications ) { ?>
198
+ <?php $counter = 0; ?>
199
+ <?php for ( $i = 0; $i < count($notifications); $i++ ) { ?>
200
+ <?php $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : ''; ?>
201
+ <li<?php echo $alt ?>><?php echo $notifications[$i] ?></li>
202
+ <?php $counter++; ?>
203
+ <?php } ?>
204
+ <?php } else { ?>
205
+ <li><a href="<?php echo $bp->loggedin_user->domain ?>"><?php _e( 'No new notifications.', 'buddypress' ); ?></a></li>
206
+ <?php
207
+ }
208
+
209
+ echo '</ul>';
210
+ echo '</li>';
211
+ }
212
+ }
213
+
214
+ // **** "Blog Authors" Menu (visible when not logged in) ********
215
+ function bp_adminbar_authors_menu() {
216
+ global $current_blog;
217
+
218
+ if ( $current_blog->blog_id > 1 ) {
219
+ $authors = get_users_of_blog();
220
+
221
+ if ( is_array( $authors ) ) {
222
+ /* This is a blog, render a menu with links to all authors */
223
+ echo '<li id="bp-adminbar-authors-menu"><a href="/">';
224
+ _e('Blog Authors', 'buddypress');
225
+ echo '</a>';
226
+
227
+ echo '<ul class="author-list">';
228
+ foreach( $authors as $author ) {
229
+ $author = new BP_Core_User( $author->user_id );
230
+ echo '<li>';
231
+
232
+ echo '<a href="' . $author->user_url . '">';
233
+ echo $author->avatar_mini;
234
+ echo ' ' . $author->fullname;
235
+ echo '<span class="activity">' . $author->last_active . '</span>';
236
+ echo '</a>';
237
+ echo '<div class="admin-bar-clear"></div>';
238
+ echo '</li>';
239
+ }
240
+ echo '</ul>';
241
+ echo '</li>';
242
+ }
243
+ }
244
+ }
245
+
246
+ // **** "Random" Menu (visible when not logged in) ********
247
+ function bp_adminbar_random_menu() {
248
+ global $bp; ?>
249
+ <li class="align-right" id="bp-adminbar-visitrandom-menu">
250
+ <a href="#"><?php _e( 'Visit', 'buddypress' ) ?></a>
251
+ <ul class="random-list">
252
+ <li><a href="<?php echo $bp->root_domain . '/' . BP_MEMBERS_SLUG . '/?random' ?>"><?php _e( 'Random Member', 'buddypress' ) ?></a></li>
253
+
254
+ <?php if ( function_exists('groups_install') ) : ?>
255
+ <li class="alt"><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug . '/?random' ?>"><?php _e( 'Random Group', 'buddypress' ) ?></a></li>
256
+ <?php endif; ?>
257
+
258
+ <?php if ( function_exists('bp_blogs_install') ) : ?>
259
+ <li><a href="<?php echo $bp->root_domain . '/' . $bp->blogs->slug . '/?random-blog' ?>"><?php _e( 'Random Blog', 'buddypress' ) ?></a></li>
260
+
261
+ <?php endif; ?>
262
+ </ul>
263
+ </li>
264
+ <?php
265
+
266
+ $doing_admin_bar = false;
267
+ }
268
+
269
+
270
+ add_action( 'bp_adminbar_logo', 'bp_adminbar_logo' );
271
+ add_action( 'bp_adminbar_menus', 'bp_adminbar_login_menu', 2 );
272
+ add_action( 'bp_adminbar_menus', 'bp_adminbar_account_menu', 4 );
273
+ add_action( 'bp_adminbar_menus', 'bp_adminbar_blogs_menu', 6 );
274
+ add_action( 'bp_adminbar_menus', 'bp_adminbar_notifications_menu', 8 );
275
+ add_action( 'bp_adminbar_menus', 'bp_adminbar_authors_menu', 12 );
276
+ add_action( 'bp_adminbar_menus', 'bp_adminbar_random_menu', 100 );
277
+
278
+ add_action( 'wp_footer', 'bp_core_admin_bar', 8 );
279
+ add_action( 'admin_footer', 'bp_core_admin_bar' );
280
+
281
+ ?>
bp-core/bp-core-ajax-handler.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ define('DOING_AJAX', true);
3
+ require_once( preg_replace('%(.*)[/\\\\]wp-content[/\\\\].*%', '\1', $_SERVER['SCRIPT_FILENAME'] ) . '/wp-load.php' );
4
+
5
+ wp();
6
+
7
+ do_action( 'wp_ajax_' . $_POST['action'] );
8
+
9
+ /* Head shot! */
10
+ die('0');
11
+ ?>
bp-core/bp-core-ajax.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function bp_core_ajax_widget_members() {
4
+ global $bp;
5
+
6
+ check_ajax_referer('bp_core_widget_members');
7
+
8
+ switch ( $_POST['filter'] ) {
9
+ case 'newest-members':
10
+ if ( !$users = wp_cache_get( 'newest_users', 'bp' ) ) {
11
+ $users = BP_Core_User::get_newest_users( $_POST['max-members'], 1 );
12
+ wp_cache_set( 'newest_users', $users, 'bp' );
13
+ }
14
+ break;
15
+ case 'recently-active-members':
16
+ if ( !$users = wp_cache_get( 'active_users', 'bp' ) ) {
17
+ $users = BP_Core_User::get_active_users( $_POST['max-members'], 1 );
18
+ wp_cache_set( 'active_users', $users, 'bp' );
19
+ }
20
+ break;
21
+ case 'popular-members':
22
+ if ( !$users = wp_cache_get( 'popular_users', 'bp' ) ) {
23
+ $users = BP_Core_User::get_popular_users( $_POST['max-members'], 1 );
24
+ wp_cache_set( 'popular_users', $users, 'bp' );
25
+ }
26
+ break;
27
+ }
28
+
29
+ if ( $users['users'] ) {
30
+ echo '0[[SPLIT]]'; // return valid result.
31
+
32
+ foreach ( (array) $users['users'] as $user ) {
33
+ ?>
34
+ <li class="vcard">
35
+ <div class="item-avatar">
36
+ <a href="<?php echo bp_core_get_userlink( $user->user_id, false, true ) ?>"><?php echo bp_core_get_avatar( $user->user_id, 1 ) ?></a>
37
+ </div>
38
+
39
+ <div class="item">
40
+ <div class="item-title"><?php echo bp_core_get_userlink( $user->user_id ) ?></div>
41
+ <div class="item-meta">
42
+ <span class="activity">
43
+ <?php
44
+ if ( 'newest-members' == $_POST['filter'] ) {
45
+ echo bp_core_get_last_activity( $user->user_registered, __( 'registered %s ago', 'buddypress' ) );
46
+ } else if ( 'recently-active-members' == $_POST['filter'] ) {
47
+ echo bp_core_get_last_activity( get_usermeta( $user->user_id, 'last_activity' ), __( 'active %s ago', 'buddypress' ) );
48
+ } else if ( 'popular-members' == $_POST['filter'] ) {
49
+ if ( 1 == get_usermeta( $user->user_id, 'total_friend_count' ) )
50
+ echo get_usermeta( $user->user_id, 'total_friend_count' ) . __(' friend', 'buddypress');
51
+ else
52
+ echo get_usermeta( $user->user_id, 'total_friend_count' ) . __(' friends', 'buddypress');
53
+ }
54
+ ?>
55
+ </span>
56
+ </div>
57
+ </div>
58
+ </li>
59
+ <?php
60
+ }
61
+ } else {
62
+ echo "-1[[SPLIT]]<li>" . __("No members matched the current filter.", 'buddypress');
63
+ }
64
+ }
65
+ add_action( 'wp_ajax_widget_members', 'bp_core_ajax_widget_members' );
66
+
67
+
68
+ function bp_core_ajax_directory_members() {
69
+ check_ajax_referer('directory_members');
70
+
71
+ load_template( TEMPLATEPATH . '/directories/members/members-loop.php' );
72
+ }
73
+ add_action( 'wp_ajax_directory_members', 'bp_core_ajax_directory_members' );
74
+
75
+
76
+ ?>
bp-core/bp-core-avatars.php ADDED
@@ -0,0 +1,498 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Based on contributions from: Beau Lebens - http://www.dentedreality.com.au/
4
+ Modified for BuddyPress by: Andy Peatling - http://apeatling.wordpress.com/
5
+ */
6
+
7
+ /* Make sure we have the core WordPress files we need */
8
+ require_once( ABSPATH . '/wp-admin/includes/image.php' );
9
+ require_once( ABSPATH . '/wp-admin/includes/file.php' );
10
+
11
+ /* Define settings for avatars. [TODO] This will eventually end up as admin configurable settings */
12
+ define( 'CORE_AVATAR_V1_W', apply_filters( 'bp_core_avatar_v1_w', 50 ) );
13
+ define( 'CORE_AVATAR_V1_H', apply_filters( 'bp_core_avatar_v1_h', 50 ) );
14
+ define( 'CORE_AVATAR_V2_W', apply_filters( 'bp_core_avatar_v2_w', 150 ) );
15
+ define( 'CORE_AVATAR_V2_H', apply_filters( 'bp_core_avatar_v2_h', 150 ) );
16
+ define( 'CORE_CROPPING_CANVAS_MAX', apply_filters( 'bp_core_avatar_cropping_canvas_max', 450 ) );
17
+ define( 'CORE_MAX_FILE_SIZE', get_site_option('fileupload_maxk') * 1024 );
18
+ define( 'CORE_DEFAULT_AVATAR', apply_filters( 'bp_core_avatar_default_src', BP_PLUGIN_URL . '/bp-xprofile/images/none.gif' ) );
19
+ define( 'CORE_DEFAULT_AVATAR_THUMB', apply_filters( 'bp_core_avatar_default_thumb_src', BP_PLUGIN_URL . '/bp-xprofile/images/none-thumbnail.gif' ) );
20
+
21
+ function bp_core_get_avatar( $user, $version = 1, $width = null, $height = null, $no_tag = false ) {
22
+ global $bp, $current_blog;
23
+
24
+ if ( !is_int($version) )
25
+ $version = (int) $version;
26
+
27
+ if ( CORE_AVATAR_V2_W == false && CORE_AVATAR_V2_H == false )
28
+ $version = 1;
29
+
30
+ if ( !$width )
31
+ $width = constant('CORE_AVATAR_V' . $version . '_W');
32
+
33
+ if ( !$height )
34
+ $height = constant('CORE_AVATAR_V' . $version . '_H');
35
+
36
+ $avatar_file = wp_cache_get( 'bp_core_avatar_v' . $version . '_u' . $user, 'bp' );
37
+ if ( false === $avatar_file ) {
38
+ $avatar_file = get_usermeta( $user, 'bp_core_avatar_v' . $version );
39
+ wp_cache_set( 'bp_core_avatar_v' . $version . '_u' . $user, $avatar_file, 'bp' );
40
+ }
41
+
42
+ $url = $bp->root_domain . '/' . $avatar_file;
43
+
44
+ if ( strlen($avatar_file) ) {
45
+ if ( $no_tag )
46
+ return $url;
47
+ else
48
+ return apply_filters( 'bp_core_get_avatar', '<img src="' . $url . '" alt="" class="avatar photo" width="' . $width . '" height="' . $height . '" />', $user, $version, $width, $height, $no_tag );
49
+ } else {
50
+ $ud = get_userdata($user);
51
+
52
+ if ( empty( $bp->grav_default ) ) {
53
+ $default_grav = 'wavatar';
54
+ } else if ( 'mystery' == $bp->grav_default ) {
55
+ $default_grav = BP_PLUGIN_URL . '/bp-core/images/mystery-man.jpg';
56
+ } else {
57
+ $default_grav = $bp->grav_default;
58
+ }
59
+
60
+ $gravatar = 'http://www.gravatar.com/avatar/' . md5( $ud->user_email ) . '?d=' . $default_grav . '&amp;s=';
61
+ if ( $no_tag )
62
+ return apply_filters( 'bp_core_get_avatar', $gravatar . constant('CORE_AVATAR_V' . $version . '_W'), $user, $version, $width, $height, $no_tag );
63
+ else
64
+ return apply_filters( 'bp_core_get_avatar', '<img src="' . $gravatar . constant('CORE_AVATAR_V' . $version . '_W') . '" alt="" class="avatar" width="' . $width . '" height="' . $height . '" />', $user, $version, $width, $height, $no_tag );
65
+ }
66
+ }
67
+
68
+ // Override internal "get_avatar()" function to use our own where possible
69
+ // WARNING: Does NOT apply size restrictions
70
+ function bp_core_get_avatar_filter( $avatar, $id_or_email, $size, $default ) {
71
+ $str = '';
72
+ $ver = ( 1 == $size || 2 == $size ) ? $size : 1;
73
+
74
+ if ( !CORE_AVATAR_V2_W && !CORE_AVATAR_V2_H )
75
+ $ver = 1;
76
+
77
+ if ( is_numeric($id_or_email) ) {
78
+ $str = bp_core_get_avatar( $id_or_email, $ver );
79
+ } elseif ( is_object($id_or_email) ) {
80
+ if ( !empty($id_or_email->user_id) ) {
81
+ $str = bp_core_get_avatar( $id_or_email->user_id, $ver );
82
+ }
83
+ }
84
+
85
+ return empty($str) ? $avatar : $str;
86
+ }
87
+ add_filter( 'get_avatar', 'bp_core_get_avatar_filter', 10, 4 );
88
+
89
+
90
+ // Main UI Rendering
91
+ function bp_core_avatar_admin( $message = null, $action, $delete_action) {
92
+ global $wp_upload_error;
93
+ ?>
94
+ <?php if ( !isset($_POST['slick_avatars_action']) && !isset($_GET['slick_avatars_action']) ) { ?>
95
+ <?php if ( $message ) { ?>
96
+ <br />
97
+ <div id="message" class="updated fade">
98
+ <p><?php echo $message; ?></p>
99
+ </div>
100
+ <?php } ?>
101
+
102
+ <p><?php _e('Your avatar will be used on your profile and throughout the site.', 'buddypress') ?></p>
103
+ <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>
104
+
105
+ <?php
106
+
107
+ bp_core_render_avatar_upload_form($action);
108
+
109
+ $str = bp_core_get_avatar( get_current_user_id(), 1 );
110
+ if ( strlen($str) ) {
111
+ echo '<h3>' . __('This is your current avatar', 'buddypress') . '</h3>';
112
+ echo '<span class="crop-img avatar">' . bp_core_get_avatar(get_current_user_id(), 1) . '</span>';
113
+ echo '<span class="crop-img avatar">' . bp_core_get_avatar(get_current_user_id(), 2) . '</span>';
114
+ echo '<a href="' . wp_nonce_url( $delete_action, 'bp_delete_avatar_link' ) . '">' . __( 'Delete', 'buddypress' ) . '</a>';
115
+ }
116
+
117
+ } else if ( isset($_POST['slick_avatars_action']) && 'upload' == $_POST['slick_avatars_action'] ) {
118
+
119
+ // Confirm that the nonce is valid
120
+ if ( !isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'slick_avatars') )
121
+ bp_core_ap_die( 'Security error.' );
122
+
123
+ // Set friendly error feedback.
124
+ $uploadErrors = array(
125
+ 0 => __("There is no error, the file uploaded with success", 'buddypress'),
126
+ 1 => __("Your image was bigger than the maximum allowed file size of: ", 'buddypress') . size_format(CORE_MAX_FILE_SIZE),
127
+ 2 => __("Your image was bigger than the maximum allowed file size of: ", 'buddypress') . size_format(CORE_MAX_FILE_SIZE),
128
+ 3 => __("The uploaded file was only partially uploaded", 'buddypress'),
129
+ 4 => __("No file was uploaded", 'buddypress'),
130
+ 6 => __("Missing a temporary folder", 'buddypress')
131
+ );
132
+
133
+ if ( !bp_core_check_avatar_upload($_FILES) )
134
+ bp_core_ap_die( sprintf( __( 'Your upload failed, please try again. Error was: %s', 'buddypress' ), $uploadErrors[$_FILES['file']['error']] ) );
135
+
136
+ if ( !bp_core_check_avatar_size($_FILES) )
137
+ bp_core_ap_die( sprintf( __( 'The file you uploaded is too big. Please upload a file under %s', 'buddypress'), size_format(CORE_MAX_FILE_SIZE) ) );
138
+
139
+ if ( !bp_core_check_avatar_type($_FILES) )
140
+ bp_core_ap_die( __( 'Please upload only JPG, GIF or PNG photos.', 'buddypress' ) );
141
+
142
+ // "Handle" upload into temporary location
143
+ if ( !$original = bp_core_handle_avatar_upload($_FILES) )
144
+ bp_core_ap_die( sprintf( __( 'Upload Failed! Error was: %s', 'buddypress' ), $wp_upload_error ) );
145
+
146
+ // Resize down to something we can display on the page or use original if its small enough already.
147
+ if ( !$canvas = bp_core_resize_avatar($original) )
148
+ $canvas = $original;
149
+
150
+ // Render the cropper UI
151
+ bp_core_render_avatar_cropper($original, $canvas, $action);
152
+
153
+ } else if ( isset($_POST['slick_avatars_action']) && 'crop' == $_POST['slick_avatars_action'] ) {
154
+ // Crop, save, store
155
+
156
+ // Confirm that the nonce is valid
157
+ if ( !isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'slick_avatars') )
158
+ bp_core_ap_die( __( 'Security error.', 'buddypress' ) );
159
+
160
+ if ( !bp_core_check_crop( $_POST['orig'], $_POST['canvas'] ) )
161
+ bp_core_ap_die( __( 'Error when cropping, please go back and try again', 'buddypress' ) );
162
+
163
+ if ( !$result = bp_core_avatar_cropstore( stripslashes($_POST['orig']), $_POST['canvas'], $_POST['v1_x1'], $_POST['v1_y1'], $_POST['v1_w'], $_POST['v1_h'], $_POST['v2_x1'], $_POST['v2_y1'], $_POST['v2_w'], $_POST['v2_h'] ) )
164
+ bp_core_ap_die( __( 'Error when saving avatars, please go back and try again.', 'buddypress' ) );
165
+
166
+ // Store details to the DB and we're done
167
+ echo '<p>' . __('Your new avatar was successfully created!', 'buddypress') . '</p>';
168
+
169
+ bp_core_avatar_save($result);
170
+
171
+ echo '<span class="crop-img">' . bp_core_get_avatar( get_current_user_id(), 1 ) . '</span>';
172
+
173
+ if ( CORE_AVATAR_V2_W && CORE_AVATAR_V2_H ) {
174
+ echo '<span class="crop-img">' . bp_core_get_avatar( get_current_user_id(), 2 ) . '</span>';
175
+ }
176
+
177
+ } else if ( isset($_GET['slick_avatars_action']) && 'delete' == $_GET['slick_avatars_action'] ) {
178
+ // Delete an avatar
179
+
180
+ bp_core_delete_avatar();
181
+
182
+ unset($_GET['slick_avatars_action']);
183
+ $message = __('Avatar successfully removed.', 'buddypress');
184
+ bp_core_avatar_admin($message);
185
+
186
+ }
187
+ ?>
188
+ <?php
189
+ }
190
+
191
+ function bp_core_check_avatar_upload($file) {
192
+ if ( $file['error'] )
193
+ return false;
194
+
195
+ return true;
196
+ }
197
+
198
+ function bp_core_check_avatar_size($file) {
199
+ if ( $file['file']['size'] > CORE_MAX_FILE_SIZE )
200
+ return false;
201
+
202
+ return true;
203
+ }
204
+
205
+ function bp_core_check_avatar_type($file) {
206
+ if ( ( strlen($file['file']['type']) && !preg_match('/(jpe?g|gif|png)$/', $file['file']['type'] ) ) && !preg_match( '/(jpe?g|gif|png)$/', $file['file']['name'] ) )
207
+ return false;
208
+
209
+ return true;
210
+ }
211
+
212
+ function bp_core_handle_avatar_upload($file) {
213
+ global $wp_upload_error;
214
+
215
+ // Change the upload file location to /avatars/user_id
216
+ add_filter( 'upload_dir', 'bp_core_avatar_upload_dir' );
217
+
218
+ $res = wp_handle_upload( $file['file'], array('action'=>'slick_avatars') );
219
+
220
+ if ( !in_array('error', array_keys($res) ) ) {
221
+ return $res['file'];
222
+ } else {
223
+ $wp_upload_error = $res['error'];
224
+ return false;
225
+ }
226
+ }
227
+
228
+ function bp_core_avatar_upload_dir( $upload, $user_id = false ) {
229
+ global $bp;
230
+
231
+ if ( !$user_id )
232
+ $user_id = $bp->loggedin_user->id;
233
+
234
+ $path = get_blog_option( 1, 'upload_path' );
235
+ $newdir = path_join( ABSPATH, $path );
236
+ $newdir .= '/avatars/' . $user_id;
237
+
238
+ $newbdir = $newdir;
239
+
240
+ @wp_mkdir_p( $newdir );
241
+
242
+ $newurl = trailingslashit( get_blog_option( 1, 'siteurl' ) ) . '/avatars/' . $user_id;
243
+ $newburl = $newurl;
244
+ $newsubdir = '/avatars/' . $user_id;
245
+
246
+ return apply_filters( 'bp_core_avatar_upload_dir', array( 'path' => $newdir, 'url' => $newurl, 'subdir' => $newsubdir, 'basedir' => $newbdir, 'baseurl' => $newburl, 'error' => false ) );
247
+ }
248
+
249
+ function bp_core_check_avatar_dimensions($file) {
250
+ $size = getimagesize($file);
251
+
252
+ if ( $size[0] < (int)CORE_AVATAR_V2_W || $size[1] < (int)CORE_CROPPING_CANVAS_MAX )
253
+ return false;
254
+
255
+ return true;
256
+ }
257
+
258
+ function bp_core_resize_avatar( $file, $size = false ) {
259
+
260
+ if ( !$size )
261
+ $size = CORE_CROPPING_CANVAS_MAX;
262
+
263
+ $canvas = wp_create_thumbnail( $file, $size );
264
+
265
+ if ( $canvas->errors )
266
+ return false;
267
+
268
+ return $canvas = str_replace( '//', '/', $canvas );
269
+ }
270
+
271
+ function bp_core_render_avatar_cropper( $original, $new, $action, $user_id = null, $no_form_tag = false, $url = false ) {
272
+ global $bp;
273
+
274
+ $size = getimagesize($new);
275
+
276
+ if ( !$user_id )
277
+ $user_id = $bp->loggedin_user->id;
278
+
279
+ $src = str_replace( array(ABSPATH), array(site_url() . '/'), $new );
280
+
281
+ // Load cropper details
282
+
283
+ // V1 UI
284
+ if ( !$no_form_tag )
285
+ echo '<form action="' . $action . '" method="post" id="avatar-cropper">';
286
+
287
+ echo '<input type="hidden" name="slick_avatars_action" value="crop" />';
288
+ echo '<input type="hidden" name="action" value="slick_avatars" />';
289
+ echo '<input type="hidden" name="nonce" value="' . wp_create_nonce('slick_avatars') . '" />';
290
+ echo '<input type="hidden" name="orig" value="' . $original . '" />';
291
+ echo '<input type="hidden" name="canvas" value="' . $new . '" />';
292
+
293
+ echo '<div id="avatar_v1">';
294
+ echo '<h3>' . __( 'Please Crop Your Avatar!', 'buddypress' ) . '</h3>';
295
+ echo '<h4>' . __('Thumbnail Avatar', 'buddypress') . '</h4>';
296
+ echo '<p>' . __('Please crop a small version of your avatar to use for thumbnails.', 'buddypress') . '</p>';
297
+
298
+ // Canvas
299
+ echo '<div id="crop-v1" class="crop-img"><img src="' . $src . '" ' . $size[3] . ' border="0" alt="' . __( 'Select the area to crop', 'buddypress' ) . '" id="crop-v1-img" /></div>';
300
+
301
+ // Preview
302
+ echo '<p class="crop-preview"><strong>' . __('Crop Preview', 'buddypress') . '</strong></p>';
303
+ echo '<div id="crop-preview-v1" class="crop-preview"></div>';
304
+
305
+ // Hidden form fields
306
+ echo '<input type="hidden" id="v1_x1" name="v1_x1" value="" />';
307
+ echo '<input type="hidden" id="v1_y1" name="v1_y1" value="" />';
308
+ echo '<input type="hidden" id="v1_x2" name="v1_x2" value="" />';
309
+ echo '<input type="hidden" id="v1_y2" name="v1_y2" value="" />';
310
+ echo '<input type="hidden" id="v1_w" name="v1_w" value="" />';
311
+ echo '<input type="hidden" id="v1_h" name="v1_h" value="" />';
312
+
313
+ // V2 UI (optional)
314
+ if (CORE_AVATAR_V2_W !== false && CORE_AVATAR_V2_H !== false) {
315
+ // Continue button (v1 => v2)
316
+ echo '<p class="submit"><input type="button" name="avatar_continue" id="avatar_continue" value="' . __('Crop Thumbnail &amp; Continue', 'buddypress') . '" onclick="cropAndContinue();" /></p>';
317
+ echo '</div>';
318
+
319
+ echo '<div id="avatar_v2" style="display: none">';
320
+ echo '<h4>' . __('Full Size Avatar', 'buddypress') . '</h4>';
321
+ echo '<p>' . __('Please crop a full size version of your avatar.', 'buddypress') . '</p>';
322
+
323
+ // Canvas
324
+ echo '<div id="crop-v2" class="crop-img"><img src="' . $src . '" ' . $size[3] . ' border="0" alt="' . __('Select the area to crop', 'buddypress' ) . '" id="crop-v2-img" /></div>';
325
+
326
+ // Preview
327
+ echo '<p class="crop-preview"><strong>' . __('Crop Preview', 'buddypress') . '</strong></p>';
328
+ echo '<div id="crop-preview-v2" class="crop-preview"></div>';
329
+
330
+ // Hidden form fields
331
+ echo '<input type="hidden" id="v2_x1" name="v2_x1" value="" />';
332
+ echo '<input type="hidden" id="v2_y1" name="v2_y1" value="" />';
333
+ echo '<input type="hidden" id="v2_x2"name="v2_x2" value="" />';
334
+ echo '<input type="hidden" id="v2_y2"name="v2_y2" value="" />';
335
+ echo '<input type="hidden" id="v2_w" name="v2_w" value="" />';
336
+ echo '<input type="hidden" id="v2_h" name="v2_h" value="" />';
337
+
338
+ // Final button to process everything
339
+ echo '<p class="submit"><input type="submit" id="crop-complete" name="save" value="' . __('Crop Full Size &amp; Save', 'buddypress') . '" /></p>';
340
+ echo '</div>';
341
+ } else {
342
+ // Close out v1 DIV
343
+ echo '</div>';
344
+
345
+ // Final button to process everything
346
+ echo '<p class="submit"><input type="submit" name="save" value="' . __('Crop Full Size &amp; Save', 'buddypress') . '" /></p>';
347
+ }
348
+
349
+ do_action( 'bp_core_render_avatar_cropper', $original, $new, $action );
350
+
351
+ if ( !$no_form_tag )
352
+ echo '</form>';
353
+ ?>
354
+ <script type="text/javascript" charset="utf-8">
355
+ jQuery(document).ready(function(){
356
+ v1Cropper();
357
+ });
358
+ </script>
359
+ <?php
360
+ }
361
+
362
+ function bp_core_check_crop( $original, $canvas ) {
363
+ if ( is_file($original) && is_readable($original) && is_file($canvas) && is_readable($canvas) )
364
+ return true;
365
+
366
+ return false;
367
+ }
368
+
369
+ function bp_core_avatar_cropstore( $source, $canvas, $v1_x1, $v1_y1, $v1_w, $v1_h, $v2_x1, $v2_y1, $v2_w, $v2_h, $from_signup = false, $filename = 'avatar', $item_id = null ) {
370
+ $size = getimagesize($source);
371
+ $dims = getimagesize($canvas);
372
+
373
+ // Figure out multiplier for scaling
374
+ $multi = $size[0] / $dims[0];
375
+
376
+ if ( $item_id )
377
+ $filename_item_id = $item_id . '-';
378
+
379
+ if ( $filename != 'avatar' ) {
380
+ $v1_filename = '-' . $filename_item_id . $filename . '-thumb';
381
+ $v2_filename = '-' . $filename_item_id . $filename . '-full';
382
+ } else {
383
+ $v1_filename = '-avatar1';
384
+ $v2_filename = '-avatar2';
385
+ }
386
+
387
+ $v1_filename = apply_filters( 'bp_avatar_v1_filename', $v1_filename );
388
+ $v2_filename = apply_filters( 'bp_avatar_v2_filename', $v2_filename );
389
+
390
+ // Perform v1 crop
391
+ $v1_dest = apply_filters( 'bp_avatar_v1_dest', dirname($source) . '/' . preg_replace('!(\.[^.]+)?$!', $v1_filename . '$1', basename($source), 1), $source );
392
+
393
+ if ( $from_signup )
394
+ $v1_out = wp_crop_image( $source, $v1_x1, $v1_y1, $v1_w, $v1_h, CORE_AVATAR_V1_W, CORE_AVATAR_V1_H, false, $v1_dest );
395
+ else
396
+ $v1_out = wp_crop_image( $source, ($v1_x1 * $multi), ($v1_y1 * $multi), ($v1_w * $multi), ($v1_h * $multi), CORE_AVATAR_V1_W, CORE_AVATAR_V1_H, false, $v1_dest );
397
+
398
+ // Perform v2 crop
399
+ if ( CORE_AVATAR_V2_W !== false && CORE_AVATAR_V2_H !== false ) {
400
+ $v2_dest = apply_filters( 'bp_avatar_v2_dest', dirname($source) . '/' . preg_replace('!(\.[^.]+)?$!', $v2_filename . '$1', basename($source), 1), $source );
401
+
402
+ if ( $from_signup )
403
+ $v2_out = wp_crop_image( $source, $v2_x1, $v2_y1, $v2_w, $v2_h, CORE_AVATAR_V2_W, CORE_AVATAR_V2_H, false, $v2_dest );
404
+ else
405
+ $v2_out = wp_crop_image( $source, ($v2_x1 * $multi), ($v2_y1 * $multi), ($v2_w * $multi), ($v2_h * $multi), CORE_AVATAR_V2_W, CORE_AVATAR_V2_H, false, $v2_dest );
406
+ }
407
+
408
+ // Clean up canvas and original images used during cropping
409
+ foreach ( array( str_replace( '..', '', $source ), str_replace( '..', '', $canvas) ) as $f ) {
410
+ @unlink($f);
411
+ }
412
+
413
+ $dir = $source;
414
+
415
+ do {
416
+ $dir = dirname($dir);
417
+ @rmdir($dir); // will fail on non-empty directories
418
+ } while ( substr_count($dir, '/') >= 2 && stristr($dir, ABSPATH) );
419
+
420
+ return apply_filters( 'bp_core_avatar_cropstore', array('v1_out' => $v1_out, 'v2_out' => $v2_out) );
421
+ }
422
+
423
+ function bp_core_avatar_save( $vars, $user_id = false ) {
424
+ if ( !$user_id )
425
+ $user_id = get_current_user_id();
426
+
427
+ $old = get_usermeta( $user_id, 'bp_core_avatar_v1_path' );
428
+ $v1_href = apply_filters( 'bp_avatar_v1_href', str_replace( array(ABSPATH), array($src), $vars['v1_out'] ), $src, $vars['v1_out'] );
429
+ update_usermeta( $user_id, 'bp_core_avatar_v1', $v1_href );
430
+ update_usermeta( $user_id, 'bp_core_avatar_v1_path', $vars['v1_out'] );
431
+ @unlink($old); // Removing old avatar
432
+
433
+ if ( CORE_AVATAR_V2_W !== false && CORE_AVATAR_V2_H !== false ) {
434
+ $old = get_usermeta( $user_id, 'bp_core_avatar_v2_path' );
435
+ $v2_href = apply_filters( 'bp_avatar_v2_href', str_replace( array(ABSPATH), array($src), $vars['v2_out'] ), $src, $vars['v2_out'] );
436
+ update_usermeta( $user_id, 'bp_core_avatar_v2', $v2_href );
437
+ update_usermeta( $user_id, 'bp_core_avatar_v2_path', $vars['v2_out'] );
438
+ @unlink($old); // Removing old avatar
439
+ }
440
+
441
+ do_action( 'bp_core_avatar_save', $user_id, $old, $v1_href, $vars['v1_out'] );
442
+ }
443
+
444
+ function bp_core_render_avatar_upload_form($action, $no_form_tag = false) {
445
+ if ( !$no_form_tag ) { ?>
446
+ <form method="post" action="<?php echo $action ?>" enctype="multipart/form-data" id="avatar-upload">
447
+ <?php } ?>
448
+ <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo CORE_MAX_FILE_SIZE; ?>" />
449
+ <input type="hidden" name="slick_avatars_action" value="upload" />
450
+ <input type="hidden" name="action" value="slick_avatars" />
451
+ <input type="hidden" name="nonce" value="<?php echo wp_create_nonce('slick_avatars'); ?>" />
452
+ <input type="file" name="file" id="file" />
453
+ <input type="submit" name="upload" id="upload" value="<?php _e( 'Upload Photo', 'buddypress' ) ?>"/>
454
+
455
+ <?php do_action( 'bp_core_render_avatar_upload_form' ) ?>
456
+
457
+ <?php if ( !$no_form_tag ) { ?>
458
+ </form>
459
+ <?php
460
+ }
461
+ }
462
+
463
+ function bp_core_delete_avatar() {
464
+ $user_id = get_current_user_id();
465
+
466
+ $old_v1 = get_usermeta( $user_id, 'bp_core_avatar_v1_path' );
467
+ $old_v2 = get_usermeta( $user_id, 'bp_core_avatar_v2_path' );
468
+
469
+ delete_usermeta( $user_id, 'bp_core_avatar_v1_path' );
470
+ delete_usermeta( $user_id, 'bp_core_avatar_v2_path' );
471
+
472
+ delete_usermeta( $user_id, 'bp_core_avatar_v1' );
473
+ delete_usermeta( $user_id, 'bp_core_avatar_v2' );
474
+
475
+ // Remove the actual images
476
+ @unlink($old_v1);
477
+ @unlink($old_v2);
478
+
479
+ do_action( 'bp_core_delete_avatar', $user_id, $old_v1, $old_v2 );
480
+ }
481
+
482
+ function bp_core_ap_die( $msg ) {
483
+ global $bp;
484
+ echo '<p><strong>' . $msg . '</strong></p>';
485
+ echo '<p><a href="' . $bp->loggedin_user->domain . $bp->profile->slug . '/change-avatar">' . __('Try Again', 'buddypress') . '</a></p>';
486
+ echo '</div>';
487
+ exit;
488
+ }
489
+
490
+ function bp_core_thumb_error( $str ) {
491
+ if ( !is_string($str) ) {
492
+ return false;
493
+ } else {
494
+ return preg_match( '/(filetype|invalid|not found)/is', $str );
495
+ }
496
+ }
497
+
498
+ ?>
bp-core/bp-core-catchuri.php ADDED
@@ -0,0 +1,302 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Based on contributions from: Chris Taylor - http://www.stillbreathing.co.uk/
4
+ Modified for BuddyPress by: Andy Peatling - http://apeatling.wordpress.com/
5
+ */
6
+
7
+ /**
8
+ * bp_core_set_uri_globals()
9
+ *
10
+ * Analyzes the URI structure and breaks it down into parts for use in code.
11
+ * The idea is that BuddyPress can use complete custom friendly URI's without the
12
+ * user having to add new re-write rules.
13
+ *
14
+ * Future custom components would then be able to use their own custom URI structure.
15
+ *
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
+ * - $current_component: string 'profile'
23
+ * - $current_action: string 'edit'
24
+ * - $action_variables: array ['group', 5]
25
+ *
26
+ * @package BuddyPress Core
27
+ */
28
+ function bp_core_set_uri_globals() {
29
+ global $current_component, $current_action, $action_variables;
30
+ global $displayed_user_id;
31
+ global $is_member_page, $is_new_friend;
32
+ global $bp_unfiltered_uri;
33
+ global $bp, $current_blog;
34
+
35
+ /* Only catch URI's on the root blog */
36
+ if ( BP_ROOT_BLOG != (int) $current_blog->blog_id )
37
+ return false;
38
+
39
+ if ( strpos( $_SERVER['REQUEST_URI'], 'bp-core-ajax-handler.php' ) )
40
+ $path = bp_core_referrer();
41
+ else
42
+ $path = clean_url( $_SERVER['REQUEST_URI'] );
43
+
44
+ $path = apply_filters( 'bp_uri', $path );
45
+
46
+ // Firstly, take GET variables off the URL to avoid problems,
47
+ // they are still registered in the global $_GET variable */
48
+ $noget = substr( $path, 0, strpos( $path, '?' ) );
49
+ if ( $noget != '' ) $path = $noget;
50
+
51
+ /* Fetch the current URI and explode each part seperated by '/' into an array */
52
+ $bp_uri = explode( "/", $path );
53
+
54
+ /* Take empties off the end of complete URI */
55
+ if ( empty( $bp_uri[count($bp_uri) - 1] ) )
56
+ array_pop( $bp_uri );
57
+
58
+ /* Take empties off the start of complete URI */
59
+ if ( empty( $bp_uri[0] ) )
60
+ array_shift( $bp_uri );
61
+
62
+ /* Get total URI segment count */
63
+ $bp_uri_count = count( $bp_uri ) - 1;
64
+ $is_member_page = false;
65
+
66
+ /* Set the indexes, these are incresed by one if we are not on a VHOST install */
67
+ $component_index = 0;
68
+ $action_index = $component_index + 1;
69
+
70
+ // If this is a WordPress page, return from the function.
71
+ if ( is_page( $bp_uri[$component_index] ) )
72
+ return false;
73
+
74
+ /* Get site path items */
75
+ $paths = explode( '/', bp_core_get_site_path() );
76
+
77
+ /* Take empties off the end of path */
78
+ if ( empty( $paths[count($paths) - 1] ) )
79
+ array_pop( $paths );
80
+
81
+ /* Take empties off the start of path */
82
+ if ( empty( $paths[0] ) )
83
+ array_shift( $paths );
84
+
85
+ for ( $i = 0; $i < $bp_uri_count; $i++ ) {
86
+ if ( in_array( $bp_uri[$i], $paths )) {
87
+ unset( $bp_uri[$i] );
88
+ }
89
+ }
90
+
91
+ /* Reset the keys by merging with an empty array */
92
+ $bp_uri = array_merge( array(), $bp_uri );
93
+ $bp_unfiltered_uri = $bp_uri;
94
+
95
+ /* Catch a member page and set the current member ID */
96
+ if ( $bp_uri[0] == BP_MEMBERS_SLUG || in_array( 'bp-core-ajax-handler.php', $bp_uri ) ) {
97
+ $is_member_page = true;
98
+ $is_root_component = true;
99
+
100
+ // We are within a member page, set up user id globals
101
+ $displayed_user_id = bp_core_get_displayed_userid( $bp_uri[1] );
102
+
103
+ unset($bp_uri[0]);
104
+ unset($bp_uri[1]);
105
+
106
+ // if the get variable 'new' is set this the first visit to a new friends profile.
107
+ // this means we need to delete friend acceptance notifications, so we set a flag of is_new_friend.
108
+ if ( isset($_GET['new']) ) {
109
+ $is_new_friend = 1;
110
+ unset($bp_uri[2]);
111
+ }
112
+
113
+ /* Reset the keys by merging with an empty array */
114
+ $bp_uri = array_merge( array(), $bp_uri );
115
+ }
116
+
117
+ if ( !isset($is_root_component) )
118
+ $is_root_component = in_array( $bp_uri[0], $bp->root_components );
119
+
120
+ if ( 'no' == VHOST && !$is_root_component ) {
121
+ $component_index++;
122
+ $action_index++;
123
+ }
124
+
125
+ /* Set the current component */
126
+ $current_component = $bp_uri[$component_index];
127
+
128
+ /* Set the current action */
129
+ $current_action = $bp_uri[$action_index];
130
+
131
+ /* Set the entire URI as the action variables, we will unset the current_component and action in a second */
132
+ $action_variables = $bp_uri;
133
+
134
+ /* Unset the current_component and action from action_variables */
135
+ unset($action_variables[$component_index]);
136
+ unset($action_variables[$action_index]);
137
+
138
+ /* Remove the username from action variables if this is not a VHOST install */
139
+ if ( 'no' == VHOST && !$is_root_component )
140
+ array_shift($action_variables);
141
+
142
+ /* Reset the keys by merging with an empty array */
143
+ $action_variables = array_merge( array(), $action_variables );
144
+
145
+ //var_dump($current_component, $current_action, $action_variables);
146
+ }
147
+ add_action( 'plugins_loaded', 'bp_core_set_uri_globals', 3 );
148
+
149
+ /**
150
+ * bp_catch_uri()
151
+ *
152
+ * Takes either a single page name or array of page names and
153
+ * loads the first template file that can be found.
154
+ *
155
+ * Please don't call this function directly anymore, use: bp_core_load_template()
156
+ *
157
+ * @package BuddyPress Core
158
+ * @global $bp_path BuddyPress global containing the template file names to use.
159
+ * @param $pages Template file names to use.
160
+ * @uses add_action() Hooks a function on to a specific action
161
+ */
162
+ function bp_catch_uri( $pages, $skip_blog_check = false ) {
163
+ global $bp_path, $bp_skip_blog_check;
164
+
165
+ $bp_skip_blog_check = $skip_blog_check;
166
+
167
+ $bp_path = $pages;
168
+
169
+ if ( !bp_is_blog_page() ) {
170
+ remove_action( 'template_redirect', 'redirect_canonical' );
171
+ }
172
+ add_action( 'template_redirect', 'bp_core_do_catch_uri', 2 );
173
+ }
174
+
175
+ /**
176
+ * bp_core_do_catch_uri()
177
+ *
178
+ * Loads the first template file found based on the $bp_path global.
179
+ *
180
+ * @package BuddyPress Core
181
+ * @global $bp_path BuddyPress global containing the template file names to use.
182
+ */
183
+ function bp_core_do_catch_uri() {
184
+ global $bp_path, $bp, $wpdb;
185
+ global $current_blog, $bp_skip_blog_check;
186
+ global $bp_no_status_set;
187
+ global $wp_query;
188
+
189
+ $pages = $bp_path;
190
+
191
+ /* Don't hijack any URLs on blog pages */
192
+ if ( !$bp_skip_blog_check ) {
193
+ if ( bp_is_blog_page() )
194
+ return false;
195
+ }
196
+
197
+ /* Make sure this is not reported as a 404 */
198
+ if ( !$bp_no_status_set ) {
199
+ status_header( 200 );
200
+ $wp_query->is_404 = false;
201
+
202
+ if ( $bp->current_component != BP_HOME_BLOG_SLUG )
203
+ $wp_query->is_page = true;
204
+ }
205
+
206
+ if ( is_array( $pages ) ) {
207
+ foreach( $pages as $page ) {
208
+ if ( file_exists( TEMPLATEPATH . "/" . $page . ".php" ) ) {
209
+ load_template( TEMPLATEPATH . "/" . $page . ".php" );
210
+ }
211
+ }
212
+ } else {
213
+ if ( file_exists( TEMPLATEPATH . "/" . $pages . ".php" ) ) {
214
+ load_template( TEMPLATEPATH . "/" . $pages . ".php" );
215
+ } else {
216
+ if ( file_exists( TEMPLATEPATH . "/404.php" ) ) {
217
+ status_header( 404 );
218
+ load_template( TEMPLATEPATH . "/404.php" );
219
+ } else {
220
+ wp_die( __( '<strong>You do not have any BuddyPress themes installed.</strong><br />Please move "/wp-content/plugins/buddypress/bp-themes/" to "/wp-content/bp-themes/" and refresh this page. You can <a href="http://buddypress.org/extend/themes/">download more themes here</a>.', 'buddypress' ) );
221
+ }
222
+ }
223
+ }
224
+ die;
225
+ }
226
+
227
+ function bp_core_catch_no_access() {
228
+ global $bp, $bp_path, $bp_unfiltered_uri, $bp_no_status_set;
229
+
230
+ // If bp_core_redirect() and $bp_no_status_set is true,
231
+ // we are redirecting to an accessable page, so skip this check.
232
+ if ( $bp_no_status_set )
233
+ return false;
234
+
235
+ // If this user does not exist, redirect to the root domain.
236
+ if ( !$bp->displayed_user->id && $bp_unfiltered_uri[0] == BP_MEMBERS_SLUG && isset($bp_unfiltered_uri[1]) )
237
+ bp_core_redirect( $bp->root_domain );
238
+
239
+ if ( !$bp_path && !bp_is_blog_page() ) {
240
+ if ( is_user_logged_in() ) {
241
+ wp_redirect( $bp->loggedin_user->domain );
242
+ } else {
243
+ wp_redirect( site_url( 'wp-login.php?redirect_to=' . site_url() . $_SERVER['REQUEST_URI'] ) );
244
+ }
245
+ }
246
+ }
247
+ add_action( 'wp', 'bp_core_catch_no_access', 10 );
248
+
249
+ /**
250
+ * bp_core_catch_profile_uri()
251
+ *
252
+ * If the extended profiles component is not installed we still need
253
+ * to catch the /profile URI's and display whatever we have installed.
254
+ *
255
+ */
256
+ function bp_core_catch_profile_uri() {
257
+ global $bp;
258
+
259
+ if ( !function_exists('xprofile_install') )
260
+ bp_core_load_template( apply_filters( 'bp_core_template_display_profile', 'profile/index' ) );
261
+ }
262
+
263
+ function bp_core_force_buddypress_theme( $template ) {
264
+ global $is_member_page, $bp;
265
+
266
+ $member_theme = get_site_option( 'active-member-theme' );
267
+
268
+ if ( empty( $member_theme ) )
269
+ $member_theme = 'bpmember';
270
+
271
+ if ( $is_member_page ) {
272
+
273
+ add_filter( 'theme_root', 'bp_core_set_member_theme_root' );
274
+ add_filter( 'theme_root_uri', 'bp_core_set_member_theme_root_uri' );
275
+
276
+ return $member_theme;
277
+ } else {
278
+ return $template;
279
+ }
280
+ }
281
+ add_filter( 'template', 'bp_core_force_buddypress_theme', 1, 1 );
282
+
283
+ function bp_core_force_buddypress_stylesheet( $stylesheet ) {
284
+ global $is_member_page;
285
+
286
+ $member_theme = get_site_option( 'active-member-theme' );
287
+
288
+ if ( empty( $member_theme ) )
289
+ $member_theme = 'bpmember';
290
+
291
+ if ( $is_member_page ) {
292
+ add_filter( 'theme_root', 'bp_core_set_member_theme_root' );
293
+ add_filter( 'theme_root_uri', 'bp_core_set_member_theme_root_uri' );
294
+
295
+ return $member_theme;
296
+ } else {
297
+ return $stylesheet;
298
+ }
299
+ }
300
+ add_filter( 'stylesheet', 'bp_core_force_buddypress_stylesheet', 1, 1 );
301
+
302
+ ?>
bp-core/bp-core-classes.php ADDED
@@ -0,0 +1,363 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
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 {
16
+ var $id;
17
+ var $avatar;
18
+ var $avatar_thumb;
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
+
29
+ var $status;
30
+ var $status_last_updated;
31
+
32
+ /* Extras */
33
+ var $total_friends;
34
+ var $total_blogs;
35
+ var $total_groups;
36
+
37
+ function bp_core_user( $user_id, $populate_extras = false ) {
38
+ if ( $user_id ) {
39
+ $this->id = $user_id;
40
+ $this->populate();
41
+
42
+ if ( $populate_extras )
43
+ $this->populate_extras();
44
+ }
45
+ }
46
+
47
+ /**
48
+ * populate()
49
+ *
50
+ * Populate the instantiated class with data based on the User ID provided.
51
+ *
52
+ * @package BuddyPress Core
53
+ * @global $userdata WordPress user data for the current logged in user.
54
+ * @uses bp_core_get_userurl() Returns the URL with no HTML markup for a user based on their user id
55
+ * @uses bp_core_get_userlink() Returns a HTML formatted link for a user with the user's full name as the link text
56
+ * @uses bp_core_get_user_email() Returns the email address for the user based on user ID
57
+ * @uses get_usermeta() WordPress function returns the value of passed usermeta name from usermeta table
58
+ * @uses bp_core_get_avatar() Returns HTML formatted avatar for a user
59
+ * @uses bp_profile_last_updated_date() Returns the last updated date for a user.
60
+ */
61
+ function populate() {
62
+ $this->user_url = bp_core_get_userurl( $this->id );
63
+ $this->user_link = bp_core_get_userlink( $this->id );
64
+
65
+ $this->fullname = bp_fetch_user_fullname( $this->id, false );
66
+ $this->email = bp_core_get_user_email( $this->id );
67
+ $this->last_active = bp_core_get_last_activity( get_usermeta( $this->id, 'last_activity' ), __( 'active %s ago', 'buddypress' ) );
68
+
69
+ $this->avatar = bp_core_get_avatar( $this->id, 2 );
70
+ $this->avatar_thumb = bp_core_get_avatar( $this->id, 1 );
71
+ $this->avatar_mini = bp_core_get_avatar( $this->id, 1, 25, 25, false );
72
+ }
73
+
74
+ function populate_extras() {
75
+ global $bp;
76
+
77
+ if ( function_exists('friends_install') ) {
78
+ $this->total_friends = BP_Friends_Friendship::total_friend_count( $this->id );
79
+
80
+ if ( $this->total_friends ) {
81
+ if ( 1 == $this->total_friends )
82
+ $this->total_friends .= ' ' . __( 'friend', 'buddypress' );
83
+ else
84
+ $this->total_friends .= ' ' . __( 'friends', 'buddypress' );
85
+
86
+ $this->total_friends = '<a href="' . $this->user_url . $bp->friends->slug . '" title="' . sprintf( __( "%s's friend list", 'buddypress' ), $this->fullname ) . '">' . $this->total_friends . '</a>';
87
+ }
88
+ }
89
+
90
+ if ( function_exists('bp_blogs_install') ) {
91
+ if ( $this->total_blogs ) {
92
+ if ( 1 == $this->total_blogs )
93
+ $this->total_blogs .= ' ' . __( 'blog', 'buddypress' );
94
+ else
95
+ $this->total_blogs .= ' ' . __( 'blogs', 'buddypress' );
96
+
97
+ $this->total_blogs = '<a href="' . $this->user_url . $bp->blogs->slug . '" title="' . sprintf( __( "%s's blog list", 'buddypress' ), $this->fullname ) . '">' . $this->total_blogs . '</a>';
98
+ }
99
+ }
100
+
101
+ if ( function_exists('groups_install') ) {
102
+ $this->total_groups = BP_Groups_Member::total_group_count( $this->id );
103
+
104
+ if ( $this->total_groups ) {
105
+ if ( 1 == $this->total_groups )
106
+ $this->total_groups .= ' ' . __( 'group', 'buddypress' );
107
+ else
108
+ $this->total_groups .= ' ' . __( 'groups', 'buddypress' );
109
+
110
+ $this->total_groups = '<a href="' . $this->user_url . $bp->groups->slug . '" title="' . sprintf( __( "%s's group list", 'buddypress' ), $this->fullname ) . '">' . $this->total_groups . '</a>';
111
+ }
112
+ }
113
+ }
114
+
115
+ /* Static Functions */
116
+
117
+ function get_newest_users( $limit = null, $page = 1 ) {
118
+ global $wpdb;
119
+
120
+ if ( $limit && $page )
121
+ $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
122
+
123
+ $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" );
124
+ $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 );
125
+
126
+ $total_users = $wpdb->get_var( $total_users_sql );
127
+ $paged_users = $wpdb->get_results( $paged_users_sql );
128
+
129
+ return array( 'users' => $paged_users, 'total' => $total_users );
130
+ }
131
+
132
+ function get_active_users( $limit = null, $page = 1 ) {
133
+ global $wpdb;
134
+
135
+ if ( $limit && $page )
136
+ $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
137
+
138
+ $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" );
139
+ $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 );
140
+
141
+ $total_users = $wpdb->get_var( $total_users_sql );
142
+ $paged_users = $wpdb->get_results( $paged_users_sql );
143
+
144
+ return array( 'users' => $paged_users, 'total' => $total_users );
145
+ }
146
+
147
+ function get_popular_users( $limit = null, $page = 1 ) {
148
+ global $wpdb;
149
+
150
+ if ( !function_exists('friends_install') )
151
+ return false;
152
+
153
+ if ( $limit && $page )
154
+ $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
155
+
156
+ $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" );
157
+ $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 );
158
+
159
+ $total_users = $wpdb->get_var( $total_users_sql );
160
+ $paged_users = $wpdb->get_results( $paged_users_sql );
161
+
162
+ return array( 'users' => $paged_users, 'total' => $total_users );
163
+ }
164
+
165
+ function get_random_users( $limit = null, $page = 1 ) {
166
+ global $wpdb, $bp;
167
+
168
+ if ( $limit && $page )
169
+ $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
170
+
171
+ $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 ) );
172
+ $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 );
173
+
174
+ $total_users = $wpdb->get_var( $total_users_sql );
175
+ $paged_users = $wpdb->get_results( $paged_users_sql );
176
+
177
+ return array( 'users' => $paged_users, 'total' => $total_users );
178
+ }
179
+
180
+ function get_online_users( $limit = null, $page = 1 ) {
181
+ global $wpdb;
182
+
183
+ if ( $limit && $page )
184
+ $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
185
+
186
+ $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" );
187
+ $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 );
188
+
189
+ $total_users = $wpdb->get_var( $total_users_sql );
190
+ $paged_users = $wpdb->get_results( $paged_users_sql );
191
+
192
+ return array( 'users' => $paged_users, 'total' => $total_users );
193
+ }
194
+
195
+ function get_alphabetical_users( $limit = null, $page = 1 ) {
196
+ global $wpdb, $bp;
197
+
198
+ if ( !function_exists( 'xprofile_install' ) )
199
+ return BP_Core_User::get_active_users( $limit, $page );
200
+
201
+ if ( $limit && $page )
202
+ $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
203
+
204
+ $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 ) );
205
+ $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 );
206
+
207
+ $total_users = $wpdb->get_var( $total_users_sql );
208
+ $paged_users = $wpdb->get_results( $paged_users_sql );
209
+
210
+ return array( 'users' => $paged_users, 'total' => $total_users );
211
+ }
212
+
213
+ function get_users_by_letter( $letter, $limit = null, $page = 1 ) {
214
+ global $wpdb, $bp;
215
+
216
+ if ( !function_exists('xprofile_install') )
217
+ return BP_Core_User::get_active_users( $limit, $page );
218
+
219
+ if ( $limit && $page )
220
+ $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
221
+
222
+ if ( strlen($letter) > 1 || is_numeric($letter) || !$letter )
223
+ return false;
224
+
225
+ like_escape($letter);
226
+
227
+ $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 );
228
+ $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 );
229
+
230
+ $total_users = $wpdb->get_var( $total_users_sql );
231
+ $paged_users = $wpdb->get_results( $paged_users_sql );
232
+
233
+ return array( 'users' => $paged_users, 'total' => $total_users );
234
+ }
235
+
236
+ function search_users( $search_terms, $limit = null, $page = 1 ) {
237
+ global $wpdb, $bp;
238
+
239
+ if ( !function_exists('xprofile_install') )
240
+ return BP_Core_User::get_active_users( $limit, $page );
241
+
242
+ if ( $limit && $page )
243
+ $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
244
+
245
+ like_escape($search_terms);
246
+
247
+ $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 pd.value LIKE '%%$search_terms%%' ORDER BY pd.value ASC", $search_terms );
248
+ $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 pd.value LIKE '%%$search_terms%%' ORDER BY pd.value ASC{$pag_sql}", $search_terms, $pag_sql );
249
+
250
+ $total_users = $wpdb->get_var( $total_users_sql );
251
+ $paged_users = $wpdb->get_results( $paged_users_sql );
252
+
253
+ return array( 'users' => $paged_users, 'total' => $total_users );
254
+ }
255
+ }
256
+
257
+
258
+ /**
259
+ * BP_Core_Notification class can be used by any component.
260
+ * It will handle the fetching, saving and deleting of a user notification.
261
+ *
262
+ * @package BuddyPress Core
263
+ */
264
+
265
+ class BP_Core_Notification {
266
+ var $id;
267
+ var $item_id;
268
+ var $secondary_item_id = null;
269
+ var $user_id;
270
+ var $component_name;
271
+ var $component_action;
272
+ var $date_notified;
273
+ var $is_new;
274
+
275
+ function bp_core_notification( $id = false ) {
276
+ if ( $id ) {
277
+ $this->id = $id;
278
+ $this->populate();
279
+ }
280
+ }
281
+
282
+ function populate() {
283
+ global $wpdb, $bp;
284
+
285
+ if ( $notification = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->core->table_name_notifications} WHERE id = %d", $this->id ) ) ) {
286
+ $this->item_id = $notification->item_id;
287
+ $this->secondary_item_id = $notification->secondary_item_id;
288
+ $this->user_id = $notification->user_id;
289
+ $this->component_name = $notification->component_name;
290
+ $this->component_action = $notification->component_action;
291
+ $this->date_notified = $notification->date_notified;
292
+ $this->is_new = $notification->is_new;
293
+ }
294
+ }
295
+
296
+ function save() {
297
+ global $wpdb, $bp;
298
+
299
+ if ( $this->id ) {
300
+ // Update
301
+ $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 );
302
+ } else {
303
+ // Save
304
+ $sql = $wpdb->prepare( "INSERT INTO {$bp->core->table_name_notifications} ( item_id, secondary_item_id, user_id, component_name, component_action, date_notified, is_new ) VALUES ( %d, %d, %d, %s, %s, FROM_UNIXTIME(%d), %d )", $this->item_id, $this->secondary_item_id, $this->user_id, $this->component_name, $this->component_action, $this->date_notified, $this->is_new );
305
+ }
306
+
307
+ if ( !$result = $wpdb->query( $sql ) )
308
+ return false;
309
+
310
+ $this->id = $wpdb->insert_id;
311
+ return true;
312
+ }
313
+
314
+ /* Static functions */
315
+
316
+ function check_access( $user_id, $notification_id ) {
317
+ global $wpdb, $bp;
318
+
319
+ 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 ) );
320
+ }
321
+
322
+ function get_all_for_user( $user_id ) {
323
+ global $wpdb, $bp;
324
+
325
+ return $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->core->table_name_notifications} WHERE user_id = %d AND is_new = 1", $user_id ) );
326
+ }
327
+
328
+ function delete_for_user_by_type( $user_id, $component_name, $component_action ) {
329
+ global $wpdb, $bp;
330
+
331
+ 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 ) );
332
+ }
333
+
334
+ function delete_for_user_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id ) {
335
+ global $wpdb, $bp;
336
+
337
+ if ( $secondary_item_id )
338
+ $secondary_item_sql = $wpdb->prepare( " AND secondary_item_id = %d", $secondary_item_id );
339
+
340
+ 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 ) );
341
+ }
342
+
343
+ function delete_from_user_by_type( $user_id, $component_name, $component_action ) {
344
+ global $wpdb, $bp;
345
+
346
+ 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 ) );
347
+ }
348
+
349
+ function delete_all_by_type( $item_id, $component_name, $component_action, $secondary_item_id ) {
350
+ global $wpdb, $bp;
351
+
352
+ if ( $component_action )
353
+ $component_action_sql = $wpdb->prepare( "AND component_action = %s", $compoennt_action );
354
+
355
+ if ( $secondary_item_id )
356
+ $secondary_item_sql = $wpdb->prepare( "AND secondary_item_id = %d", $secondary_item_id );
357
+
358
+ 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 ) );
359
+ }
360
+ }
361
+
362
+
363
+ ?>
bp-core/bp-core-cssjs.php ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * bp_core_add_js()
4
+ *
5
+ * Add the JS required by the core, as well as shared JS used by other components.
6
+ * [TODO] This needs to use wp_enqueue_script()
7
+ *
8
+ * @package BuddyPress Core
9
+ * @uses get_option() Selects a site setting from the DB.
10
+ */
11
+ function bp_core_add_js() {
12
+ wp_enqueue_script( 'jquery' );
13
+ wp_enqueue_script( 'jquery-livequery-pack', BP_PLUGIN_URL . '/bp-core/js/jquery/jquery.livequery.pack.js', 'jquery' );
14
+ wp_enqueue_script( 'bp-general-js', BP_PLUGIN_URL . '/bp-core/js/general.js' );
15
+ }
16
+ add_action( 'wp', 'bp_core_add_js' );
17
+ add_action( 'admin_menu', 'bp_core_add_js' );
18
+
19
+ /**
20
+ * bp_core_add_ajax_js()
21
+ *
22
+ * Add the reference to ajaxurl used by all ajax functionality in BuddyPress.
23
+ *
24
+ * @package BuddyPress Core
25
+ * @uses get_option() Selects a site setting from the DB.
26
+ */
27
+ function bp_core_add_ajax_js() {
28
+ echo
29
+ '<script type="text/javascript">var ajaxurl = "' . BP_PLUGIN_URL . '/bp-core/bp-core-ajax-handler.php";</script>
30
+ ';
31
+ }
32
+ add_action( 'wp_head', 'bp_core_add_ajax_js' );
33
+
34
+ /**
35
+ * bp_core_add_css()
36
+ *
37
+ * Add the CSS required by all BP components, regardless of the current theme.
38
+ *
39
+ * @package BuddyPress Core
40
+ * @uses get_option() Selects a site setting from the DB.
41
+ */
42
+ function bp_core_add_css() {
43
+ // Enable a sitewide CSS file that will apply styles to both the home blog theme
44
+ // and the member theme.
45
+ if ( file_exists( WP_CONTENT_DIR . '/themes/' . get_blog_option( 1, 'stylesheet' ) . '/css/site-wide.css' ) )
46
+ wp_enqueue_style( 'site-wide-styles', WP_CONTENT_URL . '/themes/' . get_blog_option( 1, 'stylesheet' ) . '/css/site-wide.css' );
47
+
48
+ wp_print_styles();
49
+ }
50
+ add_action( 'wp_head', 'bp_core_add_css', 2 );
51
+
52
+ /**
53
+ * bp_core_admin_bar_css()
54
+ *
55
+ * Add the CSS required for the global admin bar.
56
+ *
57
+ * @package BuddyPress Core
58
+ */
59
+ function bp_core_admin_bar_css() {
60
+ if ( defined( 'BP_DISABLE_ADMIN_BAR') )
61
+ return false;
62
+
63
+ if ( is_user_logged_in() || ( !(int)get_site_option( 'hide-loggedout-adminbar' ) && !is_user_logged_in() ) ) {
64
+ wp_enqueue_style( 'bp-admin-bar', BP_PLUGIN_URL . '/bp-core/css/admin-bar.css' );
65
+
66
+ if ( 'rtl' == get_bloginfo('text_direction') && file_exists( BP_PLUGIN_DIR . '/bp-core/css/admin-bar-rtl.css' ) )
67
+ wp_enqueue_style( 'bp-admin-bar-rtl', BP_PLUGIN_URL . '/bp-core/css/admin-bar-rtl.css' );
68
+ }
69
+ wp_print_styles();
70
+ }
71
+ add_action( 'wp_head', 'bp_core_admin_bar_css', 1 );
72
+
73
+ /**
74
+ * bp_core_add_structure_css()
75
+ *
76
+ * Add the CSS to add layout structure to BP pages in any WordPress theme.
77
+ *
78
+ * @package BuddyPress Core
79
+ * @uses get_option() Selects a site setting from the DB.
80
+ */
81
+ function bp_core_add_structure_css() {
82
+ /* Enqueue the structure CSS file to give basic positional formatting for components */
83
+ wp_enqueue_style( 'bp-core-structure', BP_PLUGIN_URL . '/bp-core/css/structure.css' );
84
+ }
85
+ add_action( 'bp_styles', 'bp_core_add_structure_css' );
86
+
87
+ /**
88
+ * bp_core_add_admin_js()
89
+ *
90
+ * Add the JS needed for all components in the admin area.
91
+ *
92
+ * @package BuddyPress Core
93
+ * @uses get_option() Selects a site setting from the DB.
94
+ */
95
+ function bp_core_add_admin_js() {
96
+ if ( false !== strpos( $_GET['page'], 'bp-core' ) ) {
97
+ wp_enqueue_script( 'bp-account-admin-js', BP_PLUGIN_URL . '/bp-core/js/account-admin.js' );
98
+ }
99
+
100
+ if ( false !== strpos( $_GET['page'], 'bp-core/admin-mods' ) ) {
101
+ wp_enqueue_script('password-strength-meter');
102
+ }
103
+ }
104
+ add_action( 'admin_menu', 'bp_core_add_admin_js' );
105
+
106
+ /**
107
+ * bp_core_add_admin_css()
108
+ *
109
+ * Add the CSS needed for all components in the admin area.
110
+ *
111
+ * @package BuddyPress Core
112
+ * @uses get_option() Selects a site setting from the DB.
113
+ */
114
+ function bp_core_add_admin_css() {
115
+ if ( defined( 'BP_DISABLE_ADMIN_BAR') )
116
+ return false;
117
+
118
+ wp_enqueue_style( 'bp-admin-bar', BP_PLUGIN_URL . '/bp-core/css/admin-bar.css' );
119
+ }
120
+ add_action( 'admin_menu', 'bp_core_add_admin_css' );
121
+
122
+ /**
123
+ * bp_core_add_cropper_js()
124
+ *
125
+ * Adds the JS needed for general avatar cropping.
126
+ *
127
+ * @package BuddyPress Core
128
+ */
129
+ function bp_core_add_cropper_js() {
130
+ ?>
131
+ <script type="text/javascript">
132
+ function cropAndContinue() {
133
+ jQuery('#avatar_v1').slideUp();
134
+ jQuery('#avatar_v2').slideDown('normal', function(){
135
+ v2Cropper();
136
+ });
137
+ }
138
+
139
+ function v1Cropper() {
140
+ v1Crop = new Cropper.ImgWithPreview(
141
+ 'crop-v1-img',
142
+ {
143
+ ratioDim: { x: <?php echo round(CORE_AVATAR_V1_W / CORE_AVATAR_V1_H, 5); ?>, y: 1 },
144
+ minWidth: <?php echo CORE_AVATAR_V1_W; ?>,
145
+ minHeight: <?php echo CORE_AVATAR_V1_H; ?>,
146
+ prevWidth: <?php echo CORE_AVATAR_V1_W; ?>,
147
+ prevHeight: <?php echo CORE_AVATAR_V1_H; ?>,
148
+ onEndCrop: onEndCropv1,
149
+ previewWrap: 'crop-preview-v1'
150
+ }
151
+ );
152
+ }
153
+
154
+ function onEndCropv1(coords, dimensions) {
155
+ jQuery('#v1_x1').val(coords.x1);
156
+ jQuery('#v1_y1').val(coords.y1);
157
+ jQuery('#v1_x2').val(coords.x2);
158
+ jQuery('#v1_y2').val(coords.y2);
159
+ jQuery('#v1_w').val(dimensions.width);
160
+ jQuery('#v1_h').val(dimensions.height);
161
+ }
162
+
163
+ <?php if ( CORE_AVATAR_V2_W !== false && CORE_AVATAR_V2_H !== false ) { ?>
164
+ function v2Cropper() {
165
+ v1Crop = new Cropper.ImgWithPreview(
166
+ 'crop-v2-img',
167
+ {
168
+ ratioDim: { x: <?php echo round(CORE_AVATAR_V2_W / CORE_AVATAR_V2_H, 5); ?>, y: 1 },
169
+ minWidth: <?php echo CORE_AVATAR_V2_W; ?>,
170
+ minHeight: <?php echo CORE_AVATAR_V2_H; ?>,
171
+ prevWidth: <?php echo CORE_AVATAR_V2_W; ?>,
172
+ prevHeight: <?php echo CORE_AVATAR_V2_H; ?>,
173
+ onEndCrop: onEndCropv2,
174
+ previewWrap: 'crop-preview-v2'
175
+ }
176
+ );
177
+ }
178
+ <?php } ?>
179
+
180
+ function onEndCropv2(coords, dimensions) {
181
+ jQuery('#v2_x1').val(coords.x1);
182
+ jQuery('#v2_y1').val(coords.y1);
183
+ jQuery('#v2_x2').val(coords.x2);
184
+ jQuery('#v2_y2').val(coords.y2);
185
+ jQuery('#v2_w').val(dimensions.width);
186
+ jQuery('#v2_h').val(dimensions.height);
187
+ }
188
+ </script>
189
+ <?php
190
+ }
bp-core/bp-core-notifications.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
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;
12
+ $notification->component_name = $component_name;
13
+ $notification->component_action = $component_action;
14
+ $notification->date_notified = $date_notified;
15
+ $notification->is_new = 1;
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
+
63
+ $item_id = ( 1 == $action_item_count ) ? $component_action_items[0]->item_id : false;
64
+ $secondary_item_id = ( 1 == $action_item_count ) ? $component_action_items[0]->secondary_item_id : false;
65
+
66
+ if ( function_exists( $bp->{$component_name}->format_notification_function ) ) {
67
+ $renderable[] = call_user_func( $bp->{$component_name}->format_notification_function, $component_action_name, $item_id, $secondary_item_id, $action_item_count );
68
+ }
69
+ }
70
+ }
71
+
72
+ return $renderable;
73
+ }
74
+
75
+ function bp_core_delete_notifications_for_user_by_type( $user_id, $component_name, $component_action ) {
76
+ return BP_Core_Notification::delete_for_user_by_type( $user_id, $component_name, $component_action );
77
+ }
78
+
79
+ function bp_core_delete_notifications_for_user_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id = false ) {
80
+ return BP_Core_Notification::delete_for_user_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id );
81
+ }
82
+
83
+ function bp_core_delete_all_notifications_by_type( $item_id, $component_name, $component_action = false, $secondary_item_id = false ) {
84
+ return BP_Core_Notification::delete_all_by_type( $item_id, $component_name, $component_action, $secondary_item_id );
85
+ }
86
+
87
+ function bp_core_delete_notifications_from_user( $user_id, $component_name, $component_action ) {
88
+ return BP_Core_Notification::delete_from_user_by_type( $user_id, $component_name, $component_action );
89
+ }
90
+
91
+ function bp_core_check_notification_access( $user_id, $notification_id ) {
92
+ if ( !BP_Core_Notification::check_access( $user_id, $notification_id ) )
93
+ return false;
94
+
95
+ return true;
96
+ }
97
+
98
+ ?>
bp-core/bp-core-settings.php ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ function bp_core_add_settings_nav() {
3
+ global $bp;
4
+
5
+ /* Add the settings navigation item */
6
+ bp_core_add_nav_item( __('Settings', 'buddypress'), 'settings', false, false );
7
+ bp_core_add_nav_default( 'settings', 'bp_core_screen_general_settings', 'general', false );
8
+
9
+ bp_core_add_subnav_item( 'settings', 'general', __('General', 'buddypress'), $bp->loggedin_user->domain . 'settings/', 'bp_core_screen_general_settings', false, bp_is_home() );
10
+ bp_core_add_subnav_item( 'settings', 'notifications', __('Notifications', 'buddypress'), $bp->loggedin_user->domain . 'settings/', 'bp_core_screen_notification_settings', false, bp_is_home() );
11
+ bp_core_add_subnav_item( 'settings', 'delete-account', __('Delete Account', 'buddypress'), $bp->loggedin_user->domain . 'settings/', 'bp_core_screen_delete_account', false, bp_is_home() );
12
+ }
13
+ add_action( 'wp', 'bp_core_add_settings_nav', 2 );
14
+ add_action( 'admin_menu', 'bp_core_add_settings_nav', 2 );
15
+
16
+ /**** GENERAL SETTINGS ****/
17
+
18
+ function bp_core_screen_general_settings() {
19
+ global $current_user, $bp_settings_updated, $pass_error;
20
+
21
+ $bp_settings_updated = false;
22
+ $pass_error = false;
23
+
24
+ if ( isset($_POST['submit']) && check_admin_referer('bp_settings_general') ) {
25
+ require_once( WPINC . '/registration.php' );
26
+
27
+ // Form has been submitted and nonce checks out, lets do it.
28
+
29
+ if ( $_POST['email'] != '' ) {
30
+ $current_user->user_email = wp_specialchars( trim( $_POST['email'] ));
31
+ }
32
+
33
+ if ( $_POST['pass1'] != '' && $_POST['pass2'] != '' ) {
34
+ if ( $_POST['pass1'] == $_POST['pass2'] && !strpos( " " . $_POST['pass1'], "\\" ) ) {
35
+ $current_user->user_pass = $_POST['pass1'];
36
+ } else {
37
+ $pass_error = true;
38
+ }
39
+ } else if ( empty( $_POST['pass1'] ) && !empty( $_POST['pass2'] ) || !empty( $_POST['pass1'] ) && empty( $_POST['pass2'] ) ) {
40
+ $pass_error = true;
41
+ } else {
42
+ unset( $current_user->user_pass );
43
+ }
44
+
45
+ if ( !$pass_error && wp_update_user( get_object_vars( $current_user ) ) )
46
+ $bp_settings_updated = true;
47
+ }
48
+
49
+ add_action( 'bp_template_title', 'bp_core_screen_general_settings_title' );
50
+ add_action( 'bp_template_content', 'bp_core_screen_general_settings_content' );
51
+
52
+ bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'plugin-template' ) );
53
+ }
54
+
55
+ function bp_core_screen_general_settings_title() {
56
+ _e( 'General Settings', 'buddypress' );
57
+ }
58
+
59
+ function bp_core_screen_general_settings_content() {
60
+ global $bp, $current_user, $bp_settings_updated, $pass_error; ?>
61
+
62
+ <?php if ( $bp_settings_updated && !$pass_error ) { ?>
63
+ <div id="message" class="updated fade">
64
+ <p><?php _e( 'Changes Saved.', 'buddypress' ) ?></p>
65
+ </div>
66
+ <?php } ?>
67
+
68
+ <?php if ( $pass_error && !$bp_settings_updated ) { ?>
69
+ <div id="message" class="error fade">
70
+ <p><?php _e( 'Your passwords did not match', 'buddypress' ) ?></p>
71
+ </div>
72
+ <?php } ?>
73
+
74
+ <form action="<?php echo $bp->loggedin_user->domain . 'settings/general' ?>" method="post" id="settings-form">
75
+ <label for="email"><?php _e( 'Account Email', 'buddypress' ) ?></label>
76
+ <input type="text" name="email" id="email" value="<?php echo $current_user->user_email ?>" class="settings-input" />
77
+
78
+ <label for="pass1"><?php _e( 'Change Password <span>(leave blank for no change)</span>', 'buddypress' ) ?></label>
79
+ <input type="password" name="pass1" id="pass1" size="16" value="" class="settings-input small" /> &nbsp;<?php _e( 'New Password', 'buddypress' ) ?>
80
+ <input type="password" name="pass2" id="pass2" size="16" value="" class="settings-input small" /> &nbsp;<?php _e( 'Repeat New Password', 'buddypress' ) ?>
81
+
82
+ <p><input type="submit" name="submit" value="<?php _e( 'Save Changes', 'buddypress' ) ?>" id="submit" class="auto"/></p>
83
+ <?php wp_nonce_field('bp_settings_general') ?>
84
+ </form>
85
+ <?php
86
+ }
87
+
88
+ /***** NOTIFICATION SETTINGS ******/
89
+
90
+ function bp_core_screen_notification_settings() {
91
+ global $current_user, $bp_settings_updated;
92
+
93
+ $bp_settings_updated = false;
94
+
95
+ if ( $_POST['submit'] && check_admin_referer('bp_settings_notifications') ) {
96
+ if ( $_POST['notifications'] ) {
97
+ foreach ( $_POST['notifications'] as $key => $value ) {
98
+ update_usermeta( (int)$current_user->id, $key, $value );
99
+ }
100
+ }
101
+
102
+ $bp_settings_updated = true;
103
+ }
104
+
105
+ add_action( 'bp_template_title', 'bp_core_screen_notification_settings_title' );
106
+ add_action( 'bp_template_content', 'bp_core_screen_notification_settings_content' );
107
+
108
+ bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'plugin-template' ) );
109
+ }
110
+
111
+ function bp_core_screen_notification_settings_title() {
112
+ _e( 'Notification Settings', 'buddypress' );
113
+ }
114
+
115
+ function bp_core_screen_notification_settings_content() {
116
+ global $bp, $current_user, $bp_settings_updated; ?>
117
+
118
+ <?php if ( $bp_settings_updated ) { ?>
119
+ <div id="message" class="updated fade">
120
+ <p><?php _e( 'Changes Saved.', 'buddypress' ) ?></p>
121
+ </div>
122
+ <?php } ?>
123
+
124
+ <form action="<?php echo $bp->loggedin_user->domain . 'settings/notifications' ?>" method="post" id="settings-form">
125
+ <h3><?php _e( 'Email Notifications', 'buddypress' ) ?></h3>
126
+ <p><?php _e( 'Send a notification by email when:', 'buddypress' ) ?></p>
127
+
128
+ <?php do_action( 'bp_notification_settings' ) ?>
129
+
130
+ <p class="submit"><input type="submit" name="submit" value="<?php _e( 'Save Changes', 'buddypress' ) ?>" id="submit" class="auto"/></p>
131
+
132
+ <?php wp_nonce_field('bp_settings_notifications') ?>
133
+
134
+ </form>
135
+ <?php
136
+ }
137
+
138
+ /**** DELETE ACCOUNT ****/
139
+
140
+ function bp_core_screen_delete_account() {
141
+ global $current_user, $bp_settings_updated, $pass_error;
142
+
143
+ if ( isset( $_POST['delete-account-button'] ) && check_admin_referer('delete-account') ) {
144
+ // delete the users account
145
+ if ( bp_core_delete_account() )
146
+ bp_core_redirect( site_url() );
147
+ }
148
+
149
+ $bp_settings_updated = false;
150
+ $pass_error = false;
151
+
152
+ if ( isset($_POST['submit']) && check_admin_referer('bp_settings_general') ) {
153
+ require_once( WPINC . '/registration.php' );
154
+
155
+ // Form has been submitted and nonce checks out, lets do it.
156
+
157
+ if ( $_POST['email'] != '' ) {
158
+ $current_user->user_email = wp_specialchars( trim( $_POST['email'] ));
159
+ }
160
+
161
+ if ( $_POST['pass1'] != '' && $_POST['pass2'] != '' ) {
162
+ if ( $_POST['pass1'] == $_POST['pass2'] && !strpos( " " . $_POST['pass1'], "\\" ) ) {
163
+ $current_user->user_pass = $_POST['pass1'];
164
+ } else {
165
+ $pass_error = true;
166
+ }
167
+ } else if ( empty( $_POST['pass1'] ) && !empty( $_POST['pass2'] ) || !empty( $_POST['pass1'] ) && empty( $_POST['pass2'] ) ) {
168
+ $pass_error = true;
169
+ } else {
170
+ unset( $current_user->user_pass );
171
+ }
172
+
173
+ if ( !$pass_error && wp_update_user( get_object_vars( $current_user ) ) )
174
+ $bp_settings_updated = true;
175
+ }
176
+
177
+ add_action( 'bp_template_title', 'bp_core_screen_delete_account_title' );
178
+ add_action( 'bp_template_content', 'bp_core_screen_delete_account_content' );
179
+
180
+ bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'plugin-template' ) );
181
+ }
182
+
183
+ function bp_core_screen_delete_account_title() {
184
+ _e( 'Delete Account', 'buddypress' );
185
+ }
186
+
187
+ function bp_core_screen_delete_account_content() {
188
+ global $bp, $current_user, $bp_settings_updated, $pass_error; ?>
189
+
190
+ <form action="<?php echo $bp->loggedin_user->domain . 'settings/delete-account'; ?>" name="account-delete-form" id="account-delete-form" class="standard-form" method="post">
191
+
192
+ <div id="message" class="info">
193
+ <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>
194
+ </div>
195
+
196
+ <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' ); ?>
197
+ <p><input type="submit" disabled="disabled" value="<?php _e( 'Delete My Account', 'buddypress' ) ?> &raquo;" id="delete-account-button" name="delete-account-button" /></p>
198
+ <?php wp_nonce_field('delete-account') ?>
199
+ </form>
200
+ <?php
201
+ }
bp-core/bp-core-signup.php ADDED
@@ -0,0 +1,420 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function bp_core_signup_set_headers() {
4
+ add_action( 'wp_head', 'bp_core_signup_register_headers' ) ;
5
+ require_once( ABSPATH . WPINC . '/registration.php' );
6
+
7
+ if( is_array( get_site_option( 'illegal_names' )) && $_GET[ 'new' ] != '' && in_array( $_GET[ 'new' ], get_site_option( 'illegal_names' ) ) == true ) {
8
+ wp_redirect( "http://{$current_site->domain}{$current_site->path}" );
9
+ die();
10
+ }
11
+ }
12
+
13
+ function bp_core_signup_do_headers() {
14
+ do_action("signup_header");
15
+ }
16
+ add_action( 'wp_head', 'bp_core_signup_do_headers' );
17
+
18
+ function bp_core_signup_register_headers() {
19
+ echo "<meta name='robots' content='noindex,nofollow' />\n";
20
+ }
21
+
22
+ function bp_core_signup_show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) {
23
+ global $current_site;
24
+
25
+ ?>
26
+ <h3><?php _e( 'Blog Details', 'buddypress' ) ?></h3>
27
+ <p id="blog-details-help">
28
+ <?php _e( "To register your first blog, just fill in the details below and your registration is complete.", 'buddypress' ) ?>
29
+ </p>
30
+
31
+ <div id="blog-details-fields">
32
+ <?php
33
+
34
+ // Blog name
35
+ if ( 'no' == constant( "VHOST" ) )
36
+ echo '<label for="blogname">' . __('Blog Name:', 'buddypress') . '</label>';
37
+ else
38
+ echo '<label for="blogname">' . __('Blog Domain:', 'buddypress') . '</label>';
39
+
40
+ if ( $errmsg = $errors->get_error_message('blogname') ) { ?>
41
+ <p class="error"><?php echo $errmsg ?></p>
42
+ <?php }
43
+
44
+ if ( 'no' == constant( "VHOST" ) ) {
45
+ echo '<span class="prefix_address">' . $current_site->domain . $current_site->path . '</span><input name="blogname" type="text" id="blogname" value="'.$blogname.'" maxlength="50" /><br />';
46
+ } else {
47
+ echo '<input name="blogname" type="text" id="blogname" value="'.$blogname.'" maxlength="50" /><span class="suffix_address">.' . $current_site->domain . $current_site->path . '</span><br />';
48
+ }
49
+
50
+ if ( !is_user_logged_in() ) {
51
+ echo '<p class="help-text">';
52
+ print '(<strong>' . __( 'Your address will be ', 'buddypress' );
53
+ if( 'no' == constant( "VHOST" ) ) {
54
+ print $current_site->domain . $current_site->path . __( 'blogname', 'buddypress' );
55
+ } else {
56
+ print __( 'domain.', 'buddypress' ) . $current_site->domain . $current_site->path;
57
+ }
58
+ echo '</strong>. ' . __( 'Must be at least 4 characters, letters and numbers only. It cannot be changed so choose carefully!)', 'buddypress' ) . '</p>';
59
+ echo '</p>';
60
+ }
61
+
62
+ // Blog Title
63
+ ?>
64
+ <label for="blog_title"><?php _e( 'Blog Title:', 'buddypress' ) ?></label>
65
+ <?php if ( $errmsg = $errors->get_error_message('blog_title') ) { ?>
66
+ <p class="error"><?php echo $errmsg ?></p>
67
+ <?php }
68
+ echo '<input name="blog_title" type="text" id="blog_title" value="'.wp_specialchars($blog_title, 1).'" /></p>';
69
+ ?>
70
+
71
+ <p>
72
+ <label for="blog_public_on"><?php _e( 'Privacy:', 'buddypress' ) ?></label>
73
+ <?php _e( 'I would like my blog to appear in search engines like Google and Technorati, and in public listings around this site.', 'buddypress' ); ?>
74
+ <label class="checkbox" for="blog_public_on">
75
+ <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 } ?> />
76
+ &nbsp;<?php _e( 'Yes', 'buddypress' ); ?>
77
+ </label>
78
+ <label class="checkbox" for="blog_public_off">
79
+ <input type="radio" id="blog_public_off" name="blog_public" value="0" <?php if( isset( $_POST['blog_public'] ) && '0' == $_POST['blog_public'] ) { ?>checked="checked"<?php } ?> />
80
+ &nbsp;<?php _e( 'No', 'buddypress' ); ?>
81
+ </label>
82
+ </p>
83
+ </div>
84
+ <?php
85
+ do_action('signup_blogform', $errors);
86
+ }
87
+
88
+ function bp_core_signup_validate_blog_form() {
89
+ $user = '';
90
+ if ( is_user_logged_in() )
91
+ $user = wp_get_current_user();
92
+
93
+ return wpmu_validate_blog_signup($_POST['blogname'], $_POST['blog_title'], $user);
94
+ }
95
+
96
+ function bp_core_signup_show_user_form($user_name = '', $user_email = '', $errors = '') {
97
+ // User name
98
+ echo '<div id="account-fields">';
99
+ echo '<label for="user_name">' . __( 'Username:', 'buddypress' ) . '</label>';
100
+ if ( $errmsg = $errors->get_error_message('user_name') ) {
101
+ echo '<p class="error">'.$errmsg.'</p>';
102
+ }
103
+ echo '<input name="user_name" type="text" id="user_name" value="'.$user_name.'" maxlength="50" />';
104
+ echo '<p class="help-text">';
105
+ _e( '(Must be at least 4 characters, letters and numbers only.)', 'buddypress' );
106
+ echo '</p>'
107
+ ?>
108
+
109
+ <label for="user_email"><?php _e( 'Email&nbsp;Address:', 'buddypress' ) ?></label>
110
+ <?php if ( $errmsg = $errors->get_error_message('user_email') ) { ?>
111
+ <p class="error"><?php echo $errmsg ?></p>
112
+ <?php } ?>
113
+ <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>
114
+ <?php
115
+ if ( $errmsg = $errors->get_error_message('generic') ) {
116
+ echo '<p class="error">'.$errmsg.'</p>';
117
+ }
118
+ echo '</div>';
119
+
120
+ echo '<div id="extra-fields">';
121
+ do_action( 'signup_extra_fields', $errors );
122
+ echo '</div>';
123
+ }
124
+
125
+ function bp_core_signup_validate_user_form() {
126
+ return wpmu_validate_user_signup($_POST['user_name'], $_POST['user_email']);
127
+ }
128
+
129
+ function bp_core_signup_signup_another_blog($blogname = '', $blog_title = '', $errors = '') {
130
+ global $current_user, $current_site;
131
+
132
+ if ( ! is_wp_error($errors) ) {
133
+ $errors = new WP_Error();
134
+ }
135
+
136
+ // allow definition of default variables
137
+ $filtered_results = apply_filters('signup_another_blog_init', array('blogname' => $blogname, 'blog_title' => $blog_title, 'errors' => $errors ));
138
+ $blogname = $filtered_results['blogname'];
139
+ $blog_title = $filtered_results['blog_title'];
140
+ $errors = $filtered_results['errors'];
141
+
142
+ ?>
143
+ <h3><?php _e( "You're already registered!", 'buddypress' )?></h3>
144
+ <p><?php _e( 'You can still create another blog however. Fill in the form below to add another blog to your account.', 'buddypress' ) ?>
145
+
146
+
147
+ <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>
148
+
149
+ <form id="setupform" method="post" action="<?php echo site_url(BP_REGISTER_SLUG) ?>">
150
+ <input type="hidden" name="stage" value="gimmeanotherblog" />
151
+ <?php do_action( "signup_hidden_fields" ); ?>
152
+ <?php bp_core_signup_show_blog_form($blogname, $blog_title, $errors); ?>
153
+ <p>
154
+ <input id="submit" type="submit" name="submit" class="submit" value="<?php _e('Create Blog &raquo;') ?>"/>
155
+ </p>
156
+ </form>
157
+ <?php
158
+ }
159
+
160
+ function bp_core_signup_validate_another_blog_signup() {
161
+ global $wpdb, $current_user, $blogname, $blog_title, $errors, $domain, $path;
162
+ $current_user = wp_get_current_user();
163
+ if( !is_user_logged_in() )
164
+ die();
165
+
166
+ $result = bp_core_signup_validate_blog_form();
167
+ extract($result);
168
+
169
+ if ( $errors->get_error_code() ) {
170
+ bp_core_signup_signup_another_blog($blogname, $blog_title, $errors);
171
+ return false;
172
+ }
173
+
174
+ $public = (int) $_POST['blog_public'];
175
+ $meta = apply_filters('signup_create_blog_meta', array ('lang_id' => 1, 'public' => $public)); // depreciated
176
+ $meta = apply_filters( "add_signup_meta", $meta );
177
+
178
+ wpmu_create_blog( $domain, $path, $blog_title, $current_user->id, $meta, $wpdb->siteid );
179
+ bp_core_signup_confirm_another_blog_signup($domain, $path, $blog_title, $current_user->user_login, $current_user->user_email, $meta);
180
+ return true;
181
+ }
182
+
183
+ function bp_core_signup_confirm_another_blog_signup($domain, $path, $blog_title, $user_name, $user_email = '', $meta = '') {
184
+ ?>
185
+ <h2><?php printf( __( 'The blog %s is yours.', 'buddypress' ), "<a href='http://{$domain}{$path}'>{$blog_title}</a>" ) ?></h2>
186
+ <p>
187
+ <?php printf( __( '<a href="http://%1$s">http://%2$s</a> is your new blog. <a href="%3$s">Login</a> as "%4$s" using your existing password.', 'buddypress' ), $domain.$path, $domain.$path, "http://" . $domain.$path . "/wp-login.php", $user_name) ?>
188
+ </p>
189
+ <?php
190
+ do_action('signup_finished');
191
+ }
192
+
193
+ function bp_core_signup_signup_user($user_name = '', $user_email = '', $errors = '') {
194
+ global $current_site, $active_signup;
195
+
196
+ $active_signup = get_site_option( 'registration' );
197
+
198
+ if ( !is_wp_error($errors) )
199
+ $errors = new WP_Error();
200
+ if( isset( $_POST[ 'signup_for' ] ) ) {
201
+ $signup[ wp_specialchars( $_POST[ 'signup_for' ] ) ] = 'checked="checked"';
202
+ } else {
203
+ $signup[ 'blog' ] = 'checked="checked"';
204
+ }
205
+
206
+ // allow definition of default variables
207
+ $filtered_results = apply_filters('signup_user_init', array('user_name' => $user_name, 'user_email' => $user_email, 'errors' => $errors ));
208
+ $user_name = $filtered_results['user_name'];
209
+ $user_email = $filtered_results['user_email'];
210
+ $errors = $filtered_results['errors'];
211
+
212
+ ?>
213
+
214
+ <form id="setupform" method="post" action="<?php echo site_url(BP_REGISTER_SLUG) ?>">
215
+ <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>
216
+ <input type="hidden" name="stage" value="validate-user-signup" />
217
+ <?php do_action( "signup_hidden_fields" ); ?>
218
+
219
+ <?php bp_core_signup_show_user_form($user_name, $user_email, $errors); ?>
220
+
221
+ <?php if( 'blog' == $active_signup ) { ?>
222
+ <input id="signupblog" type="hidden" name="signup_for" value="blog" />
223
+ <?php } elseif( 'user' == $active_signup ) { ?>
224
+ <input id="signupblog" type="hidden" name="signup_for" value="user" />
225
+ <?php } else { ?>
226
+ <div id="blog-or-username">
227
+ <h3><?php _e( 'Create a Blog?', 'buddypress' ) ?></h3>
228
+ <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>
229
+
230
+ <div id="blog-or-username-fields">
231
+ <p>
232
+ <input id="signupblog" type="radio" name="signup_for" value="blog" <?php echo $signup['blog'] ?> />
233
+ <label class="checkbox" for="signupblog"><?php _e( 'Gimme a blog!', 'buddypress' ) ?></label>
234
+ </p>
235
+
236
+ <p>
237
+ <input id="signupuser" type="radio" name="signup_for" value="user" <?php echo $signup['user'] ?> />
238
+ <label class="checkbox" for="signupuser"><?php _e( 'Just a username, please.', 'buddypress' ) ?></label>
239
+ </p>
240
+ </div>
241
+ </div>
242
+ <?php } ?>
243
+
244
+ <input id="submit" type="submit" name="submit" class="submit" value="<?php _e('Next &raquo;') ?>"/>
245
+ </form>
246
+ <?php
247
+ }
248
+
249
+ function bp_core_signup_validate_user_signup() {
250
+ $result = bp_core_signup_validate_user_form();
251
+ extract($result);
252
+
253
+ if ( $errors->get_error_code() ) {
254
+ bp_core_signup_signup_user($user_name, $user_email, $errors);
255
+ return false;
256
+ }
257
+
258
+ if ( 'blog' == $_POST['signup_for'] ) {
259
+ bp_core_signup_signup_blog($user_name, $user_email);
260
+ return false;
261
+ }
262
+
263
+ wpmu_signup_user($user_name, $user_email, apply_filters( "add_signup_meta", array() ) );
264
+
265
+ bp_core_signup_confirm_user_signup($user_name, $user_email);
266
+ return true;
267
+ }
268
+
269
+ function bp_core_signup_confirm_user_signup($user_name, $user_email) {
270
+ ?>
271
+ <h3><?php _e( 'Congratulations, you are now registered!', 'buddypress' ) ?></h3>
272
+ <p><?php printf(__('Your new username is: %s', 'buddypress' ), $user_name) ?></p>
273
+ <p>&nbsp;</p>
274
+ <p><?php printf(__('Before you can start using your new username, <strong>you must activate it</strong>. Check your inbox at <strong>%1$s</strong> and click the link given.', 'buddypress' ), $user_email) ?></p>
275
+ <p><?php _e('If you do not activate your username within two days, you will have to sign up again.', 'buddypress' ); ?></p>
276
+ <?php
277
+ do_action('signup_finished');
278
+ }
279
+
280
+ function bp_core_signup_signup_blog($user_name = '', $user_email = '', $blogname = '', $blog_title = '', $errors = '') {
281
+ if ( !is_wp_error($errors) )
282
+ $errors = new WP_Error();
283
+
284
+ // allow definition of default variables
285
+ $filtered_results = apply_filters('signup_blog_init', array('user_name' => $user_name, 'user_email' => $user_email, 'blogname' => $blogname, 'blog_title' => $blog_title, 'errors' => $errors ));
286
+ $user_name = $filtered_results['user_name'];
287
+ $user_email = $filtered_results['user_email'];
288
+ $blogname = $filtered_results['blogname'];
289
+ $blog_title = $filtered_results['blog_title'];
290
+ $errors = $filtered_results['errors'];
291
+
292
+ if ( empty($blogname) )
293
+ $blogname = $user_name;
294
+ ?>
295
+ <form id="setupform" method="post" action="<?php echo site_url(BP_REGISTER_SLUG) ?>">
296
+ <input type="hidden" name="stage" value="validate-blog-signup" />
297
+ <input type="hidden" name="user_name" value="<?php echo $user_name ?>" />
298
+ <input type="hidden" name="user_email" value="<?php echo $user_email ?>" />
299
+ <?php do_action( "signup_hidden_fields" ); ?>
300
+ <?php bp_core_signup_show_blog_form($blogname, $blog_title, $errors); ?>
301
+ <p>
302
+ <input id="submit" type="submit" name="submit" class="submit" value="<?php _e('Signup &raquo;') ?>"/></p>
303
+ </form>
304
+ <?php
305
+ }
306
+
307
+ function bp_core_signup_validate_blog_signup() {
308
+ // Re-validate user info.
309
+ $result = wpmu_validate_user_signup($_POST['user_name'], $_POST['user_email']);
310
+ extract($result);
311
+
312
+ if ( $errors->get_error_code() ) {
313
+ bp_core_signup_signup_user($user_name, $user_email, $errors);
314
+ return false;
315
+ }
316
+
317
+ $result = wpmu_validate_blog_signup($_POST['blogname'], $_POST['blog_title']);
318
+ extract($result);
319
+
320
+ if ( $errors->get_error_code() ) {
321
+ bp_core_signup_signup_blog($user_name, $user_email, $blogname, $blog_title, $errors);
322
+ return false;
323
+ }
324
+
325
+ $public = (int) $_POST['blog_public'];
326
+ $meta = array ('lang_id' => 1, 'public' => $public);
327
+ $meta = apply_filters( "add_signup_meta", $meta );
328
+
329
+ wpmu_signup_blog($domain, $path, $blog_title, $user_name, $user_email, $meta);
330
+ bp_core_signup_confirm_blog_signup($domain, $path, $blog_title, $user_name, $user_email, $meta);
331
+ return true;
332
+ }
333
+
334
+ function bp_core_signup_confirm_blog_signup($domain, $path, $blog_title, $user_name = '', $user_email = '', $meta) {
335
+ ?>
336
+ <h3><?php _e('Congratulations, You are now registered!', 'buddypress' ) ?></h3>
337
+
338
+ <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>
339
+ <p>&nbsp;</p>
340
+
341
+ <h3><?php _e( 'Still waiting for your email?', 'buddypress' ); ?></h3>
342
+ <p>
343
+ <?php _e( "If you haven't received your email yet, there are a number of things you can do:", 'buddypress' ) ?>
344
+ <ul>
345
+ <li><p><strong><?php _e( 'Wait a little longer. Sometimes delivery of email can be delayed by processes outside of our control.', 'buddypress' ) ?></strong></p></li>
346
+ <li><p><?php _e( 'Check the junk email or spam folder of your email client. Sometime emails wind up there by mistake.', 'buddypress' ) ?></p></li>
347
+ <li><?php printf( __( "Have you entered your email correctly? We think it's %s but if you've entered it incorrectly, you won't receive it.", 'buddypress' ), $user_email) ?></li>
348
+ </ul>
349
+ </p>
350
+ <?php
351
+ do_action('signup_finished');
352
+ }
353
+
354
+ function bp_core_signup_do_signup() {
355
+ // Main
356
+ $active_signup = get_site_option( 'registration' );
357
+ if( !$active_signup )
358
+ $active_signup = 'all';
359
+
360
+ $active_signup = apply_filters( 'wpmu_active_signup', $active_signup ); // return "all", "none", "blog" or "user"
361
+
362
+ if( is_site_admin() )
363
+ echo '<div class="mu_alert">' . sprintf( __( "Greetings Site Administrator! You are currently allowing '%s' registrations. To change or disable registration go to your <a href='wp-admin/wpmu-options.php'>Options page</a>.", 'buddypress' ), $active_signup ) . '</div>';
364
+
365
+ $newblogname = isset($_GET['new']) ? strtolower(preg_replace('/^-|-$|[^-a-zA-Z0-9]/', '', $_GET['new'])) : null;
366
+
367
+ $current_user = wp_get_current_user();
368
+ if( $active_signup == "none" ) {
369
+ _e( "Registration has been disabled.", 'buddypress' );
370
+ } elseif( $active_signup == 'blog' && !is_user_logged_in() ){
371
+ if( is_ssl() ) {
372
+ $proto = 'https://';
373
+ } else {
374
+ $proto = 'http://';
375
+ }
376
+ $login_url = site_url( 'wp-login.php?redirect_to=' . site_url(BP_REGISTER_SLUG) );
377
+ echo sprintf( __( "You must first <a href=\"%s\">login</a>, and then you can create a new blog.", 'buddypress' ), $login_url );
378
+ } else {
379
+ switch ($_POST['stage']) {
380
+ case 'validate-user-signup' :
381
+ if( $active_signup == 'all' || $_POST[ 'signup_for' ] == 'blog' && $active_signup == 'blog' || $_POST[ 'signup_for' ] == 'user' && $active_signup == 'user' )
382
+ bp_core_signup_validate_user_signup();
383
+ else
384
+ _e( "User registration has been disabled.", 'buddypress' );
385
+ break;
386
+ case 'validate-blog-signup':
387
+ if( $active_signup == 'all' || $active_signup == 'blog' )
388
+ bp_core_signup_validate_blog_signup();
389
+ else
390
+ _e( "Blog registration has been disabled.", 'buddypress' );
391
+ break;
392
+ case 'gimmeanotherblog':
393
+ bp_core_signup_validate_another_blog_signup();
394
+ break;
395
+ default :
396
+ $user_email = $_POST[ 'user_email' ];
397
+ do_action( "preprocess_signup_form" ); // populate the form from invites, elsewhere?
398
+ if ( is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'blog' ) ) {
399
+ bp_core_signup_signup_another_blog($newblogname);
400
+ } elseif( is_user_logged_in() == false && ( $active_signup == 'all' || $active_signup == 'user' ) ) {
401
+ bp_core_signup_signup_user( $newblogname, $user_email );
402
+ } elseif( is_user_logged_in() == false && ( $active_signup == 'blog' ) ) {
403
+ _e( "I'm sorry. We're not accepting new registrations at this time.", 'buddypress' );
404
+ } else {
405
+ _e( "You're logged in already. No need to register again!", 'buddypress' );
406
+ }
407
+ if ($newblogname) {
408
+ if( constant( "VHOST" ) == 'no' )
409
+ $newblog = 'http://' . $current_site->domain . $current_site->path . $newblogname . '/';
410
+ else
411
+ $newblog = 'http://' . $newblogname . '.' . $current_site->domain . $current_site->path;
412
+ if ($active_signup == 'blog' || $active_signup == 'all')
413
+ printf( __( "<p><em>The blog you were looking for, <strong>%s</strong> doesn't exist but you can create it now!</em></p>", 'buddypress' ), $newblog );
414
+ else
415
+ printf( __( "<p><em>The blog you were looking for, <strong>%s</strong> doesn't exist.</em></p>", 'buddypress' ), $newblog );
416
+ }
417
+ break;
418
+ }
419
+ }
420
+ }
bp-core/bp-core-templatetags.php ADDED
@@ -0,0 +1,1127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * bp_get_nav()
4
+ * TEMPLATE TAG
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
+ *
12
+ * The function will also analyze the current component the user is in, to determine whether
13
+ * or not to highlight a particular nav item.
14
+ *
15
+ * @package BuddyPress Core
16
+ * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
17
+ */
18
+ function bp_get_nav() {
19
+ global $bp, $current_blog;
20
+
21
+ /* Sort the nav by key as the array has been put together in different locations */
22
+ $bp->bp_nav = bp_core_sort_nav_items( $bp->bp_nav );
23
+
24
+ /* Loop through each navigation item */
25
+ foreach( (array) $bp->bp_nav as $nav_item ) {
26
+ /* If the current component matches the nav item id, then add a highlight CSS class. */
27
+ if ( $bp->current_component == $nav_item['css_id'] ) {
28
+ $selected = ' class="current"';
29
+ } else {
30
+ $selected = '';
31
+ }
32
+
33
+ /* If we are viewing another person (current_userid does not equal loggedin_user->id)
34
+ then check to see if the two users are friends. if they are, add a highlight CSS class
35
+ to the friends nav item if it exists. */
36
+ if ( !bp_is_home() && $bp->displayed_user->id ) {
37
+ $selected = '';
38
+
39
+ if ( function_exists('friends_install') ) {
40
+ if ( $nav_item['css_id'] == $bp->friends->slug ) {
41
+ if ( friends_check_friendship( $bp->loggedin_user->id, $bp->displayed_user->id ) )
42
+ $selected = ' class="current"';
43
+ }
44
+ }
45
+ }
46
+
47
+ /* echo out the final list item */
48
+ echo '<li' . $selected . '><a id="my-' . $nav_item['css_id'] . '" href="' . $nav_item['link'] . '">' . $nav_item['name'] . '</a></li>';
49
+ }
50
+
51
+ /* Always add a log out list item to the end of the navigation */
52
+ if ( function_exists( 'wp_logout_url' ) ) {
53
+ echo '<li><a id="wp-logout" href="' . wp_logout_url( site_url() . $_SERVER['REQUEST_URI'] ) . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>';
54
+ } else {
55
+ echo '<li><a id="wp-logout" href="' . site_url() . '/wp-login.php?action=logout&amp;redirect_to=' . site_url() . $_SERVER['REQUEST_URI'] . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>';
56
+ }
57
+ }
58
+
59
+ /**
60
+ * bp_get_options_nav()
61
+ * TEMPLATE TAG
62
+ *
63
+ * Uses the $bp->bp_options_nav global to render out the sub navigation for the current component.
64
+ * Each component adds to its sub navigation array within its own [component_name]_setup_nav() function.
65
+ *
66
+ * This sub navigation array is the secondary level navigation, so for profile it contains:
67
+ * [Public, Edit Profile, Change Avatar]
68
+ *
69
+ * The function will also analyze the current action for the current component to determine whether
70
+ * or not to highlight a particular sub nav item.
71
+ *
72
+ * @package BuddyPress Core
73
+ * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
74
+ * @uses bp_get_user_nav() Renders the navigation for a profile of a currently viewed user.
75
+ */
76
+ function bp_get_options_nav() {
77
+ global $bp;
78
+
79
+ /***
80
+ * Only render this navigation when the logged in user is looking at one of their own pages, or we are using it to display nav
81
+ * menus for something like a group, or event.
82
+ */
83
+ if ( bp_is_home() || $bp->is_single_item ) {
84
+ if ( count( $bp->bp_options_nav[$bp->current_component] ) < 1 )
85
+ return false;
86
+
87
+ /* Loop through each navigation item */
88
+ foreach ( $bp->bp_options_nav[$bp->current_component] as $slug => $values ) {
89
+ $title = $values['name'];
90
+ $link = $values['link'];
91
+ $css_id = $values['css_id'];
92
+
93
+ /* If the current action or an action variable matches the nav item id, then add a highlight CSS class. */
94
+ if ( $slug == $bp->current_action || in_array( $slug, $bp->action_variables ) ) {
95
+ $selected = ' class="current"';
96
+ } else {
97
+ $selected = '';
98
+ }
99
+
100
+ /* echo out the final list item */
101
+ echo '<li' . $selected . '><a id="' . $css_id . '" href="' . $link . '">' . $title . '</a></li>';
102
+ }
103
+ } else {
104
+ if ( !$bp->bp_users_nav )
105
+ return false;
106
+
107
+ bp_get_user_nav();
108
+ }
109
+ }
110
+
111
+ /**
112
+ * bp_get_user_nav()
113
+ * TEMPLATE TAG
114
+ *
115
+ * Uses the $bp->bp_users_nav global to render out the user navigation when viewing another user other than
116
+ * yourself.
117
+ *
118
+ * @package BuddyPress Core
119
+ * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
120
+ */
121
+ function bp_get_user_nav() {
122
+ global $bp;
123
+
124
+ /* Sort the nav by key as the array has been put together in different locations */
125
+ $bp->bp_users_nav = bp_core_sort_nav_items( $bp->bp_users_nav );
126
+
127
+ foreach ( $bp->bp_users_nav as $user_nav_item ) {
128
+ if ( $bp->current_component == $user_nav_item['css_id'] ) {
129
+ $selected = ' class="current"';
130
+ } else {
131
+ $selected = '';
132
+ }
133
+
134
+ echo '<li' . $selected . '><a id="user-' . $user_nav_item['css_id'] . '" href="' . $user_nav_item['link'] . '">' . $user_nav_item['name'] . '</a></li>';
135
+ }
136
+ }
137
+
138
+ /**
139
+ * bp_has_options_avatar()
140
+ * TEMPLATE TAG
141
+ *
142
+ * Check to see if there is an options avatar. An options avatar is an avatar for something
143
+ * like a group, or a friend. Basically an avatar that appears in the sub nav options bar.
144
+ *
145
+ * @package BuddyPress Core
146
+ * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
147
+ */
148
+ function bp_has_options_avatar() {
149
+ global $bp;
150
+
151
+ if ( empty( $bp->bp_options_avatar ) )
152
+ return false;
153
+
154
+ return true;
155
+ }
156
+
157
+ /**
158
+ * bp_get_options_avatar()
159
+ * TEMPLATE TAG
160
+ *
161
+ * Gets the avatar for the current sub nav (eg friends avatar or group avatar).
162
+ * Does not check if there is one - so always use if ( bp_has_options_avatar() )
163
+ *
164
+ * @package BuddyPress Core
165
+ * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
166
+ */
167
+ function bp_get_options_avatar() {
168
+ global $bp;
169
+
170
+ echo apply_filters( 'bp_get_options_avatar', $bp->bp_options_avatar );
171
+ }
172
+
173
+ function bp_get_options_title() {
174
+ global $bp;
175
+
176
+ if ( empty( $bp->bp_options_title ) )
177
+ $bp->bp_options_title = __( 'Options', 'buddypress' );
178
+
179
+ echo apply_filters( 'bp_get_options_avatar', $bp->bp_options_title );
180
+ }
181
+
182
+ function bp_comment_author_avatar() {
183
+ global $comment;
184
+
185
+ if ( function_exists('bp_core_get_avatar') ) {
186
+ echo apply_filters( 'bp_comment_author_avatar', bp_core_get_avatar( $comment->user_id, 1 ) );
187
+ } else if ( function_exists('get_avatar') ) {
188
+ get_avatar();
189
+ }
190
+ }
191
+
192
+ function bp_post_author_avatar() {
193
+ global $post;
194
+
195
+ if ( function_exists('bp_core_get_avatar') ) {
196
+ echo apply_filters( 'bp_post_author_avatar', bp_core_get_avatar( $post->post_author, 1 ) );
197
+ } else if ( function_exists('get_avatar') ) {
198
+ get_avatar();
199
+ }
200
+ }
201
+
202
+ function bp_loggedinuser_avatar( $width = false, $height = false ) {
203
+ global $bp;
204
+
205
+ if ( $width && $height )
206
+ echo apply_filters( 'bp_loggedinuser_avatar', bp_core_get_avatar( $bp->loggedin_user->id, 2, $width, $height ) );
207
+ else
208
+ echo apply_filters( 'bp_loggedinuser_avatar', bp_core_get_avatar( $bp->loggedin_user->id, 2 ) );
209
+ }
210
+
211
+ function bp_loggedinuser_avatar_thumbnail( $width = false, $height = false ) {
212
+ global $bp;
213
+
214
+ if ( $width && $height )
215
+ echo apply_filters( 'bp_get_options_avatar', bp_core_get_avatar( $bp->loggedin_user->id, 1, $width, $height ) );
216
+ else
217
+ echo apply_filters( 'bp_get_options_avatar', bp_core_get_avatar( $bp->loggedin_user->id, 1 ) );
218
+ }
219
+
220
+ function bp_site_name() {
221
+ echo apply_filters( 'bp_site_name', get_blog_option( 1, 'blogname' ) );
222
+ }
223
+
224
+ function bp_is_home() {
225
+ global $bp;
226
+
227
+ if ( is_user_logged_in() && $bp->loggedin_user->id == $bp->displayed_user->id )
228
+ return true;
229
+
230
+ return false;
231
+ }
232
+
233
+ function bp_fetch_user_fullname( $user_id, $echo = true ) {
234
+ global $bp;
235
+
236
+ if ( !$user_id )
237
+ return false;
238
+
239
+ if ( !$fullname = wp_cache_get( 'bp_user_fullname_' . $user_id, 'bp' ) ) {
240
+ if ( function_exists('xprofile_install') ) {
241
+ $fullname = xprofile_get_field_data( BP_XPROFILE_FULLNAME_FIELD_NAME, $user_id );
242
+
243
+ if ( empty($fullname) || !$fullname ) {
244
+ $ud = get_userdata($user_id);
245
+ $fullname = $ud->display_name;
246
+
247
+ xprofile_set_field_data( BP_XPROFILE_FULLNAME_FIELD_NAME, $user_id, $fullname );
248
+ }
249
+ } else {
250
+ $ud = get_userdata($user_id);
251
+ $fullname = $ud->display_name;
252
+ }
253
+
254
+ wp_cache_set( 'bp_user_fullname_' . $user_id, $fullname, 'bp' );
255
+ }
256
+
257
+ if ( $echo )
258
+ echo apply_filters( 'bp_fetch_user_fullname', stripslashes( trim( $fullname ) ) );
259
+ else
260
+ return apply_filters( 'bp_fetch_user_fullname', stripslashes ( trim ( $fullname ) ) );
261
+ }
262
+
263
+ function bp_last_activity( $user_id = false, $echo = true ) {
264
+ global $bp;
265
+
266
+ if ( !$user_id )
267
+ $user_id = $bp->displayed_user->id;
268
+
269
+ $last_activity = bp_core_get_last_activity( get_usermeta( $user_id, 'last_activity' ), __('active %s ago', 'buddypress') );
270
+
271
+ if ( $echo )
272
+ echo apply_filters( 'bp_last_activity', $last_activity );
273
+ else
274
+ return apply_filters( 'bp_last_activity', $last_activity );
275
+ }
276
+
277
+ function bp_the_avatar() {
278
+ global $bp;
279
+ echo apply_filters( 'bp_the_avatar', bp_core_get_avatar( $bp->displayed_user->id, 2 ) );
280
+ }
281
+
282
+ function bp_the_avatar_thumbnail() {
283
+ global $bp;
284
+ echo apply_filters( 'bp_the_avatar_thumbnail', bp_core_get_avatar( $bp->displayed_user->id, 1 ) );
285
+ }
286
+
287
+ function bp_user_link() {
288
+ global $bp;
289
+
290
+ echo apply_filters( 'bp_the_avatar_thumbnail', $bp->displayed_user->domain );
291
+ }
292
+
293
+ function bp_get_loggedin_user_link() {
294
+ global $bp;
295
+
296
+ return $bp->loggedin_user->domain;
297
+ }
298
+
299
+ function bp_get_displayed_user_link() {
300
+ global $bp;
301
+
302
+ return $bp->displayed_user->domain;
303
+ }
304
+
305
+ function bp_core_get_wp_profile() {
306
+ global $bp;
307
+
308
+ $ud = get_userdata( $bp->displayed_user->id );
309
+ ?>
310
+
311
+ <div class="info-group wp-profile">
312
+ <h4><?php _e( 'My Profile' ) ?></h4>
313
+
314
+ <table class="wp-profile-fields">
315
+ <?php if ( $ud->display_name ) { ?>
316
+ <tr id="wp_displayname">
317
+ <td class="label">
318
+ <?php _e( 'Name', 'buddypress' ) ?>
319
+ </td>
320
+ <td class="data">
321
+ <?php echo $ud->display_name ?>
322
+ </td>
323
+ </tr>
324
+ <?php } ?>
325
+ <?php if ( $ud->user_description ) { ?>
326
+ <tr id="wp_desc">
327
+ <td class="label">
328
+ <?php _e( 'About Me', 'buddypress' ) ?>
329
+ </td>
330
+ <td class="data">
331
+ <?php echo $ud->user_description ?>
332
+ </td>
333
+ </tr>
334
+ <?php } ?>
335
+ <?php if ( $ud->user_url ) { ?>
336
+ <tr id="wp_website">
337
+ <td class="label">
338
+ <?php _e( 'Website', 'buddypress' ) ?>
339
+ </td>
340
+ <td class="data">
341
+ <?php echo make_clickable( $ud->user_url ) ?>
342
+ </td>
343
+ </tr>
344
+ <?php } ?>
345
+ <?php if ( $ud->jabber ) { ?>
346
+ <tr id="wp_jabber">
347
+ <td class="label">
348
+ <?php _e( 'Jabber', 'buddypress' ) ?>
349
+ </td>
350
+ <td class="data">
351
+ <?php echo $ud->jabber ?>
352
+ </td>
353
+ </tr>
354
+ <?php } ?>
355
+ <?php if ( $ud->aim ) { ?>
356
+ <tr id="wp_aim">
357
+ <td class="label">
358
+ <?php _e( 'AOL Messenger', 'buddypress' ) ?>
359
+ </td>
360
+ <td class="data">
361
+ <?php echo $ud->aim ?>
362
+ </td>
363
+ </tr>
364
+ <?php } ?>
365
+ <?php if ( $ud->yim ) { ?>
366
+ <tr id="wp_yim">
367
+ <td class="label">
368
+ <?php _e( 'Yahoo Messenger', 'buddypress' ) ?>
369
+ </td>
370
+ <td class="data">
371
+ <?php echo $ud->yim ?>
372
+ </td>
373
+ </tr>
374
+ <?php } ?>
375
+ </table>
376
+ </div>
377
+ <?php
378
+ }
379
+
380
+ function bp_get_profile_header() {
381
+ load_template( TEMPLATEPATH . '/profile/profile-header.php' );
382
+ }
383
+
384
+ function bp_exists( $component_name ) {
385
+ if ( function_exists($component_name . '_install') )
386
+ return true;
387
+
388
+ return false;
389
+ }
390
+
391
+ function bp_format_time( $time, $just_date = false ) {
392
+ $date = date( get_option('date_format'), $time );
393
+
394
+ if ( !$just_date ) {
395
+ $date .= ' ' . __( 'at', 'buddypress' ) . date( ' ' . get_option('time_format'), $time );
396
+ }
397
+
398
+ return apply_filters( 'bp_format_time', $date );
399
+ }
400
+
401
+ function bp_word_or_name( $youtext, $nametext, $capitalize = true, $echo = true ) {
402
+ global $bp;
403
+
404
+ if ( $capitalize )
405
+ $youtext = bp_core_ucfirst($youtext);
406
+
407
+ if ( $bp->displayed_user->id == $bp->loggedin_user->id ) {
408
+ if ( $echo )
409
+ echo apply_filters( 'bp_word_or_name', $youtext );
410
+ else
411
+ return apply_filters( 'bp_word_or_name', $youtext );
412
+ } else {
413
+ $nametext = sprintf( $nametext, $bp->displayed_user->fullname );
414
+ if ( $echo )
415
+ echo apply_filters( 'bp_word_or_name', $nametext );
416
+ else
417
+ return apply_filters( 'bp_word_or_name', $nametext );
418
+ }
419
+ }
420
+
421
+ function bp_your_or_their( $capitalize = true, $echo = true ) {
422
+ global $bp;
423
+
424
+ if ( $capitalize )
425
+ $yourtext = bp_core_ucfirst($yourtext);
426
+
427
+ if ( $bp->displayed_user->id == $bp->loggedin_user->id ) {
428
+ if ( $echo )
429
+ echo apply_filters( 'bp_your_or_their', $yourtext );
430
+ else
431
+ return apply_filters( 'bp_your_or_their', $yourtext );
432
+ } else {
433
+ if ( $echo )
434
+ echo apply_filters( 'bp_your_or_their', $theirtext );
435
+ else
436
+ return apply_filters( 'bp_your_or_their', $theirtext );
437
+ }
438
+ }
439
+
440
+ function bp_loggedinuser_link() {
441
+ global $bp, $current_user;
442
+
443
+ if ( $link = bp_core_get_userlink( $bp->loggedin_user->id ) ) {
444
+ echo apply_filters( 'bp_loggedinuser_link', $link );
445
+ } else {
446
+ $ud = get_userdata($displayed_user->id);
447
+ echo apply_filters( 'bp_loggedinuser_link', $ud->user_login );
448
+ }
449
+ }
450
+
451
+ function bp_get_plugin_sidebar() {
452
+ if ( file_exists(TEMPLATEPATH . '/plugin-sidebar.php') )
453
+ load_template( TEMPLATEPATH . '/plugin-sidebar.php' );
454
+ }
455
+
456
+ function bp_is_blog_page() {
457
+ global $bp, $is_member_page;
458
+
459
+ if ( $bp->current_component == BP_HOME_BLOG_SLUG )
460
+ return true;
461
+
462
+ if ( !$is_member_page && !in_array( $bp->current_component, $bp->root_components ) )
463
+ return true;
464
+
465
+ return false;
466
+ }
467
+
468
+ function bp_page_title() {
469
+ global $bp, $post, $wp_query;
470
+
471
+ if ( is_home() && bp_is_page( 'home' ) ) {
472
+ $title = __( 'Home', 'buddypress' );
473
+ } else if ( bp_is_blog_page() ) {
474
+ if ( is_single() ) {
475
+ $title = __( 'Blog &#8212; ' . $post->post_title, 'buddypress' );
476
+ } else if ( is_category() ) {
477
+ $title = __( 'Blog &#8212; Categories &#8212; ' . ucwords( $wp_query->query_vars['category_name'] ), 'buddypress' );
478
+ } else if ( is_tag() ) {
479
+ $title = __( 'Blog &#8212; Tags &#8212; ' . ucwords( $wp_query->query_vars['tag'] ), 'buddypress' );
480
+ } else {
481
+ $title = __( 'Blog', 'buddypress' );
482
+ }
483
+ } else if ( !empty( $bp->displayed_user->fullname ) ) {
484
+ $title = strip_tags( $bp->displayed_user->fullname . ' &#8212; ' . ucwords( $bp->current_component ) . ' &#8212; ' . $bp->bp_options_nav[$bp->current_component][$bp->current_action]['name'] );
485
+ } else if ( $bp->is_single_item ) {
486
+ $title = ucwords( $bp->current_component ) . ' &#8212; ' . $bp->bp_options_title;
487
+ } else if ( $bp->is_directory ) {
488
+ if ( !$bp->current_component )
489
+ $title = sprintf( __( '%s Directory', 'buddypress' ), ucwords( BP_MEMBERS_SLUG ) );
490
+ else
491
+ $title = sprintf( __( '%s Directory', 'buddypress' ), ucwords( $bp->current_component ) );
492
+ } else {
493
+ global $post;
494
+ $title = get_the_title($post->ID);
495
+ }
496
+
497
+ echo apply_filters( 'bp_page_title', get_blog_option( BP_ROOT_BLOG, 'blogname' ) . ' &#8212; ' . $title, $title );
498
+
499
+ }
500
+
501
+ function bp_styles() {
502
+ do_action( 'bp_styles' );
503
+ wp_print_styles();
504
+ }
505
+
506
+ function bp_is_page($page) {
507
+ global $bp;
508
+
509
+ if ( $bp->displayed_user->id || $bp->is_single_item )
510
+ return false;
511
+
512
+ if ( $page == $bp->current_component || ( is_home() && $page == 'home' && $bp->current_component == $bp->default_component ) || ( $page == BP_MEMBERS_SLUG && !$bp->current_component ) )
513
+ return true;
514
+
515
+ return false;
516
+ }
517
+
518
+ function bp_has_custom_signup_page() {
519
+ if ( file_exists( WP_CONTENT_DIR . '/themes/' . get_blog_option( 1, 'template') . '/register.php') )
520
+ return true;
521
+
522
+ return false;
523
+ }
524
+
525
+ function bp_signup_page( $echo = true ) {
526
+ global $bp;
527
+
528
+ if ( bp_has_custom_signup_page() ) {
529
+ if ( $echo )
530
+ echo $bp->root_domain . '/' . BP_REGISTER_SLUG;
531
+ else
532
+ return $bp->root_domain . '/' . BP_REGISTER_SLUG;
533
+ } else {
534
+ if ( $echo )
535
+ echo $bp->root_domain . '/wp-signup.php';
536
+ else
537
+ return $bp->root_domain . '/wp-signup.php';
538
+ }
539
+ }
540
+
541
+ function bp_has_custom_activation_page() {
542
+ if ( file_exists( WP_CONTENT_DIR . '/themes/' . get_blog_option( 1, 'template') . '/activate.php') )
543
+ return true;
544
+
545
+ return false;
546
+ }
547
+
548
+ function bp_activation_page( $echo = true ) {
549
+ global $bp;
550
+
551
+ if ( bp_has_custom_activation_page() ) {
552
+ if ( $echo )
553
+ echo $bp->root_domain . '/' . BP_ACTIVATION_SLUG;
554
+ else
555
+ return $bp->root_domain . '/' . BP_ACTIVATION_SLUG;
556
+ } else {
557
+ if ( $echo )
558
+ echo $bp->root_domain . '/wp-activate.php';
559
+ else
560
+ return $bp->root_domain . '/wp-activate.php';
561
+ }
562
+ }
563
+
564
+ function bp_search_form_action() {
565
+ global $bp;
566
+
567
+ return apply_filters( 'bp_search_form_action', $bp->root_domain . '/search' );
568
+ }
569
+
570
+ function bp_search_form_type_select() {
571
+ // Eventually this won't be needed and a page will be built to integrate all search results.
572
+ $selection_box = '<select name="search-which" id="search-which" style="width: auto">';
573
+
574
+ if ( function_exists( 'xprofile_install' ) ) {
575
+ $selection_box .= '<option value="members">' . __( 'Members', 'buddypress' ) . '</option>';
576
+ }
577
+
578
+ if ( function_exists( 'groups_install' ) ) {
579
+ $selection_box .= '<option value="groups">' . __( 'Groups', 'buddypress' ) . '</option>';
580
+ }
581
+
582
+ if ( function_exists( 'bp_blogs_install' ) ) {
583
+ $selection_box .= '<option value="blogs">' . __( 'Blogs', 'buddypress' ) . '</option>';
584
+ }
585
+
586
+ $selection_box .= '</select>';
587
+
588
+ return apply_filters( 'bp_search_form_type_select', $selection_box );
589
+ }
590
+
591
+ function bp_search_form() {
592
+ $form = '
593
+ <form action="' . bp_search_form_action() . '" method="post" id="search-form">
594
+ <input type="text" id="search-terms" name="search-terms" value="" />
595
+ ' . bp_search_form_type_select() . '
596
+
597
+ <input type="submit" name="search-submit" id="search-submit" value="' . __( 'Search', 'buddypress' ) . '" />
598
+ ' . wp_nonce_field( 'bp_search_form' ) . '
599
+ </form>
600
+ ';
601
+
602
+ echo apply_filters( 'bp_search_form', $form );
603
+ }
604
+
605
+ function bp_login_bar() {
606
+ global $bp;
607
+
608
+ if ( !is_user_logged_in() ) : ?>
609
+
610
+ <form name="login-form" id="login-form" action="<?php echo $bp->root_domain . '/wp-login.php' ?>" method="post">
611
+ <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' ) ?>';}" />
612
+ <input type="password" name="pwd" id="user_pass" class="input" value="" />
613
+
614
+ <input type="checkbox" name="rememberme" id="rememberme" value="forever" title="<?php _e( 'Remember Me', 'buddypress' ) ?>" />
615
+
616
+ <input type="submit" name="wp-submit" id="wp-submit" value="<?php _e( 'Log In', 'buddypress' ) ?>"/>
617
+ <input type="button" name="signup-submit" id="signup-submit" value="<?php _e( 'Sign Up', 'buddypress' ) ?>" onclick="location.href='<?php echo bp_signup_page() ?>'" />
618
+
619
+ <input type="hidden" name="redirect_to" value="http://<?php echo $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] ?>" />
620
+ <input type="hidden" name="testcookie" value="1" />
621
+
622
+ <?php do_action( 'bp_login_bar_logged_out' ) ?>
623
+ </form>
624
+
625
+ <?php else : ?>
626
+
627
+ <div id="logout-link">
628
+ <?php bp_loggedinuser_avatar_thumbnail( 20, 20 ) ?> &nbsp;
629
+ <?php bp_loggedinuser_link() ?>
630
+ <?php
631
+ if ( function_exists('wp_logout_url') ) {
632
+ $logout_link = '/ <a href="' . wp_logout_url( $bp->root_domain ) . '">' . __( 'Log Out', 'buddypress' ) . '</a>';
633
+ } else {
634
+ $logout_link = '/ <a href="' . $bp->root_domain . '/wp-login.php?action=logout&amp;redirect_to=' . $bp->root_domain . '">' . __( 'Log Out', 'buddypress' ) . '</a>';
635
+ }
636
+
637
+ echo apply_filters( 'bp_logout_link', $logout_link );
638
+ ?>
639
+
640
+ <?php do_action( 'bp_login_bar_logged_in' ) ?>
641
+ </div>
642
+
643
+ <?php endif;
644
+ }
645
+
646
+ function bp_profile_wire_can_post() {
647
+ global $bp;
648
+
649
+ if ( bp_is_home() )
650
+ return true;
651
+
652
+ if ( function_exists('friends_install') ) {
653
+ if ( friends_check_friendship( $bp->loggedin_user->id, $bp->displayed_user->id ) )
654
+ return true;
655
+ else
656
+ return false;
657
+ }
658
+
659
+ return true;
660
+ }
661
+
662
+ function bp_nav_items() {
663
+ global $bp;
664
+ // This is deprecated, you should put these navigation items in your template header.php for easy editing.
665
+ ?>
666
+ <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>
667
+ <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>
668
+ <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>
669
+
670
+ <?php if ( function_exists( 'groups_install' ) ) { ?>
671
+ <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>
672
+ <?php } ?>
673
+
674
+ <?php if ( function_exists( 'bp_blogs_install' ) ) { ?>
675
+ <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>
676
+ <?php } ?>
677
+ <?php
678
+ do_action( 'bp_nav_items' );
679
+ }
680
+
681
+ function bp_custom_profile_boxes() {
682
+ do_action( 'bp_custom_profile_boxes' );
683
+ }
684
+
685
+ function bp_custom_profile_sidebar_boxes() {
686
+ do_action( 'bp_custom_profile_sidebar_boxes' );
687
+ }
688
+
689
+ function bp_get_userbar( $hide_on_directory = true ) {
690
+ global $bp;
691
+
692
+ if ( $hide_on_directory && $bp->is_directory )
693
+ return false;
694
+
695
+ include_once( TEMPLATEPATH . '/userbar.php' );
696
+ }
697
+
698
+ function bp_get_optionsbar( $hide_on_directory = true ) {
699
+ global $bp;
700
+
701
+ if ( $hide_on_directory && $bp->is_directory )
702
+ return false;
703
+
704
+ include_once( TEMPLATEPATH . '/optionsbar.php' );
705
+ }
706
+
707
+ function bp_is_directory() {
708
+ global $bp;
709
+
710
+ return $bp->is_directory;
711
+ }
712
+
713
+ /**
714
+ * bp_create_excerpt()
715
+ *
716
+ * Fakes an excerpt on any content. Will not truncate words.
717
+ *
718
+ * @package BuddyPress Core
719
+ * @param $text str The text to create the excerpt from
720
+ * @uses $excerpt_length The maximum length in characters of the excerpt.
721
+ * @return str The excerpt text
722
+ */
723
+ function bp_create_excerpt( $text, $excerpt_length = 55, $filter_shortcodes = true ) { // Fakes an excerpt if needed
724
+ $text = str_replace(']]>', ']]&gt;', $text);
725
+ $text = strip_tags($text);
726
+
727
+ if ( $filter_shortcodes )
728
+ $text = preg_replace( '|\[(.+?)\](.+?\[/\\1\])?|s', '', $text );
729
+
730
+ $words = explode(' ', $text, $excerpt_length + 1);
731
+ if (count($words) > $excerpt_length) {
732
+ array_pop($words);
733
+ array_push($words, '[...]');
734
+ $text = implode(' ', $words);
735
+ }
736
+
737
+ return apply_filters( 'the_excerpt', stripslashes($text) );
738
+ }
739
+
740
+ /**
741
+ * bp_is_serialized()
742
+ *
743
+ * Checks to see if the data passed has been serialized.
744
+ *
745
+ * @package BuddyPress Core
746
+ * @param $data str The data that will be checked
747
+ * @return bool false if the data is not serialized
748
+ * @return bool true if the data is serialized
749
+ */
750
+ function bp_is_serialized( $data ) {
751
+ if ( '' == trim($data) ) {
752
+ return false;
753
+ }
754
+
755
+ if ( preg_match( "/^(i|s|a|o|d)(.*);/si", $data ) ) {
756
+ return true;
757
+ }
758
+
759
+ return false;
760
+ }
761
+
762
+
763
+ /*** CUSTOM LOOP TEMPLATE CLASSES *******************/
764
+
765
+ class BP_Core_Members_Template {
766
+ var $current_member = -1;
767
+ var $member_count;
768
+ var $members;
769
+ var $member;
770
+
771
+ var $in_the_loop;
772
+
773
+ var $pag_page;
774
+ var $pag_num;
775
+ var $pag_links;
776
+ var $total_member_count;
777
+
778
+ function bp_core_members_template( $type, $per_page, $max ) {
779
+ global $bp, $bp_the_member_query;
780
+
781
+ $this->pag_page = isset( $_REQUEST['upage'] ) ? intval( $_REQUEST['upage'] ) : 1;
782
+ $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
783
+
784
+ if ( isset( $_REQUEST['s'] ) && '' != $_REQUEST['s'] && $type != 'random' ) {
785
+ $this->members = BP_Core_User::search_users( $_REQUEST['s'], $this->pag_num, $this->pag_page );
786
+ } else if ( isset( $_REQUEST['letter'] ) && '' != $_REQUEST['letter'] ) {
787
+ $this->members = BP_Core_User::get_users_by_letter( $_REQUEST['letter'], $this->pag_num, $this->pag_page );
788
+ } else {
789
+ switch ( $type ) {
790
+ case 'random':
791
+ $this->members = BP_Core_User::get_random_users( $this->pag_num, $this->pag_page );
792
+ break;
793
+
794
+ case 'newest':
795
+ $this->members = BP_Core_User::get_newest_users( $this->pag_num, $this->pag_page );
796
+ break;
797
+
798
+ case 'popular':
799
+ $this->members = BP_Core_User::get_popular_users( $this->pag_num, $this->pag_page );
800
+ break;
801
+
802
+ case 'online':
803
+ $this->members = BP_Core_User::get_online_users( $this->pag_num, $this->pag_page );
804
+ break;
805
+
806
+ case 'alphabetical':
807
+ $this->members = BP_Core_User::get_alphabetical_users( $this->pag_num, $this->pag_page );
808
+ break;
809
+
810
+ case 'active': default:
811
+ $this->members = BP_Core_User::get_active_users( $this->pag_num, $this->pag_page );
812
+ break;
813
+ }
814
+ }
815
+
816
+ if ( !$max )
817
+ $this->total_member_count = (int)$this->members['total'];
818
+ else
819
+ $this->total_member_count = (int)$max;
820
+
821
+ $this->members = $this->members['users'];
822
+
823
+ if ( $max ) {
824
+ if ( $max >= count($this->members) )
825
+ $this->member_count = count($this->members);
826
+ else
827
+ $this->member_count = (int)$max;
828
+ } else {
829
+ $this->member_count = count($this->members);
830
+ }
831
+
832
+ $this->pag_links = paginate_links( array(
833
+ 'base' => add_query_arg( 'upage', '%#%' ),
834
+ 'format' => '',
835
+ 'total' => ceil( (int) $this->total_member_count / (int) $this->pag_num ),
836
+ 'current' => (int) $this->pag_page,
837
+ 'prev_text' => '&laquo;',
838
+ 'next_text' => '&raquo;',
839
+ 'mid_size' => 1
840
+ ));
841
+ }
842
+
843
+ function has_members() {
844
+ if ( $this->member_count )
845
+ return true;
846
+
847
+ return false;
848
+ }
849
+
850
+ function next_member() {
851
+ $this->current_member++;
852
+ $this->member = $this->members[$this->current_member];
853
+
854
+ return $this->member;
855
+ }
856
+
857
+ function rewind_members() {
858
+ $this->current_member = -1;
859
+ if ( $this->member_count > 0 ) {
860
+ $this->member = $this->members[0];
861
+ }
862
+ }
863
+
864
+ function site_members() {
865
+ if ( $this->current_member + 1 < $this->member_count ) {
866
+ return true;
867
+ } elseif ( $this->current_member + 1 == $this->member_count ) {
868
+ do_action('loop_end');
869
+ // Do some cleaning up after the loop
870
+ $this->rewind_members();
871
+ }
872
+
873
+ $this->in_the_loop = false;
874
+ return false;
875
+ }
876
+
877
+ function the_member() {
878
+ global $member, $bp;
879
+
880
+ $this->in_the_loop = true;
881
+ $this->member = $this->next_member();
882
+ $user_id = $this->member->user_id;
883
+
884
+ if ( !$this->member = wp_cache_get( 'bp_user_' . $user_id, 'bp' ) ) {
885
+ $this->member = new BP_Core_User( $user_id );
886
+ wp_cache_set( 'bp_user_' . $user_id, $this->member, 'bp' );
887
+ }
888
+
889
+ if ( 0 == $this->current_member ) // loop has just started
890
+ do_action('loop_start');
891
+ }
892
+ }
893
+
894
+ function bp_rewind_site_members() {
895
+ global $site_members_template;
896
+
897
+ return $site_members_template->rewind_members();
898
+ }
899
+
900
+ function bp_has_site_members( $args = '' ) {
901
+ global $bp, $site_members_template;
902
+
903
+ $defaults = array(
904
+ 'type' => 'active',
905
+ 'per_page' => 10,
906
+ 'max' => false
907
+ );
908
+
909
+ $r = wp_parse_args( $args, $defaults );
910
+ extract( $r, EXTR_SKIP );
911
+
912
+ // type: active ( default ) | random | newest | popular | online | alphabetical
913
+
914
+ if ( $max ) {
915
+ if ( $per_page > $max )
916
+ $per_page = $max;
917
+ }
918
+
919
+ $site_members_template = new BP_Core_Members_Template( $type, $per_page, $max );
920
+
921
+ return $site_members_template->has_members();
922
+ }
923
+
924
+ function bp_the_site_member() {
925
+ global $site_members_template;
926
+ return $site_members_template->the_member();
927
+ }
928
+
929
+ function bp_site_members() {
930
+ global $site_members_template;
931
+ return $site_members_template->site_members();
932
+ }
933
+
934
+ function bp_site_members_pagination_count() {
935
+ global $bp, $site_members_template;
936
+
937
+ $from_num = intval( ( $site_members_template->pag_page - 1 ) * $site_members_template->pag_num ) + 1;
938
+ $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) ;
939
+
940
+ echo sprintf( __( 'Viewing member %d to %d (of %d members)', 'buddypress' ), $from_num, $to_num, $site_members_template->total_member_count ); ?> &nbsp;
941
+ <img id="ajax-loader-members" src="<?php echo $bp->core->image_base ?>/ajax-loader.gif" height="7" alt="<?php _e( "Loading", "buddypress" ) ?>" style="display: none;" /><?php
942
+ }
943
+
944
+ function bp_site_members_pagination_links() {
945
+ echo bp_get_site_members_pagination_links();
946
+ }
947
+ function bp_get_site_members_pagination_links() {
948
+ global $site_members_template;
949
+
950
+ return apply_filters( 'bp_get_site_members_pagination_links', $site_members_template->pag_links );
951
+ }
952
+
953
+ function bp_the_site_member_user_id() {
954
+ echo bp_get_the_site_member_user_id();
955
+ }
956
+ function bp_get_the_site_member_user_id() {
957
+ global $site_members_template;
958
+
959
+ return apply_filters( 'bp_get_the_site_member_user_id', $site_members_template->member->id );
960
+ }
961
+
962
+ function bp_the_site_member_avatar() {
963
+ echo apply_filters( 'bp_the_site_member_avatar', bp_get_the_site_member_avatar() );
964
+ }
965
+ function bp_get_the_site_member_avatar() {
966
+ global $site_members_template;
967
+
968
+ return apply_filters( 'bp_get_the_site_member_avatar', $site_members_template->member->avatar_thumb );
969
+ }
970
+
971
+ function bp_the_site_member_link() {
972
+ echo bp_get_the_site_member_link();
973
+ }
974
+ function bp_get_the_site_member_link() {
975
+ global $site_members_template;
976
+
977
+ echo apply_filters( 'bp_get_the_site_member_link', $site_members_template->member->user_url );
978
+ }
979
+
980
+ function bp_the_site_member_name() {
981
+ echo apply_filters( 'bp_the_site_member_name', bp_get_the_site_member_name() );
982
+ }
983
+ function bp_get_the_site_member_name() {
984
+ global $site_members_template;
985
+
986
+ return apply_filters( 'bp_get_the_site_member_name', $site_members_template->member->fullname );
987
+ }
988
+ add_filter( 'bp_get_the_site_member_name', 'wp_filter_kses' );
989
+
990
+ function bp_the_site_member_last_active() {
991
+ echo bp_get_the_site_member_last_active();
992
+ }
993
+ function bp_get_the_site_member_last_active() {
994
+ global $site_members_template;
995
+
996
+ return apply_filters( 'bp_the_site_member_last_active', $site_members_template->member->last_active );
997
+ }
998
+
999
+ function bp_the_site_member_add_friend_button() {
1000
+ global $site_members_template;
1001
+
1002
+ if ( function_exists( 'bp_add_friend_button' ) ) {
1003
+ echo bp_add_friend_button( $site_members_template->member->id );
1004
+ }
1005
+ }
1006
+
1007
+ function bp_the_site_member_total_friend_count() {
1008
+ global $site_members_template;
1009
+
1010
+ if ( !(int) $site_members_template->member->total_friends )
1011
+ return false;
1012
+
1013
+ echo bp_get_the_site_member_total_friend_count();
1014
+ }
1015
+ function bp_get_the_site_member_total_friend_count() {
1016
+ global $site_members_template;
1017
+
1018
+ if ( !(int) $site_members_template->member->total_friends )
1019
+ return false;
1020
+
1021
+ if ( 1 == (int) $site_members_template->member->total_friends )
1022
+ return apply_filters( 'bp_get_the_site_member_total_friend_count', sprintf( __( '%d friend', 'buddypress' ), (int) $site_members_template->member->total_friends ) );
1023
+ else
1024
+ return apply_filters( 'bp_get_the_site_member_total_friend_count', sprintf( __( '%d friends', 'buddypress' ), (int) $site_members_template->member->total_friends ) );
1025
+ }
1026
+
1027
+ function bp_the_site_member_random_profile_data() {
1028
+ global $site_members_template;
1029
+
1030
+ if ( function_exists( 'xprofile_get_random_profile_data' ) ) { ?>
1031
+ <?php $random_data = xprofile_get_random_profile_data( $site_members_template->member->id, true ); ?>
1032
+ <strong><?php echo wp_filter_kses( $random_data[0]->name ) ?></strong>
1033
+ <?php echo wp_filter_kses( $random_data[0]->value ) ?>
1034
+ <?php }
1035
+ }
1036
+
1037
+ function bp_the_site_member_hidden_fields() {
1038
+ if ( isset( $_REQUEST['s'] ) ) {
1039
+ echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['s'] ) . '" name="search_terms" />';
1040
+ }
1041
+
1042
+ if ( isset( $_REQUEST['letter'] ) ) {
1043
+ echo '<input type="hidden" id="selected_letter" value="' . attribute_escape( $_REQUEST['letter'] ) . '" name="selected_letter" />';
1044
+ }
1045
+
1046
+ if ( isset( $_REQUEST['members_search'] ) ) {
1047
+ echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['members_search'] ) . '" name="search_terms" />';
1048
+ }
1049
+ }
1050
+
1051
+ function bp_directory_members_search_form() {
1052
+ global $bp; ?>
1053
+ <form action="<?php echo $bp->root_domain . '/' . BP_MEMBERS_SLUG . '/search/' ?>" method="post" id="search-members-form">
1054
+ <label><input type="text" name="members_search" id="members_search" value="<?php if ( isset( $_GET['s'] ) ) { echo attribute_escape( $_GET['s'] ); } else { _e( 'Search anything...', 'buddypress' ); } ?>" onfocus="if (this.value == '<?php _e( 'Search anything...', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Search anything...', 'buddypress' ) ?>';}" /></label>
1055
+ <input type="submit" id="members_search_submit" name="members_search_submit" value="<?php _e( 'Search', 'buddypress' ) ?>" />
1056
+ <?php wp_nonce_field( 'directory_members', '_wpnonce-member-filter' ) ?>
1057
+ </form>
1058
+ <?php
1059
+ }
1060
+
1061
+ function bp_home_blog_url() {
1062
+ global $bp;
1063
+
1064
+ if ( 'bphome' == get_blog_option( BP_ROOT_BLOG, 'template' ) )
1065
+ echo $bp->root_domain . '/' . BP_HOME_BLOG_SLUG;
1066
+ else
1067
+ echo $bp->root_domain;
1068
+ }
1069
+
1070
+
1071
+ /* Template functions for fetching globals, without querying the DB again
1072
+ also means we dont have to use the $bp variable in the template (looks messy) */
1073
+
1074
+ function bp_displayed_user_id() {
1075
+ global $bp;
1076
+ return apply_filters( 'bp_displayed_user_id', $bp->displayed_user->id );
1077
+ }
1078
+ function bp_current_user_id() { return bp_displayed_user_id(); }
1079
+
1080
+ function bp_loggedin_user_id() {
1081
+ global $bp;
1082
+ return apply_filters( 'bp_loggedin_user_id', $bp->loggedin_user->id );
1083
+ }
1084
+
1085
+ function bp_displayed_user_domain() {
1086
+ global $bp;
1087
+ return apply_filters( 'bp_displayed_user_domain', $bp->displayed_user->domain );
1088
+ }
1089
+
1090
+ function bp_loggedin_user_domain() {
1091
+ global $bp;
1092
+ return apply_filters( 'bp_loggedin_user_domain', $bp->loggedin_user->domain );
1093
+ }
1094
+
1095
+ function bp_user_fullname() {
1096
+ global $bp;
1097
+ echo apply_filters( 'bp_user_fullname', $bp->displayed_user->fullname );
1098
+ }
1099
+ function bp_displayed_user_fullname() {
1100
+ return bp_user_fullname();
1101
+ }
1102
+
1103
+ function bp_loggedin_user_fullname() {
1104
+ echo bp_get_loggedin_user_fullname();
1105
+ }
1106
+ function bp_get_loggedin_user_fullname() {
1107
+ global $bp;
1108
+ return apply_filters( 'bp_get_loggedin_user_fullname', $bp->loggedin_user->fullname );
1109
+ }
1110
+
1111
+ function bp_current_component() {
1112
+ global $bp;
1113
+ return apply_filters( 'bp_current_component', $bp->current_component );
1114
+ }
1115
+
1116
+ function bp_current_action() {
1117
+ global $bp;
1118
+ return apply_filters( 'bp_current_action', $bp->current_action );
1119
+ }
1120
+
1121
+ function bp_action_variables() {
1122
+ global $bp;
1123
+ return apply_filters( 'bp_action_variables', $bp->action_variables );
1124
+ }
1125
+
1126
+
1127
+ ?>
bp-core/bp-core-widgets.php ADDED
@@ -0,0 +1,231 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /* Register widgets for the core component */
4
+ function bp_core_register_widgets() {
5
+ global $current_blog;
6
+
7
+ /* Site welcome widget */
8
+ wp_register_sidebar_widget( 'buddypress-welcome', __( 'Welcome', 'buddypress' ), 'bp_core_widget_welcome' );
9
+ wp_register_widget_control( 'buddypress-welcome', __( 'Welcome', 'buddypress' ), 'bp_core_widget_welcome_control' );
10
+
11
+ /* Site members widget */
12
+ wp_register_sidebar_widget( 'buddypress-members', __( 'Members', 'buddypress' ), 'bp_core_widget_members' );
13
+ wp_register_widget_control( 'buddypress-members', __( 'Members', 'buddypress' ), 'bp_core_widget_members_control' );
14
+
15
+ /* Include the javascript needed for activated widgets only */
16
+ if ( is_active_widget( 'bp_core_widget_members' ) ) {
17
+ wp_enqueue_script( 'bp_core_widget_members-js', BP_PLUGIN_URL . '/bp-core/js/widget-members.js', array('jquery', 'jquery-livequery-pack') );
18
+ wp_enqueue_style( 'bp_core_widget_members-css', BP_PLUGIN_URL . '/bp-core/css/widget-members.css' );
19
+ }
20
+
21
+ wp_register_sidebar_widget( 'buddypress-whosonline', __( "Who's Online", 'buddypress' ), 'bp_core_widget_whos_online' );
22
+ wp_register_widget_control( 'buddypress-whosonline', __( "Who's Online", 'buddypress' ), 'bp_core_widget_whos_online_control' );
23
+
24
+ }
25
+ add_action( 'plugins_loaded', 'bp_core_register_widgets' );
26
+
27
+
28
+ /*** WELCOME WIDGET *****************/
29
+
30
+ function bp_core_widget_welcome($args) {
31
+ global $current_blog;
32
+
33
+ extract($args);
34
+ $options = get_blog_option( $current_blog->blog_id, 'bp_core_widget_welcome' );
35
+ ?>
36
+ <?php echo $before_widget; ?>
37
+ <?php echo $before_title
38
+ . $widget_name
39
+ . $after_title; ?>
40
+
41
+ <?php if ( $options['title'] ) : ?><h3><?php echo $options['title'] ?></h3><?php endif; ?>
42
+ <?php if ( $options['text'] ) : ?><p><?php echo $options['text'] ?></p><?php endif; ?>
43
+
44
+ <?php if ( !is_user_logged_in() ) { ?>
45
+ <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>
46
+ <?php } ?>
47
+
48
+ <?php echo $after_widget; ?>
49
+ <?php
50
+ }
51
+
52
+ function bp_core_widget_welcome_control() {
53
+ global $current_blog;
54
+
55
+ $options = $newoptions = get_blog_option( $current_blog->blog_id, 'bp_core_widget_welcome' );
56
+
57
+ if ( $_POST['bp-widget-welcome-submit'] ) {
58
+ $newoptions['title'] = strip_tags( stripslashes( $_POST['bp-widget-welcome-title'] ) );
59
+ $newoptions['text'] = stripslashes( wp_filter_post_kses( $_POST['bp-widget-welcome-text'] ) );
60
+ }
61
+
62
+ if ( $options != $newoptions ) {
63
+ $options = $newoptions;
64
+ update_blog_option( $current_blog->blog_id, 'bp_core_widget_welcome', $options );
65
+ }
66
+
67
+ $title = attribute_escape( $options['title'] );
68
+ $text = attribute_escape( $options['text'] );
69
+ ?>
70
+ <p><label for="bp-widget-welcome-title"><?php _e('Title:', 'buddypress'); ?> <input class="widefat" id="bp-widget-welcome-title" name="bp-widget-welcome-title" type="text" value="<?php echo $title; ?>" /></label></p>
71
+ <p>
72
+ <label for="bp-widget-welcome-text"><?php _e( 'Welcome Text:' , 'buddypress'); ?>
73
+ <textarea id="bp-widget-welcome-text" name="bp-widget-welcome-text" class="widefat" style="height: 100px"><?php echo $text; ?></textarea>
74
+ </label>
75
+ </p>
76
+ <input type="hidden" id="bp-widget-welcome-submit" name="bp-widget-welcome-submit" value="1" />
77
+ <?php
78
+ }
79
+
80
+ /*** MEMBERS WIDGET *****************/
81
+
82
+ function bp_core_widget_members($args) {
83
+ global $current_blog, $bp;
84
+
85
+ extract($args);
86
+ $options = get_blog_option( $current_blog->blog_id, 'bp_core_widget_members' );
87
+ ?>
88
+ <?php echo $before_widget; ?>
89
+ <?php echo $before_title
90
+ . $widget_name
91
+ . $after_title; ?>
92
+
93
+ <?php
94
+ if ( !$users = wp_cache_get( 'newest_users', 'bp' ) ) {
95
+ $users = BP_Core_User::get_newest_users( $options['max_members'] );
96
+ wp_cache_set( 'newest_users', $users, 'bp' );
97
+ }
98
+ ?>
99
+
100
+ <?php if ( $users['users'] ) : ?>
101
+ <div class="item-options" id="members-list-options">
102
+ <img id="ajax-loader-members" src="<?php echo $bp->core->image_base ?>/ajax-loader.gif" height="7" alt="<?php _e( 'Loading', 'buddypress' ) ?>" style="display: none;" />
103
+ <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="newest-members" class="selected"><?php _e( 'Newest', 'buddypress' ) ?></a> |
104
+ <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="recently-active-members"><?php _e( 'Active', 'buddypress' ) ?></a> |
105
+ <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="popular-members"><?php _e( 'Popular', 'buddypress' ) ?></a>
106
+ </div>
107
+ <ul id="members-list" class="item-list">
108
+ <?php foreach ( (array) $users['users'] as $user ) : ?>
109
+ <li class="vcard">
110
+ <div class="item-avatar">
111
+ <a href="<?php echo bp_core_get_userlink( $user->user_id, false, true ) ?>"><?php echo bp_core_get_avatar( $user->user_id, 1 ) ?></a>
112
+ </div>
113
+
114
+ <div class="item">
115
+ <div class="item-title fn"><?php echo bp_core_get_userlink( $user->user_id ) ?></div>
116
+ <div class="item-meta"><span class="activity"><?php echo bp_core_get_last_activity( $user->user_registered, __( 'registered %s ago', 'buddypress' ) ) ?></span></div>
117
+ </div>
118
+ </li>
119
+ <?php $counter++; ?>
120
+ <?php endforeach; ?>
121
+ </ul>
122
+
123
+ <?php
124
+ if ( function_exists('wp_nonce_field') )
125
+ wp_nonce_field( 'bp_core_widget_members', '_wpnonce-members' );
126
+ ?>
127
+
128
+ <input type="hidden" name="members_widget_max" id="members_widget_max" value="<?php echo $options['max_members'] ?>" />
129
+
130
+ <?php else: ?>
131
+ <div class="widget-error">
132
+ <?php _e('No one has signed up yet!', 'buddypress') ?>
133
+ </div>
134
+ <?php endif; ?>
135
+
136
+ <?php echo $after_widget; ?>
137
+ <?php
138
+ }
139
+
140
+ function bp_core_widget_members_control() {
141
+ global $current_blog;
142
+
143
+ $options = $newoptions = get_blog_option( $current_blog->blog_id, 'bp_core_widget_members');
144
+
145
+ if ( $_POST['bp-core-widget-members-submit'] ) {
146
+ $newoptions['max_members'] = strip_tags( stripslashes( $_POST['bp-core-widget-members-max'] ) );
147
+ }
148
+
149
+ if ( $options != $newoptions ) {
150
+ $options = $newoptions;
151
+ update_blog_option( $current_blog->blog_id, 'bp_core_widget_members', $options );
152
+ }
153
+
154
+ $max_members = attribute_escape( $options['max_members'] );
155
+ ?>
156
+ <p><label for="bp-core-widget-members-max"><?php _e('Max Members to show:', 'buddypress'); ?> <input class="widefat" id="bp-core-widget-members-max" name="bp-core-widget-members-max" type="text" value="<?php echo $max_members; ?>" style="width: 30%" /></label></p>
157
+ <input type="hidden" id="bp-core-widget-members-submit" name="bp-core-widget-members-submit" value="1" />
158
+ <?php
159
+ }
160
+
161
+ /*** WHO'S ONLINE WIDGET *****************/
162
+
163
+ function bp_core_widget_whos_online($args) {
164
+ global $current_blog;
165
+
166
+ extract($args);
167
+ $options = get_blog_option( $current_blog->blog_id, 'bp_core_widget_whos_online' );
168
+ ?>
169
+ <?php echo $before_widget; ?>
170
+ <?php echo $before_title
171
+ . $widget_name
172
+ . $after_title; ?>
173
+
174
+ <?php
175
+ if ( !$users = wp_cache_get( 'online_users', 'bp' ) ) {
176
+ $users = BP_Core_User::get_online_users( $options['max_members'] );
177
+ wp_cache_set( 'online_users', $users, 'bp' );
178
+ }
179
+ ?>
180
+
181
+ <?php $users = BP_Core_User::get_online_users($options['max_members']) ?>
182
+
183
+ <?php if ( $users['users'] ) : ?>
184
+ <div class="avatar-block">
185
+ <?php foreach ( (array) $users['users'] as $user ) : ?>
186
+ <div class="item-avatar">
187
+ <a href="<?php echo bp_core_get_userurl($user->user_id) ?>" title="<?php bp_fetch_user_fullname( $user->user_id, true ) ?>"><?php echo bp_core_get_avatar( $user->user_id, 1 ) ?></a>
188
+ </div>
189
+ <?php endforeach; ?>
190
+ </div>
191
+
192
+ <?php
193
+ if ( function_exists('wp_nonce_field') )
194
+ wp_nonce_field( 'bp_core_widget_members', '_wpnonce-members' );
195
+ ?>
196
+
197
+ <input type="hidden" name="bp_core_widget_members_max" id="bp_core_widget_members_max" value="<?php echo $options['max_members'] ?>" />
198
+
199
+ <?php else: ?>
200
+ <div class="widget-error">
201
+ <?php _e('There are no users currently online.', 'buddypress') ?>
202
+ </div>
203
+ <?php endif; ?>
204
+
205
+ <?php echo $after_widget; ?>
206
+
207
+ <div class="clear" style="margin-bottom: 25px"></div>
208
+
209
+ <?php
210
+ }
211
+
212
+ function bp_core_widget_whos_online_control() {
213
+ global $current_blog;
214
+
215
+ $options = $newoptions = get_blog_option( $current_blog->blog_id, 'bp_core_widget_whos_online' );
216
+
217
+ if ( $_POST['bp-widget-whos-online-submit'] ) {
218
+ $newoptions['max_members'] = strip_tags( stripslashes( $_POST['bp-widget-whos-online-max-members'] ) );
219
+ }
220
+
221
+ if ( $options != $newoptions ) {
222
+ $options = $newoptions;
223
+ update_blog_option( $current_blog->blog_id, 'bp_core_widget_whos_online', $options );
224
+ }
225
+
226
+ $max_members = attribute_escape( $options['max_members'] );
227
+ ?>
228
+ <p><label for="bp-widget-whos-online-max-members"><?php _e('Maximum number of members to show:', 'buddypress'); ?><br /><input class="widefat" id="bp-widget-whos-online-max-members" name="bp-widget-whos-online-max-members" type="text" value="<?php echo $max_members; ?>" style="width: 30%" /></label></p>
229
+ <input type="hidden" id="bp-widget-whos-online-submit" name="bp-widget-whos-online-submit" value="1" />
230
+ <?php
231
+ }
bp-core/css/admin-bar.css ADDED
@@ -0,0 +1,234 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ body { padding-top: 28px !important; }
2
+
3
+ #wp-admin-bar {
4
+ position: absolute !important;
5
+ top: 0 !important;
6
+ left: 0 !important;
7
+ width: 100% !important;
8
+ z-index: 1001 !important;
9
+ height: 28px !important;
10
+ color: #fff !important;
11
+ text-align: left !important;
12
+ background:url(../images/admin_bar_back.gif) #818181 repeat-x !important;
13
+ font: 12px normal "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Tahoma, Verdana, Arial, sans-serif !important;
14
+ font-weight: normal !important;
15
+ }
16
+
17
+ #wp-admin-bar * { z-index: 999 !important; }
18
+
19
+ #wp-admin-bar img#admin-bar-logo {
20
+ position: absolute !important;
21
+ top: 8px;
22
+ left: 10px;
23
+ }
24
+
25
+ #wp-admin-bar a img {
26
+ border: none !important;
27
+ }
28
+
29
+ #wp-admin-bar li {
30
+ list-style: none !important;
31
+ margin: 0 !important;
32
+ }
33
+
34
+ #wp-admin-bar li * {
35
+ font: 12px normal "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Tahoma, Verdana, Arial, sans-serif !important;
36
+ font-weight: normal !important;
37
+ background-image: none !important;
38
+ }
39
+
40
+ #wp-admin-bar li a {
41
+ padding: 5px 25px 7px 15px !important;
42
+ font: 12px normal "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Tahoma, Verdana, Arial, sans-serif !important;
43
+ font-weight: normal !important;
44
+ }
45
+ #wp-admin-bar li.no-arrow a {
46
+ padding-right: 15px !important;
47
+ }
48
+
49
+ #wp-admin-bar li:hover, #wp-admin-bar li.hover {
50
+ position: static;
51
+ }
52
+
53
+ /*******************/
54
+
55
+ #wp-admin-bar ul { /* all lists */
56
+ margin: 0 !important;
57
+ list-style: none !important;
58
+ line-height: 1 !important;
59
+ cursor: pointer !important;
60
+ height: auto !important;
61
+ padding: 0 !important;
62
+ }
63
+
64
+ #wp-admin-bar ul {
65
+ margin-left: 80px !important;
66
+ }
67
+
68
+ #wp-admin-bar ul li { /* all list items */
69
+ padding: 0 !important;
70
+ float: left !important;
71
+ background: url( ../images/admin-menu-arrow.gif ) 88% 53% no-repeat;
72
+ position: relative;
73
+ }
74
+ #wp-admin-bar ul li.no-arrow {
75
+ background: none;
76
+ }
77
+
78
+ #wp-admin-bar ul li ul a {
79
+ color: #666 !important;
80
+ }
81
+
82
+ #wp-admin-bar ul li.align-right {
83
+ position: absolute;
84
+ right: 0;
85
+ }
86
+
87
+ #wp-admin-bar ul li a {
88
+ display: block !important;
89
+ font-size: 12px !important;
90
+ font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Tahoma, Verdana, Arial, sans-serif !important;
91
+ text-decoration: none !important;
92
+ color: #fff !important;
93
+ }
94
+
95
+ #wp-admin-bar ul.main-nav li:hover, #wp-admin-bar ul.main-nav li.sfhover, #wp-admin-bar ul.main-nav li ul li.sfhover {
96
+ background-color: #666 !important;
97
+ }
98
+
99
+ #wp-admin-bar ul.main-nav li ul li:hover a, #wp-admin-bar ul.main-nav li ul li.sfhover a {
100
+ background-color: #888 !important;
101
+ color: #fff !important;
102
+ }
103
+
104
+ #wp-admin-bar ul.main-nav li ul li:hover ul li.alt a {
105
+ background-color: #fafafa !important;
106
+ color: #666 !important;
107
+ }
108
+
109
+ #wp-admin-bar ul.main-nav li ul li:hover ul li a {
110
+ background-color: #f4f4f4 !important;
111
+ color: #666 !important;
112
+ }
113
+
114
+ #wp-admin-bar ul.main-nav li ul li:hover ul li:hover a {
115
+ background-color: #888 !important;
116
+ color: white !important;
117
+ }
118
+
119
+ #wp-admin-bar ul.main-nav li ul li ul li:hover a, #wp-admin-bar ul.main-nav li ul li ul li.sfhover a {
120
+ color: #fff !important;
121
+ }
122
+
123
+ /* second-level lists */
124
+
125
+ #wp-admin-bar ul li ul {
126
+ position: absolute !important;
127
+ width: 185px !important;
128
+ left: -999em !important;
129
+ margin-left: 0 !important;
130
+ }
131
+
132
+ #wp-admin-bar ul li ul li {
133
+ float: left !important;
134
+ width: 183px;
135
+ margin: 0 !important;
136
+ border: none !important;
137
+ border-bottom: 1px solid #f4f4f4 !important;
138
+ background-color: #f4f4f4 !important;
139
+ border-left: 1px solid #ccc !important;
140
+ border-right: 1px solid #ccc !important;
141
+ margin-top: -1px !important;
142
+ }
143
+
144
+ #wp-admin-bar ul li ul li.alt {
145
+ background-color: #fafafa !important;
146
+ border-bottom: 1px solid #fafafa !important;
147
+ }
148
+
149
+ #wp-admin-bar ul li ul li:last-child {
150
+ border-bottom: 1px solid #ccc !important;
151
+ -moz-border-radius-bottomleft: 4px !important;
152
+ -khtml-border-bottom-left-radius: 4px !important;
153
+ -webkit-border-bottom-left-radius: 4px !important;
154
+ border-bottom-left-radius: 4px !important;
155
+ -moz-border-radius-bottomright: 4px !important;
156
+ -khtml-border-bottom-right-radius: 4px !important;
157
+ -webkit-border-bottom-right-radius: 4px !important;
158
+ border-bottom-right-radius: 4px !important;
159
+ }
160
+
161
+ #wp-admin-bar ul.main-nav li ul li a:hover, #wp-admin-bar ul.main-nav li.sfhover ul li a:hover {
162
+ background-color: #888 !important;
163
+ }
164
+
165
+ #wp-admin-bar ul li div.admin-bar-clear {
166
+ clear: both !important;
167
+ background-color: #eee !important;
168
+ border-bottom: 3px solid #eee !important;
169
+ }
170
+
171
+ /* third-and-above-level lists */
172
+
173
+ #wp-admin-bar ul li ul ul {
174
+ margin: -28px 0 0 183px !important;
175
+ }
176
+
177
+ #wp-admin-bar ul li:hover ul, #wp-admin-bar ul li li:hover ul, #wp-admin-bar ul li.sfhover ul, #wp-admin-bar ul li ul li.sfhover ul { /* lists nested under hovered list items */
178
+ left: auto !important;
179
+ }
180
+
181
+ #wp-admin-bar ul li.align-right:hover ul {
182
+ right: 0 !important;
183
+ }
184
+
185
+ #wp-admin-bar ul li:hover ul ul, #wp-admin-bar li.sfhover ul li ul {
186
+ left: -999em !important;
187
+ }
188
+
189
+ #wp-admin-bar ul li ul li ul li:first-child {
190
+ border-top: 1px solid #ccc !important;
191
+ -moz-border-radius-topright: 4px !important;
192
+ -khtml-border-top-right-radius: 4px !important;
193
+ -webkit-border-top-right-radius: 4px !important;
194
+ border-top-right-radius: 4px !important;
195
+ margin-top: -2px !important;
196
+ }
197
+
198
+ /* Menu item css */
199
+
200
+ #wp-admin-bar img.avatar {
201
+ float: left !important;
202
+ border: 2px solid #fff !important !important;
203
+ margin-right: 8px !important;
204
+ }
205
+
206
+ #wp-admin-bar span.activity {
207
+ display: block !important;
208
+ color: #888 !important;
209
+ margin-left: 34px !important;
210
+ font-size: 10px !important;
211
+ background: none !important;
212
+ border: none !important;
213
+ padding: 0 !important;
214
+ }
215
+
216
+ #wp-admin-bar li a:hover span.activity {
217
+ color: #ccc !important;
218
+ }
219
+
220
+ #wp-admin-bar ul.author-list li {
221
+ height: 55px !important;
222
+ }
223
+
224
+ #wp-admin-bar ul li#bp-adminbar-notifications-menu a span {
225
+ background: #fff !important;
226
+ padding: 0 6px !important;
227
+ color: #555 !important;
228
+ font-weight: bold !important;
229
+ font-size: 0.8em !important;
230
+ -moz-border-radius: 2px !important;
231
+ -khtml-border-radius: 2px !important;
232
+ -webkit-border-radius: 2px !important;
233
+ margin-left: 2px !important;
234
+ }
bp-core/css/structure.css ADDED
@@ -0,0 +1,321 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Basic layout structure styles for BuddyPress. Formats BuddyPress pages within any WordPress theme.
3
+ No colors, fonts or pretty stuff.
4
+
5
+ These structure styles can be overridden by the theme CSS file if needed.
6
+ */
7
+
8
+ /***
9
+ * Mini reset
10
+ */
11
+
12
+ #main #content { background: none; }
13
+
14
+ .main-column ul, .left-menu ul, #userbar ul, #optionsbar ul, #wrap ul {
15
+ list-style: none;
16
+ padding: 0;
17
+ margin: 0;
18
+ }
19
+
20
+ /***
21
+ * Userbar
22
+ */
23
+
24
+ #userbar {
25
+ margin-bottom: 15px;
26
+ }
27
+ #userbar ul li {
28
+ float: left;
29
+ margin-right: 10px;
30
+ }
31
+
32
+ #userbar img.avatar {
33
+ float: left;
34
+ margin-right: 8px;
35
+ margin-top: 2px;
36
+ }
37
+
38
+ /***
39
+ * Options bar
40
+ */
41
+
42
+ #optionsbar {
43
+ margin-bottom: 15px;
44
+ }
45
+ #optionsbar ul li {
46
+ float: left;
47
+ margin-right: 10px;
48
+ }
49
+
50
+ #optionsbar img.avatar {
51
+ float: left;
52
+ margin-right: 8px;
53
+ margin-top: 2px;
54
+ }
55
+
56
+ #userbar li.current a, #optionsbar li.current a, .content-header-nav li.current a {
57
+ font-weight: bold;
58
+ }
59
+
60
+ /***
61
+ * Main Column & Info Groups
62
+ */
63
+
64
+ .main-column {
65
+ margin-left: 200px;
66
+ }
67
+ .main-column h1, #blog-info h1 {
68
+ margin-bottom: 0.3em;
69
+ }
70
+ .main-column p.status, #blog-info p.desc {
71
+ margin: 0 0 1.2em 0;
72
+ }
73
+
74
+ div.info-group {
75
+ margin-bottom: 2em;
76
+ }
77
+ div.info-group h4 {
78
+ height: 30px;
79
+ padding: 3px 10px;
80
+ margin-bottom: 0.5em;
81
+ position: relative;
82
+ }
83
+ .left-menu div.info-group {
84
+ margin-top: 1.5em;
85
+ }
86
+
87
+ div.info-group h4 a {
88
+ position: absolute;
89
+ top: 0.31em;
90
+ right: 1em;
91
+ font-weight: normal;
92
+ }
93
+
94
+ .left-menu div.info-group img.avatar {
95
+ float: left;
96
+ margin-right: 1em;
97
+ }
98
+
99
+ .horiz-gallery li {
100
+ float: left;
101
+ margin: 0 1.5em 0 0;
102
+ width: 15%;
103
+ text-align: center;
104
+ }
105
+
106
+ /***
107
+ * Left Menu
108
+ */
109
+
110
+ .left-menu, .page-menu {
111
+ position: relative;
112
+ float: left;
113
+ width: 158px;
114
+ }
115
+
116
+ /***
117
+ * Pagination
118
+ */
119
+
120
+ .pagination-links {
121
+ margin-top: -3.7em;
122
+ float: right;
123
+ }
124
+ .pagination-links .page-numbers {
125
+ padding: 0.65em 0.7em;
126
+ height: 24px;
127
+ }
128
+ .pagination-links .current {
129
+ padding: 0.5em 0.7em;
130
+ }
131
+
132
+ div.info-group .pagination-links {
133
+ margin: 0 0 5px 0;
134
+ float: none;
135
+ text-align: right;
136
+ }
137
+
138
+ .pag-count {
139
+ margin-bottom: -20px;
140
+ }
141
+
142
+
143
+ /***
144
+ * Item lists
145
+ */
146
+
147
+ ul.item-list li {
148
+ position: relative;
149
+ padding: 1em;
150
+ min-height: 60px;
151
+ }
152
+
153
+ ul.item-list li img.avatar {
154
+ float: left;
155
+ margin: 0 1em 0 0;
156
+ }
157
+
158
+ ul.item-list p.desc {
159
+ margin-left: 70px;
160
+ }
161
+
162
+ .item-list .action {
163
+ position: absolute;
164
+ top: 30%;
165
+ right: 1em;
166
+ }
167
+
168
+ /***
169
+ * Form Styles & Misc
170
+ */
171
+
172
+ .standard-form label {
173
+ display: block;
174
+ padding: 0 0 0.3em 0;
175
+ margin: 1em 0 0 0;
176
+ }
177
+
178
+ .standard-form input, .standard-form select, .standard-form textarea {
179
+ font-size: 1.3em;
180
+ font-family: inherit;
181
+ width: 65%;
182
+ padding: 0.2em;
183
+ }
184
+
185
+ .standard-form textarea {
186
+ height: 100px;
187
+ }
188
+
189
+ .standard-form input[type="submit"], .standard-form input#save {
190
+ width: auto;
191
+ }
192
+
193
+ a#accept, a#reject {
194
+ float: right;
195
+ margin-left: 10px;
196
+ }
197
+
198
+
199
+ form#settings-form h3 {
200
+ margin-bottom: 10px !important;
201
+ }
202
+
203
+ form#settings-form label {
204
+ display: block;
205
+ margin-bottom: 3px;
206
+ }
207
+ form#settings-form label span {
208
+ color: #888;
209
+ font-size: 0.9em;
210
+ }
211
+
212
+
213
+ /***
214
+ * Settings Screens
215
+ */
216
+
217
+ input.settings-input {
218
+ padding: 0.2em;
219
+ width: 65%;
220
+ margin-bottom: 15px;
221
+ }
222
+ input.small { width: 45%; }
223
+ input.auto { width: auto; }
224
+
225
+ table.notification-settings {
226
+ width: 80%;
227
+ margin-bottom: 20px;
228
+ }
229
+ table.notification-settings td {
230
+ padding: 3px 0;
231
+ }
232
+
233
+ table.notification-settings th.icon {
234
+ width: 35px;
235
+ }
236
+
237
+ table.notification-settings th.title {
238
+ width: 80%;
239
+ }
240
+
241
+ table.notification-settings .yes, table.notification-settings .no {
242
+ width: 40px;
243
+ }
244
+
245
+ /* Buttons */
246
+
247
+ .friendship-button {
248
+ background: url(../../bp-core/images/button_back.gif) top left no-repeat;
249
+ display: inline-block;
250
+ margin-bottom: 10px;
251
+ margin-left: -6px;
252
+ margin-right: 5px;
253
+ }
254
+
255
+ .friendship-button a {
256
+ display: block;
257
+ height: 19px;
258
+ color: #777;
259
+ font-size: 11px;
260
+ padding: 0 33px 0 11px;
261
+ text-shadow: 0 1px 0 #fff;
262
+ text-decoration: none;
263
+ margin-right: -7px;
264
+ }
265
+ .friendship-button a:hover {
266
+ color: #555;
267
+ text-decoration: none;
268
+ }
269
+
270
+ .friendship-button a.add {
271
+ background: url(../../bp-core/images/add_button_side.gif) top right no-repeat;
272
+ }
273
+
274
+ .friendship-button a.remove {
275
+ background: url(../../bp-core/images/remove_button_side.gif) top right no-repeat;
276
+ }
277
+
278
+ .friendship-button a.requested {
279
+ background: url(../../bp-core/images/check_button_side.gif) top right no-repeat;
280
+ }
281
+
282
+ .loading a {
283
+ background: url(../../bp-core/images/loading_button_side.gif) top right no-repeat !important;
284
+ }
285
+
286
+ .button-block {
287
+ text-align: right;
288
+ margin: 1em 2px;
289
+ }
290
+
291
+ .generic-button {
292
+ background: url(../../bp-core/images/button_back.gif) top left no-repeat;
293
+ display: inline-block;
294
+ margin: 0 5px 8px 0;
295
+ }
296
+
297
+ .generic-button a {
298
+ display: block;
299
+ height: 19px;
300
+ color: #777;
301
+ font-size: 11px;
302
+ padding: 0 33px 0 11px;
303
+ margin-right: -7px;
304
+ text-shadow: 0 1px 0 #fff;
305
+ text-decoration: none;
306
+ background: url(../../bp-core/images/view_button_side.gif) top right no-repeat;
307
+ }
308
+ .accept a { background-image: url(../../bp-core/images/accept_button_side.gif); }
309
+ .reject a { background-image: url(../../bp-core/images/reject_button_side.gif); }
310
+
311
+ .generic-button a:hover {
312
+ color: #555;
313
+ text-decoration: none;
314
+ }
315
+
316
+ .button-block div {
317
+ margin-bottom: 15px;
318
+ }
319
+
320
+
321
+
bp-core/css/widget-members.css ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .bp_core_widget_members ul#members-list {
2
+ margin: 15px 0 0 0;
3
+ padding: 0;
4
+ list-style: none;
5
+ }
6
+
7
+ .bp_core_widget_members ul#members-list li {
8
+ min-height: 60px;
9
+ }
10
+
11
+ .bp_core_widget_members ul#members-list li img.avatar {
12
+ float: left;
13
+ margin: 0 10px 0 0;
14
+ }
15
+
16
+ .bp_core_widget_members ul#members-list li span.activity {
17
+ font-size: 11px;
18
+ }
19
+
20
+ .bp_core_widget_members img#ajax-loader-members {
21
+ float: right;
22
+ }
bp-core/images/accept_button_side.gif ADDED
Binary file
bp-core/images/add_button_side.gif ADDED
Binary file
bp-core/images/add_friend_button.gif ADDED
Binary file
bp-core/images/admin-menu-arrow.gif ADDED
Binary file
bp-core/images/admin_bar_back.gif ADDED
Binary file
bp-core/images/admin_bar_logo.gif ADDED
Binary file
bp-core/images/ajax-loader.gif ADDED
Binary file
bp-core/images/blog.png ADDED
Binary file
bp-core/images/button_back.gif ADDED
Binary file
bp-core/images/check_button_side.gif ADDED
Binary file
bp-core/images/loading_button_side.gif ADDED
Binary file
bp-core/images/logout_bullet.gif ADDED
Binary file
bp-core/images/member.png ADDED
Binary file
bp-core/images/mystery-man.jpg ADDED
Binary file
bp-core/images/nav_bullet.gif ADDED
Binary file
bp-core/images/reject_button_side.gif ADDED
Binary file
bp-core/images/remove_button_side.gif ADDED
Binary file
bp-core/images/remove_friend_button.gif ADDED
Binary file
bp-core/images/requested_friend_button.gif ADDED
Binary file
bp-core/images/view_button_side.gif ADDED
Binary file
bp-core/js/account-admin.js ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function check_pass_strength ( ) {
2
+
3
+ var pass = jQuery('#pass1').val();
4
+ var user = jQuery('#user_login').val();
5
+
6
+ // get the result as an object, i'm tired of typing it
7
+ var res = jQuery('#pass-strength-result');
8
+
9
+ var strength = passwordStrength(pass, user);
10
+
11
+ jQuery(res).removeClass('short bad good strong');
12
+
13
+ if ( strength == pwsL10n.bad ) {
14
+ jQuery(res).addClass('bad');
15
+ jQuery(res).html( pwsL10n.bad );
16
+ }
17
+ else if ( strength == pwsL10n.good ) {
18
+ jQuery(res).addClass('good');
19
+ jQuery(res).html( pwsL10n.good );
20
+ }
21
+ else if ( strength == pwsL10n.strong ) {
22
+ jQuery(res).addClass('strong');
23
+ jQuery(res).html( pwsL10n.strong );
24
+ }
25
+ else {
26
+ // this catches 'Too short' and the off chance anything else comes along
27
+ jQuery(res).addClass('short');
28
+ jQuery(res).html( pwsL10n.short );
29
+ }
30
+ }
31
+
32
+ function update_nickname ( ) {
33
+
34
+ var nickname = jQuery('#nickname').val();
35
+ var display_nickname = jQuery('#display_nickname').val();
36
+
37
+ if ( nickname == '' ) {
38
+ jQuery('#display_nickname').remove();
39
+ }
40
+ jQuery('#display_nickname').val(nickname).html(nickname);
41
+
42
+ }
43
+
44
+ jQuery(function($) {
45
+ $('#pass1').keyup( check_pass_strength )
46
+ $('.color-palette').click(function(){$(this).siblings('input[name=admin_color]').attr('checked', 'checked')});
47
+ } );
48
+
49
+ jQuery(document).ready( function() {
50
+ jQuery('#pass1,#pass2').attr('autocomplete','off');
51
+ jQuery('#nickname').blur(update_nickname);
52
+ });
53
+
54
+ function clear(container) {
55
+ if(!document.getElementById(container)) return false;
56
+
57
+ var container = document.getElementById(container);
58
+
59
+ radioButtons = container.getElementsByTagName('INPUT');
60
+
61
+ for(var i=0; i<radioButtons.length; i++) {
62
+ radioButtons[i].checked = false;
63
+ }
64
+ }
bp-core/js/directory-members.js ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready( function() {
2
+ jQuery("ul#letter-list li a").livequery('click',
3
+ function() {
4
+ jQuery('#ajax-loader-members').toggle();
5
+
6
+ jQuery("div#members-list-options a").removeClass("selected");
7
+ jQuery(this).addClass('selected');
8
+ jQuery("input#members_search").val('');
9
+
10
+ var letter = jQuery(this).attr('id')
11
+ letter = letter.split('-');
12
+
13
+ var page = ( jQuery('input#members-page-num').val() ) ? jQuery('input#members-page-num').val() : 1;
14
+
15
+ jQuery.post( ajaxurl, {
16
+ action: 'directory_members',
17
+ 'cookie': encodeURIComponent(document.cookie),
18
+ '_wpnonce': jQuery("input#_wpnonce-member-filter").val(),
19
+ 'letter': letter[1],
20
+ 'page': page
21
+ },
22
+ function(response)
23
+ {
24
+ response = response.substr(0, response.length-1);
25
+
26
+ jQuery("#member-dir-list").fadeOut(200,
27
+ function() {
28
+ jQuery('#ajax-loader-members').toggle();
29
+ jQuery("#member-dir-list").html(response);
30
+ jQuery("#member-dir-list").fadeIn(200);
31
+ }
32
+ );
33
+ });
34
+
35
+ return false;
36
+ }
37
+ );
38
+
39
+ jQuery("form#search-members-form").submit( function() {
40
+ jQuery('#ajax-loader-members').toggle();
41
+
42
+ var page = ( jQuery('input#members-page-num').val() ) ? jQuery('input#members-page-num').val() : 1;
43
+
44
+ jQuery.post( ajaxurl, {
45
+ action: 'directory_members',
46
+ 'cookie': encodeURIComponent(document.cookie),
47
+ '_wpnonce': jQuery("input#_wpnonce-member-filter").val(),
48
+ 's': jQuery("input#members_search").val(),
49
+ 'page': page
50
+ },
51
+ function(response)
52
+ {
53
+ response = response.substr(0, response.length-1);
54
+
55
+ jQuery("#member-dir-list").fadeOut(200,
56
+ function() {
57
+ jQuery('#ajax-loader-members').toggle();
58
+ jQuery("#member-dir-list").html(response);
59
+ jQuery("#member-dir-list").fadeIn(200);
60
+ }
61
+ );
62
+ });
63
+
64
+ return false;
65
+ }
66
+ );
67
+
68
+ jQuery("div#member-dir-pag a").livequery('click',
69
+ function() {
70
+ jQuery('#ajax-loader-members').toggle();
71
+
72
+ var page = jQuery(this).attr('href');
73
+ page = page.split('upage=');
74
+
75
+ if ( !jQuery("input#selected_letter").val() )
76
+ var letter = '';
77
+ else
78
+ var letter = jQuery("input#selected_letter").val();
79
+
80
+ if ( !jQuery("input#search_terms").val() )
81
+ var search_terms = '';
82
+ else
83
+ var search_terms = jQuery("input#search_terms").val();
84
+
85
+ jQuery.post( ajaxurl, {
86
+ action: 'directory_members',
87
+ 'cookie': encodeURIComponent(document.cookie),
88
+ '_wpnonce': jQuery("input#_wpnonce").val(),
89
+ 'upage': page[1],
90
+ '_wpnonce': jQuery("input#_wpnonce-member-filter").val(),
91
+
92
+ 'letter': letter,
93
+ 's': search_terms
94
+ },
95
+ function(response)
96
+ {
97
+ response = response.substr(0, response.length-1);
98
+
99
+ jQuery("#member-dir-list").fadeOut(200,
100
+ function() {
101
+ jQuery('#ajax-loader-members').toggle();
102
+ jQuery("#member-dir-list").html(response);
103
+ jQuery("#member-dir-list").fadeIn(200);
104
+ }
105
+ );
106
+ });
107
+
108
+ return false;
109
+ }
110
+ );
111
+ });
bp-core/js/general.js ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready( function() {
2
+ jQuery("div.friendship-button a").livequery('click',
3
+ function() {
4
+ jQuery(this).parent().addClass('loading');
5
+
6
+ var fid = jQuery(this).attr('id');
7
+ fid = fid.split('-');
8
+ fid = fid[1];
9
+
10
+ var nonce = jQuery(this).attr('href');
11
+ nonce = nonce.split('?_wpnonce=');
12
+ nonce = nonce[1].split('&');
13
+ nonce = nonce[0];
14
+
15
+ var thelink = jQuery(this);
16
+
17
+ jQuery.post( ajaxurl, {
18
+ action: 'addremove_friend',
19
+ 'cookie': encodeURIComponent(document.cookie),
20
+ 'fid': fid,
21
+ '_wpnonce': nonce
22
+ },
23
+ function(response)
24
+ {
25
+ response = response.substr(0, response.length-1);
26
+
27
+ var action = thelink.attr('rel');
28
+ var parentdiv = thelink.parent();
29
+
30
+ if ( action == 'add' ) {
31
+ jQuery(parentdiv).fadeOut(200,
32
+ function() {
33
+ parentdiv.removeClass('add_friend');
34
+ parentdiv.removeClass('loading');
35
+ parentdiv.addClass('pending');
36
+ parentdiv.fadeIn(200).html(response);
37
+ }
38
+ );
39
+
40
+ } else if ( action == 'remove' ) {
41
+ jQuery(parentdiv).fadeOut(200,
42
+ function() {
43
+ parentdiv.removeClass('remove_friend');
44
+ parentdiv.removeClass('loading');
45
+ parentdiv.addClass('add');
46
+ parentdiv.fadeIn(200).html(response);
47
+ }
48
+ );
49
+ }
50
+ });
51
+ return false;
52
+ }
53
+ );
54
+ });
55
+
56
+ jQuery("div#wire-pagination a").livequery('click',
57
+ function() {
58
+ jQuery('#ajax-loader').toggle();
59
+
60
+ var fpage = jQuery(this).attr('href');
61
+ fpage = fpage.split('=');
62
+
63
+ jQuery.post( ajaxurl, {
64
+ action: 'get_wire_posts',
65
+ 'cookie': encodeURIComponent(document.cookie),
66
+ '_wpnonce': jQuery("input#_wpnonce").val(),
67
+ 'wpage': fpage[1],
68
+ 'bp_wire_item_id': jQuery("input#bp_wire_item_id").val()
69
+ },
70
+ function(response)
71
+ {
72
+ jQuery('#ajax-loader').toggle();
73
+
74
+ response = response.substr(0, response.length-1);
75
+
76
+ jQuery("form#wire-post-list-form").fadeOut(200,
77
+ function() {
78
+ jQuery("form#wire-post-list-form").html(response);
79
+ jQuery("form#wire-post-list-form").fadeIn(200);
80
+ }
81
+ );
82
+
83
+ return false;
84
+ });
85
+
86
+ return false;
87
+ }
88
+ );
89
+
90
+
91
+ function clear(container) {
92
+ if(!document.getElementById(container)) return false;
93
+
94
+ var container = document.getElementById(container);
95
+
96
+ radioButtons = container.getElementsByTagName('INPUT');
97
+
98
+ for(var i=0; i<radioButtons.length; i++) {
99
+ radioButtons[i].checked = false;
100
+ }
101
+ }
102
+
103
+ /* For admin-bar */
104
+ jQuery(document).ready( function() {
105
+ jQuery("#wp-admin-bar ul.main-nav li").mouseover( function() {
106
+ jQuery(this).addClass('sfhover');
107
+ });
108
+
109
+ jQuery("#wp-admin-bar ul.main-nav li").mouseout( function() {
110
+ jQuery(this).removeClass('sfhover');
111
+ });
112
+ });
bp-core/js/jquery/jquery.livequery.pack.js ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ /* Copyright (c) 2007 Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
2
+ * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
3
+ * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
4
+ *
5
+ * Version: 1.0.2
6
+ * Requires jQuery 1.1.3+
7
+ * Docs: http://docs.jquery.com/Plugins/livequery
8
+ */
9
+ eval(function(p,a,c,k,e,r){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--)r[e(c)]=k[c]||e(c);k=[function(e){return r[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}('(4($){$.R($.7,{3:4(c,b,d){9 e=2,q;5($.O(c))d=b,b=c,c=z;$.h($.3.j,4(i,a){5(e.8==a.8&&e.g==a.g&&c==a.m&&(!b||b.$6==a.7.$6)&&(!d||d.$6==a.o.$6))l(q=a)&&v});q=q||Y $.3(2.8,2.g,c,b,d);q.u=v;$.3.s(q.F);l 2},T:4(c,b,d){9 e=2;5($.O(c))d=b,b=c,c=z;$.h($.3.j,4(i,a){5(e.8==a.8&&e.g==a.g&&(!c||c==a.m)&&(!b||b.$6==a.7.$6)&&(!d||d.$6==a.o.$6)&&!2.u)$.3.y(a.F)});l 2}});$.3=4(e,c,a,b,d){2.8=e;2.g=c||S;2.m=a;2.7=b;2.o=d;2.t=[];2.u=v;2.F=$.3.j.K(2)-1;b.$6=b.$6||$.3.I++;5(d)d.$6=d.$6||$.3.I++;l 2};$.3.p={y:4(){9 b=2;5(2.m)2.t.16(2.m,2.7);E 5(2.o)2.t.h(4(i,a){b.o.x(a)});2.t=[];2.u=Q},s:4(){5(2.u)l;9 b=2;9 c=2.t,w=$(2.8,2.g),H=w.11(c);2.t=w;5(2.m){H.10(2.m,2.7);5(c.C>0)$.h(c,4(i,a){5($.B(a,w)<0)$.Z.P(a,b.m,b.7)})}E{H.h(4(){b.7.x(2)});5(2.o&&c.C>0)$.h(c,4(i,a){5($.B(a,w)<0)b.o.x(a)})}}};$.R($.3,{I:0,j:[],k:[],A:v,D:X,N:4(){5($.3.A&&$.3.k.C){9 a=$.3.k.C;W(a--)$.3.j[$.3.k.V()].s()}},U:4(){$.3.A=v},M:4(){$.3.A=Q;$.3.s()},L:4(){$.h(G,4(i,n){5(!$.7[n])l;9 a=$.7[n];$.7[n]=4(){9 r=a.x(2,G);$.3.s();l r}})},s:4(b){5(b!=z){5($.B(b,$.3.k)<0)$.3.k.K(b)}E $.h($.3.j,4(a){5($.B(a,$.3.k)<0)$.3.k.K(a)});5($.3.D)1j($.3.D);$.3.D=1i($.3.N,1h)},y:4(b){5(b!=z)$.3.j[b].y();E $.h($.3.j,4(a){$.3.j[a].y()})}});$.3.L(\'1g\',\'1f\',\'1e\',\'1b\',\'1a\',\'19\',\'18\',\'17\',\'1c\',\'15\',\'1d\',\'P\');$(4(){$.3.M()});9 f=$.p.J;$.p.J=4(a,c){9 r=f.x(2,G);5(a&&a.8)r.g=a.g,r.8=a.8;5(14 a==\'13\')r.g=c||S,r.8=a;l r};$.p.J.p=$.p})(12);',62,82,'||this|livequery|function|if|lqguid|fn|selector|var|||||||context|each||queries|queue|return|type||fn2|prototype|||run|elements|stopped|false|els|apply|stop|undefined|running|inArray|length|timeout|else|id|arguments|nEls|guid|init|push|registerPlugin|play|checkQueue|isFunction|remove|true|extend|document|expire|pause|shift|while|null|new|event|bind|not|jQuery|string|typeof|toggleClass|unbind|addClass|removeAttr|attr|wrap|before|removeClass|empty|after|prepend|append|20|setTimeout|clearTimeout'.split('|'),0,{}))
bp-core/js/jquery/jquery.tablednd.js ADDED
@@ -0,0 +1,314 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * TableDnD plug-in for JQuery, allows you to drag and drop table rows
3
+ * You can set up various options to control how the system will work
4
+ * Copyright � Denis Howlett <denish@isocra.com>
5
+ * Licensed like jQuery, see http://docs.jquery.com/License.
6
+ *
7
+ * Configuration options:
8
+ *
9
+ * onDragStyle
10
+ * This is the style that is assigned to the row during drag. There are limitations to the styles that can be
11
+ * associated with a row (such as you can't assign a border—well you can, but it won't be
12
+ * displayed). (So instead consider using onDragClass.) The CSS style to apply is specified as
13
+ * a map (as used in the jQuery css(...) function).
14
+ * onDropStyle
15
+ * This is the style that is assigned to the row when it is dropped. As for onDragStyle, there are limitations
16
+ * to what you can do. Also this replaces the original style, so again consider using onDragClass which
17
+ * is simply added and then removed on drop.
18
+ * onDragClass
19
+ * This class is added for the duration of the drag and then removed when the row is dropped. It is more
20
+ * flexible than using onDragStyle since it can be inherited by the row cells and other content. The default
21
+ * is class is tDnD_whileDrag. So to use the default, simply customise this CSS class in your
22
+ * stylesheet.
23
+ * onDrop
24
+ * Pass a function that will be called when the row is dropped. The function takes 2 parameters: the table
25
+ * and the row that was dropped. You can work out the new order of the rows by using
26
+ * table.rows.
27
+ * onDragStart
28
+ * Pass a function that will be called when the user starts dragging. The function takes 2 parameters: the
29
+ * table and the row which the user has started to drag.
30
+ * onAllowDrop
31
+ * Pass a function that will be called as a row is over another row. If the function returns true, allow
32
+ * dropping on that row, otherwise not. The function takes 2 parameters: the dragged row and the row under
33
+ * the cursor. It returns a boolean: true allows the drop, false doesn't allow it.
34
+ * scrollAmount
35
+ * This is the number of pixels to scroll if the user moves the mouse cursor to the top or bottom of the
36
+ * window. The page should automatically scroll up or down as appropriate (tested in IE6, IE7, Safari, FF2,
37
+ * FF3 beta)
38
+ *
39
+ * Other ways to control behaviour:
40
+ *
41
+ * Add class="nodrop" to any rows for which you don't want to allow dropping, and class="nodrag" to any rows
42
+ * that you don't want to be draggable.
43
+ *
44
+ * Inside the onDrop method you can also call $.tableDnD.serialize() this returns a string of the form
45
+ * <tableID>[]=<rowID1>&<tableID>[]=<rowID2> so that you can send this back to the server. The table must have
46
+ * an ID as must all the rows.
47
+ *
48
+ * Known problems:
49
+ * - Auto-scoll has some problems with IE7 (it scrolls even when it shouldn't), work-around: set scrollAmount to 0
50
+ *
51
+ * Version 0.2: 2008-02-20 First public version
52
+ * Version 0.3: 2008-02-07 Added onDragStart option
53
+ * Made the scroll amount configurable (default is 5 as before)
54
+ * Version 0.4: 2008-03-15 Changed the noDrag/noDrop attributes to nodrag/nodrop classes
55
+ * Added onAllowDrop to control dropping
56
+ * Fixed a bug which meant that you couldn't set the scroll amount in both directions
57
+ * Added serialise method
58
+ */
59
+ jQuery.tableDnD = {
60
+ /** Keep hold of the current table being dragged */
61
+ currentTable : null,
62
+ /** Keep hold of the current drag object if any */
63
+ dragObject: null,
64
+ /** The current mouse offset */
65
+ mouseOffset: null,
66
+ /** Remember the old value of Y so that we don't do too much processing */
67
+ oldY: 0,
68
+
69
+ /** Actually build the structure */
70
+ build: function(options) {
71
+ // Make sure options exists
72
+ options = options || {};
73
+ // Set up the defaults if any
74
+
75
+ this.each(function() {
76
+ // Remember the options
77
+ this.tableDnDConfig = {
78
+ onDragStyle: options.onDragStyle,
79
+ onDropStyle: options.onDropStyle,
80
+ // Add in the default class for whileDragging
81
+ onDragClass: options.onDragClass ? options.onDragClass : "tDnD_whileDrag",
82
+ onDrop: options.onDrop,
83
+ onDragStart: options.onDragStart,
84
+ scrollAmount: options.scrollAmount ? options.scrollAmount : 5
85
+ };
86
+ // Now make the rows draggable
87
+ jQuery.tableDnD.makeDraggable(this);
88
+ });
89
+
90
+ // Now we need to capture the mouse up and mouse move event
91
+ // We can use bind so that we don't interfere with other event handlers
92
+ jQuery(document)
93
+ .bind('mousemove', jQuery.tableDnD.mousemove)
94
+ .bind('mouseup', jQuery.tableDnD.mouseup);
95
+
96
+ // Don't break the chain
97
+ return this;
98
+ },
99
+
100
+ /** This function makes all the rows on the table draggable apart from those marked as "NoDrag" */
101
+ makeDraggable: function(table) {
102
+ // Now initialise the rows
103
+ var rows = table.rows; //getElementsByTagName("tr")
104
+ var config = table.tableDnDConfig;
105
+ for (var i=0; i<rows.length; i++) {
106
+ // To make non-draggable rows, add the nodrag class (eg for Category and Header rows)
107
+ // inspired by John Tarr and Famic
108
+ var nodrag = jQuery(rows[i]).hasClass("nodrag");
109
+ if (! nodrag) { //There is no NoDnD attribute on rows I want to drag
110
+ jQuery(rows[i]).mousedown(function(ev) {
111
+ if (ev.target.tagName == "TD") {
112
+ jQuery.tableDnD.dragObject = this;
113
+ jQuery.tableDnD.currentTable = table;
114
+ jQuery.tableDnD.mouseOffset = jQuery.tableDnD.getMouseOffset(this, ev);
115
+ if (config.onDragStart) {
116
+ // Call the onDrop method if there is one
117
+ config.onDragStart(table, this);
118
+ }
119
+ return false;
120
+ }
121
+ }).css("cursor", "move"); // Store the tableDnD object
122
+ }
123
+ }
124
+ },
125
+
126
+ /** Get the mouse coordinates from the event (allowing for browser differences) */
127
+ mouseCoords: function(ev){
128
+ if(ev.pageX || ev.pageY){
129
+ return {x:ev.pageX, y:ev.pageY};
130
+ }
131
+ return {
132
+ x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
133
+ y:ev.clientY + document.body.scrollTop - document.body.clientTop
134
+ };
135
+ },
136
+
137
+ /** Given a target element and a mouse event, get the mouse offset from that element.
138
+ To do this we need the element's position and the mouse position */
139
+ getMouseOffset: function(target, ev) {
140
+ ev = ev || window.event;
141
+
142
+ var docPos = this.getPosition(target);
143
+ var mousePos = this.mouseCoords(ev);
144
+ return {x:mousePos.x - docPos.x, y:mousePos.y - docPos.y};
145
+ },
146
+
147
+ /** Get the position of an element by going up the DOM tree and adding up all the offsets */
148
+ getPosition: function(e){
149
+ var left = 0;
150
+ var top = 0;
151
+ /** Safari fix -- thanks to Luis Chato for this! */
152
+ if (e.offsetHeight == 0) {
153
+ /** Safari 2 doesn't correctly grab the offsetTop of a table row
154
+ this is detailed here:
155
+ http://jacob.peargrove.com/blog/2006/technical/table-row-offsettop-bug-in-safari/
156
+ the solution is likewise noted there, grab the offset of a table cell in the row - the firstChild.
157
+ note that firefox will return a text node as a first child, so designing a more thorough
158
+ solution may need to take that into account, for now this seems to work in firefox, safari, ie */
159
+ e = e.firstChild; // a table cell
160
+ }
161
+
162
+ while (e.offsetParent){
163
+ left += e.offsetLeft;
164
+ top += e.offsetTop;
165
+ e = e.offsetParent;
166
+ }
167
+
168
+ left += e.offsetLeft;
169
+ top += e.offsetTop;
170
+
171
+ return {x:left, y:top};
172
+ },
173
+
174
+ mousemove: function(ev) {
175
+ if (jQuery.tableDnD.dragObject == null) {
176
+ return;
177
+ }
178
+
179
+ var dragObj = jQuery(jQuery.tableDnD.dragObject);
180
+ var config = jQuery.tableDnD.currentTable.tableDnDConfig;
181
+ var mousePos = jQuery.tableDnD.mouseCoords(ev);
182
+ var y = mousePos.y - jQuery.tableDnD.mouseOffset.y;
183
+ //auto scroll the window
184
+ var yOffset = window.pageYOffset;
185
+ if (document.all) {
186
+ // Windows version
187
+ //yOffset=document.body.scrollTop;
188
+ if (typeof document.compatMode != 'undefined' &&
189
+ document.compatMode != 'BackCompat') {
190
+ yOffset = document.documentElement.scrollTop;
191
+ }
192
+ else if (typeof document.body != 'undefined') {
193
+ yOffset=document.body.scrollTop;
194
+ }
195
+
196
+ }
197
+
198
+ if (mousePos.y-yOffset < config.scrollAmount) {
199
+ window.scrollBy(0, -config.scrollAmount);
200
+ } else {
201
+ var windowHeight = window.innerHeight ? window.innerHeight
202
+ : document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
203
+ if (windowHeight-(mousePos.y-yOffset) < config.scrollAmount) {
204
+ window.scrollBy(0, config.scrollAmount);
205
+ }
206
+ }
207
+
208
+
209
+ if (y != jQuery.tableDnD.oldY) {
210
+ // work out if we're going up or down...
211
+ var movingDown = y > jQuery.tableDnD.oldY;
212
+ // update the old value
213
+ jQuery.tableDnD.oldY = y;
214
+ // update the style to show we're dragging
215
+ if (config.onDragClass) {
216
+ dragObj.addClass(config.onDragClass);
217
+ } else {
218
+ dragObj.css(config.onDragStyle);
219
+ }
220
+ // If we're over a row then move the dragged row to there so that the user sees the
221
+ // effect dynamically
222
+ var currentRow = jQuery.tableDnD.findDropTargetRow(dragObj, y);
223
+ if (currentRow) {
224
+ // TODO worry about what happens when there are multiple TBODIES
225
+ if (movingDown && jQuery.tableDnD.dragObject != currentRow) {
226
+ jQuery.tableDnD.dragObject.parentNode.insertBefore(jQuery.tableDnD.dragObject, currentRow.nextSibling);
227
+ } else if (! movingDown && jQuery.tableDnD.dragObject != currentRow) {
228
+ jQuery.tableDnD.dragObject.parentNode.insertBefore(jQuery.tableDnD.dragObject, currentRow);
229
+ }
230
+ }
231
+ }
232
+
233
+ return false;
234
+ },
235
+
236
+ /** We're only worried about the y position really, because we can only move rows up and down */
237
+ findDropTargetRow: function(draggedRow, y) {
238
+ var rows = jQuery.tableDnD.currentTable.rows;
239
+ for (var i=0; i<rows.length; i++) {
240
+ var row = rows[i];
241
+ var rowY = this.getPosition(row).y;
242
+ var rowHeight = parseInt(row.offsetHeight)/2;
243
+ if (row.offsetHeight == 0) {
244
+ rowY = this.getPosition(row.firstChild).y;
245
+ rowHeight = parseInt(row.firstChild.offsetHeight)/2;
246
+ }
247
+ // Because we always have to insert before, we need to offset the height a bit
248
+ if ((y > rowY - rowHeight) && (y < (rowY + rowHeight))) {
249
+ // that's the row we're over
250
+ // If it's the same as the current row, ignore it
251
+ if (row == draggedRow) {return null;}
252
+ var config = jQuery.tableDnD.currentTable.tableDnDConfig;
253
+ if (config.onAllowDrop) {
254
+ if (config.onAllowDrop(draggedRow, row)) {
255
+ return row;
256
+ } else {
257
+ return null;
258
+ }
259
+ } else {
260
+ // If a row has nodrop class, then don't allow dropping (inspired by John Tarr and Famic)
261
+ var nodrop = jQuery(row).hasClass("nodrop");
262
+ if (! nodrop) {
263
+ return row;
264
+ } else {
265
+ return null;
266
+ }
267
+ }
268
+ return row;
269
+ }
270
+ }
271
+ return null;
272
+ },
273
+
274
+ mouseup: function(e) {
275
+ if (jQuery.tableDnD.currentTable && jQuery.tableDnD.dragObject) {
276
+ var droppedRow = jQuery.tableDnD.dragObject;
277
+ var config = jQuery.tableDnD.currentTable.tableDnDConfig;
278
+ // If we have a dragObject, then we need to release it,
279
+ // The row will already have been moved to the right place so we just reset stuff
280
+ if (config.onDragClass) {
281
+ jQuery(droppedRow).removeClass(config.onDragClass);
282
+ } else {
283
+ jQuery(droppedRow).css(config.onDropStyle);
284
+ }
285
+ jQuery.tableDnD.dragObject = null;
286
+ if (config.onDrop) {
287
+ // Call the onDrop method if there is one
288
+ config.onDrop(jQuery.tableDnD.currentTable, droppedRow);
289
+ }
290
+ jQuery.tableDnD.currentTable = null; // let go of the table too
291
+ }
292
+ },
293
+
294
+ serialize: function() {
295
+ if (jQuery.tableDnD.currentTable) {
296
+ var result = "";
297
+ var tableId = jQuery.tableDnD.currentTable.id;
298
+ var rows = jQuery.tableDnD.currentTable.rows;
299
+ for (var i=0; i<rows.length; i++) {
300
+ if (result.length > 0) result += "&";
301
+ result += tableId + '[]=' + rows[i].id;
302
+ }
303
+ return result;
304
+ } else {
305
+ return "Error: No Table id set, you need to set an id on your table and every row";
306
+ }
307
+ }
308
+ }
309
+
310
+ jQuery.fn.extend(
311
+ {
312
+ tableDnD : jQuery.tableDnD.build
313
+ }
314
+ );
bp-core/js/widget-members.js ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready( function() {
2
+ jQuery("div#members-list-options a").livequery('click',
3
+ function() {
4
+ jQuery('#ajax-loader-members').toggle();
5
+
6
+ jQuery("div#members-list-options a").removeClass("selected");
7
+ jQuery(this).addClass('selected');
8
+
9
+ jQuery.post( ajaxurl, {
10
+ action: 'widget_members',
11
+ 'cookie': encodeURIComponent(document.cookie),
12
+ '_wpnonce': jQuery("input#_wpnonce-members").val(),
13
+ 'max-members': jQuery("input#members_widget_max").val(),
14
+ 'filter': jQuery(this).attr('id')
15
+ },
16
+ function(response)
17
+ {
18
+ member_wiget_response(response);
19
+ });
20
+
21
+ return false;
22
+ }
23
+ );
24
+ });
25
+
26
+ function member_wiget_response(response) {
27
+ response = response.substr(0, response.length-1);
28
+ response = response.split('[[SPLIT]]');
29
+
30
+ if ( response[0] != "-1" ) {
31
+ jQuery("ul#members-list").fadeOut(200,
32
+ function() {
33
+ jQuery('#ajax-loader-members').toggle();
34
+ jQuery("ul#members-list").html(response[1]);
35
+ jQuery("ul#members-list").fadeIn(200);
36
+ }
37
+ );
38
+
39
+ } else {
40
+ jQuery("ul#members-list").fadeOut(200,
41
+ function() {
42
+ jQuery('#ajax-loader-members').toggle();
43
+ var message = '<p>' + response[1] + '</p>';
44
+ jQuery("ul#members-list").html(message);
45
+ jQuery("ul#members-list").fadeIn(200);
46
+ }
47
+ );
48
+ }
49
+ }
bp-forums.php ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ define ( 'BP_FORUMS_VERSION', '1.0' );
4
+
5
+ /* Define the parent forum ID */
6
+ if ( !defined( 'BP_FORUMS_PARENT_FORUM_ID' ) )
7
+ define ( 'BP_FORUMS_PARENT_FORUM_ID', 1 );
8
+
9
+ require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-bbpress-live.php' );
10
+ require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-templatetags.php' );
11
+ require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-filters.php' );
12
+
13
+ if ( is_admin() )
14
+ require ( 'bp-forums/bp-forums-admin.php' );
15
+
16
+ function bp_forums_setup() {
17
+ global $bp, $bbpress_live;
18
+
19
+ if ( '' == get_usermeta( $bp->loggedin_user->id, 'bb_capabilities' ) )
20
+ bp_forums_make_user_active_member( $bp->loggedin_user->id );
21
+
22
+ $bp->version_numbers->forums = BP_FORUMS_VERSION;
23
+ }
24
+ add_action( 'plugins_loaded', 'bp_forums_setup', 5 );
25
+ add_action( 'admin_head', 'bp_forums_setup', 3 );
26
+
27
+ function bp_forums_is_installed_correctly() {
28
+ global $bbpress_live;
29
+
30
+ if ( !is_object( $bbpress_live ) ) {
31
+ include_once( ABSPATH . WPINC . '/class-IXR.php' );
32
+ $bbpress_live = new bbPress_Live();
33
+ }
34
+
35
+ if ( !$bbpress_live->fetch->endpoint )
36
+ return false;
37
+
38
+ return true;
39
+ }
40
+
41
+ function bp_forums_get_forum( $parent = 0, $depth = 0 ) {
42
+ global $bbpress_live;
43
+
44
+ if ( !is_object( $bbpress_live ) ) {
45
+ include_once( ABSPATH . WPINC . '/class-IXR.php' );
46
+ $bbpress_live = new bbPress_Live();
47
+ }
48
+
49
+ if ( $forum = $bbpress_live->get_forums( $parent, $depth ) ) {
50
+ do_action( 'bp_forums_get_forum', $forum );
51
+ return $forum;
52
+ }
53
+
54
+ return false;
55
+ }
56
+
57
+ function bp_forums_get_topics( $forum_id = 0, $number = 0, $page = 1 ) {
58
+ global $bbpress_live;
59
+
60
+ if ( !is_object( $bbpress_live ) ) {
61
+ include_once( ABSPATH . WPINC . '/class-IXR.php' );
62
+ $bbpress_live = new bbPress_Live();
63
+ }
64
+
65
+ if ( $topics = $bbpress_live->get_topics( $forum_id, $number, $page ) ) {
66
+ do_action( 'bp_forums_get_topics', $topics );
67
+ return $topics;
68
+ }
69
+
70
+ return false;
71
+ }
72
+
73
+ function bp_forums_get_topic_details( $topic_id = 0 ) {
74
+ global $bbpress_live;
75
+
76
+ if ( !is_object( $bbpress_live ) ) {
77
+ include_once( ABSPATH . WPINC . '/class-IXR.php' );
78
+ $bbpress_live = new bbPress_Live();
79
+ }
80
+
81
+ if ( $topic = $bbpress_live->get_topic_details( $topic_id ) ) {
82
+ do_action( 'bp_forums_get_topic_details', $topic );
83
+ return $topic;
84
+ }
85
+
86
+ return false;
87
+ }
88
+
89
+ function bp_forums_get_posts( $topic_id = 0, $number = 0, $page = 1 ) {
90
+ global $bbpress_live;
91
+
92
+ if ( !is_object( $bbpress_live ) ) {
93
+ include_once( ABSPATH . WPINC . '/class-IXR.php' );
94
+ $bbpress_live = new bbPress_Live();
95
+ }
96
+
97
+ if ( $posts = $bbpress_live->get_posts( $topic_id, $number, $page ) ) {
98
+ do_action( 'bp_forums_get_posts', $posts );
99
+ return $posts;
100
+ }
101
+
102
+ return false;
103
+ }
104
+
105
+ function bp_forums_get_post( $post_id = 0 ) {
106
+ global $bbpress_live;
107
+
108
+ if ( !is_object( $bbpress_live ) ) {
109
+ include_once( ABSPATH . WPINC . '/class-IXR.php' );
110
+ $bbpress_live = new bbPress_Live();
111
+ }
112
+
113
+ if ( $post = $bbpress_live->get_post( $post_id ) ) {
114
+ do_action( 'bp_forums_get_post', $post );
115
+ return $post;
116
+ }
117
+
118
+ return false;
119
+ }
120
+
121
+ function bp_forums_new_forum( $name = '', $desc = '', $parent = BP_FORUMS_PARENT_FORUM_ID, $order = 0, $is_category = false ) {
122
+ global $bbpress_live;
123
+
124
+ if ( !is_object( $bbpress_live ) ) {
125
+ include_once( ABSPATH . WPINC . '/class-IXR.php' );
126
+ $bbpress_live = new bbPress_Live();
127
+ }
128
+
129
+ if ( $forum = $bbpress_live->new_forum( $name, $desc, $parent, $order, $is_category ) ) {
130
+ do_action( 'bp_forums_new_forum', $forum );
131
+ return $forum;
132
+ }
133
+
134
+ return false;
135
+ }
136
+
137
+ function bp_forums_new_topic( $title = '', $topic_text = '', $topic_tags = '', $forum_id = 0 ) {
138
+ global $bbpress_live;
139
+
140
+ if ( !is_object( $bbpress_live ) ) {
141
+ include_once( ABSPATH . WPINC . '/class-IXR.php' );
142
+ $bbpress_live = new bbPress_Live();
143
+ }
144
+
145
+ $topic_text = apply_filters( 'bp_forums_new_post_text', $topic_text );
146
+ $title = apply_filters( 'bp_forums_new_post_title', $title );
147
+ $topic_tags = apply_filters( 'bp_forums_new_post_tags', $topic_tags );
148
+
149
+ if ( $topic = $bbpress_live->new_topic( $title, $topic_text, $topic_tags, (int)$forum_id ) ) {
150
+ do_action( 'bp_forums_new_topic', $topic );
151
+ return $topic;
152
+ }
153
+
154
+ return false;
155
+ }
156
+
157
+ function bp_forums_new_post( $post_text = '', $topic_id = 0 ) {
158
+ global $bbpress_live;
159
+
160
+ if ( !check_admin_referer( 'bp_forums_new_reply' ) )
161
+ return false;
162
+
163
+ if ( !is_object( $bbpress_live ) ) {
164
+ include_once( ABSPATH . WPINC . '/class-IXR.php' );
165
+ $bbpress_live = new bbPress_Live();
166
+ }
167
+
168
+ $post_text = apply_filters( 'bp_forums_new_post_text', $post_text );
169
+
170
+ if ( $post = $bbpress_live->new_post( $post_text, (int)$topic_id ) ) {
171
+ do_action( 'bp_forums_new_post', $post );
172
+ return $post;
173
+ }
174
+
175
+ return false;
176
+ }
177
+
178
+ function bp_forums_make_user_active_member( $user_id ) {
179
+ update_usermeta( $user_id, 'bb_capabilities', array( 'member' => true ) );
180
+ }
181
+ add_action( 'wpmu_new_user', 'bp_forums_make_user_active_member' );
182
+
183
+ function bp_forums_get_keymaster() {
184
+ global $wpdb;
185
+
186
+ $user_id = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM " . CUSTOM_USER_META_TABLE . " WHERE meta_key = 'bb_capabilities' AND meta_value LIKE '%%keymaster%%'" ) );
187
+
188
+ return get_userdata( $user_id );
189
+ }
190
+
191
+ // List actions to clear super cached pages on, if super cache is installed
192
+ add_action( 'bp_forums_new_forum', 'bp_core_clear_cache' );
193
+ add_action( 'bp_forums_new_topic', 'bp_core_clear_cache' );
194
+ add_action( 'bp_forums_new_post', 'bp_core_clear_cache' );
195
+
196
+
197
+
198
+ ?>
bp-forums/bbpress-plugins/buddypress-enable.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: BuddyPress Support Plugin
4
+ Plugin URI: http://buddypress.org/
5
+ Description: Modifies bbPress behaviour to provide better support for integration in BuddyPress.
6
+ Author: Andy Peatling
7
+ Version: 1.0-RC1
8
+ Author URI: http://apeatling.wordpress.com/
9
+ */
10
+
11
+ function for_buddypress_strip_tags( $_post, $post ) {
12
+
13
+ // Cast to an array
14
+ $_post = (array) $post;
15
+ // Set the URI
16
+ $_post['post_uri'] = get_post_link( $_post['post_id'] );
17
+ // Set readable times
18
+ $_post['post_time_since'] = bb_since( $_post['post_time'] );
19
+ // Set the display names
20
+ $_post['poster_display_name'] = get_user_display_name( $_post['poster_id'] );
21
+ // Remove some sensitive data
22
+ unset(
23
+ $_post['poster_ip'],
24
+ $_post['pingback_queued']
25
+ );
26
+
27
+ $_post['post_text'] = str_replace( '<', '[', $_post['post_text'] );
28
+ $_post['post_text'] = str_replace( '>', ']', $_post['post_text'] );
29
+
30
+ return $_post;
31
+ }
32
+ add_filter( 'bb_xmlrpc_prepare_post', 'for_buddypress_strip_tags', 10, 2 );
33
+
34
+ function for_buddypress_prepare_topic( $_topic, $topic ) {
35
+ // Cast to an array
36
+ $_topic = (array) $topic;
37
+ // Set the URI
38
+ $_topic['topic_uri'] = get_topic_link( $_topic['topic_id'] );
39
+ // Set readable times
40
+ $_topic['topic_start_time_since'] = bb_since( $_topic['topic_start_time'] );
41
+ $_topic['topic_time_since'] = bb_since( $_topic['topic_time'] );
42
+ // Set the display names
43
+ $_topic['topic_poster_display_name'] = get_user_display_name( $_topic['topic_poster'] );
44
+ $_topic['topic_last_poster_display_name'] = get_user_display_name( $_topic['topic_last_poster'] );
45
+
46
+ return $_topic;
47
+ }
48
+ add_filter( 'bb_xmlrpc_prepare_topic', 'for_buddypress_prepare_topic', 10, 2 );
49
+
50
+ function for_buddypress_pre_post( $post_text, $post_id, $topic_id ){
51
+ $post_text = stripslashes( stripslashes_deep($post_text) );
52
+ $post_text = str_replace( '/amp/', '&', $post_text );
53
+ $post_text = html_entity_decode( $post_text, ENT_COMPAT, "UTF-8" );
54
+
55
+ return $post_text;
56
+ }
57
+ add_filter( 'pre_post', 'for_buddypress_pre_post', 10, 3 );
58
+
59
+ ?>
bp-forums/bp-forums-admin.php ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ function bp_forums_add_admin_menu() {
3
+ global $wpdb, $bp;
4
+
5
+ if ( is_site_admin() ) {
6
+ /* Add the administration tab under the "Site Admin" tab for site administrators */
7
+ add_submenu_page( 'bp-core.php', __( 'Forums Setup', 'buddypress' ), __( 'Forums Setup', 'buddypress' ), 2, __FILE__, "bp_forums_bbpress_admin" );
8
+ }
9
+ }
10
+ add_action( 'admin_menu', 'bp_forums_add_admin_menu' );
11
+
12
+ function bp_forums_bbpress_admin() {
13
+ global $bp, $bbpress_live;
14
+
15
+ if ( !is_object( $bbpress_live ) ) {
16
+ include_once( ABSPATH . WPINC . '/class-IXR.php' );
17
+ $bbpress_live = new bbPress_Live();
18
+ }
19
+
20
+ if ( isset( $_POST['submit'] ) ) {
21
+ check_admin_referer('bbpress-settings');
22
+
23
+ $_fetch_options = array(
24
+ 'target_uri' => stripslashes((string) $_POST['target_uri']),
25
+ 'username' => stripslashes((string) $_POST['username']),
26
+ 'password' => stripslashes((string) $_POST['password']),
27
+ 'always_use_auth' => (bool) $_POST['always_use_auth']
28
+ );
29
+ update_option( 'bbpress_live_fetch', $_fetch_options );
30
+
31
+ $_options = array(
32
+ 'cache_enabled' => (bool) $_POST['cache_enabled'],
33
+ 'cache_timeout' => (int) $_POST['cache_timeout'],
34
+ 'widget_forums' => (bool) $_POST['widget_forums'],
35
+ 'widget_topics' => (bool) $_POST['widget_topics'],
36
+ 'post_to_topic' => (bool) $_POST['post_to_topic'],
37
+ 'post_to_topic_forum' => stripslashes((string) $_POST['post_to_topic_forum']),
38
+ 'post_to_topic_delay' => (int) $_POST['post_to_topic_delay']
39
+ );
40
+ update_option( 'bbpress_live', $_options );
41
+
42
+ $fetch_options = $_fetch_options;
43
+ $options = $_options;
44
+
45
+ do_action( 'bp_forums_bbpress_admin', $_fetch_options, $_options );
46
+
47
+ } else {
48
+ $fetch_options = $bbpress_live->fetch->options;
49
+ $options = $bbpress_live->options;
50
+ }
51
+ ?>
52
+ <div class="wrap">
53
+
54
+ <h2><?php _e( 'Forums Setup', 'buddypress' ) ?></h2>
55
+
56
+ <?php if ( isset( $_POST['submit'] ) ) : ?>
57
+ <div id="message" class="updated fade">
58
+ <p><?php _e( 'Settings Saved.', 'buddypress' ) ?></p>
59
+ </div>
60
+ <?php endif; ?>
61
+ <br />
62
+
63
+ <?php if ( isset($path_success) ) : ?><?php echo "<p id='message' class='updated fade'>$path_success</p>" ?><?php endif; ?>
64
+
65
+ <p><?php _e( 'To enable forums for each group in a BuddyPress installation, you must first download, install, and setup bbPress and integrate it with WordPress MU.', 'buddypress' ) ?></p>
66
+ <p><?php _e( 'Once you have bbPress set up correctly, enter the options below so that BuddyPress can connect.', 'buddypress' ) ?></p>
67
+
68
+ <form action="<?php echo site_url() . '/wp-admin/admin.php?page=' . BP_PLUGIN_DIR . '/bp-forums/bp-forums-admin.php' ?>" name="bbpress-path-form" id="bbpress-path-form" method="post">
69
+ <input type="hidden" name="option_page" value="bbpress-live" />
70
+
71
+ <table class="form-table">
72
+ <tr valign="top">
73
+ <th scope="row"><label for="target_uri"><?php _e( 'bbPress URL', 'buddypress' ) ?></label></th>
74
+ <td>
75
+ <input name="target_uri" type="text" id="target_uri" value="<?php echo attribute_escape( $fetch_options['target_uri'] ); ?>" size="60" /><br />
76
+ <?php _e( 'The URL of the location you installed bbPress. For example, http://example.com/forums/', 'buddypress' ); ?>
77
+ </td>
78
+ </tr>
79
+ <tr valign="top">
80
+ <th scope="row"><label for="username"><?php _e( 'bbPress username', 'buddypress' ) ?></label></th>
81
+ <td>
82
+ <input name="username" type="text" id="username" value="<?php echo attribute_escape( $fetch_options['username'] ); ?>" size="20" /><br />
83
+ <?php _e( 'The username for the user (with admin rights) that you created for BuddyPress integration', 'buddypress' ); ?>
84
+ </td>
85
+ </tr>
86
+ <tr valign="top">
87
+ <th scope="row"><label for="password"><?php _e( 'bbPress password', 'buddypress' ) ?></label></th>
88
+ <td>
89
+ <input name="password" type="password" id="password" value="<?php echo attribute_escape( $fetch_options['password'] ); ?>" size="20" /><br />
90
+ <?php _e( 'The password for the user (with admin rights) that you created for BuddyPress integration', 'buddypress' ); ?>
91
+ </td>
92
+ </tr>
93
+ </table>
94
+ <br />
95
+ <h3><?php _e( 'Cache requests', 'buddypress' ) ?></h3>
96
+ <table class="form-table">
97
+ <tr valign="top">
98
+ <th scope="row"><label for="cache_enabled"><?php _e( 'Caching enabled', 'buddypress' ) ?></label></th>
99
+ <td>
100
+ <input name="cache_enabled" type="checkbox" id="cache_enabled" value="1"<?php echo( $options['cache_enabled'] ? ' checked="checked"' : '' ); ?> />
101
+ <?php _e( 'Turn on caching of requests to reduce latency and load.', 'buddypress' ); ?>
102
+ </td>
103
+ </tr>
104
+ <tr valign="top">
105
+ <th scope="row"><label for="cache_timeout"><?php _e( 'Cache timeout', 'buddypress' ) ?></label></th>
106
+ <td>
107
+ <input name="cache_timeout" type="text" id="cache_timeout" value="<?php echo attribute_escape( $options['cache_timeout'] ); ?>" size="10" /> <?php _e( '(seconds)', 'buddypress' ) ?><br />
108
+ <?php _e( 'The amount of time in seconds that a cached request is valid for.', 'buddypress' ); ?>
109
+ </td>
110
+ </tr>
111
+ </table>
112
+ <br />
113
+ <p class="submit">
114
+ <input class="button-primary" type="submit" name="submit" value="<?php _e('Save Settings', 'buddypress') ?>"/>
115
+ </p>
116
+ <?php wp_nonce_field('bbpress-settings') ?>
117
+ </form>
118
+ </div>
119
+ <?php
120
+ }
121
+ ?>
bp-forums/bp-forums-bbpress-live.php ADDED
@@ -0,0 +1,683 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class bbPress_Live_Widget_Forums
4
+ {
5
+ var $options;
6
+
7
+ function bbPress_Live_Widget_Forums()
8
+ {
9
+ if ( !$this->options = get_option( 'bbpress_live_widget_forums' ) ) {
10
+ $this->options = array();
11
+ }
12
+
13
+ add_action( 'widgets_init', array($this, 'init') );
14
+ }
15
+
16
+ function init()
17
+ {
18
+ $widget_options = array(
19
+ 'classname' => 'bbpress_live_widget_forums',
20
+ 'description' => __( 'Forum lists from your bbPress forums', 'buddypress' )
21
+ );
22
+
23
+ $control_options = array(
24
+ 'height' => 350,
25
+ 'id_base' => 'bbpress_live_widget_forums'
26
+ );
27
+
28
+ if ( !count($this->options) ) {
29
+ $options = array(-1 => false);
30
+ } else {
31
+ $options = $this->options;
32
+ }
33
+ foreach ( $options as $instance => $option ) {
34
+ wp_register_sidebar_widget(
35
+ 'bbpress_live_widget_forums-' . $instance,
36
+ __('bbPress Forum list', 'buddypress'),
37
+ array($this, 'display'),
38
+ $widget_options,
39
+ array( 'number' => $instance )
40
+ );
41
+
42
+ wp_register_widget_control(
43
+ 'bbpress_live_widget_forums-' . $instance,
44
+ __('bbPress Forum list', 'buddypress'),
45
+ array($this, 'control'),
46
+ $control_options,
47
+ array( 'number' => $instance )
48
+ );
49
+ }
50
+ }
51
+
52
+ function display( $args, $instance = false )
53
+ {
54
+ if ( is_array( $instance ) ) {
55
+ $instance = $instance['number'];
56
+ }
57
+
58
+ if ( !$instance || !is_numeric($instance) || 1 > $instance ) {
59
+ return;
60
+ }
61
+
62
+ global $bbpress_live;
63
+
64
+ extract($args);
65
+
66
+ echo $before_widget;
67
+ if ( $this->options[$instance]['title'] ) {
68
+ echo $before_title;
69
+ echo $this->options[$instance]['title'];
70
+ echo $after_title;
71
+ }
72
+
73
+ if ( $forums = $bbpress_live->get_forums($this->options[$instance]['parent'], $this->options[$instance]['depth']) ) {
74
+ switch ($this->options[$instance]['layout']) {
75
+ default:
76
+ case 'list':
77
+ echo '<ol>';
78
+ foreach ( $forums as $forum ) {
79
+ echo '<li>';
80
+ echo '<a href="' . $forum['forum_uri'] . '">' . $forum['forum_name'] . '</a> ';
81
+ echo '</li>';
82
+ }
83
+ echo '</ol>';
84
+ break;
85
+
86
+ case 'table':
87
+ echo '<table>';
88
+ echo '<tr>';
89
+ echo '<th>'. __('Forum', 'buddypress') . '</th>';
90
+ echo '<th>'. __('Topics', 'buddypress') . '</th>';
91
+ echo '<th>'. __('Posts', 'buddypress') . '</th>';
92
+ echo '</tr>';
93
+ foreach ( $forums as $forum ) {
94
+ echo '<tr>';
95
+ echo '<td><a href="' . $forum['forum_uri'] . '">' . $forum['forum_name'] . '</a></td>';
96
+ echo '<td>' . $forum['topics'] . '</td>';
97
+ echo '<td>' . $forum['posts'] . '</td>';
98
+ echo '</tr>';
99
+ }
100
+ echo '</table>';
101
+ break;
102
+ }
103
+ }
104
+ echo $after_widget;
105
+ }
106
+
107
+ function control( $instance = false )
108
+ {
109
+ if ( is_array( $instance ) ) {
110
+ $instance = $instance['number'];
111
+ }
112
+
113
+ if ( !$instance || !is_numeric($instance) || 1 > $instance ) {
114
+ $instance = '%i%';
115
+ }
116
+
117
+ $options = $this->options;
118
+
119
+ if ( 'POST' == strtoupper( $_SERVER['REQUEST_METHOD'] ) ) {
120
+ if ( isset( $_POST['bbpress_live_widget_forums'] ) ) {
121
+ foreach ( $_POST['bbpress_live_widget_forums'] as $_instance => $_value ) {
122
+ if ( !$_value ) {
123
+ continue;
124
+ }
125
+ $options[$_instance]['title'] = strip_tags( stripslashes( $_POST['bbpress_live_widget_forums'][$_instance]['title'] ) );
126
+ $options[$_instance]['parent'] = strip_tags( stripslashes( $_POST['bbpress_live_widget_forums'][$_instance]['parent'] ) );
127
+ $options[$_instance]['depth'] = (int) $_POST['bbpress_live_widget_forums'][$_instance]['depth'];
128
+ $layout = $_POST['bbpress_live_widget_forums'][$_instance]['layout'];
129
+ if ( in_array( $layout, array('list', 'table') ) ) {
130
+ $options[$_instance]['layout'] = $layout;
131
+ } else {
132
+ $options[$_instance]['layout'] = 'list';
133
+ }
134
+ }
135
+ if ( $this->options != $options ) {
136
+ $this->options = $options;
137
+ update_option('bbpress_live_widget_forums', $this->options);
138
+ }
139
+ } else {
140
+ $this->options = array();
141
+ delete_option('bbpress_live_widget_forums');
142
+ }
143
+ }
144
+
145
+ $options['%i%']['title'] = '';
146
+ $options['%i%']['parent'] = '';
147
+ $options['%i%']['depth'] = '';
148
+ $options['%i%']['layout'] = 'list';
149
+
150
+ $title = attribute_escape( stripslashes( $options[$instance]['title'] ) );
151
+ $parent = attribute_escape( stripslashes( $options[$instance]['parent'] ) );
152
+ if ( !$depth = $options[$instance]['depth'] ) {
153
+ $depth = '';
154
+ }
155
+ if ( !$options[$instance]['layout'] ) {
156
+ $options[$instance]['layout'] = 'list';
157
+ }
158
+ $layout = array(
159
+ 'list' => '',
160
+ 'table' => ''
161
+ );
162
+ $layout[$options[$instance]['layout']] = ' checked="checked"';
163
+ ?>
164
+ <p>
165
+ <label for="bbpress_live_widget_forums_title_<?php echo $instance; ?>">
166
+ <?php _e('Title:', 'buddypress'); ?>
167
+ <input class="widefat" id="bbpress_live_widget_forums_title_<?php echo $instance; ?>" name="bbpress_live_widget_forums[<?php echo $instance; ?>][title]" type="text" value="<?php echo $title; ?>" />
168
+ </label>
169
+ </p>
170
+ <p>
171
+ <label for="bbpress_live_widget_forums_parent_<?php echo $instance; ?>">
172
+ <?php _e('Parent forum id or slug (optional):', 'buddypress'); ?>
173
+ <input class="widefat" id="bbpress_live_widget_forums_parent_<?php echo $instance; ?>" name="bbpress_live_widget_forums[<?php echo $instance; ?>][parent]" type="text" value="<?php echo $parent; ?>" />
174
+ </label>
175
+ </p>
176
+ <p>
177
+ <label for="bbpress_live_widget_forums_depth_<?php echo $instance; ?>">
178
+ <?php _e('Hierarchy depth:', 'buddypress'); ?>
179
+ <input style="width: 25px;" id="bbpress_live_widget_forums_depth_<?php echo $instance; ?>" name="bbpress_live_widget_forums[<?php echo $instance; ?>][depth]" type="text" value="<?php echo $depth; ?>" />
180
+ </label>
181
+ </p>
182
+ <div>
183
+ <p style="margin-bottom: 0;">
184
+ <?php _e('Layout style:', 'buddypress'); ?>
185
+ </p>
186
+ <div>
187
+ <label for="bbpress_live_widget_forums_list_<?php echo $instance; ?>">
188
+ <input id="bbpress_live_widget_forums_list_<?php echo $instance; ?>" name="bbpress_live_widget_forums[<?php echo $instance; ?>][layout]" type="radio" value="list"<?php echo $layout['list']; ?> /> <?php _e('ordered list', 'buddypress'); ?>
189
+ </label>
190
+ </div>
191
+ <div>
192
+ <label for="bbpress_live_widget_forums_table_<?php echo $instance; ?>">
193
+ <input id="bbpress_live_widget_forums_table_<?php echo $instance; ?>" name="bbpress_live_widget_forums[<?php echo $instance; ?>][layout]" type="radio" value="table"<?php echo $layout['table']; ?> /> <?php _e('table', 'buddypress'); ?>
194
+ </label>
195
+ </div>
196
+ </div>
197
+ <input type="hidden" id="bbpress_live_widget_forums_submit" name="bbpress_live_widget_forums[<?php echo $instance; ?>][submit]" value="1" />
198
+ <?php
199
+ }
200
+ }
201
+
202
+
203
+
204
+ class bbPress_Live_Widget_Topics
205
+ {
206
+ var $options;
207
+
208
+ function bbPress_Live_Widget_Topics()
209
+ {
210
+ if ( !$this->options = get_option( 'bbpress_live_widget_topics' ) ) {
211
+ $this->options = array();
212
+ }
213
+
214
+ add_action( 'widgets_init', array($this, 'init') );
215
+ }
216
+
217
+ function init()
218
+ {
219
+ $widget_options = array(
220
+ 'classname' => 'bbpress_live_widget_topics',
221
+ 'description' => __( 'The latest topics from your bbPress forums', 'buddypress' )
222
+ );
223
+
224
+ $control_options = array(
225
+ 'height' => 350,
226
+ 'id_base' => 'bbpress_live_widget_topics'
227
+ );
228
+
229
+ if ( !count($this->options) ) {
230
+ $options = array(-1 => false);
231
+ } else {
232
+ $options = $this->options;
233
+ }
234
+ foreach ( $options as $instance => $option ) {
235
+ wp_register_sidebar_widget(
236
+ 'bbpress_live_widget_topics-' . $instance,
237
+ __('bbPress latest topics', 'buddypress'),
238
+ array($this, 'display'),
239
+ $widget_options,
240
+ array( 'number' => $instance )
241
+ );
242
+
243
+ wp_register_widget_control(
244
+ 'bbpress_live_widget_topics-' . $instance,
245
+ __('bbPress latest topics', 'buddypress'),
246
+ array($this, 'control'),
247
+ $control_options,
248
+ array( 'number' => $instance )
249
+ );
250
+ }
251
+ }
252
+
253
+ function display( $args, $instance = false )
254
+ {
255
+ if ( is_array( $instance ) ) {
256
+ $instance = $instance['number'];
257
+ }
258
+
259
+ if ( !$instance || !is_numeric($instance) || 1 > $instance ) {
260
+ return;
261
+ }
262
+
263
+ global $bbpress_live;
264
+
265
+ extract($args);
266
+
267
+ echo $before_widget;
268
+ if ( $this->options[$instance]['title'] ) {
269
+ echo $before_title;
270
+ echo $this->options[$instance]['title'];
271
+ echo $after_title;
272
+ }
273
+
274
+ if ( $topics = $bbpress_live->get_topics($this->options[$instance]['forum'], $this->options[$instance]['number']) ) {
275
+ switch ($this->options[$instance]['layout']) {
276
+ default:
277
+ case 'list':
278
+ echo '<ol>';
279
+ foreach ( $topics as $topic ) {
280
+ echo '<li>';
281
+ echo '<a href="' . $topic['topic_uri'] . '">' . $topic['topic_title'] . '</a> ';
282
+ printf( __( '%1$s posted %2$s ago', 'buddypress' ), $topic['topic_last_poster_display_name'], $topic['topic_time_since'] );
283
+ echo '</li>';
284
+ }
285
+ echo '</ol>';
286
+ break;
287
+
288
+ case 'table':
289
+ echo '<table>';
290
+ echo '<tr>';
291
+ echo '<th>'. __('Topic', 'buddypress') . '</th>';
292
+ echo '<th>'. __('Posts', 'buddypress') . '</th>';
293
+ echo '<th>'. __('Last Poster', 'buddypress') . '</th>';
294
+ echo '<th>'. __('Freshness', 'buddypress') . '</th>';
295
+ echo '</tr>';
296
+ foreach ( $topics as $topic ) {
297
+ echo '<tr>';
298
+ echo '<td><a href="' . $topic['topic_uri'] . '">' . $topic['topic_title'] . '</a></td>';
299
+ echo '<td>' . $topic['topic_posts'] . '</td>';
300
+ echo '<td>' . $topic['topic_last_poster_display_name'] . '</td>';
301
+ echo '<td>' . $topic['topic_time_since'] . '</td>';
302
+ echo '</tr>';
303
+ }
304
+ echo '</table>';
305
+ break;
306
+ }
307
+ }
308
+ echo $after_widget;
309
+ }
310
+
311
+ function control( $instance = false )
312
+ {
313
+ if ( is_array( $instance ) ) {
314
+ $instance = $instance['number'];
315
+ }
316
+
317
+ if ( !$instance || !is_numeric($instance) || 1 > $instance ) {
318
+ $instance = '%i%';
319
+ }
320
+
321
+ $options = $this->options;
322
+
323
+ if ( 'POST' == strtoupper( $_SERVER['REQUEST_METHOD'] ) ) {
324
+ if ( isset( $_POST['bbpress_live_widget_topics'] ) ) {
325
+ foreach ( $_POST['bbpress_live_widget_topics'] as $_instance => $_value ) {
326
+ if ( !$_value ) {
327
+ continue;
328
+ }
329
+ $options[$_instance]['title'] = strip_tags( stripslashes( $_POST['bbpress_live_widget_topics'][$_instance]['title'] ) );
330
+ $options[$_instance]['forum'] = strip_tags( stripslashes( $_POST['bbpress_live_widget_topics'][$_instance]['forum'] ) );
331
+ $options[$_instance]['number'] = (int) $_POST['bbpress_live_widget_topics'][$_instance]['number'];
332
+ $layout = $_POST['bbpress_live_widget_topics'][$_instance]['layout'];
333
+ if ( in_array( $layout, array('list', 'table') ) ) {
334
+ $options[$_instance]['layout'] = $layout;
335
+ } else {
336
+ $options[$_instance]['layout'] = 'list';
337
+ }
338
+ }
339
+ if ( $this->options != $options ) {
340
+ $this->options = $options;
341
+ update_option('bbpress_live_widget_topics', $this->options);
342
+ }
343
+ } else {
344
+ $this->options = array();
345
+ delete_option('bbpress_live_widget_topics');
346
+ }
347
+ }
348
+
349
+ $options['%i%']['title'] = '';
350
+ $options['%i%']['forum'] = '';
351
+ $options['%i%']['number'] = 5;
352
+ $options['%i%']['layout'] = 'list';
353
+
354
+ $title = attribute_escape( stripslashes( $options[$instance]['title'] ) );
355
+ $forum = attribute_escape( stripslashes( $options[$instance]['forum'] ) );
356
+ if ( !$number = (int) $options[$instance]['number'] ) {
357
+ $number = 5;
358
+ }
359
+ if ( !$options[$instance]['layout'] ) {
360
+ $options[$instance]['layout'] = 'list';
361
+ }
362
+ $layout = array(
363
+ 'list' => '',
364
+ 'table' => ''
365
+ );
366
+ $layout[$options[$instance]['layout']] = ' checked="checked"';
367
+ ?>
368
+ <p>
369
+ <label for="bbpress_live_widget_topics_title_<?php echo $instance; ?>">
370
+ <?php _e('Title:', 'buddypress'); ?>
371
+ <input class="widefat" id="bbpress_live_widget_topics_title_<?php echo $instance; ?>" name="bbpress_live_widget_topics[<?php echo $instance; ?>][title]" type="text" value="<?php echo $title; ?>" />
372
+ </label>
373
+ </p>
374
+ <p>
375
+ <label for="bbpress_live_widget_topics_forum_<?php echo $instance; ?>">
376
+ <?php _e('Forum id or slug (optional):', 'buddypress'); ?>
377
+ <input class="widefat" id="bbpress_live_widget_topics_forum_<?php echo $instance; ?>" name="bbpress_live_widget_topics[<?php echo $instance; ?>][forum]" type="text" value="<?php echo $forum; ?>" />
378
+ </label>
379
+ </p>
380
+ <p>
381
+ <label for="bbpress_live_widget_topics_number_<?php echo $instance; ?>">
382
+ <?php _e('Number of topics to show:', 'buddypress'); ?>
383
+ <input style="width: 25px;" id="bbpress_live_widget_topics_number_<?php echo $instance; ?>" name="bbpress_live_widget_topics[<?php echo $instance; ?>][number]" type="text" value="<?php echo $number; ?>" />
384
+ </label>
385
+ </p>
386
+ <div>
387
+ <p style="margin-bottom: 0;">
388
+ <?php _e('Layout style:', 'buddypress'); ?>
389
+ </p>
390
+ <div>
391
+ <label for="bbpress_live_widget_topics_list_<?php echo $instance; ?>">
392
+ <input id="bbpress_live_widget_topics_list_<?php echo $instance; ?>" name="bbpress_live_widget_topics[<?php echo $instance; ?>][layout]" type="radio" value="list"<?php echo $layout['list']; ?> /> <?php _e('ordered list', 'buddypress'); ?>
393
+ </label>
394
+ </div>
395
+ <div>
396
+ <label for="bbpress_live_widget_topics_table_<?php echo $instance; ?>">
397
+ <input id="bbpress_live_widget_topics_table_<?php echo $instance; ?>" name="bbpress_live_widget_topics[<?php echo $instance; ?>][layout]" type="radio" value="table"<?php echo $layout['table']; ?> /> <?php _e('table', 'buddypress'); ?>
398
+ </label>
399
+ </div>
400
+ </div>
401
+ <input type="hidden" id="bbpress_live_widget_topics_submit" name="bbpress_live_widget_topics[<?php echo $instance; ?>][submit]" value="1" />
402
+ <?php
403
+ }
404
+ }
405
+
406
+ class bbPress_Live_Fetch
407
+ {
408
+ var $endpoint = false;
409
+ var $result;
410
+ var $readonly_methods = array(
411
+ 'bb.getForums',
412
+ 'bb.getTopics'
413
+ );
414
+
415
+ function bbPress_Live_Fetch()
416
+ {
417
+ $this->options = array(
418
+ 'target_uri' => '',
419
+ 'username' => '',
420
+ 'password' => '',
421
+ 'always_use_auth' => false
422
+ );
423
+
424
+ if ( $options = get_option( 'bbpress_live_fetch' ) ) {
425
+ $this->options = array_merge( $this->options, $options );
426
+ }
427
+
428
+ $this->set_endpoint( $this->options['target_uri'] );
429
+ }
430
+
431
+ function set_endpoint( $uri = false )
432
+ {
433
+ $old_endpoint = $this->endpoint;
434
+ if ( $new_endpoint = discover_pingback_server_uri( $uri ) ) {
435
+ $this->endpoint = $new_endpoint;
436
+ }
437
+ return $old_endpoint;
438
+ }
439
+
440
+ function query( $method, $args = false, $username = false )
441
+ {
442
+ if (!$method) {
443
+ return false;
444
+ }
445
+
446
+ $client = new IXR_Client( $this->endpoint );
447
+ $client->debug = false;
448
+ $client->timeout = 3;
449
+ $client->useragent .= ' -- bbPress Live Data/0.1.2';
450
+
451
+ if ( !$username ) {
452
+ $username = $this->options['username'];
453
+ } else {
454
+ $username = array( $this->options['username'], $username );
455
+ }
456
+
457
+ $password = $this->options['password'];
458
+
459
+ array_unshift( $args, $username, $password );
460
+
461
+ if ( !$client->query( $method, $args ) ) {
462
+ //var_dump( $client->message, $client->error ); die;
463
+ return false;
464
+ }
465
+
466
+ return $client->getResponse();
467
+ }
468
+ }
469
+
470
+
471
+ class bbPress_Live
472
+ {
473
+ var $options;
474
+ var $fetch;
475
+
476
+ function bbPress_Live()
477
+ {
478
+ $this->options = array(
479
+ 'cache_enabled' => false,
480
+ 'cache_timeout' => 3600,
481
+ 'widget_forums' => true,
482
+ 'widget_topics' => true,
483
+ 'post_to_topic' => false,
484
+ 'post_to_topic_forum' => false,
485
+ 'post_to_topic_delay' => 60,
486
+ 'host_all_comments' => false
487
+ );
488
+
489
+ if ( $options = get_option('buddypress') ) {
490
+ $this->options = array_merge( $this->options, $options );
491
+ }
492
+
493
+ $this->fetch = new bbPress_Live_Fetch();
494
+
495
+ if ( $this->options['widget_forums'] ) {
496
+ new bbPress_Live_Widget_Forums();
497
+ }
498
+
499
+ if ( $this->options['widget_topics'] ) {
500
+ new bbPress_Live_Widget_Topics();
501
+ }
502
+ }
503
+
504
+ function cache_update( $key, $value )
505
+ {
506
+ if ( !$key ) {
507
+ return false;
508
+ }
509
+
510
+ if ( !$value ) {
511
+ return $this->cache_delete( $key );
512
+ }
513
+
514
+ $cache = array(
515
+ 'time' => time(),
516
+ 'content' => $value
517
+ );
518
+
519
+ if ( !update_option( 'bbpress_live_cache_' . $key, $cache ) ) {
520
+ return false;
521
+ }
522
+
523
+ return $cache['time'];
524
+ }
525
+
526
+ function cache_delete( $key )
527
+ {
528
+ if ( !$key ) {
529
+ return false;
530
+ }
531
+
532
+ if ( !delete_option( 'bbpress_live_cache_' . $key ) ) {
533
+ return false;
534
+ }
535
+
536
+ return true;
537
+ }
538
+
539
+ function cache_get( $key )
540
+ {
541
+ if ( !$key ) {
542
+ return false;
543
+ }
544
+
545
+ if ( !$this->options['cache_enabled'] ) {
546
+ return false;
547
+ }
548
+
549
+ $cache = get_option( 'bbpress_live_cache_' . $key );
550
+
551
+ if ( ( (int) $cache['time'] + (int) $this->options['cache_timeout'] ) < time() ) {
552
+ return false;
553
+ }
554
+
555
+ return $cache['content'];
556
+ }
557
+
558
+ function get_forums( $parent = 0, $depth = 0 )
559
+ {
560
+ $key = md5('forums_' . $parent . '_' . $depth);
561
+
562
+ if ( $forums = $this->cache_get( $key ) ) {
563
+ return $forums;
564
+ }
565
+
566
+ if ( !$forums = $this->fetch->query( 'bb.getForums', array($parent, $depth) ) ) {
567
+ return false;
568
+ }
569
+
570
+ $this->cache_update( $key, $forums );
571
+
572
+ return $forums;
573
+ }
574
+
575
+ function get_topics( $forum = 0, $number = 0, $page = 1 )
576
+ {
577
+ $key = md5('topics_' . $forum . '_' . $number . '_' . $page);
578
+
579
+ if ( $topics = $this->cache_get( $key ) ) {
580
+ return $topics;
581
+ }
582
+
583
+ if ( !$topics = $this->fetch->query( 'bb.getTopics', array($forum, $number, $page) ) ) {
584
+ return false;
585
+ }
586
+
587
+ $this->cache_update( $key, $topics );
588
+
589
+ return $topics;
590
+ }
591
+
592
+ function get_topic_details( $topic_id )
593
+ {
594
+ $key = md5( 'topic_' . $topic_id );
595
+
596
+ if ( $topic = $this->cache_get( $key ) ) {
597
+ return $topic;
598
+ }
599
+
600
+ if ( !$topic = $this->fetch->query( 'bb.getTopic', array( $topic_id ) ) ) {
601
+ return false;
602
+ }
603
+
604
+ $this->cache_update( $key, $topic );
605
+
606
+ return $topic;
607
+ }
608
+
609
+ function new_forum( $name = '', $desc = '', $parent = 0, $order = 0, $is_category = false )
610
+ {
611
+ if ( !$forum = $this->fetch->query( 'bb.newForum', array( array( 'name' => $name, 'description' => $desc, 'parent_id' => $parent, 'order' => $order, 'is_category' => $is_category ) ) ) ) {
612
+ return false;
613
+ }
614
+
615
+ return $forum;
616
+ }
617
+
618
+ function get_posts( $topic = 0, $number = 0, $page = 1 )
619
+ {
620
+ $key = md5('posts_' . $topic . '_' . $number . '_' . $page);
621
+
622
+ if ( $posts = $this->cache_get( $key ) ) {
623
+ return $posts;
624
+ }
625
+
626
+ if ( !$posts = $this->fetch->query( 'bb.getPosts', array( $topic, $number, $page ) ) ) {
627
+ return false;
628
+ }
629
+
630
+ $this->cache_update( $key, $posts );
631
+
632
+ return $posts;
633
+ }
634
+
635
+ function get_post( $post_id = 0 )
636
+ {
637
+ $key = md5( 'post_' . $post_id );
638
+
639
+ if ( $post = $this->cache_get( $key ) ) {
640
+ return $post;
641
+ }
642
+
643
+ if ( !$post = $this->fetch->query( 'bb.getPost', array( $post_id ) ) ) {
644
+ return false;
645
+ }
646
+
647
+ $this->cache_update( $key, $post );
648
+
649
+ return $post;
650
+ }
651
+
652
+ function new_post( $post_text = '', $topic = 0 )
653
+ {
654
+ global $current_user;
655
+
656
+ if ( !$post = $this->fetch->query( 'bb.newPost', array( array( 'text' => $post_text, 'topic_id' => $topic ) ), $current_user->user_login ) ) {
657
+ return false;
658
+ }
659
+
660
+ $key = md5( 'post_' . $post->post_id );
661
+ $this->cache_update( $key, $post );
662
+
663
+ return $post;
664
+ }
665
+
666
+ function new_topic( $title = '', $topic_text = '', $tags = '', $forum = 0 )
667
+ {
668
+ global $current_user;
669
+
670
+ if ( !$topic = $this->fetch->query( 'bb.newTopic', array( array( 'title' => $title, 'text' => $topic_text, 'tags' => $tags, 'forum_id' => (int)$forum ) ), $current_user->user_login ) ) {
671
+ return false;
672
+ }
673
+
674
+ $key = md5( 'topic_' . $topic->topic_id );
675
+ $this->cache_update( $key, $post );
676
+
677
+ return $topic;
678
+ }
679
+
680
+ }
681
+
682
+
683
+ ?>
bp-forums/bp-forums-filters.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /* BuddyPress filters */
4
+ add_filter( 'bp_forums_new_post_text', 'bp_forums_filter_encode' );
5
+
6
+ add_filter( 'bp_get_the_topic_post_content', 'bp_forums_filter_decode' );
7
+ add_filter( 'bp_get_the_topic_latest_post_excerpt', 'bp_forums_filter_decode' );
8
+
9
+ add_filter( 'bp_get_the_topic_latest_post_excerpt', 'bp_create_excerpt' );
10
+
11
+ /* Apply WordPress defined filters */
12
+ add_filter( 'bp_get_the_topic_title', 'wptexturize' );
13
+ add_filter( 'bp_get_the_topic_poster_name', 'wptexturize' );
14
+ add_filter( 'bp_get_the_topic_last_poster_name', 'wptexturize' );
15
+ add_filter( 'bp_get_the_topic_post_content', 'wptexturize' );
16
+ add_filter( 'bp_get_the_topic_post_poster_name', 'wptexturize' );
17
+
18
+ add_filter( 'bp_get_the_topic_title', 'convert_smilies' );
19
+ add_filter( 'bp_get_the_topic_latest_post_excerpt', 'convert_smilies' );
20
+ add_filter( 'bp_get_the_topic_post_content', 'convert_smilies' );
21
+
22
+ add_filter( 'bp_get_the_topic_title', 'convert_chars' );
23
+ add_filter( 'bp_get_the_topic_latest_post_excerpt', 'convert_chars' );
24
+ add_filter( 'bp_get_the_topic_post_content', 'convert_chars' );
25
+
26
+ add_filter( 'bp_get_the_topic_post_content', 'wpautop' );
27
+ add_filter( 'bp_get_the_topic_latest_post_excerpt', 'wpautop' );
28
+
29
+ add_filter( 'bp_get_the_topic_post_content', 'stripslashes_deep' );
30
+ add_filter( 'bp_get_the_topic_title', 'stripslashes_deep' );
31
+ add_filter( 'bp_get_the_topic_latest_post_excerpt', 'stripslashes_deep' );
32
+
33
+ add_filter( 'bp_get_the_topic_post_content', 'make_clickable' );
34
+
35
+ function bp_forums_add_allowed_tags( $allowedtags ) {
36
+ $allowedtags['p'] = array();
37
+ $allowedtags['br'] = array();
38
+
39
+ return $allowedtags;
40
+ }
41
+ add_filter( 'edit_allowedtags', 'bp_forums_add_allowed_tags' );
42
+
43
+
44
+ function bp_forums_filter_encode( $content ) {
45
+ $content = htmlentities( $content, ENT_COMPAT, "UTF-8" );
46
+ $content = str_replace( '&', '/amp/', $content );
47
+
48
+ return $content;
49
+ }
50
+
51
+ function bp_forums_filter_decode( $content ) {
52
+ $content = str_replace( '/amp/', '&', $content );
53
+ $content = @html_entity_decode( $content, ENT_COMPAT, "UTF-8" );
54
+ $content = str_replace( '[', '<', $content );
55
+ $content = str_replace( ']', '>', $content );
56
+ $content = stripslashes( wp_filter_kses( $content ) );
57
+
58
+ return $content;
59
+ }
60
+
61
+ ?>
bp-forums/bp-forums-templatetags.php ADDED
@@ -0,0 +1,601 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class BP_Forums_Template_Forum {
4
+ var $current_topic = -1;
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( $forum_id, $per_page, $max ) {
22
+ global $bp, $current_user;
23
+
24
+ $this->pag_page = isset( $_REQUEST['forum_page'] ) ? intval( $_REQUEST['forum_page'] ) : 1;
25
+ $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
26
+
27
+ $this->topics = bp_forums_get_topics( $forum_id, $this->pag_num, $this->pag_page );
28
+
29
+ if ( !$this->topics ) {
30
+ $this->topic_count = 0;
31
+ $this->total_topic_count = 0;
32
+ } else {
33
+ if ( !$max )
34
+ $this->total_topic_count = count( bp_forums_get_topics( $forum_id ) );
35
+ else
36
+ $this->total_topic_count = (int)$max;
37
+
38
+ if ( $max ) {
39
+ if ( $max >= count($this->topics) )
40
+ $this->topic_count = count( $this->topics );
41
+ else
42
+ $this->topic_count = (int)$max;
43
+ } else {
44
+ $this->topic_count = count( $this->topics );
45
+ }
46
+ }
47
+
48
+ $this->pag_links = paginate_links( array(
49
+ 'base' => add_query_arg( array( 'forum_page' => '%#%', 'num' => $this->pag_num ) ),
50
+ 'format' => '',
51
+ 'total' => ceil($this->total_topic_count / $this->pag_num),
52
+ 'current' => $this->pag_page,
53
+ 'prev_text' => '&laquo;',
54
+ 'next_text' => '&raquo;',
55
+ 'mid_size' => 1
56
+ ));
57
+ }
58
+
59
+ function has_topics() {
60
+ if ( $this->topic_count )
61
+ return true;
62
+
63
+ return false;
64
+ }
65
+
66
+ function next_topic() {
67
+ $this->current_topic++;
68
+ $this->topic = $this->topics[$this->current_topic];
69
+
70
+ return $this->topic;
71
+ }
72
+
73
+ function rewind_topics() {
74
+ $this->current_topic = -1;
75
+ if ( $this->topic_count > 0 ) {
76
+ $this->topic = $this->topics[0];
77
+ }
78
+ }
79
+
80
+ function user_topics() {
81
+ if ( $this->current_topic + 1 < $this->topic_count ) {
82
+ return true;
83
+ } elseif ( $this->current_topic + 1 == $this->topic_count ) {
84
+ do_action('loop_end');
85
+ // Do some cleaning up after the loop
86
+ $this->rewind_topics();
87
+ }
88
+
89
+ $this->in_the_loop = false;
90
+ return false;
91
+ }
92
+
93
+ function the_topic() {
94
+ global $topic;
95
+
96
+ $this->in_the_loop = true;
97
+ $this->topic = $this->next_topic();
98
+ $this->topic = (object)$this->topic;
99
+
100
+ if ( $this->current_topic == 0 ) // loop has just started
101
+ do_action('loop_start');
102
+ }
103
+ }
104
+
105
+ function bp_has_topics( $args = '' ) {
106
+ global $forum_template, $bp;
107
+ global $group_obj;
108
+
109
+ $defaults = array(
110
+ 'forum_id' => false,
111
+ 'per_page' => 10,
112
+ 'max' => false
113
+ );
114
+
115
+ $r = wp_parse_args( $args, $defaults );
116
+ extract( $r, EXTR_SKIP );
117
+
118
+ if ( !$forum_id && $bp->current_component == $bp->groups->slug && 'forum' == $bp->current_action )
119
+ $forum_id = groups_get_groupmeta( $group_obj->id, 'forum_id' );
120
+
121
+ if ( is_numeric( $forum_id ) )
122
+ $forum_template = new BP_Forums_Template_Forum( $forum_id, $per_page, $max );
123
+ else
124
+ return false;
125
+
126
+ return $forum_template->has_topics();
127
+ }
128
+
129
+ function bp_topics() {
130
+ global $forum_template;
131
+ return $forum_template->user_topics();
132
+ }
133
+
134
+ function bp_the_topic() {
135
+ global $forum_template;
136
+ return $forum_template->the_topic();
137
+ }
138
+
139
+ function bp_the_topic_id() {
140
+ echo bp_get_the_topic_id();
141
+ }
142
+ function bp_get_the_topic_id() {
143
+ global $forum_template;
144
+
145
+ return apply_filters( 'bp_get_the_topic_id', $forum_template->topic->topic_id );
146
+ }
147
+
148
+ function bp_the_topic_title() {
149
+ echo bp_get_the_topic_title();
150
+ }
151
+ function bp_get_the_topic_title() {
152
+ global $forum_template;
153
+
154
+ return apply_filters( 'bp_get_the_topic_title', stripslashes( $forum_template->topic->topic_title ) );
155
+ }
156
+
157
+ function bp_the_topic_slug() {
158
+ echo bp_get_the_topic_slug();
159
+ }
160
+ function bp_get_the_topic_slug() {
161
+ global $forum_template;
162
+
163
+ return apply_filters( 'bp_get_the_topic_slug', $forum_template->topic->topic_slug );
164
+ }
165
+
166
+ function bp_the_topic_poster_id() {
167
+ echo bp_get_the_topic_poster_id();
168
+ }
169
+ function bp_get_the_topic_poster_id() {
170
+ global $forum_template;
171
+
172
+ return apply_filters( 'bp_get_the_topic_poster_id', $forum_template->topic->topic_poster );
173
+ }
174
+
175
+ function bp_the_topic_poster_avatar() {
176
+ echo bp_get_the_topic_poster_avatar();
177
+ }
178
+ function bp_get_the_topic_poster_avatar() {
179
+ global $forum_template;
180
+
181
+ return apply_filters( 'bp_get_the_topic_poster_avatar', bp_core_get_avatar( $forum_template->topic->topic_poster, 1 ) );
182
+ }
183
+
184
+ function bp_the_topic_poster_name() {
185
+ echo bp_get_the_topic_poster_name();
186
+ }
187
+ function bp_get_the_topic_poster_name() {
188
+ global $forum_template;
189
+
190
+ return apply_filters( 'bp_get_the_topic_poster_name', bp_core_get_userlink( $forum_template->topic->topic_poster ) );
191
+ }
192
+
193
+ function bp_the_topic_last_poster_name() {
194
+ echo bp_get_the_topic_last_poster_name();
195
+ }
196
+ function bp_get_the_topic_last_poster_name() {
197
+ global $forum_template;
198
+
199
+ return apply_filters( 'bp_get_the_topic_last_poster_name', bp_core_get_userlink( $forum_template->topic->topic_last_poster ) );
200
+ }
201
+
202
+ function bp_the_topic_last_poster_avatar() {
203
+ echo bp_get_the_topic_last_poster_avatar();
204
+ }
205
+ function bp_get_the_topic_last_poster_avatar() {
206
+ global $forum_template;
207
+
208
+ return apply_filters( 'bp_get_the_topic_last_poster_avatar', bp_core_get_avatar( $forum_template->topic->topic_last_poster, 1 ) );
209
+ }
210
+
211
+ function bp_the_topic_start_time() {
212
+ echo bp_get_the_topic_start_time();
213
+ }
214
+ function bp_get_the_topic_start_time() {
215
+ global $forum_template;
216
+
217
+ return apply_filters( 'bp_get_the_topic_start_time', $forum_template->topic->topic_start_time );
218
+ }
219
+
220
+ function bp_the_topic_time() {
221
+ echo bp_get_the_topic_time();
222
+ }
223
+ function bp_get_the_topic_time() {
224
+ global $forum_template;
225
+
226
+ return apply_filters( 'bp_get_the_topic_time', $forum_template->topic->topic_time );
227
+ }
228
+
229
+ function bp_the_topic_forum_id() {
230
+ echo bp_get_the_topic_forum_id();
231
+ }
232
+ function bp_get_the_topic_forum_id() {
233
+ global $forum_template;
234
+
235
+ return apply_filters( 'bp_get_the_topic_forum_id', $forum_template->topic->topic_forum_id );
236
+ }
237
+
238
+ function bp_the_topic_status() {
239
+ echo bp_get_the_topic_status();
240
+ }
241
+ function bp_get_the_topic_status() {
242
+ global $forum_template;
243
+
244
+ return apply_filters( 'bp_get_the_topic_status', $forum_template->topic->topic_status );
245
+ }
246
+
247
+ function bp_the_topic_is_topic_open() {
248
+ echo bp_get_the_topic_is_topic_open();
249
+ }
250
+ function bp_get_the_topic_is_topic_open() {
251
+ global $forum_template;
252
+
253
+ return apply_filters( 'bp_get_the_topic_is_topic_open', $forum_template->topic->topic_open );
254
+ }
255
+
256
+ function bp_the_topic_last_post_id() {
257
+ echo bp_get_the_topic_last_post_id();
258
+ }
259
+ function bp_get_the_topic_last_post_id() {
260
+ global $forum_template;
261
+
262
+ return apply_filters( 'bp_get_the_topic_last_post_id', $forum_template->topic->topic_last_post_id );
263
+ }
264
+
265
+ function bp_the_topic_is_sticky() {
266
+ echo bp_get_the_topic_is_sticky();
267
+ }
268
+ function bp_get_the_topic_is_sticky() {
269
+ global $forum_template;
270
+
271
+ return apply_filters( 'bp_get_the_topic_is_sticky', $forum_template->topic->topic_sticky );
272
+ }
273
+
274
+ function bp_the_topic_total_post_count() {
275
+ echo bp_get_the_topic_total_post_count();
276
+ }
277
+ function bp_get_the_topic_total_post_count() {
278
+ global $forum_template;
279
+
280
+ if ( $forum_template->topic->topic_posts == 1 )
281
+ return apply_filters( 'bp_get_the_topic_total_post_count', sprintf( __( '%d post', 'buddypress' ), $forum_template->topic->topic_posts ) );
282
+ else
283
+ return apply_filters( 'bp_get_the_topic_total_post_count', sprintf( __( '%d posts', 'buddypress' ), $forum_template->topic->topic_posts ) );
284
+ }
285
+
286
+ function bp_the_topic_tag_count() {
287
+ echo bp_get_the_topic_tag_count();
288
+ }
289
+ function bp_get_the_topic_tag_count() {
290
+ global $forum_template;
291
+
292
+ return apply_filters( 'bp_get_the_topic_tag_count', $forum_template->topic->tag_count );
293
+ }
294
+
295
+ function bp_the_topic_permalink() {
296
+ echo bp_get_the_topic_permalink();
297
+ }
298
+ function bp_get_the_topic_permalink() {
299
+ global $forum_template, $bbpress_live, $group_obj;
300
+
301
+ $target_uri = $bbpress_live->fetch->options['target_uri'];
302
+
303
+ return apply_filters( 'bp_get_the_topic_permalink', bp_get_group_permalink( $group_obj ) . '/forum/topic/' . $forum_template->topic->topic_id );
304
+ }
305
+
306
+ function bp_the_topic_time_since_created() {
307
+ echo bp_get_the_topic_time_since_created();
308
+ }
309
+ function bp_get_the_topic_time_since_created() {
310
+ global $forum_template;
311
+
312
+ return apply_filters( 'bp_get_the_topic_time_since_created', $forum_template->topic->topic_start_time_since );
313
+ }
314
+
315
+ function bp_the_topic_latest_post_excerpt() {
316
+ echo bp_get_the_topic_latest_post_excerpt();
317
+ }
318
+ function bp_get_the_topic_latest_post_excerpt() {
319
+ global $forum_template;
320
+
321
+ $post = bp_forums_get_post( $forum_template->topic->topic_last_post_id );
322
+ return apply_filters( 'bp_get_the_topic_latest_post_excerpt', $post['post_text'] );
323
+ }
324
+
325
+ function bp_the_topic_time_since_last_post( $deprecated = true ) {
326
+ global $forum_template;
327
+
328
+ if ( !$deprecated )
329
+ return bp_get_the_topic_time_since_last_post();
330
+ else
331
+ echo bp_get_the_topic_time_since_last_post();
332
+ }
333
+ function bp_get_the_topic_time_since_last_post() {
334
+ global $forum_template;
335
+
336
+ return apply_filters( 'bp_get_the_topic_time_since_last_post', $forum_template->topic->topic_time_since );
337
+ }
338
+
339
+ function bp_forum_pagination() {
340
+ echo bp_get_forum_pagination();
341
+ }
342
+ function bp_get_forum_pagination() {
343
+ global $forum_template;
344
+
345
+ return apply_filters( 'bp_get_forum_pagination', $forum_template->pag_links );
346
+ }
347
+
348
+ function bp_forum_pagination_count() {
349
+ global $bp, $forum_template;
350
+
351
+ $from_num = intval( ( $forum_template->pag_page - 1 ) * $forum_template->pag_num ) + 1;
352
+ $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 );
353
+
354
+ 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 ) );
355
+ ?>
356
+ <img id="ajax-loader-groups" src="<?php echo $bp->core->image_base ?>/ajax-loader.gif" height="7" alt="<?php _e( "Loading", "buddypress" ) ?>" style="display: none;" />
357
+ <?php
358
+ }
359
+
360
+
361
+ class BP_Forums_Template_Topic {
362
+ var $current_post = -1;
363
+ var $post_count;
364
+ var $posts;
365
+ var $post;
366
+
367
+ var $topic_id;
368
+ var $topic;
369
+
370
+ var $in_the_loop;
371
+
372
+ var $pag_page;
373
+ var $pag_num;
374
+ var $pag_links;
375
+ var $total_post_count;
376
+
377
+ var $single_post = false;
378
+
379
+ var $sort_by;
380
+ var $order;
381
+
382
+ function BP_Forums_Template_Topic( $topic_id, $per_page, $max ) {
383
+ global $bp, $current_user, $forum_template;
384
+
385
+ $this->pag_page = isset( $_REQUEST['topic_page'] ) ? intval( $_REQUEST['topic_page'] ) : 1;
386
+ $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
387
+
388
+ $this->topic_id = $topic_id;
389
+ $forum_template->topic = (object) bp_forums_get_topic_details( $this->topic_id );
390
+
391
+ $this->posts = bp_forums_get_posts( $this->topic_id, $this->pag_num, $this->pag_page );
392
+
393
+ if ( !$this->posts ) {
394
+ $this->post_count = 0;
395
+ $this->total_post_count = 0;
396
+ } else {
397
+ if ( !$max )
398
+ $this->total_post_count = (int) $forum_template->topic->topic_posts;
399
+ else
400
+ $this->total_post_count = (int)$max;
401
+
402
+ if ( $max ) {
403
+ if ( $max >= count($this->posts) )
404
+ $this->post_count = count( $this->posts );
405
+ else
406
+ $this->post_count = (int)$max;
407
+ } else {
408
+ $this->post_count = count( $this->posts );
409
+ }
410
+ }
411
+
412
+ $this->pag_links = paginate_links( array(
413
+ 'base' => add_query_arg( array( 'topic_page' => '%#%', 'num' => $this->pag_num ) ),
414
+ 'format' => '',
415
+ 'total' => ceil($this->total_post_count / $this->pag_num),
416
+ 'current' => $this->pag_page,
417
+ 'prev_text' => '&laquo;',
418
+ 'next_text' => '&raquo;',
419
+ 'mid_size' => 1
420
+ ));
421
+ }
422
+
423
+ function has_posts() {
424
+ if ( $this->post_count )
425
+ return true;
426
+
427
+ return false;
428
+ }
429
+
430
+ function next_post() {
431
+ $this->current_post++;
432
+ $this->post = $this->posts[$this->current_post];
433
+
434
+ return $this->post;
435
+ }
436
+
437
+ function rewind_posts() {
438
+ $this->current_post = -1;
439
+ if ( $this->post_count > 0 ) {
440
+ $this->post = $this->posts[0];
441
+ }
442
+ }
443
+
444
+ function user_posts() {
445
+ if ( $this->current_post + 1 < $this->post_count ) {
446
+ return true;
447
+ } elseif ( $this->current_post + 1 == $this->post_count ) {
448
+ do_action('loop_end');
449
+ // Do some cleaning up after the loop
450
+ $this->rewind_posts();
451
+ }
452
+
453
+ $this->in_the_loop = false;
454
+ return false;
455
+ }
456
+
457
+ function the_post() {
458
+ global $post;
459
+
460
+ $this->in_the_loop = true;
461
+ $this->post = $this->next_post();
462
+ $this->post = (object)$this->post;
463
+
464
+ if ( $this->current_post == 0 ) // loop has just started
465
+ do_action('loop_start');
466
+ }
467
+ }
468
+
469
+ function bp_has_topic_posts( $args = '' ) {
470
+ global $topic_template, $bp;
471
+
472
+ $defaults = array(
473
+ 'topic_id' => false,
474
+ 'per_page' => 10,
475
+ 'max' => false
476
+ );
477
+
478
+ $r = wp_parse_args( $args, $defaults );
479
+ extract( $r, EXTR_SKIP );
480
+
481
+ if ( !$topic_id && $bp->current_component == $bp->groups->slug && 'forum' == $bp->current_action && 'topic' == $bp->action_variables[0] )
482
+ $topic_id = $bp->action_variables[1];
483
+
484
+ if ( is_numeric( $topic_id ) )
485
+ $topic_template = new BP_Forums_Template_Topic( $topic_id, $per_page, $max );
486
+ else
487
+ return false;
488
+
489
+ return $topic_template->has_posts();
490
+ }
491
+
492
+ function bp_topic_posts() {
493
+ global $topic_template;
494
+ return $topic_template->user_posts();
495
+ }
496
+
497
+ function bp_the_topic_post() {
498
+ global $topic_template;
499
+ return $topic_template->the_post();
500
+ }
501
+
502
+ function bp_the_topic_post_id() {
503
+ echo bp_get_the_topic_post_id();
504
+ }
505
+ function bp_get_the_topic_post_id() {
506
+ global $topic_template;
507
+
508
+ return apply_filters( 'bp_get_the_topic_post_id', $topic_template->post->post_id );
509
+ }
510
+
511
+ function bp_the_topic_post_content() {
512
+ echo bp_get_the_topic_post_content();
513
+ }
514
+ function bp_get_the_topic_post_content() {
515
+ global $topic_template;
516
+
517
+ return apply_filters( 'bp_get_the_topic_post_content', stripslashes( $topic_template->post->post_text ) );
518
+ }
519
+
520
+ function bp_the_topic_post_poster_avatar() {
521
+ echo bp_get_the_topic_post_poster_avatar();
522
+ }
523
+ function bp_get_the_topic_post_poster_avatar() {
524
+ global $topic_template;
525
+
526
+ return apply_filters( 'bp_get_the_topic_post_poster_avatar', bp_core_get_avatar( $topic_template->post->poster_id, 1, 20, 20 ) );
527
+ }
528
+
529
+ function bp_the_topic_post_poster_name( $deprecated = true ) {
530
+ if ( !$deprecated )
531
+ return bp_get_the_topic_post_poster_name();
532
+ else
533
+ echo bp_get_the_topic_post_poster_name();
534
+ }
535
+ function bp_get_the_topic_post_poster_name() {
536
+ global $topic_template;
537
+
538
+ return apply_filters( 'bp_get_the_topic_post_poster_name', bp_core_get_userlink( $topic_template->post->poster_id ) );
539
+ }
540
+
541
+ function bp_the_topic_post_time_since( $deprecated = true ) {
542
+ if ( !$deprecated )
543
+ return bp_get_the_topic_post_time_since();
544
+ else
545
+ echo bp_get_the_topic_post_time_since();
546
+ }
547
+ function bp_get_the_topic_post_time_since() {
548
+ global $topic_template;
549
+
550
+ return apply_filters( 'bp_get_the_topic_post_time_since', $topic_template->post->post_time_since );
551
+ }
552
+
553
+ function bp_the_topic_pagination() {
554
+ echo bp_get_the_topic_pagination();
555
+ }
556
+ function bp_get_the_topic_pagination() {
557
+ global $topic_template;
558
+
559
+ return apply_filters( 'bp_get_the_topic_pagination', $topic_template->pag_links );
560
+ }
561
+
562
+ function bp_the_topic_pagination_count() {
563
+ global $bp, $topic_template;
564
+
565
+ $from_num = intval( ( $topic_template->pag_page - 1 ) * $topic_template->pag_num ) + 1;
566
+ $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 );
567
+
568
+ 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 ) );
569
+ ?>
570
+ <img id="ajax-loader-groups" src="<?php echo $bp->core->image_base ?>/ajax-loader.gif" height="7" alt="<?php _e( "Loading", "buddypress" ) ?>" style="display: none;" />
571
+ <?php
572
+ }
573
+
574
+ function bp_forum_permalink() {
575
+ echo bp_get_forum_permalink();
576
+ }
577
+ function bp_get_forum_permalink() {
578
+ global $group_obj;
579
+
580
+ return apply_filters( 'bp_get_forum_permalink', bp_get_group_permalink( $group_obj ) . '/forum' );
581
+ }
582
+
583
+ function bp_forum_action() {
584
+ echo bp_get_forum_action();
585
+ }
586
+ function bp_get_forum_action() {
587
+ global $topic_template;
588
+
589
+ return apply_filters( 'bp_get_forum_action', bp_get_group_permalink( $group_obj ) . '/forum' );
590
+ }
591
+
592
+ function bp_forum_topic_action() {
593
+ echo bp_get_forum_topic_action();
594
+ }
595
+ function bp_get_forum_topic_action() {
596
+ global $topic_template;
597
+
598
+ return apply_filters( 'bp_get_forum_topic_action', bp_get_group_permalink( $group_obj ) . '/forum/topic/' . $topic_template->topic_id );
599
+ }
600
+
601
+ ?>
bp-forums/installation-readme.txt ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Installing and setting up bp-forums
2
+ '''''''''''''''''''''''''''''''''''
3
+
4
+ The bp-forums component provides a link between bbPress and BuddyPress so forums can be
5
+ created and manipulated directly in BuddyPress.
6
+
7
+ Forum functionality is currently quite basic and limited to creating forums, creating topics and posting.
8
+ More advanced integration including moderation, searching and tagging support will come in later
9
+ versions of the component.
10
+
11
+ *** Please Note ***
12
+
13
+ You *must* be running the latest alpha of bbPress and at least WPMU version 2.7 for forum integration to
14
+ work.
15
+
16
+ ************************************************
17
+ Follow these steps to get forums up and running:
18
+ ************************************************
19
+
20
+ 1. Run the bbPress installer by browsing to the location that you uploaded bbPress.
21
+
22
+ 2. On Step 2 you will need to integrate bbPress with WordPress
23
+
24
+ - Check the "Add integration settings" box
25
+
26
+ - Leave "Add cookie integration settings" unchecked
27
+
28
+ - Check the "Add user database integration settings" box
29
+ - Add your table prefix (usually always 'wp_')
30
+ - Add your WordPress database settings found in wp-config.php
31
+ - You can usually ignore the "character set" and "collation" boxes
32
+ - Leave the "Custom user tables" section blank.
33
+
34
+ 3. On Step 3 enter anything you like for your site name and first forum name. Select "Admin" from the
35
+ dropdown to use as your keymaster user.
36
+
37
+ 4. Head to your new bbPress install and log in with your WordPress administrator account (admin).
38
+
39
+ 5. Head to the Admin area (/bb-admin) and then the settings menu. Check the "Enable XML-RPC" option.
40
+ Also check the "Enable Pingbacks" option just below.
41
+
42
+ 6. In the bp-forums component there is a /bbpress-plugins/ folder. Copy the 'buddypress-enable.php'
43
+ plugin file from that folder into your bbpress plugins folder (eg domain/bbpress/bb-plugins/)
44
+
45
+ 7. Enable the plugin in the bbPress admin area under the plugins menu.
46
+
47
+ 8. Head back to your BuddyPress installation and sign up as a new user. Once you have
48
+ activated the new user, make a note of the username and password given.
49
+
50
+ 9. Log back into your bbPress installation as the administrator, and head back to the admin panel (/bb-admin).
51
+ Go to the "Users" tab and look for the new user you signed up in step 8 in the list. Hit the "Edit"
52
+ link for that user, on the end of the row.
53
+
54
+ 10. On the edit user screen there is a drop down menu called "User Type". Select "Administrator" as the user
55
+ type for this user. Hit the "Update Profile" button.
56
+
57
+ 11. Enable user switching in bbPress by copying the following line of code into your bbPress bb-config.php
58
+ file:
59
+
60
+ $bb->bb_xmlrpc_allow_user_switching = true;
61
+
62
+ 12. Log into your WPMU admin interface and head to "Site Admin > Group Forums" fill in the details on that
63
+ page. Make sure you don't leave out the ending slash on your bbPress URL. (http://example.com/bbpress/)
64
+ Enter the username and password for the user that you signed up in step 8.
65
+
66
+ 13. Once you have saved those details you can create group forums. Existing groups you will need to head
67
+ to the group admin settings page, disable then enable the group forum setting to generate a new forum.
68
+ New groups will work fine.
69
+
70
+ *** NOTE ***
71
+
72
+ Group forums are public, even if a group is private its forum will be accessable through the bbPress interface.
73
+ This will change eventually, but please be aware of the public status of forums before posting.
bp-friends.php ADDED
@@ -0,0 +1,664 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ define ( 'BP_FRIENDS_VERSION', '1.0' );
4
+ define ( 'BP_FRIENDS_DB_VERSION', '1300' );
5
+
6
+ /* Define the slug for the component */
7
+ if ( !defined( 'BP_FRIENDS_SLUG' ) )
8
+ define ( 'BP_FRIENDS_SLUG', 'friends' );
9
+
10
+ require ( BP_PLUGIN_DIR . '/bp-friends/bp-friends-classes.php' );
11
+ require ( BP_PLUGIN_DIR . '/bp-friends/bp-friends-ajax.php' );
12
+ require ( BP_PLUGIN_DIR . '/bp-friends/bp-friends-cssjs.php' );
13
+ require ( BP_PLUGIN_DIR . '/bp-friends/bp-friends-templatetags.php' );
14
+
15
+ /**************************************************************************
16
+ friends_install()
17
+
18
+ Sets up the database tables ready for use on a site installation.
19
+ **************************************************************************/
20
+
21
+ function friends_install() {
22
+ global $wpdb, $bp;
23
+
24
+ if ( !empty($wpdb->charset) )
25
+ $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
26
+
27
+ $sql[] = "CREATE TABLE {$bp->friends->table_name} (
28
+ id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
29
+ initiator_user_id bigint(20) NOT NULL,
30
+ friend_user_id bigint(20) NOT NULL,
31
+ is_confirmed bool DEFAULT 0,
32
+ is_limited bool DEFAULT 0,
33
+ date_created datetime NOT NULL,
34
+ KEY initiator_user_id (initiator_user_id),
35
+ KEY friend_user_id (friend_user_id)
36
+ ) {$charset_collate};";
37
+
38
+ require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
39
+ dbDelta($sql);
40
+
41
+ update_site_option( 'bp-friends-db-version', BP_FRIENDS_DB_VERSION );
42
+ }
43
+
44
+
45
+ /**************************************************************************
46
+ friends_setup_globals()
47
+
48
+ Set up and add all global variables for this component, and add them to
49
+ the $bp global variable array.
50
+ **************************************************************************/
51
+
52
+ function friends_setup_globals() {
53
+ global $bp, $wpdb;
54
+
55
+ $bp->friends->table_name = $wpdb->base_prefix . 'bp_friends';
56
+ $bp->friends->image_base = BP_PLUGIN_URL . '/bp-friends/images';
57
+ $bp->friends->format_activity_function = 'friends_format_activity';
58
+ $bp->friends->format_notification_function = 'friends_format_notifications';
59
+
60
+ $bp->friends->slug = BP_FRIENDS_SLUG;
61
+
62
+ $bp->version_numbers->friends = BP_FRIENDS_VERSION;
63
+ }
64
+ add_action( 'plugins_loaded', 'friends_setup_globals', 5 );
65
+ add_action( 'admin_menu', 'friends_setup_globals', 1 );
66
+
67
+ function friends_check_installed() {
68
+ global $wpdb, $bp;
69
+
70
+ if ( !is_site_admin() )
71
+ return false;
72
+
73
+ /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
74
+ if ( get_site_option('bp-friends-db-version') < BP_FRIENDS_DB_VERSION )
75
+ friends_install();
76
+ }
77
+ add_action( 'admin_menu', 'friends_check_installed' );
78
+
79
+ /**************************************************************************
80
+ friends_setup_nav()
81
+
82
+ Set up front end navigation.
83
+ **************************************************************************/
84
+
85
+ function friends_setup_nav() {
86
+ global $bp;
87
+
88
+ /* Add 'Friends' to the main navigation */
89
+ bp_core_add_nav_item( __('Friends', 'buddypress'), $bp->friends->slug );
90
+ bp_core_add_nav_default( $bp->friends->slug, 'friends_screen_my_friends', 'my-friends' );
91
+
92
+ $friends_link = $bp->loggedin_user->domain . $bp->friends->slug . '/';
93
+
94
+ /* Add the subnav items to the friends nav item */
95
+ bp_core_add_subnav_item( $bp->friends->slug, 'my-friends', __( 'My Friends', 'buddypress' ), $friends_link, 'friends_screen_my_friends', 'friends-my-friends' );
96
+ bp_core_add_subnav_item( $bp->friends->slug, 'requests', __( 'Requests', 'buddypress' ), $friends_link, 'friends_screen_requests', false, bp_is_home() );
97
+
98
+ if ( $bp->current_component == $bp->friends->slug ) {
99
+ if ( bp_is_home() ) {
100
+ $bp->bp_options_title = __( 'My Friends', 'buddypress' );
101
+ } else {
102
+ $bp->bp_options_avatar = bp_core_get_avatar( $bp->displayed_user->id, 1 );
103
+ $bp->bp_options_title = $bp->displayed_user->fullname;
104
+ }
105
+ }
106
+ }
107
+ add_action( 'wp', 'friends_setup_nav', 2 );
108
+ add_action( 'admin_menu', 'friends_setup_nav', 2 );
109
+
110
+ /***** Screens **********/
111
+
112
+ function friends_screen_my_friends() {
113
+ global $bp;
114
+
115
+ // Delete any friendship acceptance notifications for the user when viewing a profile
116
+ bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, 'friends', 'friendship_accepted' );
117
+
118
+ do_action( 'friends_screen_my_friends' );
119
+
120
+ bp_core_load_template( apply_filters( 'friends_template_my_friends', 'friends/index' ) );
121
+ }
122
+
123
+ function friends_screen_requests() {
124
+ global $bp;
125
+
126
+ if ( isset($bp->action_variables) && 'accept' == $bp->action_variables[0] && is_numeric($bp->action_variables[1]) ) {
127
+
128
+ if ( friends_accept_friendship( $bp->action_variables[1] ) ) {
129
+ bp_core_add_message( __( 'Friendship accepted', 'buddypress' ) );
130
+ } else {
131
+ bp_core_add_message( __( 'Friendship could not be accepted', 'buddypress' ), 'error' );
132
+ }
133
+ bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action );
134
+
135
+ } else if ( isset($bp->action_variables) && 'reject' == $bp->action_variables[0] && is_numeric($bp->action_variables[1]) ) {
136
+
137
+ if ( friends_reject_friendship( $bp->action_variables[1] ) ) {
138
+ bp_core_add_message( __( 'Friendship rejected', 'buddypress' ) );
139
+ } else {
140
+ bp_core_add_message( __( 'Friendship could not be rejected', 'buddypress' ), 'error' );
141
+ }
142
+ bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action );
143
+ }
144
+
145
+ do_action( 'friends_screen_requests' );
146
+
147
+ bp_core_load_template( apply_filters( 'friends_template_requests', 'friends/requests' ) );
148
+ }
149
+
150
+ function friends_screen_friend_finder() {
151
+ do_action( 'friends_screen_friend_finder' );
152
+ bp_core_load_template( apply_filters( 'friends_template_friend_finder', 'friends/friend-finder' ) );
153
+ }
154
+
155
+ function friends_screen_notification_settings() {
156
+ global $current_user; ?>
157
+ <table class="notification-settings" id="friends-notification-settings">
158
+ <tr>
159
+ <th class="icon"></th>
160
+ <th class="title"><?php _e( 'Friends', 'buddypress' ) ?></th>
161
+ <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th>
162
+ <th class="no"><?php _e( 'No', 'buddypress' )?></th>
163
+ </tr>
164
+ <tr>
165
+ <td></td>
166
+ <td><?php _e( 'A member sends you a friendship request', 'buddypress' ) ?></td>
167
+ <td class="yes"><input type="radio" name="notifications[notification_friends_friendship_request]" value="yes" <?php if ( !get_usermeta( $current_user->id,'notification_friends_friendship_request') || 'yes' == get_usermeta( $current_user->id,'notification_friends_friendship_request') ) { ?>checked="checked" <?php } ?>/></td>
168
+ <td class="no"><input type="radio" name="notifications[notification_friends_friendship_request]" value="no" <?php if ( get_usermeta( $current_user->id,'notification_friends_friendship_request') == 'no' ) { ?>checked="checked" <?php } ?>/></td>
169
+ </tr>
170
+ <tr>
171
+ <td></td>
172
+ <td><?php _e( 'A member accepts your friendship request', 'buddypress' ) ?></td>
173
+ <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>
174
+ <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>
175
+ </tr>
176
+
177
+ <?php do_action( 'friends_screen_notification_settings' ); ?>
178
+ </table>
179
+ <?php
180
+ }
181
+ add_action( 'bp_notification_settings', 'friends_screen_notification_settings' );
182
+
183
+
184
+ /**************************************************************************
185
+ friends_record_activity()
186
+
187
+ Records activity for the logged in user within the friends component so that
188
+ it will show in the users activity stream (if installed)
189
+ **************************************************************************/
190
+
191
+ function friends_record_activity( $args ) {
192
+ if ( function_exists('bp_activity_record') ) {
193
+ extract( (array)$args );
194
+ bp_activity_record( $item_id, $component_name, $component_action, $is_private, $secondary_item_id, $user_id, $secondary_user_id );
195
+ }
196
+ }
197
+ add_action( 'friends_friendship_accepted', 'friends_record_activity' );
198
+
199
+ function friends_delete_activity( $args ) {
200
+ if ( function_exists('bp_activity_delete') ) {
201
+ extract( (array)$args );
202
+ bp_activity_delete( $item_id, $component_name, $component_action, $user_id, $secondary_item_id );
203
+ }
204
+ }
205
+
206
+ /**************************************************************************
207
+ friends_format_activity()
208
+
209
+ Selects and formats recorded friends component activity.
210
+ Example: Selects the friend details for an added connection, then
211
+ formats it to read "Andy Peatling & John Smith are now friends"
212
+ **************************************************************************/
213
+
214
+ function friends_format_activity( $item_id, $user_id, $action, $secondary_item_id = false, $for_secondary_user = false ) {
215
+ global $bp;
216
+
217
+ switch( $action ) {
218
+ case 'friendship_accepted':
219
+ $friendship = new BP_Friends_Friendship( $item_id, false, false );
220
+
221
+ if ( !$friendship->initiator_user_id || !$friendship->friend_user_id )
222
+ return false;
223
+
224
+ if ( $for_secondary_user ) {
225
+
226
+ $user_1 = bp_core_get_userlink( $friendship->initiator_user_id );
227
+ $user_2 = bp_core_get_userlink($friendship->friend_user_id, false, false, true);
228
+
229
+ return array(
230
+ 'primary_link' => bp_core_get_userlink( $friendship->friend_user_id, false, true ),
231
+ 'content' => apply_filters( 'bp_friends_friendship_accepted_activity', sprintf( __( '%s and %s are now friends', 'buddypress' ), $user_1, $user_2 ) . ' <span class="time-since">%s</span>', $user_1, $user_2 )
232
+ );
233
+ } else {
234
+
235
+ $user_1 = bp_core_get_userlink( $friendship->friend_user_id );
236
+ $user_2 = bp_core_get_userlink($friendship->initiator_user_id);
237
+
238
+ return array(
239
+ 'primary_link' => bp_core_get_userlink( $friendship->friend_user_id, false, true ),
240
+ 'content' => apply_filters( 'bp_friends_friendship_accepted_activity', sprintf( __( '%s and %s are now friends', 'buddypress' ), bp_core_get_userlink( $friendship->friend_user_id ), bp_core_get_userlink($friendship->initiator_user_id) ) . ' <span class="time-since">%s</span>', $user_1, $user_2 )
241
+ );
242
+ }
243
+ break;
244
+ }
245
+
246
+ do_action( 'friends_format_activity', $action, $item_id, $user_id, $action, $secondary_item_id, $for_secondary_user );
247
+
248
+ return false;
249
+ }
250
+
251
+ function friends_format_notifications( $action, $item_id, $secondary_item_id, $total_items ) {
252
+ global $bp;
253
+
254
+ switch ( $action ) {
255
+ case 'friendship_accepted':
256
+ if ( (int)$total_items > 1 ) {
257
+ 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 );
258
+ } else {
259
+ $user_fullname = bp_core_global_user_fullname( $item_id );
260
+ $user_url = bp_core_get_userurl( $item_id );
261
+ 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 );
262
+ }
263
+ break;
264
+
265
+ case 'friendship_request':
266
+ if ( (int)$total_items > 1 ) {
267
+ 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 );
268
+ } else {
269
+ $user_fullname = bp_core_global_user_fullname( $item_id );
270
+ $user_url = bp_core_get_userurl( $item_id );
271
+ 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 );
272
+ }
273
+ break;
274
+ }
275
+
276
+ do_action( 'friends_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
277
+
278
+ return false;
279
+ }
280
+
281
+ function friends_check_user_has_friends( $user_id ) {
282
+ $friend_count = get_usermeta( $user_id, 'total_friend_count');
283
+
284
+ if ( empty( $friend_count ) )
285
+ return false;
286
+
287
+ if ( !(int)$friend_count )
288
+ return false;
289
+
290
+ return true;
291
+ }
292
+
293
+ function friends_get_friend_user_ids( $user_id, $friend_requests_only = false, $assoc_arr = false, $filter = false ) {
294
+ return BP_Friends_Friendship::get_friend_user_ids( $user_id, $friend_requests_only, $assoc_arr, $filter );
295
+ }
296
+
297
+ function friends_get_friendship_ids( $user_id, $friend_requests_only = false ) {
298
+ return BP_Friends_Friendship::get_friendship_ids( $user_id, $friend_requests_only );
299
+ }
300
+
301
+ function friends_search_friends( $search_terms, $user_id, $pag_num = 10, $pag_page = 1 ) {
302
+ return BP_Friends_Friendship::search_friends( $search_terms, $user_id, $pag_num, $pag_page );
303
+ }
304
+
305
+ function friends_get_friendship_requests( $user_id ) {
306
+ $fship_ids = friends_get_friendship_ids( $user_id, true );
307
+
308
+ return array( 'requests' => $fship_ids, 'total' => count($requests) );
309
+ }
310
+
311
+ function friends_get_recently_active( $user_id, $pag_num = false, $pag_page = false, $filter = false ) {
312
+ if ( $filter )
313
+ $friend_ids = friends_search_friends( $filter, $user_id, false );
314
+ else
315
+ $friend_ids = friends_get_friend_user_ids( $user_id );
316
+
317
+ if ( !$friend_ids )
318
+ return false;
319
+
320
+ if ( $filter )
321
+ $friend_ids = $friend_ids['friends'];
322
+
323
+ $ids_and_activity = friends_get_bulk_last_active( implode( ',', (array)$friend_ids ) );
324
+
325
+ if ( !$ids_and_activity )
326
+ return false;
327
+
328
+ $total_friends = count( $ids_and_activity );
329
+
330
+ if ( $pag_num && $pag_page )
331
+ return array( 'friends' => array_slice( $ids_and_activity, intval( ( $pag_page - 1 ) * $pag_num), intval( $pag_num ) ), 'total' => $total_friends );
332
+ else
333
+ return array( 'friends' => $ids_and_activity, 'total' => $total_friends );
334
+ }
335
+
336
+ function friends_get_alphabetically( $user_id, $pag_num = false, $pag_page = false, $filter = false ) {
337
+ if ( $filter )
338
+ $friend_ids = friends_search_friends( $filter, $user_id, false );
339
+ else
340
+ $friend_ids = friends_get_friend_user_ids( $user_id );
341
+
342
+ if ( !$friend_ids )
343
+ return false;
344
+
345
+ if ( $filter )
346
+ $friend_ids = $friend_ids['friends'];
347
+
348
+ $sorted_ids = BP_Friends_Friendship::sort_by_name( implode( ',', $friend_ids ) );
349
+
350
+ if ( !$sorted_ids )
351
+ return false;
352
+
353
+ $total_friends = count( $sorted_ids );
354
+
355
+ if ( $pag_num && $pag_page )
356
+ return array( 'friends' => array_slice( $sorted_ids, intval( ( $pag_page - 1 ) * $pag_num), intval( $pag_num ) ), 'total' => $total_friends );
357
+ else
358
+ return array( 'friends' => $sorted_ids, 'total' => $total_friends );
359
+ }
360
+
361
+ function friends_get_newest( $user_id, $pag_num = false, $pag_page = false, $filter = false ) {
362
+ if ( $filter )
363
+ $friend_ids = friends_search_friends( $filter, $user_id, false );
364
+ else
365
+ $friend_ids = friends_get_friend_user_ids( $user_id );
366
+
367
+ if ( !$friend_ids )
368
+ return false;
369
+
370
+ if ( $filter )
371
+ $friend_ids = $friend_ids['friends'];
372
+
373
+ $total_friends = count( $friend_ids );
374
+
375
+ if ( $pag_num && $pag_page )
376
+ return array( 'friends' => array_slice( $friend_ids, intval( ( $pag_page - 1 ) * $pag_num), intval( $pag_num ) ), 'total' => $total_friends );
377
+ else
378
+ return array( 'friends' => $friend_ids, 'total' => $total_friends );
379
+ }
380
+
381
+ function friends_get_bulk_last_active( $friend_ids ) {
382
+ return BP_Friends_Friendship::get_bulk_last_active( $friend_ids );
383
+ }
384
+
385
+ function friends_get_friends_list( $user_id ) {
386
+ global $bp;
387
+
388
+ $friend_ids = BP_Friends_Friendship::get_friend_user_ids( $user_id );
389
+
390
+ if ( !$friend_ids )
391
+ return false;
392
+
393
+ for ( $i = 0; $i < count($friend_ids); $i++ ) {
394
+ if ( function_exists('bp_user_fullname') )
395
+ $display_name = bp_fetch_user_fullname($friend_ids[$i], false);
396
+
397
+ if ( $display_name != ' ' ) {
398
+ $friends[] = array(
399
+ 'id' => $friend_ids[$i],
400
+ 'full_name' => $display_name
401
+ );
402
+ }
403
+ }
404
+
405
+ if ( $friends && is_array($friends) )
406
+ usort($friends, 'friends_sort_by_name');
407
+
408
+ if ( !$friends )
409
+ return false;
410
+
411
+ return $friends;
412
+ }
413
+
414
+ function friends_sort_by_name($a, $b) {
415
+ return strcasecmp($a['full_name'], $b['full_name']);
416
+ }
417
+
418
+ function friends_get_friends_invite_list( $user_id = false, $group_id ) {
419
+ global $bp;
420
+
421
+ if ( !$user_id )
422
+ $user_id = $bp->loggedin_user->id;
423
+
424
+ $friend_ids = friends_get_alphabetically( $user_id );
425
+
426
+ if ( (int) $friend_ids['total'] < 1 )
427
+ return false;
428
+
429
+ for ( $i = 0; $i < count($friend_ids['friends']); $i++ ) {
430
+ 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 ) )
431
+ continue;
432
+
433
+ $display_name = bp_fetch_user_fullname($friend_ids['friends'][$i]->user_id, false);
434
+
435
+ if ( $display_name != ' ' ) {
436
+ $friends[] = array(
437
+ 'id' => $friend_ids['friends'][$i]->user_id,
438
+ 'full_name' => $display_name
439
+ );
440
+ }
441
+ }
442
+
443
+ if ( !$friends )
444
+ return false;
445
+
446
+ return $friends;
447
+ }
448
+
449
+ function friends_count_invitable_friends( $user_id, $group_id ) {
450
+ return BP_Friends_Friendship::get_invitable_friend_count( $user_id, $group_id );
451
+ }
452
+
453
+ function friends_get_friend_count_for_user( $user_id ) {
454
+ return BP_Friends_Friendship::total_friend_count( $user_id );
455
+ }
456
+
457
+ /**************************************************************************
458
+ friends_search_users()
459
+
460
+ Return an array of user objects based on the users search terms
461
+ **************************************************************************/
462
+
463
+ function friends_search_users( $search_terms, $user_id, $pag_num = false, $pag_page = false ) {
464
+ global $bp;
465
+
466
+ $user_ids = BP_Friends_Friendship::search_users( $search_terms, $user_id, $pag_num, $pag_page );
467
+
468
+ if ( !$user_ids )
469
+ return false;
470
+
471
+ for ( $i = 0; $i < count($user_ids); $i++ ) {
472
+ $users[] = new BP_Core_User($user_ids[$i]);
473
+ }
474
+
475
+ return array( 'users' => $users, 'count' => BP_Friends_Friendship::search_users_count($search_terms) );
476
+ }
477
+
478
+ /**************************************************************************
479
+ friends_check_friendship()
480
+
481
+ Check to see if the user is already a confirmed friend with this user.
482
+ **************************************************************************/
483
+
484
+ function friends_check_friendship( $user_id, $possible_friend_id ) {
485
+ global $bp;
486
+
487
+ if ( 'is_friend' == BP_Friends_Friendship::check_is_friend( $user_id, $possible_friend_id ) )
488
+ return true;
489
+
490
+ return false;
491
+ }
492
+
493
+ /**************************************************************************
494
+ friends_add_friend()
495
+
496
+ Create a new friend relationship
497
+ **************************************************************************/
498
+
499
+ function friends_add_friend( $initiator_userid, $friend_userid ) {
500
+ global $bp;
501
+
502
+ /* Check the nonce */
503
+ if ( !check_admin_referer( 'friends_add_friend' ) )
504
+ return false;
505
+
506
+ $friendship = new BP_Friends_Friendship;
507
+
508
+ if ( (int)$friendship->is_confirmed )
509
+ return true;
510
+
511
+ $friendship->initiator_user_id = $initiator_userid;
512
+ $friendship->friend_user_id = $friend_userid;
513
+ $friendship->is_confirmed = 0;
514
+ $friendship->is_limited = 0;
515
+ $friendship->date_created = time();
516
+
517
+ if ( $friendship->save() ) {
518
+
519
+ // Add the on screen notification
520
+ bp_core_add_notification( $friendship->initiator_user_id, $friendship->friend_user_id, 'friends', 'friendship_request' );
521
+
522
+ // Send the email notification
523
+ require_once( BP_PLUGIN_DIR . '/bp-friends/bp-friends-notifications.php' );
524
+ friends_notification_new_request( $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id );
525
+
526
+ do_action( 'friends_friendship_requested', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id );
527
+
528
+ return true;
529
+ }
530
+
531
+ return false;
532
+ }
533
+
534
+ /**************************************************************************
535
+ friends_remove_friend()
536
+
537
+ Remove a friend relationship
538
+ **************************************************************************/
539
+
540
+ function friends_remove_friend( $initiator_userid, $friend_userid ) {
541
+ global $bp;
542
+
543
+ /* Check the nonce */
544
+ if ( !check_admin_referer( 'friends_remove_friend' ) )
545
+ return false;
546
+
547
+ $friendship_id = BP_Friends_Friendship::get_friendship_id( $initiator_userid, $friend_userid );
548
+ $friendship = new BP_Friends_Friendship( $friendship_id );
549
+
550
+ // Remove the activity stream items
551
+ friends_delete_activity( array( 'item_id' => $friendship_id, 'component_name' => 'friends', 'component_action' => 'friendship_accepted', 'user_id' => $bp->displayed_user->id ) );
552
+
553
+ do_action( 'friends_friendship_deleted', $friendship_id, $initiator_userid, $friend_userid );
554
+
555
+ if ( $friendship->delete() ) {
556
+ friends_update_friend_totals( $initiator_userid, $friend_userid, 'remove' );
557
+
558
+ return true;
559
+ }
560
+
561
+ return false;
562
+ }
563
+
564
+ function friends_accept_friendship( $friendship_id ) {
565
+ /* Check the nonce */
566
+ if ( !check_admin_referer( 'friends_accept_friendship' ) )
567
+ return false;
568
+
569
+ $friendship = new BP_Friends_Friendship( $friendship_id, true, false );
570
+
571
+ if ( !$friendship->is_confirmed && BP_Friends_Friendship::accept( $friendship_id ) ) {
572
+ friends_update_friend_totals( $friendship->initiator_user_id, $friendship->friend_user_id );
573
+
574
+ // Remove the friend request notice
575
+ bp_core_delete_notifications_for_user_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, 'friends', 'friendship_request' );
576
+
577
+ // Add a friend accepted notice for the initiating user
578
+ bp_core_add_notification( $friendship->friend_user_id, $friendship->initiator_user_id, 'friends', 'friendship_accepted' );
579
+
580
+ // Record in activity streams
581
+ friends_record_activity( array( 'item_id' => $friendship_id, 'component_name' => 'friends', 'component_action' => 'friendship_accepted', 'is_private' => 0, 'user_id' => $friendship->initiator_user_id, 'secondary_user_id' => $friendship->friend_user_id ) );
582
+
583
+ // Send the email notification
584
+ require_once( BP_PLUGIN_DIR . '/bp-friends/bp-friends-notifications.php' );
585
+ friends_notification_accepted_request( $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id );
586
+
587
+ do_action( 'friends_friendship_accepted', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id );
588
+
589
+ return true;
590
+ }
591
+
592
+ return false;
593
+ }
594
+
595
+ function friends_reject_friendship( $friendship_id ) {
596
+ /* Check the nonce */
597
+ if ( !check_admin_referer( 'friends_reject_friendship' ) )
598
+ return false;
599
+
600
+ $friendship = new BP_Friends_Friendship( $friendship_id, true, false );
601
+
602
+ if ( !$friendship->is_confirmed && BP_Friends_Friendship::reject( $friendship_id ) ) {
603
+ // Remove the friend request notice
604
+ bp_core_delete_notifications_for_user_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, 'friends', 'friendship_request' );
605
+
606
+ do_action( 'friends_friendship_rejected', $friendship_id );
607
+ return true;
608
+ }
609
+
610
+ return false;
611
+ }
612
+
613
+ function friends_is_friendship_confirmed( $friendship_id ) {
614
+ $friendship = new BP_Friends_Friendship( $friendship_id );
615
+ return $friendship->is_confirmed;
616
+ }
617
+
618
+ function friends_update_friend_totals( $initiator_user_id, $friend_user_id, $status = 'add' ) {
619
+ if ( 'add' == $status ) {
620
+ update_usermeta( $initiator_user_id, 'total_friend_count', (int)get_usermeta( $initiator_user_id, 'total_friend_count' ) + 1 );
621
+ update_usermeta( $friend_user_id, 'total_friend_count', (int)get_usermeta( $friend_user_id, 'total_friend_count' ) + 1 );
622
+ } else {
623
+ update_usermeta( $initiator_user_id, 'total_friend_count', (int)get_usermeta( $initiator_user_id, 'total_friend_count' ) - 1 );
624
+ update_usermeta( $friend_user_id, 'total_friend_count', (int)get_usermeta( $friend_user_id, 'total_friend_count' ) - 1 );
625
+ }
626
+ }
627
+
628
+ function friends_remove_data( $user_id ) {
629
+ BP_Friends_Friendship::delete_all_for_user($user_id);
630
+
631
+ /* Remove usermeta */
632
+ delete_usermeta( $user_id, 'total_friend_count' );
633
+
634
+ /* Remove friendship requests FROM user */
635
+ bp_core_delete_notifications_from_user( $user_id, $bp->friends->slug, 'friendship_request' );
636
+
637
+ do_action( 'friends_remove_data', $user_id );
638
+ }
639
+ add_action( 'wpmu_delete_user', 'friends_remove_data', 1 );
640
+ add_action( 'delete_user', 'friends_remove_data', 1 );
641
+
642
+ function friends_clear_friend_object_cache( $friendship_id ) {
643
+ if ( !$friendship = new BP_Friends_Friendship( $friendship_id ) )
644
+ return false;
645
+
646
+ wp_cache_delete( 'friends_friend_ids_' . $friendship->initiator_user_id, 'bp' );
647
+ wp_cache_delete( 'friends_friend_ids_' . $friendship->friend_user_id, 'bp' );
648
+ wp_cache_delete( 'popular_users', 'bp' );
649
+
650
+ /* Clear the sitewide activity cache */
651
+ wp_cache_delete( 'sitewide_activity', 'bp' );
652
+ }
653
+
654
+ // List actions to clear object caches on
655
+ add_action( 'friends_friendship_accepted', 'friends_clear_friend_object_cache' );
656
+ add_action( 'friends_friendship_deleted', 'friends_clear_friend_object_cache' );
657
+
658
+ // List actions to clear super cached pages on, if super cache is installed
659
+ add_action( 'friends_friendship_rejected', 'bp_core_clear_cache' );
660
+ add_action( 'friends_friendship_accepted', 'bp_core_clear_cache' );
661
+ add_action( 'friends_friendship_deleted', 'bp_core_clear_cache' );
662
+ add_action( 'friends_friendship_requested', 'bp_core_clear_cache' );
663
+
664
+ ?>
bp-friends/bp-friends-ajax.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function friends_ajax_friends_search() {
4
+ global $bp;
5
+
6
+ check_ajax_referer( 'friends_search' );
7
+
8
+ load_template( get_template_directory() . '/friends/friends-loop.php' );
9
+ }
10
+ add_action( 'wp_ajax_friends_search', 'friends_ajax_friends_search' );
11
+
12
+ function friends_ajax_addremove_friend() {
13
+ global $bp;
14
+
15
+ if ( 'is_friend' == BP_Friends_Friendship::check_is_friend( $bp->loggedin_user->id, $_POST['fid'] ) ) {
16
+
17
+ check_ajax_referer('friends_remove_friend');
18
+
19
+ if ( !friends_remove_friend( $bp->loggedin_user->id, $_POST['fid'] ) ) {
20
+ echo __("Friendship could not be canceled.", 'buddypress');
21
+ } else {
22
+ echo '<a id="friend-' . $_POST['fid'] . '" class="add" rel="add" title="' . __( 'Add Friend', 'buddypress' ) . '" href="' . wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/add-friend/' . $_POST['fid'], 'friends_add_friend' ) . '">' . __( 'Add Friend', 'buddypress' ) . '</a>';
23
+ }
24
+ } else if ( 'not_friends' == BP_Friends_Friendship::check_is_friend( $bp->loggedin_user->id, $_POST['fid'] ) ) {
25
+
26
+ check_ajax_referer('friends_add_friend');
27
+
28
+ if ( !friends_add_friend( $bp->loggedin_user->id, $_POST['fid'] ) ) {
29
+ echo __("Friendship could not be requested.", 'buddypress');
30
+ } else {
31
+ echo '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '" class="requested">' . __( 'Friendship Requested', 'buddypress' ) . '</a>';
32
+ }
33
+ } else {
34
+ echo __( 'Request Pending', 'buddypress' );
35
+ }
36
+
37
+ return false;
38
+ }
39
+ add_action( 'wp_ajax_addremove_friend', 'friends_ajax_addremove_friend' );
40
+
41
+ ?>
bp-friends/bp-friends-classes.php ADDED
@@ -0,0 +1,329 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class BP_Friends_Friendship {
4
+ var $id;
5
+ var $initiator_user_id;
6
+ var $friend_user_id;
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;
22
+ $this->populate( $this->id );
23
+ }
24
+ }
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;
32
+ $this->is_confirmed = $friendship->is_confirmed;
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 );
44
+ } else {
45
+ $this->friend = new BP_Core_User( $this->friend_user_id );
46
+ }
47
+ }
48
+ }
49
+
50
+ function save() {
51
+ global $wpdb, $bp;
52
+
53
+ $this->initiator_user_id = apply_filters( 'friends_friendship_initiator_user_id_before_save', $this->initiator_user_id, $this->id );
54
+ $this->friend_user_id = apply_filters( 'friends_friendship_friend_user_id_before_save', $this->friend_user_id, $this->id );
55
+ $this->is_confirmed = apply_filters( 'friends_friendship_is_confirmed_before_save', $this->is_confirmed, $this->id );
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 ) );
64
+ } else {
65
+ // Save
66
+ $result = $wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->friends->table_name} ( initiator_user_id, friend_user_id, is_confirmed, is_limited, date_created ) VALUES ( %d, %d, %d, %d, FROM_UNIXTIME(%d) )", $this->initiator_user_id, $this->friend_user_id, $this->is_confirmed, $this->is_limited, $this->date_created ) );
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 );
89
+ } else {
90
+ $oc_sql = $wpdb->prepare( "AND is_confirmed = 1" );
91
+ $friend_sql = $wpdb->prepare ( " WHERE (initiator_user_id = %d OR friend_user_id = %d)", $user_id, $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
+
109
+ if ( $friend_requests_only ) {
110
+ $oc_sql = $wpdb->prepare( "AND is_confirmed = 0" );
111
+ $friend_sql = $wpdb->prepare ( " WHERE friend_user_id = %d", $user_id );
112
+ } else {
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 ) {
127
+ global $wpdb, $bp;
128
+
129
+ /* This is stored in 'total_friend_count' usermeta.
130
+ This function will recalculate, update and return. */
131
+
132
+ $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 ) );
133
+
134
+ if ( !$count )
135
+ return 0;
136
+
137
+ update_usermeta( $user_id, 'total_friend_count', $count );
138
+ return $count;
139
+ }
140
+
141
+ function search_friends( $filter, $user_id, $limit = null, $page = null ) {
142
+ global $wpdb, $bp;
143
+
144
+ // TODO: Optimize this function.
145
+
146
+ if ( !$user_id )
147
+ $user_id = $bp->loggedin_user->id;
148
+
149
+ like_escape($filter);
150
+
151
+ if ( $limit && $page )
152
+ $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
153
+
154
+ if ( !$friend_ids = BP_Friends_Friendship::get_friend_user_ids( $user_id ) )
155
+ return false;
156
+
157
+ // Get all the user ids for the current user's friends.
158
+ $fids = implode( ',', $friend_ids );
159
+
160
+ if ( empty($fids) )
161
+ return false;
162
+
163
+ // filter the user_ids based on the search criteria.
164
+ if ( function_exists('xprofile_install') ) {
165
+ $sql = $wpdb->prepare( "SELECT DISTINCT user_id FROM {$bp->profile->table_name_data} WHERE user_id IN ($fids) AND value LIKE '$filter%%' {$pag_sql}" );
166
+ $total_sql = $wpdb->prepare( "SELECT DISTINCT count(user_id) FROM {$bp->profile->table_name_data} WHERE user_id IN ($fids) AND value LIKE '$filter%%'" );
167
+ } else {
168
+ $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}" );
169
+ $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%%'" );
170
+ }
171
+
172
+ $filtered_friend_ids = $wpdb->get_col($sql);
173
+ $total_friend_ids = $wpdb->get_var($total_sql);
174
+
175
+ if ( !$filtered_friend_ids )
176
+ return false;
177
+
178
+ return array( 'friends' => $filtered_friend_ids, 'total' => (int)$total_friend_ids );
179
+ }
180
+
181
+ function check_is_friend( $loggedin_userid, $possible_friend_userid ) {
182
+ global $wpdb, $bp;
183
+
184
+ if ( !$loggedin_userid || !$possible_friend_userid )
185
+ return false;
186
+
187
+ $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 ) );
188
+
189
+ if ( $result ) {
190
+ if ( 0 == (int)$result[0]->is_confirmed ) {
191
+ return 'pending';
192
+ } else {
193
+ return 'is_friend';
194
+ }
195
+ } else {
196
+ return 'not_friends';
197
+ }
198
+ }
199
+
200
+ function get_bulk_last_active( $user_ids ) {
201
+ global $wpdb, $bp;
202
+
203
+ 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" ) );
204
+ }
205
+
206
+ function accept($friendship_id) {
207
+ global $wpdb, $bp;
208
+
209
+ 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 ) );
210
+ }
211
+
212
+ function reject($friendship_id) {
213
+ global $wpdb, $bp;
214
+
215
+ 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 ) );
216
+ }
217
+
218
+ function search_users( $filter, $user_id, $limit = null, $page = null ) {
219
+ global $wpdb, $bp;
220
+
221
+ like_escape($filter);
222
+ $usermeta_table = $wpdb->base_prefix . 'usermeta';
223
+ $users_table = $wpdb->base_prefix . 'users';
224
+
225
+ if ( $limit && $page )
226
+ $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
227
+
228
+ // filter the user_ids based on the search criteria.
229
+ if ( function_exists('xprofile_install') ) {
230
+ $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" );
231
+ } else {
232
+ $sql = $wpdb->prepare( "SELECT DISTINCT user_id as id FROM $usermeta_table WHERE meta_value LIKE '$filter%%' ORDER BY d.value DESC $pag_sql" );
233
+ }
234
+
235
+ $filtered_fids = $wpdb->get_col($sql);
236
+
237
+ if ( !$filtered_fids )
238
+ return false;
239
+
240
+ return $filtered_fids;
241
+ }
242
+
243
+ function search_users_count( $filter ) {
244
+ global $wpdb, $bp;
245
+
246
+ like_escape($filter);
247
+ $usermeta_table = $wpdb->prefix . 'usermeta';
248
+ $users_table = $wpdb->base_prefix . 'users';
249
+
250
+ // filter the user_ids based on the search criteria.
251
+ if ( function_exists('xprofile_install') ) {
252
+ $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%%'" );
253
+ } else {
254
+ $sql = $wpdb->prepare( "SELECT DISTINCT count(user_id) FROM $usermeta_table WHERE meta_value LIKE '$filter%%'" );
255
+ }
256
+
257
+ $user_count = $wpdb->get_col($sql);
258
+
259
+ if ( !$user_count )
260
+ return false;
261
+
262
+ return $user_count[0];
263
+ }
264
+
265
+ function sort_by_name( $user_ids ) {
266
+ global $wpdb, $bp;
267
+
268
+ if ( !function_exists( 'xprofile_install') )
269
+ return false;
270
+
271
+ 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 ) );
272
+ }
273
+
274
+ function get_random_friends( $user_id, $total_friends = 5 ) {
275
+ global $wpdb, $bp;
276
+
277
+ $sql = $wpdb->prepare( "SELECT friend_user_id, initiator_user_id FROM {$bp->friends->table_name} WHERE (friend_user_id = %d || initiator_user_id = %d) && is_confirmed = 1 ORDER BY rand() LIMIT %d", $user_id, $user_id, $total_friends );
278
+ $results = $wpdb->get_results($sql);
279
+
280
+ for ( $i = 0; $i < count($results); $i++ ) {
281
+ $fids[] = ( $results[$i]->friend_user_id == $user_id ) ? $results[$i]->initiator_user_id : $results[$i]->friend_user_id;
282
+ }
283
+
284
+ // remove duplicates
285
+ if ( count($fids) > 0 )
286
+ return array_flip(array_flip($fids));
287
+ else
288
+ return false;
289
+ }
290
+
291
+ function get_invitable_friend_count( $user_id, $group_id ) {
292
+ global $wpdb, $bp;
293
+
294
+ $friend_ids = BP_Friends_Friendship::get_friend_user_ids( $user_id );
295
+
296
+ $invitable_count = 0;
297
+ for ( $i = 0; $i < count($friend_ids); $i++ ) {
298
+
299
+ if ( BP_Groups_Member::check_is_member( (int)$friend_ids[$i], $group_id ) )
300
+ continue;
301
+
302
+ if ( BP_Groups_Member::check_has_invite( (int)$friend_ids[$i], $group_id ) )
303
+ continue;
304
+
305
+ $invitable_count++;
306
+ }
307
+
308
+ return $invitable_count;
309
+ }
310
+
311
+ function get_user_ids_for_friendship( $friendship_id ) {
312
+ global $wpdb, $bp;
313
+
314
+ return $wpdb->get_row( $wpdb->prepare( "SELECT friend_user_id, initiator_user_id FROM {$bp->friends->table_name} WHERE id = %d", $friendship_id ) );
315
+ }
316
+
317
+ function delete_all_for_user( $user_id ) {
318
+ global $wpdb, $bp;
319
+
320
+ $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->friends->table_name} WHERE friend_user_id = %d OR initiator_user_id = %d", $user_id, $user_id ) );
321
+
322
+ // Delete friend request notifications for members who have a notification from this user.
323
+ $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 ) );
324
+ }
325
+ }
326
+
327
+
328
+
329
+ ?>
bp-friends/bp-friends-cssjs.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**************************************************************************
3
+ friends_add_js()
4
+
5
+ Inserts the Javascript needed for managing friends.
6
+ **************************************************************************/
7
+
8
+ function friends_add_js() {
9
+ global $bp;
10
+
11
+ if ( $bp->current_component == $bp->friends->slug )
12
+ wp_enqueue_script( 'bp-friends-js', BP_PLUGIN_URL . '/bp-friends/js/general.js' );
13
+ }
14
+ add_action( 'template_redirect', 'friends_add_js', 1 );
15
+
16
+ function friends_add_structure_css() {
17
+ /* Enqueue the structure CSS file to give basic positional formatting for components */
18
+ wp_enqueue_style( 'bp-friends-structure', BP_PLUGIN_URL . '/bp-friends/css/structure.css' );
19
+ }
20
+ add_action( 'bp_styles', 'friends_add_structure_css' );
21
+
22
+ ?>
bp-friends/bp-friends-notifications.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function friends_notification_new_request( $friendship_id, $initiator_id, $friend_id ) {
4
+ global $bp;
5
+
6
+ $initiator_name = bp_fetch_user_fullname( $initiator_id, false );
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 = site_url( BP_MEMBERS_SLUG . '/' . $ud->user_login . '/friends/requests/' );
15
+ $settings_link = site_url( BP_MEMBERS_SLUG . '/' . $ud->user_login . '/settings/notifications' );
16
+
17
+ $initiator_link = site_url( BP_MEMBERS_SLUG . '/' . $initiator_ud->user_login . '/profile' );
18
+
19
+ // Set up and send the message
20
+ $to = $ud->user_email;
21
+ $subject = '[' . get_blog_option( 1, '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
27
+
28
+ To view %s's profile: %s
29
+
30
+ ---------------------
31
+ ", 'buddypress' ), $initiator_name, $all_requests_link, $initiator_name, $initiator_link );
32
+
33
+ $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
34
+
35
+ // Send it
36
+ wp_mail( $to, $subject, $message );
37
+ }
38
+
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_fetch_user_fullname( $friend_id, false );
46
+
47
+ if ( 'no' == get_usermeta( (int)$initiator_id, 'notification_friends_friendship_accepted' ) )
48
+ return false;
49
+
50
+ $ud = get_userdata( $initiator_id );
51
+ $friend_ud = get_userdata( $friend_id );
52
+
53
+ $friend_link = site_url() . '/' . BP_MEMBERS_SLUG . '/' . $friend_ud->user_login;
54
+ $settings_link = site_url() . '/' . BP_MEMBERS_SLUG . '/' . $ud->user_login . '/settings/notifications';
55
+
56
+ // Set up and send the message
57
+ $to = $ud->user_email;
58
+ $subject = '[' . get_blog_option( 1, 'blogname' ) . '] ' . sprintf( __( '%s accepted your friendship request', 'buddypress' ), $friend_name );
59
+
60
+ $message = sprintf( __(
61
+ '%s accepted your friend request.
62
+
63
+ To view %s\'s profile: %s
64
+
65
+ ---------------------
66
+ ', 'buddypress' ), $friend_name, $friend_name, $friend_link );
67
+
68
+ $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
69
+
70
+ // Send it
71
+ wp_mail( $to, $subject, $message );
72
+ }
73
+
74
+
75
+ ?>
bp-friends/bp-friends-templatetags.php ADDED
@@ -0,0 +1,463 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class BP_Friendship_Template {
4
+ var $current_friendship = -1;
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;
25
+
26
+ switch ( $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':
36
+ $this->friendships = friends_get_friendship_requests( $user_id );
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
+
44
+ if ( 'requests' == $type ) {
45
+ $this->total_friend_count = $this->friendships['total'];
46
+ $this->friendships = $this->friendships['requests'];
47
+ $this->friendship_count = count($this->friendships);
48
+ } else {
49
+ if ( !$max )
50
+ $this->total_friend_count = (int)$this->friendships['total'];
51
+ else
52
+ $this->total_friend_count = (int)$max;
53
+
54
+ $this->friendships = $this->friendships['friends'];
55
+
56
+ if ( $max ) {
57
+ if ( $max >= count($this->friendships) )
58
+ $this->friendship_count = count($this->friendships);
59
+ else
60
+ $this->friendship_count = (int)$max;
61
+ } else {
62
+ $this->friendship_count = count($this->friendships);
63
+ }
64
+ }
65
+
66
+ $this->pag_links = paginate_links( array(
67
+ 'base' => add_query_arg( 'frpage', '%#%' ),
68
+ 'format' => '',
69
+ 'total' => ceil($this->total_friend_count / $this->pag_num),
70
+ 'current' => $this->pag_page,
71
+ 'prev_text' => '&laquo;',
72
+ 'next_text' => '&raquo;',
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 ) {
102
+ do_action('loop_end');
103
+ // Do some cleaning up after the loop
104
+ $this->rewind_friendships();
105
+ }
106
+
107
+ $this->in_the_loop = false;
108
+ return false;
109
+ }
110
+
111
+ function the_friendship() {
112
+ global $friendship, $bp;
113
+
114
+ $this->in_the_loop = true;
115
+ $this->friendship = $this->next_friendship();
116
+
117
+ if ( 'requests' == $this->type ) {
118
+ $this->friendship = new BP_Friends_Friendship( $this->friendship );
119
+ $this->friendship->user_id = ( $this->friendship->friend_user_id == $bp->loggedin_user->id ) ? $this->friendship->initiator_user_id : $this->friendship->friend_user_id;
120
+ } else {
121
+ if ( 'newest' == $this->type )
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
+ }
136
+
137
+ if ( 0 == $this->current_friendship ) // loop has just started
138
+ do_action('loop_start');
139
+ }
140
+ }
141
+
142
+ function bp_has_friendships( $args = '' ) {
143
+ global $bp, $friends_template;
144
+
145
+ $defaults = array(
146
+ 'type' => 'active',
147
+ 'user_id' => false,
148
+ 'per_page' => 10,
149
+ 'max' => false,
150
+ 'filter' => false
151
+ );
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'
159
+ */
160
+ if ( 'my-friends' == $bp->current_action ) {
161
+ $order = $bp->action_variables[0];
162
+ if ( 'newest' == $order )
163
+ $type = 'newest';
164
+ else if ( 'alphabetically' == $order )
165
+ $type = 'alphabetical';
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
+
173
+ $friends_template = new BP_Friendship_Template( $user_id, $type, $per_page, $max, $filter );
174
+ return $friends_template->has_friendships();
175
+ }
176
+
177
+ function bp_the_friendship() {
178
+ global $friends_template;
179
+ return $friends_template->the_friendship();
180
+ }
181
+
182
+ function bp_user_friendships() {
183
+ global $friends_template;
184
+ return $friends_template->user_friendships();
185
+ }
186
+
187
+ function bp_friend_id() {
188
+ echo bp_get_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() {
197
+ echo bp_get_friend_avatar_thumb();
198
+ }
199
+ function bp_get_friend_avatar_thumb() {
200
+ global $friends_template;
201
+
202
+ if ( !$template )
203
+ $template = &$friends_template->friendship->friend;
204
+
205
+ return apply_filters( 'bp_get_friend_avatar_thumb', $friends_template->friendship->friend->avatar_thumb );
206
+ }
207
+
208
+ function bp_friend_name() {
209
+ echo bp_get_friend_name();
210
+ }
211
+ function bp_get_friend_name() {
212
+ global $friends_template;
213
+
214
+ return apply_filters( 'bp_get_friend_name', strip_tags( $friends_template->friendship->friend->user_link ) );
215
+ }
216
+
217
+ function bp_friend_link() {
218
+ echo bp_get_friend_link();
219
+ }
220
+ function bp_get_friend_link() {
221
+ global $friends_template;
222
+
223
+ return apply_filters( 'bp_get_friend_link', $friends_template->friendship->friend->user_link );
224
+ }
225
+
226
+ function bp_friend_url() {
227
+ echo bp_get_friend_url();
228
+ }
229
+ function bp_get_friend_url() {
230
+ global $friends_template;
231
+
232
+ return apply_filters( 'bp_get_friend_url', $friends_template->friendship->friend->user_url );
233
+ }
234
+
235
+ function bp_friend_last_active() {
236
+ echo bp_get_friend_last_active();
237
+ }
238
+ function bp_get_friend_last_active() {
239
+ global $friends_template;
240
+
241
+ return apply_filters( 'bp_get_friend_last_active', $friends_template->friendship->friend->last_active );
242
+ }
243
+
244
+ function bp_friend_time_since_requested() {
245
+ echo bp_get_friend_time_since_requested();
246
+ }
247
+ function bp_get_friend_time_since_requested() {
248
+ global $friends_template;
249
+
250
+ if ( $friends_template->friendship->date_created != "0000-00-00 00:00:00" ) {
251
+ return apply_filters( 'bp_friend_time_since_requested', sprintf( __( 'requested %s ago', 'buddypress' ), bp_core_time_since( strtotime( $friends_template->friendship->date_created ) ) ) );
252
+ }
253
+
254
+ return false;
255
+ }
256
+
257
+ function bp_friend_accept_request_link() {
258
+ echo bp_get_friend_accept_request_link();
259
+ }
260
+ function bp_get_friend_accept_request_link() {
261
+ global $friends_template, $bp;
262
+
263
+ return apply_filters( 'bp_get_friend_accept_request_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/requests/accept/' . $friends_template->friendship->id, 'friends_accept_friendship' ) );
264
+ }
265
+
266
+ function bp_friend_reject_request_link() {
267
+ echo bp_get_friend_reject_request_link();
268
+ }
269
+ function bp_get_friend_reject_request_link() {
270
+ global $friends_template, $bp;
271
+
272
+ 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' ) );
273
+ }
274
+
275
+ function bp_friend_pagination() {
276
+ echo bp_get_friend_pagination();
277
+ }
278
+ function bp_get_friend_pagination() {
279
+ global $friends_template;
280
+
281
+ return apply_filters( 'bp_friend_pagination', $friends_template->pag_links );
282
+ }
283
+
284
+ function bp_friend_pagination_count() {
285
+ global $bp, $friends_template;
286
+
287
+ $from_num = intval( ( $friends_template->pag_page - 1 ) * $friends_template->pag_num ) + 1;
288
+ $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) ;
289
+
290
+ echo sprintf( __( 'Viewing friend %d to %d (of %d friends)', 'buddypress' ), $from_num, $to_num, $friends_template->total_friend_count ); ?> &nbsp;
291
+ <img id="ajax-loader-friends" src="<?php echo $bp->core->image_base ?>/ajax-loader.gif" height="7" alt="<?php _e( "Loading", "buddypress" ) ?>" style="display: none;" /><?php
292
+ }
293
+
294
+
295
+ function bp_friend_search_form() {
296
+ global $friends_template, $bp;
297
+
298
+ $action = $bp->displayed_user->domain . $bp->friends->slug . '/my-friends/search/';
299
+ $label = __( 'Filter Friends', 'buddypress' );
300
+ ?>
301
+ <form action="<?php echo $action ?>" id="friend-search-form" method="post">
302
+
303
+ <label for="friend-search-box" id="friend-search-label"><?php echo $label ?> <img id="ajax-loader" src="<?php echo $bp->friends->image_base ?>/ajax-loader.gif" height="7" alt="<?php _e( 'Loading', 'buddypress' ) ?>" style="display: none;" /></label>
304
+ <input type="search" name="friend-search-box" id="friend-search-box" value="<?php echo $value ?>"<?php echo $disabled ?> />
305
+
306
+ <?php wp_nonce_field( 'friends_search', '_wpnonce_friend_search' ) ?>
307
+ <input type="hidden" name="initiator" id="initiator" value="<?php echo $bp->displayed_user->id ?>" />
308
+
309
+ </form>
310
+ <?php
311
+ }
312
+
313
+ function bp_friends_is_filtered() {
314
+ if ( isset( $_POST['friend-search-box'] ) )
315
+ return true;
316
+
317
+ return false;
318
+ }
319
+
320
+ function bp_friend_all_friends_link() {
321
+ global $bp;
322
+ echo apply_filters( 'bp_friend_all_friends_link', $bp->displayed_user->domain . 'my-friends/all-friends' );
323
+ }
324
+
325
+ function bp_friend_latest_update_link() {
326
+ global $bp;
327
+ echo apply_filters( 'bp_friend_latest_update_link', $bp->displayed_user->domain . 'my-friends/last-updated' );
328
+ }
329
+
330
+ function bp_friend_recent_activity_link() {
331
+ global $bp;
332
+ echo apply_filters( 'bp_friend_recent_activity_link', $bp->displayed_user->domain . 'my-friends/recently-active' );
333
+ }
334
+
335
+ function bp_friend_recent_status_link() {
336
+ global $bp;
337
+ echo apply_filters( 'bp_friend_recent_status_link', $bp->displayed_user->domain . 'my-friends/status-updates' );
338
+ }
339
+
340
+ function bp_add_friend_button( $potential_friend_id = false ) {
341
+ global $bp, $friends_template;
342
+
343
+ if ( is_user_logged_in() ) {
344
+
345
+ if ( !$potential_friend_id && $friends_template->friendship->friend )
346
+ $potential_friend_id = $friends_template->friendship->friend->id;
347
+ else if ( !$potential_friend_id && !$friends_template->friendship->friend )
348
+ $potential_friend_id = $bp->displayed_user->id;
349
+
350
+ if ( $bp->loggedin_user->id == $potential_friend_id )
351
+ return false;
352
+
353
+ $friend_status = BP_Friends_Friendship::check_is_friend( $bp->loggedin_user->id, $potential_friend_id );
354
+
355
+ echo '<div class="friendship-button ' . $friend_status . '" id="friendship-button-' . $potential_friend_id . '">';
356
+ if ( 'pending' == $friend_status ) {
357
+ echo '<a class="requested" href="' . $bp->loggedin_user->domain . $bp->friends->slug . '">' . __( 'Friendship Requested', 'buddypress' ) . '</a>';
358
+ } else if ( 'is_friend' == $friend_status ) {
359
+ echo '<a href="' . wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/remove-friend/' . $potential_friend_id, 'friends_remove_friend' ) . '" title="' . __('Cancel Friendship', 'buddypress') . '" id="friend-' . $potential_friend_id . '" rel="remove" class="remove">' . __('Cancel Friendship', 'buddypress') . '</a>';
360
+ } else {
361
+ echo '<a href="' . wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/add-friend/' . $potential_friend_id, 'friends_add_friend' ) . '" title="' . __('Add Friend', 'buddypress') . '" id="friend-' . $potential_friend_id . '" rel="add" class="add">' . __('Add Friend', 'buddypress') . '</a>';
362
+ }
363
+ echo '</div>';
364
+ }
365
+ }
366
+
367
+ function bp_friends_header_tabs() {
368
+ global $bp, $create_group_step, $completed_to_step;
369
+ ?>
370
+ <li<?php if ( !isset($bp->action_variables[0]) || 'recently-active' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->friends->slug ?>/my-friends/recently-active"><?php _e( 'Recently Active', 'buddypress' ) ?></a></li>
371
+ <li<?php if ( 'newest' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->friends->slug ?>/my-friends/newest"><?php _e( 'Newest', 'buddypress' ) ?></a></li>
372
+ <li<?php if ( 'alphabetically' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->friends->slug ?>/my-friends/alphabetically""><?php _e( 'Alphabetically', 'buddypress' ) ?></a></li>
373
+ <?php
374
+ do_action( 'friends_header_tabs' );
375
+ }
376
+
377
+ function bp_friends_filter_title() {
378
+ global $bp;
379
+
380
+ $current_filter = $bp->action_variables[0];
381
+
382
+ switch ( $current_filter ) {
383
+ case 'recently-active': default:
384
+ _e( 'Recently Active', 'buddypress' );
385
+ break;
386
+ case 'newest':
387
+ _e( 'Newest', 'buddypress' );
388
+ break;
389
+ case 'alphabetically':
390
+ _e( 'Alphabetically', 'buddypress' );
391
+ break;
392
+ }
393
+ }
394
+
395
+ function bp_friends_random_friends() {
396
+ global $bp;
397
+
398
+ if ( !$friend_ids = wp_cache_get( 'friends_friend_ids_' . $bp->displayed_user->id, 'bp' ) ) {
399
+ $friend_ids = BP_Friends_Friendship::get_random_friends( $bp->displayed_user->id );
400
+ wp_cache_set( 'friends_friend_ids_' . $bp->displayed_user->id, $friend_ids, 'bp' );
401
+ }
402
+ ?>
403
+ <div class="info-group">
404
+ <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 ) ?>) <a href="<?php echo $bp->displayed_user->domain . $bp->friends->slug ?>"><?php _e('See All', 'buddypress') ?> &raquo;</a></h4>
405
+
406
+ <?php if ( $friend_ids ) { ?>
407
+ <ul class="horiz-gallery">
408
+ <?php for ( $i = 0; $i < count( $friend_ids ); $i++ ) { ?>
409
+ <li>
410
+ <a href="<?php echo bp_core_get_userurl( $friend_ids[$i] ) ?>"><?php echo bp_core_get_avatar( $friend_ids[$i], 1 ) ?></a>
411
+ <h5><?php echo bp_core_get_userlink($friend_ids[$i]) ?></h5>
412
+ </li>
413
+ <?php } ?>
414
+ </ul>
415
+ <?php } else { ?>
416
+ <div id="message" class="info">
417
+ <p><?php bp_word_or_name( __( "You haven't added any friend connections yet.", 'buddypress' ), __( "%s hasn't created any friend connections yet.", 'buddypress' ) ) ?></p>
418
+ </div>
419
+ <?php } ?>
420
+ <div class="clear"></div>
421
+ </div>
422
+ <?php
423
+ }
424
+
425
+ function bp_friends_random_members( $total_members = 5 ) {
426
+ global $bp;
427
+
428
+ if ( !$user_ids = wp_cache_get( 'friends_random_users', 'bp' ) ) {
429
+ $user_ids = BP_Core_User::get_random_users( $total_members );
430
+ wp_cache_set( 'friends_random_users', $user_ids, 'bp' );
431
+ }
432
+ ?>
433
+ <?php if ( $user_ids['users'] ) { ?>
434
+ <ul class="item-list" id="random-members-list">
435
+ <?php for ( $i = 0; $i < count( $user_ids['users'] ); $i++ ) { ?>
436
+ <li>
437
+ <a href="<?php echo bp_core_get_userurl( $user_ids['users'][$i]->user_id ) ?>"><?php echo bp_core_get_avatar( $user_ids['users'][$i]->user_id, 1 ) ?></a>
438
+ <h5><?php echo bp_core_get_userlink($user_ids['users'][$i]->user_id) ?></h5>
439
+ <?php if ( function_exists( 'xprofile_get_random_profile_data' ) ) { ?>
440
+ <?php $random_data = xprofile_get_random_profile_data( $user_ids['users'][$i]->user_id, true ); ?>
441
+ <div class="profile-data">
442
+ <p class="field-name"><?php echo $random_data[0]->name ?></p>
443
+ <?php echo $random_data[0]->value ?>
444
+ </div>
445
+ <?php } ?>
446
+
447
+ <div class="action">
448
+ <?php if ( function_exists( 'bp_add_friend_button' ) ) { ?>
449
+ <?php bp_add_friend_button( $user_ids['users'][$i]->user_id ) ?>
450
+ <?php } ?>
451
+ </div>
452
+ </li>
453
+ <?php } ?>
454
+ </ul>
455
+ <?php } else { ?>
456
+ <div id="message" class="info">
457
+ <p><?php _e( "There aren't enough site members to show a random sample just yet.", 'buddypress' ) ?></p>
458
+ </div>
459
+ <?php } ?>
460
+ <?php
461
+ }
462
+
463
+ ?>
bp-friends/css/structure.css ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Basic layout structure styles for BuddyPress Friends. Formats BuddyPress friend pages within any WordPress theme.
3
+ No colors, fonts or pretty stuff.
4
+
5
+ These structure styles can be overridden by the theme CSS file if needed.
6
+ */
7
+
8
+ #predefined-lists {
9
+ margin: 1em 1.2em 0 0;
10
+ }
11
+
12
+ #predefined-lists li {
13
+ padding: 0.25em 0;
14
+ }
15
+
16
+ .left-menu img#ajax-loader {
17
+ position: absolute;
18
+ right: 0;
19
+ top: 7px;
20
+ }
21
+
22
+ #friend-list .friendship-button {
23
+ margin-top: -1.5em;
24
+ }
25
+
26
+ .left-menu .friendship-button {
27
+ margin-top: 1em;
28
+ }
bp-friends/images/ajax-loader.gif ADDED
Binary file
bp-friends/js/general.js ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ jQuery(document).ready( function() {
3
+ jQuery("form#friend-search-form").submit(
4
+ function() {
5
+ return false;
6
+ }
7
+ );
8
+
9
+ jQuery("div#pag a").livequery('click',
10
+ function() {
11
+ jQuery('#ajax-loader').toggle();
12
+
13
+ var frpage = jQuery(this).attr('href');
14
+ frpage = frpage.split('=');
15
+
16
+ jQuery.post( ajaxurl, {
17
+ action: 'friends_search',
18
+ 'cookie': encodeURIComponent(document.cookie),
19
+ '_wpnonce': jQuery("input#_wpnonce_friend_search").val(),
20
+ 'initiator_id': jQuery("input#initiator").val(),
21
+ 'frpage': frpage[1],
22
+
23
+ 'friend-search-box': jQuery("#friend-search-box").val()
24
+ },
25
+ function(response)
26
+ {
27
+ response = response.substr( 0, response.length - 1 );
28
+
29
+ jQuery("div#friends-loop").fadeOut(200,
30
+ function() {
31
+ jQuery('#ajax-loader').toggle();
32
+ jQuery("div#friends-loop").html(response);
33
+ jQuery("div#friends-loop").fadeIn(200);
34
+ }
35
+ );
36
+ });
37
+
38
+ return false;
39
+ }
40
+ );
41
+
42
+ jQuery("input#friend-search-box").keyup(
43
+
44
+ function(e) {
45
+ if ( e.which == 13 ) {
46
+ jQuery('#ajax-loader').toggle();
47
+
48
+ jQuery.post( ajaxurl, {
49
+ action: 'friends_search',
50
+ 'cookie': encodeURIComponent(document.cookie),
51
+ '_wpnonce': jQuery("input#_wpnonce_friend_search").val(),
52
+
53
+ 'friend-search-box': jQuery("#friend-search-box").val()
54
+ },
55
+ function(response)
56
+ {
57
+ response = response.substr( 0, response.length - 1 );
58
+
59
+ jQuery("div#friends-loop").fadeOut(200,
60
+ function() {
61
+ jQuery('#ajax-loader').toggle();
62
+ jQuery("div#friends-loop").html(response);
63
+ jQuery("div#friends-loop").fadeIn(200);
64
+ }
65
+ );
66
+
67
+ });
68
+
69
+ return false;
70
+ }
71
+ }
72
+ );
73
+ });
bp-groups.php ADDED
@@ -0,0 +1,2352 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ define ( 'BP_GROUPS_VERSION', '1.0' );
4
+ define ( 'BP_GROUPS_DB_VERSION', '1300' );
5
+
6
+ /* Define the slug for the component */
7
+ if ( !defined( 'BP_GROUPS_SLUG' ) )
8
+ define ( 'BP_GROUPS_SLUG', 'groups' );
9
+
10
+ require ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-classes.php' );
11
+ require ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-ajax.php' );
12
+ require ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-cssjs.php' );
13
+ require ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-templatetags.php' );
14
+ require ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-widgets.php' );
15
+ require ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-filters.php' );
16
+
17
+
18
+ /**************************************************************************
19
+ groups_install()
20
+
21
+ Sets up the database tables ready for use on a site installation.
22
+ **************************************************************************/
23
+
24
+ function groups_install() {
25
+ global $wpdb, $bp;
26
+
27
+ if ( !empty($wpdb->charset) )
28
+ $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
29
+
30
+ $sql[] = "CREATE TABLE {$bp->groups->table_name} (
31
+ id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
32
+ creator_id bigint(20) NOT NULL,
33
+ name varchar(100) NOT NULL,
34
+ slug varchar(100) NOT NULL,
35
+ description longtext NOT NULL,
36
+ news longtext NOT NULL,
37
+ status varchar(10) NOT NULL DEFAULT 'open',
38
+ is_invitation_only tinyint(1) NOT NULL DEFAULT '0',
39
+ enable_wire tinyint(1) NOT NULL DEFAULT '1',
40
+ enable_forum tinyint(1) NOT NULL DEFAULT '1',
41
+ enable_photos tinyint(1) NOT NULL DEFAULT '1',
42
+ photos_admin_only tinyint(1) NOT NULL DEFAULT '0',
43
+ date_created datetime NOT NULL,
44
+ avatar_thumb varchar(250) NOT NULL,
45
+ avatar_full varchar(250) NOT NULL,
46
+ KEY creator_id (creator_id),
47
+ KEY status (status),
48
+ KEY is_invitation_only (is_invitation_only)
49
+ ) {$charset_collate};";
50
+
51
+ $sql[] = "CREATE TABLE {$bp->groups->table_name_members} (
52
+ id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
53
+ group_id bigint(20) NOT NULL,
54
+ user_id bigint(20) NOT NULL,
55
+ inviter_id bigint(20) NOT NULL,
56
+ is_admin tinyint(1) NOT NULL DEFAULT '0',
57
+ is_mod tinyint(1) NOT NULL DEFAULT '0',
58
+ user_title varchar(100) NOT NULL,
59
+ date_modified datetime NOT NULL,
60
+ comments longtext NOT NULL,
61
+ is_confirmed tinyint(1) NOT NULL DEFAULT '0',
62
+ is_banned tinyint(1) NOT NULL DEFAULT '0',
63
+ invite_sent tinyint(1) NOT NULL DEFAULT '0',
64
+ KEY group_id (group_id),
65
+ KEY is_admin (is_admin),
66
+ KEY is_mod (is_mod),
67
+ KEY user_id (user_id),
68
+ KEY inviter_id (inviter_id),
69
+ KEY is_confirmed (is_confirmed)
70
+ ) {$charset_collate};";
71
+
72
+ $sql[] = "CREATE TABLE {$bp->groups->table_name_groupmeta} (
73
+ id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
74
+ group_id bigint(20) NOT NULL,
75
+ meta_key varchar(255) DEFAULT NULL,
76
+ meta_value longtext DEFAULT NULL,
77
+ KEY group_id (group_id),
78
+ KEY meta_key (meta_key)
79
+ ) {$charset_collate};";
80
+
81
+ require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
82
+ dbDelta($sql);
83
+
84
+ if ( function_exists('bp_wire_install') )
85
+ groups_wire_install();
86
+
87
+ update_site_option( 'bp-groups-db-version', BP_GROUPS_DB_VERSION );
88
+ }
89
+
90
+ function groups_wire_install() {
91
+ global $wpdb, $bp;
92
+
93
+ if ( !empty($wpdb->charset) )
94
+ $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
95
+
96
+ $sql[] = "CREATE TABLE {$bp->groups->table_name_wire} (
97
+ id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
98
+ item_id bigint(20) NOT NULL,
99
+ user_id bigint(20) NOT NULL,
100
+ content longtext NOT NULL,
101
+ date_posted datetime NOT NULL,
102
+ KEY item_id (item_id),
103
+ KEY user_id (user_id)
104
+ ) {$charset_collate};";
105
+
106
+ require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
107
+ dbDelta($sql);
108
+ }
109
+
110
+
111
+ /**************************************************************************
112
+ groups_setup_globals()
113
+
114
+ Set up and add all global variables for this component, and add them to
115
+ the $bp global variable array.
116
+ **************************************************************************/
117
+
118
+ function groups_setup_globals( $no_global = false ) {
119
+ global $wpdb;
120
+
121
+ if ( !$no_global )
122
+ global $bp;
123
+
124
+ $bp->groups->table_name = $wpdb->base_prefix . 'bp_groups';
125
+ $bp->groups->table_name_members = $wpdb->base_prefix . 'bp_groups_members';
126
+ $bp->groups->table_name_groupmeta = $wpdb->base_prefix . 'bp_groups_groupmeta';
127
+ $bp->groups->image_base = BP_PLUGIN_URL . '/bp-groups/images';
128
+ $bp->groups->format_activity_function = 'groups_format_activity';
129
+ $bp->groups->format_notification_function = 'groups_format_notifications';
130
+ $bp->groups->slug = BP_GROUPS_SLUG;
131
+
132
+ if ( function_exists('bp_wire_install') )
133
+ $bp->groups->table_name_wire = $wpdb->base_prefix . 'bp_groups_wire';
134
+
135
+ $bp->groups->forbidden_names = apply_filters( 'groups_forbidden_names', array( 'my-groups', 'group-finder', 'create', 'invites', 'delete', 'add', 'admin', 'request-membership' ) );
136
+ $bp->version_numbers->groups = BP_GROUPS_VERSION;
137
+
138
+ return $bp;
139
+ }
140
+ add_action( 'plugins_loaded', 'groups_setup_globals', 5 );
141
+ add_action( 'admin_menu', 'groups_setup_globals', 1 );
142
+
143
+ function groups_setup_root_component() {
144
+ /* Register 'groups' as a root component */
145
+ bp_core_add_root_component( BP_GROUPS_SLUG );
146
+ }
147
+ add_action( 'plugins_loaded', 'groups_setup_root_component', 1 );
148
+
149
+ function groups_check_installed() {
150
+ global $wpdb, $bp;
151
+
152
+ require ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-admin.php' );
153
+
154
+ /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
155
+ if ( get_site_option('bp-groups-db-version') < BP_GROUPS_DB_VERSION )
156
+ groups_install();
157
+ }
158
+ add_action( 'admin_menu', 'groups_check_installed' );
159
+
160
+ function groups_add_admin_menu() {
161
+ global $wpdb, $bp;
162
+
163
+ if ( !is_site_admin() )
164
+ return false;
165
+
166
+ /* Add the administration tab under the "Site Admin" tab for site administrators */
167
+ add_submenu_page( 'wpmu-admin.php', __("Groups", 'buddypress'), __("Groups", 'buddypress'), 1, "groups_admin_settings", "groups_admin_settings" );
168
+ }
169
+ add_action( 'admin_menu', 'groups_add_admin_menu' );
170
+
171
+ /**************************************************************************
172
+ groups_setup_nav()
173
+
174
+ Set up front end navigation.
175
+ **************************************************************************/
176
+
177
+ function groups_setup_nav() {
178
+ global $bp, $current_blog;
179
+ global $group_obj;
180
+
181
+ if ( $group_id = BP_Groups_Group::group_exists($bp->current_action) ) {
182
+
183
+ /* This is a single group page. */
184
+ $bp->is_single_item = true;
185
+ $group_obj = new BP_Groups_Group( $group_id );
186
+
187
+ /* Using "item" not "group" for generic support in other components. */
188
+ if ( is_site_admin() )
189
+ $bp->is_item_admin = 1;
190
+ else
191
+ $bp->is_item_admin = groups_is_user_admin( $bp->loggedin_user->id, $group_obj->id );
192
+
193
+ /* If the user is not an admin, check if they are a moderator */
194
+ if ( !$bp->is_item_admin )
195
+ $bp->is_item_mod = groups_is_user_mod( $bp->loggedin_user->id, $group_obj->id );
196
+
197
+ /* Is the logged in user a member of the group? */
198
+ $is_member = ( groups_is_user_member( $bp->loggedin_user->id, $group_obj->id ) ) ? true : false;
199
+
200
+ /* Should this group be visible to the logged in user? */
201
+ $is_visible = ( 'public' == $group_obj->status || $is_member ) ? true : false;
202
+ }
203
+
204
+ /* Add 'Groups' to the main navigation */
205
+ bp_core_add_nav_item( __('Groups', 'buddypress'), $bp->groups->slug );
206
+
207
+ if ( $bp->displayed_user->id )
208
+ bp_core_add_nav_default( $bp->groups->slug, 'groups_screen_my_groups', 'my-groups' );
209
+
210
+ $groups_link = $bp->loggedin_user->domain . $bp->groups->slug . '/';
211
+
212
+ /* Add the subnav items to the groups nav item */
213
+ bp_core_add_subnav_item( $bp->groups->slug, 'my-groups', __('My Groups', 'buddypress'), $groups_link, 'groups_screen_my_groups', 'my-groups-list' );
214
+ bp_core_add_subnav_item( $bp->groups->slug, 'create', __('Create a Group', 'buddypress'), $groups_link, 'groups_screen_create_group', false, bp_is_home() );
215
+ bp_core_add_subnav_item( $bp->groups->slug, 'invites', __('Invites', 'buddypress'), $groups_link, 'groups_screen_group_invites', false, bp_is_home() );
216
+
217
+ if ( $bp->current_component == $bp->groups->slug ) {
218
+
219
+ if ( bp_is_home() && !$bp->is_single_item ) {
220
+
221
+ $bp->bp_options_title = __('My Groups', 'buddypress');
222
+
223
+ } else if ( !bp_is_home() && !$bp->is_single_item ) {
224
+
225
+ $bp->bp_options_avatar = bp_core_get_avatar( $bp->displayed_user->id, 1 );
226
+ $bp->bp_options_title = $bp->displayed_user->fullname;
227
+
228
+ } else if ( $bp->is_single_item ) {
229
+ // We are viewing a single group, so set up the
230
+ // group navigation menu using the $group_obj global.
231
+
232
+ /* When in a single group, the first action is bumped down one because of the
233
+ group name, so we need to adjust this and set the group name to current_item. */
234
+ $bp->current_item = $bp->current_action;
235
+ $bp->current_action = $bp->action_variables[0];
236
+ array_shift($bp->action_variables);
237
+
238
+ $bp->bp_options_title = $group_obj->name;
239
+ $bp->bp_options_avatar = '<img src="' . $group_obj->avatar_thumb . '" alt="Group Avatar Thumbnail" />';
240
+
241
+ $group_link = $bp->root_domain . '/' . $bp->groups->slug . '/' . $group_obj->slug . '/';
242
+
243
+ // If this is a private or hidden group, does the user have access?
244
+ if ( 'private' == $group_obj->status || 'hidden' == $group_obj->status ) {
245
+ if ( groups_is_user_member( $bp->loggedin_user->id, $group_obj->id ) && is_user_logged_in() )
246
+ $has_access = true;
247
+ else
248
+ $has_access = false;
249
+ } else {
250
+ $has_access = true;
251
+ }
252
+
253
+ // Reset the existing subnav items
254
+ bp_core_reset_subnav_items($bp->groups->slug);
255
+
256
+ bp_core_add_nav_default( $bp->groups->slug, 'groups_screen_group_home', 'home' );
257
+ bp_core_add_subnav_item( $bp->groups->slug, 'home', __('Home', 'buddypress'), $group_link, 'groups_screen_group_home', 'group-home' );
258
+
259
+ // If the user is a group mod or more, then show the group admin nav item */
260
+ if ( $bp->is_item_mod || $bp->is_item_admin )
261
+ bp_core_add_subnav_item( $bp->groups->slug, 'admin', __('Admin', 'buddypress'), $group_link , 'groups_screen_group_admin', 'group-admin', ( $bp->is_item_admin + (int)$bp->is_item_mod ) );
262
+
263
+ // If this is a private group, and the user is not a member, show a "Request Membership" nav item.
264
+ if ( !$has_access && !groups_check_for_membership_request( $bp->loggedin_user->id, $group_obj->id ) && $group_obj->status == 'private' )
265
+ bp_core_add_subnav_item( $bp->groups->slug, 'request-membership', __('Request Membership', 'buddypress'), $group_link , 'groups_screen_group_request_membership', 'request-membership' );
266
+
267
+ if ( $has_access && $group_obj->enable_forum && function_exists('bp_forums_setup') )
268
+ bp_core_add_subnav_item( $bp->groups->slug, 'forum', __('Forum', 'buddypress'), $group_link , 'groups_screen_group_forum', 'group-forum', $is_visible);
269
+
270
+ if ( $has_access && $group_obj->enable_wire && function_exists('bp_wire_install') )
271
+ bp_core_add_subnav_item( $bp->groups->slug, 'wire', __('Wire', 'buddypress'), $group_link, 'groups_screen_group_wire', 'group-wire', $is_visible );
272
+
273
+ if ( $has_access && $group_obj->enable_photos && function_exists('bp_gallery_install') )
274
+ bp_core_add_subnav_item( $bp->groups->slug, 'photos', __('Photos', 'buddypress'), $group_link, 'groups_screen_group_photos', 'group-photos', $is_visible );
275
+
276
+ if ( $has_access )
277
+ bp_core_add_subnav_item( $bp->groups->slug, 'members', __('Members', 'buddypress'), $group_link, 'groups_screen_group_members', 'group-members', $is_visible );
278
+
279
+ if ( is_user_logged_in() && groups_is_user_member( $bp->loggedin_user->id, $group_obj->id ) ) {
280
+ if ( function_exists('friends_install') )
281
+ bp_core_add_subnav_item( $bp->groups->slug, 'send-invites', __('Send Invites', 'buddypress'), $group_link, 'groups_screen_group_invite', 'group-invite', $is_member );
282
+
283
+ bp_core_add_subnav_item( $bp->groups->slug, 'leave-group', __('Leave Group', 'buddypress'), $group_link, 'groups_screen_group_leave', 'group-leave', $is_member );
284
+ }
285
+ }
286
+ }
287
+ }
288
+ add_action( 'wp', 'groups_setup_nav', 2 );
289
+ add_action( 'admin_menu', 'groups_setup_nav', 2 );
290
+
291
+ function groups_directory_groups_setup() {
292
+ global $bp;
293
+
294
+ if ( $bp->current_component == $bp->groups->slug && empty( $bp->current_action ) ) {
295
+ $bp->is_directory = true;
296
+
297
+ wp_enqueue_script( 'bp-groups-directory-groups', BP_PLUGIN_URL . '/bp-groups/js/directory-groups.js', array( 'jquery', 'jquery-livequery-pack' ) );
298
+ bp_core_load_template( apply_filters( 'groups_template_directory_groups', 'directories/groups/index' ) );
299
+ }
300
+ }
301
+ add_action( 'wp', 'groups_directory_groups_setup', 5 );
302
+
303
+ /***** Screens **********/
304
+
305
+ function groups_screen_my_groups() {
306
+ global $bp;
307
+
308
+ bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'member_promoted_to_mod' );
309
+ bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'member_promoted_to_admin' );
310
+
311
+ do_action( 'groups_screen_my_groups' );
312
+
313
+ bp_core_load_template( apply_filters( 'groups_template_my_groups', 'groups/index' ) );
314
+ }
315
+
316
+ function groups_screen_group_invites() {
317
+ global $bp;
318
+
319
+ $group_id = $bp->action_variables[1];
320
+
321
+ if ( isset($bp->action_variables) && in_array( 'accept', $bp->action_variables ) && is_numeric($group_id) ) {
322
+
323
+ if ( !groups_accept_invite( $bp->loggedin_user->id, $group_id ) ) {
324
+ bp_core_add_message( __('Group invite could not be accepted', 'buddypress'), 'error' );
325
+ } else {
326
+ bp_core_add_message( __('Group invite accepted', 'buddypress') );
327
+
328
+ /* Record this in activity streams */
329
+ groups_record_activity( array( 'item_id' => $group_id, 'component_name' => $bp->groups->slug, 'component_action' => 'joined_group', 'is_private' => 0 ) );
330
+ }
331
+
332
+ bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action );
333
+
334
+ } else if ( isset($bp->action_variables) && in_array( 'reject', $bp->action_variables ) && is_numeric($group_id) ) {
335
+
336
+ if ( !groups_reject_invite( $bp->loggedin_user->id, $group_id ) ) {
337
+ bp_core_add_message( __('Group invite could not be rejected', 'buddypress'), 'error' );
338
+ } else {
339
+ bp_core_add_message( __('Group invite rejected', 'buddypress') );
340
+ }
341
+
342
+ bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action );
343
+ }
344
+
345
+ // Remove notifications
346
+ bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'group_invite' );
347
+
348
+ do_action( 'groups_screen_group_invites', $group_id );
349
+
350
+ bp_core_load_template( apply_filters( 'groups_template_group_invites', 'groups/list-invites' ) );
351
+ }
352
+
353
+ function groups_screen_create_group() {
354
+ global $bp;
355
+ global $create_group_step, $group_obj, $completed_to_step;
356
+
357
+ $no_instantiate = false;
358
+ $reset_steps = false;
359
+
360
+ if ( !$create_group_step = $bp->action_variables[1] ) {
361
+ $create_group_step = 1;
362
+ $completed_to_step = 0;
363
+
364
+ unset($_SESSION['group_obj_id']);
365
+ unset($_SESSION['completed_to_step']);
366
+
367
+ $no_instantiate = true;
368
+ $reset_steps = true;
369
+ }
370
+
371
+ if ( isset($_SESSION['completed_to_step']) && !$reset_steps ) {
372
+ $completed_to_step = $_SESSION['completed_to_step'];
373
+ }
374
+
375
+ if ( isset( $_POST['save'] ) || isset( $_POST['skip'] ) ) {
376
+ $group_obj = new BP_Groups_Group( $_SESSION['group_obj_id'] );
377
+
378
+ if ( !$group_id = groups_create_group( $create_group_step, $_SESSION['group_obj_id'] ) ) {
379
+ bp_core_add_message( __('There was an error saving group details. Please try again.', 'buddypress'), 'error' );
380
+ bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $create_group_step );
381
+ } else {
382
+ $create_group_step++;
383
+ $completed_to_step++;
384
+ $_SESSION['completed_to_step'] = $completed_to_step;
385
+ $_SESSION['group_obj_id'] = $group_id;
386
+ }
387
+
388
+ if ( $completed_to_step == 4 )
389
+ bp_core_redirect( bp_get_group_permalink( $group_obj ) );
390
+ }
391
+
392
+ if ( isset($_SESSION['group_obj_id']) && !$group_obj && !$no_instantiate )
393
+ $group_obj = new BP_Groups_Group( $_SESSION['group_obj_id'] );
394
+
395
+ bp_core_load_template( apply_filters( 'groups_template_create_group', 'groups/create' ) );
396
+ }
397
+
398
+ function groups_screen_group_home() {
399
+ global $bp;
400
+
401
+ if ( $bp->is_single_item ) {
402
+
403
+ if ( isset($_GET['new']) ) {
404
+ // Delete group request notifications for the user
405
+ bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'membership_request_accepted' );
406
+ bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'membership_request_rejected' );
407
+ bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'member_promoted_to_mod' );
408
+ bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'member_promoted_to_admin' );
409
+ }
410
+
411
+ do_action( 'groups_screen_group_home' );
412
+
413
+ bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/group-home' ) );
414
+ }
415
+ }
416
+
417
+ function groups_screen_group_forum() {
418
+ global $bp, $group_obj;
419
+
420
+ if ( $bp->is_single_item ) {
421
+ $topic_id = $bp->action_variables[1];
422
+ $forum_id = groups_get_groupmeta( $group_obj->id, 'forum_id' );
423
+
424
+ if ( $topic_id ) {
425
+
426
+ /* Posting a reply */
427
+ if ( isset( $_POST['submit_reply'] ) && function_exists( 'bp_forums_new_post') ) {
428
+ groups_new_group_forum_post( $_POST['reply_text'], $topic_id );
429
+ bp_core_redirect( bp_get_group_permalink( $group_obj ) . '/forum/topic/' . $topic_id );
430
+ }
431
+
432
+ do_action( 'groups_screen_group_forum_topic' );
433
+
434
+ // If we are viewing a topic, load it.
435
+ bp_core_load_template( apply_filters( 'groups_template_group_forum', 'groups/forum/topic' ) );
436
+ } else {
437
+
438
+ /* Posting a topic */
439
+ if ( isset( $_POST['submit_topic'] ) && function_exists( 'bp_forums_new_topic') ) {
440
+ groups_new_group_forum_topic( $_POST['topic_title'], $_POST['topic_text'], $_POST['topic_tags'], $forum_id );
441
+ bp_core_redirect( bp_get_group_permalink( $group_obj ) . '/forum/' );
442
+ }
443
+
444
+ do_action( 'groups_screen_group_forum', $topic_id, $forum_id );
445
+
446
+ // Load the forum home.
447
+ bp_core_load_template( apply_filters( 'groups_template_group_forum', 'groups/forum/index' ) );
448
+ }
449
+ }
450
+ }
451
+
452
+ function groups_screen_group_wire() {
453
+ global $bp;
454
+ global $group_obj;
455
+
456
+ $wire_action = $bp->action_variables[0];
457
+
458
+ if ( $bp->is_single_item ) {
459
+ if ( 'post' == $wire_action && BP_Groups_Member::check_is_member( $bp->loggedin_user->id, $group_obj->id ) ) {
460
+
461
+ if ( !groups_new_wire_post( $group_obj->id, $_POST['wire-post-textarea'] ) ) {
462
+ bp_core_add_message( __('Wire message could not be posted.', 'buddypress'), 'error' );
463
+ } else {
464
+ bp_core_add_message( __('Wire message successfully posted.', 'buddypress') );
465
+ }
466
+
467
+ if ( !strpos( $_SERVER['HTTP_REFERER'], $bp->wire->slug ) ) {
468
+ bp_core_redirect( bp_get_group_permalink( $group_obj ) );
469
+ } else {
470
+ bp_core_redirect( bp_get_group_permalink( $group_obj ) . '/' . $bp->wire->slug );
471
+ }
472
+
473
+ } else if ( 'delete' == $wire_action && BP_Groups_Member::check_is_member( $bp->loggedin_user->id, $group_obj->id ) ) {
474
+ $wire_message_id = $bp->action_variables[1];
475
+
476
+ if ( !groups_delete_wire_post( $wire_message_id, $bp->groups->table_name_wire ) ) {
477
+ bp_core_add_message( __('There was an error deleting the wire message.', 'buddypress'), 'error' );
478
+ } else {
479
+ bp_core_add_message( __('Wire message successfully deleted.', 'buddypress') );
480
+ }
481
+
482
+ if ( !strpos( $_SERVER['HTTP_REFERER'], $bp->wire->slug ) ) {
483
+ bp_core_redirect( bp_get_group_permalink( $group_obj ) );
484
+ } else {
485
+ bp_core_redirect( bp_get_group_permalink( $group_obj ) . '/' . $bp->wire->slug );
486
+ }
487
+
488
+ } else if ( ( !$wire_action || 'latest' == $bp->action_variables[1] ) ) {
489
+ bp_core_load_template( apply_filters( 'groups_template_group_wire', 'groups/wire' ) );
490
+ } else {
491
+ bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/group-home' ) );
492
+ }
493
+ }
494
+ }
495
+
496
+ function groups_screen_group_members() {
497
+ global $bp;
498
+ global $group_obj;
499
+
500
+ if ( $bp->is_single_item ) {
501
+ do_action( 'groups_screen_group_members', $group_obj->id );
502
+
503
+ bp_core_load_template( apply_filters( 'groups_template_group_members', 'groups/list-members' ) );
504
+ }
505
+ }
506
+
507
+ function groups_screen_group_invite() {
508
+ global $bp;
509
+ global $group_obj;
510
+
511
+ if ( $bp->is_single_item ) {
512
+ if ( isset($bp->action_variables) && 'send' == $bp->action_variables[0] ) {
513
+ // Send the invites.
514
+ groups_send_invites($group_obj);
515
+
516
+ bp_core_add_message( __('Group invites sent.', 'buddypress') );
517
+
518
+ do_action( 'groups_screen_group_invite', $group_obj->id );
519
+
520
+ bp_core_redirect( bp_get_group_permalink( $group_obj ) );
521
+ } else {
522
+ // Show send invite page
523
+ bp_core_load_template( apply_filters( 'groups_template_group_invite', 'groups/send-invite' ) );
524
+ }
525
+ }
526
+ }
527
+
528
+ function groups_screen_group_leave() {
529
+ global $bp;
530
+ global $group_obj;
531
+
532
+ if ( $bp->is_single_item ) {
533
+ if ( isset($bp->action_variables) && 'yes' == $bp->action_variables[0] ) {
534
+
535
+ // Check if the user is the group admin first.
536
+ if ( groups_is_group_admin( $bp->loggedin_user->id, $group_obj->id ) ) {
537
+ bp_core_add_message( __('As the only group administrator, you cannot leave this group.', 'buddypress'), 'error' );
538
+ bp_core_redirect( bp_get_group_permalink( $group_obj ) );
539
+ }
540
+
541
+ // remove the user from the group.
542
+ if ( !groups_leave_group( $group_obj->id ) ) {
543
+ bp_core_add_message( __('There was an error leaving the group. Please try again.', 'buddypress'), 'error' );
544
+ bp_core_redirect( bp_get_group_permalink( $group_obj ) );
545
+ } else {
546
+ bp_core_add_message( __('You left the group successfully.', 'buddypress') );
547
+ bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug );
548
+ }
549
+
550
+ } else if ( isset($bp->action_variables) && 'no' == $bp->action_variables[0] ) {
551
+
552
+ bp_core_redirect( bp_get_group_permalink( $group_obj ) );
553
+
554
+ } else {
555
+
556
+ do_action( 'groups_screen_group_leave', $group_obj->id );
557
+
558
+ // Show leave group page
559
+ bp_core_load_template( apply_filters( 'groups_template_group_leave', 'groups/leave-group-confirm' ) );
560
+
561
+ }
562
+ }
563
+ }
564
+
565
+ function groups_screen_group_request_membership() {
566
+ global $bp, $group_obj;
567
+
568
+ if ( !is_user_logged_in() )
569
+ return false;
570
+
571
+ if ( 'private' == $group_obj->status ) {
572
+ // If the user has submitted a request, send it.
573
+ if ( isset( $_POST['group-request-send']) ) {
574
+ if ( !groups_send_membership_request( $bp->loggedin_user->id, $group_obj->id ) ) {
575
+ bp_core_add_message( __( 'There was an error sending your group membership request, please try again.', 'buddypress' ), 'error' );
576
+ } else {
577
+ bp_core_add_message( __( 'Your membership request was sent to the group administrator successfully. You will be notified when the group administrator responds to your request.', 'buddypress' ) );
578
+ }
579
+ bp_core_redirect( bp_get_group_permalink( $group_obj ) );
580
+ }
581
+
582
+ do_action( 'groups_screen_group_request_membership', $group_obj->id );
583
+
584
+ bp_core_load_template( apply_filters( 'groups_template_group_request_membership', 'groups/request-membership' ) );
585
+ }
586
+ }
587
+
588
+ function groups_screen_group_admin() {
589
+ global $bp, $group_obj;
590
+
591
+ if ( $bp->current_component == $bp->groups->slug && !$bp->action_variables ) {
592
+
593
+ do_action( 'groups_screen_group_admin', $group_obj->id );
594
+
595
+ bp_core_load_template( apply_filters( 'groups_template_group_admin', 'groups/admin/edit-details' ) );
596
+ }
597
+
598
+ }
599
+
600
+ function groups_screen_group_admin_edit_details() {
601
+ global $bp, $group_obj;
602
+
603
+ if ( $bp->current_component == $bp->groups->slug && 'edit-details' == $bp->action_variables[0] ) {
604
+
605
+ if ( $bp->is_item_admin || $bp->is_item_mod ) {
606
+
607
+ // If the edit form has been submitted, save the edited details
608
+ if ( isset( $_POST['save'] ) ) {
609
+ if ( !groups_edit_base_group_details( $_POST['group-id'], $_POST['group-name'], $_POST['group-desc'], $_POST['group-news'], (int)$_POST['group-notify-members'] ) ) {
610
+ bp_core_add_message( __( 'There was an error updating group details, please try again.', 'buddypress' ), 'error' );
611
+ } else {
612
+ bp_core_add_message( __( 'Group details were successfully updated.', 'buddypress' ) );
613
+ }
614
+
615
+ do_action( 'groups_group_details_edited', $group_obj->id );
616
+
617
+ bp_core_redirect( site_url() . '/' . $bp->current_component . '/' . $bp->current_item . '/admin/edit-details' );
618
+ }
619
+
620
+ do_action( 'groups_screen_group_admin_edit_details', $group_obj->id );
621
+
622
+ bp_core_load_template( apply_filters( 'groups_template_group_admin_edit_details', 'groups/admin/edit-details' ) );
623
+
624
+ }
625
+ }
626
+ }
627
+ add_action( 'wp', 'groups_screen_group_admin_edit_details', 4 );
628
+
629
+
630
+ function groups_screen_group_admin_settings() {
631
+ global $bp, $group_obj;
632
+
633
+ if ( $bp->current_component == $bp->groups->slug && 'group-settings' == $bp->action_variables[0] ) {
634
+
635
+ if ( !$bp->is_item_admin )
636
+ return false;
637
+
638
+ // If the edit form has been submitted, save the edited details
639
+ if ( isset( $_POST['save'] ) ) {
640
+ $enable_wire = ( isset($_POST['group-show-wire'] ) ) ? 1 : 0;
641
+ $enable_forum = ( isset($_POST['group-show-forum'] ) ) ? 1 : 0;
642
+ $enable_photos = ( isset($_POST['group-show-photos'] ) ) ? 1 : 0;
643
+ $photos_admin_only = ( $_POST['group-photos-status'] != 'all' ) ? 1 : 0;
644
+ $status = $_POST['group-status'];
645
+
646
+ if ( !groups_edit_group_settings( $_POST['group-id'], $enable_wire, $enable_forum, $enable_photos, $photos_admin_only, $status ) ) {
647
+ bp_core_add_message( __( 'There was an error updating group settings, please try again.', 'buddypress' ), 'error' );
648
+ } else {
649
+ bp_core_add_message( __( 'Group settings were successfully updated.', 'buddypress' ) );
650
+ }
651
+
652
+ do_action( 'groups_group_settings_edited', $group_obj->id );
653
+
654
+ bp_core_redirect( site_url() . '/' . $bp->current_component . '/' . $bp->current_item . '/admin/group-settings' );
655
+ }
656
+
657
+ do_action( 'groups_screen_group_admin_settings', $group_obj->id );
658
+
659
+ bp_core_load_template( apply_filters( 'groups_template_group_admin_settings', 'groups/admin/group-settings' ) );
660
+ }
661
+ }
662
+ add_action( 'wp', 'groups_screen_group_admin_settings', 4 );
663
+
664
+ function groups_screen_group_admin_avatar() {
665
+ global $bp, $group_obj;
666
+
667
+ if ( $bp->current_component == $bp->groups->slug && 'group-avatar' == $bp->action_variables[0] ) {
668
+
669
+ if ( !$bp->is_item_admin )
670
+ return false;
671
+
672
+ if ( isset( $_POST['save'] ) ) {
673
+
674
+ // Image already cropped and uploaded, lets store a reference in the DB.
675
+ if ( !wp_verify_nonce($_POST['nonce'], 'slick_avatars') || !$result = bp_core_avatar_cropstore( $_POST['orig'], $_POST['canvas'], $_POST['v1_x1'], $_POST['v1_y1'], $_POST['v1_w'], $_POST['v1_h'], $_POST['v2_x1'], $_POST['v2_y1'], $_POST['v2_w'], $_POST['v2_h'], false, 'groupavatar', $group_obj->id ) )
676
+ return false;
677
+
678
+ // Success on group avatar cropping, now save the results.
679
+ $avatar_hrefs = groups_get_avatar_hrefs($result);
680
+
681
+ // Delete the old group avatars first
682
+ $avatar_thumb_path = groups_get_avatar_path( $group_obj->avatar_thumb );
683
+ $avatar_full_path = groups_get_avatar_path( $group_obj->avatar_full );
684
+
685
+ @unlink($avatar_thumb_path);
686
+ @unlink($avatar_full_path);
687
+
688
+ $group_obj->avatar_thumb = stripslashes( $avatar_hrefs['thumb_href'] );
689
+ $group_obj->avatar_full = stripslashes( $avatar_hrefs['full_href'] );
690
+
691
+ if ( !$group_obj->save() ) {
692
+ bp_core_add_message( __( 'There was an error updating the group avatar, please try again.', 'buddypress' ), 'error' );
693
+ } else {
694
+ bp_core_add_message( __( 'The group avatar was successfully updated.', 'buddypress' ) );
695
+ }
696
+
697
+ do_action( 'groups_group_avatar_updated', $group_obj->id );
698
+
699
+ bp_core_redirect( site_url() . '/' . $bp->current_component . '/' . $bp->current_item . '/admin/group-avatar' );
700
+ }
701
+
702
+ do_action( 'groups_screen_group_admin_avatar', $group_obj->id );
703
+
704
+ bp_core_load_template( apply_filters( 'groups_template_group_admin_avatar', 'groups/admin/group-avatar' ) );
705
+ }
706
+ }
707
+ add_action( 'wp', 'groups_screen_group_admin_avatar', 4 );
708
+
709
+ function groups_screen_group_admin_manage_members() {
710
+ global $bp, $group_obj;
711
+
712
+ if ( $bp->current_component == $bp->groups->slug && 'manage-members' == $bp->action_variables[0] ) {
713
+
714
+ if ( !$bp->is_item_admin )
715
+ return false;
716
+
717
+ if ( 'promote' == $bp->action_variables[1] && is_numeric( $bp->action_variables[2] ) ) {
718
+ $user_id = $bp->action_variables[2];
719
+
720
+ // Promote a user.
721
+ if ( !groups_promote_member( $user_id, $group_obj->id ) ) {
722
+ bp_core_add_message( __( 'There was an error when promoting that user, please try again', 'buddypress' ), 'error' );
723
+ } else {
724
+ bp_core_add_message( __( 'User promoted successfully', 'buddypress' ) );
725
+ }
726
+
727
+ do_action( 'groups_promoted_member', $user_id, $group_obj->id );
728
+
729
+ bp_core_redirect( site_url() . '/' . $bp->current_component . '/' . $bp->current_item . '/admin/manage-members' );
730
+ }
731
+
732
+ if ( 'demote' == $bp->action_variables[1] && is_numeric( $bp->action_variables[2] ) ) {
733
+ $user_id = $bp->action_variables[2];
734
+
735
+ // Demote a user.
736
+ if ( !groups_demote_member( $user_id, $group_obj->id ) ) {
737
+ bp_core_add_message( __( 'There was an error when demoting that user, please try again', 'buddypress' ), 'error' );
738
+ } else {
739
+ bp_core_add_message( __( 'User demoted successfully', 'buddypress' ) );
740
+ }
741
+
742
+ do_action( 'groups_demoted_member', $user_id, $group_obj->id );
743
+
744
+ bp_core_redirect( site_url() . '/' . $bp->current_component . '/' . $bp->current_item . '/admin/manage-members' );
745
+ }
746
+
747
+ if ( 'ban' == $bp->action_variables[1] && is_numeric( $bp->action_variables[2] ) ) {
748
+ $user_id = $bp->action_variables[2];
749
+
750
+ // Ban a user.
751
+ if ( !groups_ban_member( $user_id, $group_obj->id ) ) {
752
+ bp_core_add_message( __( 'There was an error when banning that user, please try again', 'buddypress' ), 'error' );
753
+ } else {
754
+ bp_core_add_message( __( 'User banned successfully', 'buddypress' ) );
755
+ }
756
+
757
+ do_action( 'groups_banned_member', $user_id, $group_obj->id );
758
+
759
+ bp_core_redirect( site_url() . '/' . $bp->current_component . '/' . $bp->current_item . '/admin/manage-members' );
760
+ }
761
+
762
+ if ( 'unban' == $bp->action_variables[1] && is_numeric( $bp->action_variables[2] ) ) {
763
+ $user_id = $bp->action_variables[2];
764
+
765
+ // Remove a ban for user.
766
+ if ( !groups_unban_member( $user_id, $group_obj->id ) ) {
767
+ bp_core_add_message( __( 'There was an error when unbanning that user, please try again', 'buddypress' ), 'error' );
768
+ } else {
769
+ bp_core_add_message( __( 'User ban removed successfully', 'buddypress' ) );
770
+ }
771
+
772
+ do_action( 'groups_unbanned_member', $user_id, $group_obj->id );
773
+
774
+ bp_core_redirect( site_url() . '/' . $bp->current_component . '/' . $bp->current_item . '/admin/manage-members' );
775
+ }
776
+
777
+ do_action( 'groups_screen_group_admin_manage_members', $group_obj->id );
778
+
779
+ bp_core_load_template( apply_filters( 'groups_template_group_admin_manage_members', 'groups/admin/manage-members' ) );
780
+ }
781
+ }
782
+ add_action( 'wp', 'groups_screen_group_admin_manage_members', 4 );
783
+
784
+
785
+ function groups_screen_group_admin_requests() {
786
+ global $bp, $group_obj;
787
+
788
+ if ( $bp->current_component == $bp->groups->slug && 'membership-requests' == $bp->action_variables[0] ) {
789
+
790
+ if ( !$bp->is_item_admin || 'public' == $group_obj->status )
791
+ return false;
792
+
793
+ // Remove any screen notifications
794
+ bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'new_membership_request' );
795
+
796
+ $request_action = $bp->action_variables[1];
797
+ $membership_id = $bp->action_variables[2];
798
+
799
+ if ( isset($request_action) && isset($membership_id) ) {
800
+ if ( 'accept' == $request_action && is_numeric($membership_id) ) {
801
+
802
+ // Accept the membership request
803
+ if ( !groups_accept_membership_request( $membership_id ) ) {
804
+ bp_core_add_message( __( 'There was an error accepting the membership request, please try again.', 'buddypress' ), 'error' );
805
+ } else {
806
+ bp_core_add_message( __( 'Group membership request accepted', 'buddypress' ) );
807
+ }
808
+
809
+ } else if ( 'reject' == $request_action && is_numeric($membership_id) ) {
810
+
811
+ // Reject the membership request
812
+ if ( !groups_reject_membership_request( $membership_id ) ) {
813
+ bp_core_add_message( __( 'There was an error rejecting the membership request, please try again.', 'buddypress' ), 'error' );
814
+ } else {
815
+ bp_core_add_message( __( 'Group membership request rejected', 'buddypress' ) );
816
+ }
817
+
818
+ }
819
+
820
+ do_action( 'groups_group_request_managed', $group_obj->id, $request_action, $membership_id );
821
+
822
+ bp_core_redirect( site_url() . '/' . $bp->current_component . '/' . $bp->current_item . '/admin/membership-requests' );
823
+ }
824
+
825
+ do_action( 'groups_screen_group_admin_requests', $group_obj->id );
826
+
827
+ bp_core_load_template( apply_filters( 'groups_template_group_admin_requests', 'groups/admin/membership-requests' ) );
828
+ }
829
+ }
830
+ add_action( 'wp', 'groups_screen_group_admin_requests', 4 );
831
+
832
+ function groups_screen_group_admin_delete_group() {
833
+ global $bp, $group_obj;
834
+
835
+ if ( $bp->current_component == $bp->groups->slug && 'delete-group' == $bp->action_variables[0] ) {
836
+
837
+ if ( !$bp->is_item_admin )
838
+ return false;
839
+
840
+ if ( isset( $_POST['delete-group-button'] ) && isset( $_POST['delete-group-understand'] ) ) {
841
+ // Group admin has deleted the group, now do it.
842
+ if ( !groups_delete_group( $_POST['group-id']) ) {
843
+ bp_core_add_message( __( 'There was an error deleting the group, please try again.', 'buddypress' ), 'error' );
844
+ } else {
845
+ bp_core_add_message( __( 'The group was deleted successfully', 'buddypress' ) );
846
+
847
+ do_action( 'groups_group_deleted', $_POST['group-id'] );
848
+
849
+ bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . '/' );
850
+ }
851
+
852
+ bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component );
853
+ } else {
854
+ do_action( 'groups_screen_group_admin_delete_group', $group_obj->id );
855
+
856
+ bp_core_load_template( apply_filters( 'groups_template_group_admin_delete_group', 'groups/admin/delete-group' ) );
857
+ }
858
+ }
859
+ }
860
+ add_action( 'wp', 'groups_screen_group_admin_delete_group', 4 );
861
+
862
+ function groups_screen_notification_settings() {
863
+ global $current_user; ?>
864
+ <table class="notification-settings" id="groups-notification-settings">
865
+ <tr>
866
+ <th class="icon"></th>
867
+ <th class="title"><?php _e( 'Groups', 'buddypress' ) ?></th>
868
+ <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th>
869
+ <th class="no"><?php _e( 'No', 'buddypress' )?></th>
870
+ </tr>
871
+ <tr>
872
+ <td></td>
873
+ <td><?php _e( 'A member invites you to join a group', 'buddypress' ) ?></td>
874
+ <td class="yes"><input type="radio" name="notifications[notification_groups_invite]" value="yes" <?php if ( !get_usermeta( $current_user->id, 'notification_groups_invite') || 'yes' == get_usermeta( $current_user->id, 'notification_groups_invite') ) { ?>checked="checked" <?php } ?>/></td>
875
+ <td class="no"><input type="radio" name="notifications[notification_groups_invite]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id, 'notification_groups_invite') ) { ?>checked="checked" <?php } ?>/></td>
876
+ </tr>
877
+ <tr>
878
+ <td></td>
879
+ <td><?php _e( 'Group information is updated', 'buddypress' ) ?></td>
880
+ <td class="yes"><input type="radio" name="notifications[notification_groups_group_updated]" value="yes" <?php if ( !get_usermeta( $current_user->id, 'notification_groups_group_updated') || 'yes' == get_usermeta( $current_user->id, 'notification_groups_group_updated') ) { ?>checked="checked" <?php } ?>/></td>
881
+ <td class="no"><input type="radio" name="notifications[notification_groups_group_updated]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id, 'notification_groups_group_updated') ) { ?>checked="checked" <?php } ?>/></td>
882
+ </tr>
883
+ <?php if ( function_exists('bp_wire_install') ) { ?>
884
+ <tr>
885
+ <td></td>
886
+ <td><?php _e( 'A member posts on the wire of a group you belong to', 'buddypress' ) ?></td>
887
+ <td class="yes"><input type="radio" name="notifications[notification_groups_wire_post]" value="yes" <?php if ( !get_usermeta( $current_user->id, 'notification_groups_wire_post') || 'yes' == get_usermeta( $current_user->id, 'notification_groups_wire_post') ) { ?>checked="checked" <?php } ?>/></td>
888
+ <td class="no"><input type="radio" name="notifications[notification_groups_wire_post]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id, 'notification_groups_wire_post') ) { ?>checked="checked" <?php } ?>/></td>
889
+ </tr>
890
+ <?php } ?>
891
+ <tr>
892
+ <td></td>
893
+ <td><?php _e( 'You are promoted to a group administrator or moderator', 'buddypress' ) ?></td>
894
+ <td class="yes"><input type="radio" name="notifications[notification_groups_admin_promotion]" value="yes" <?php if ( !get_usermeta( $current_user->id, 'notification_groups_admin_promotion') || 'yes' == get_usermeta( $current_user->id, 'notification_groups_admin_promotion') ) { ?>checked="checked" <?php } ?>/></td>
895
+ <td class="no"><input type="radio" name="notifications[notification_groups_admin_promotion]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id, 'notification_groups_admin_promotion') ) { ?>checked="checked" <?php } ?>/></td>
896
+ </tr>
897
+ <tr>
898
+ <td></td>
899
+ <td><?php _e( 'A member requests to join a private group for which you are an admin', 'buddypress' ) ?></td>
900
+ <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>
901
+ <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>
902
+ </tr>
903
+
904
+ <?php do_action( 'groups_screen_notification_settings' ); ?>
905
+ </table>
906
+ <?php
907
+ }
908
+ add_action( 'bp_notification_settings', 'groups_screen_notification_settings' );
909
+
910
+
911
+ /***** Actions **********/
912
+
913
+ function groups_action_join_group() {
914
+ global $bp;
915
+ global $group_obj;
916
+
917
+ if ( !$bp->is_single_item || $bp->current_component != $bp->groups->slug || $bp->current_action != 'join' )
918
+ return false;
919
+
920
+ // user wants to join a group
921
+ if ( !groups_is_user_member( $bp->loggedin_user->id, $group_obj->id ) && !groups_is_user_banned( $bp->loggedin_user->id, $group_obj->id ) ) {
922
+ if ( !groups_join_group($group_obj->id) ) {
923
+ bp_core_add_message( __('There was an error joining the group.', 'buddypress'), 'error' );
924
+ } else {
925
+ bp_core_add_message( __('You joined the group!', 'buddypress') );
926
+ }
927
+ bp_core_redirect( bp_get_group_permalink( $group_obj ) );
928
+ }
929
+
930
+ bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/group-home' ) );
931
+ }
932
+ add_action( 'wp', 'groups_action_join_group', 3 );
933
+
934
+
935
+ /**************************************************************************
936
+ groups_record_activity()
937
+
938
+ Records activity for the logged in user within the friends component so that
939
+ it will show in the users activity stream (if installed)
940
+ **************************************************************************/
941
+
942
+ function groups_record_activity( $args = true ) {
943
+ global $group_obj;
944
+
945
+ if ( function_exists('bp_activity_record') ) {
946
+ extract($args);
947
+
948
+ if ( !$group_obj ) {
949
+ if ( !$group_obj = wp_cache_get( 'groups_group_nouserdata_' . $item_id, 'bp' ) ) {
950
+ $group_obj = new BP_Groups_Group( $group_obj->id, false, false );
951
+ wp_cache_set( 'groups_group_nouserdata_' . $item_id, $group_obj, 'bp' );
952
+ }
953
+ }
954
+
955
+ if ( 'public' == $group_obj->status )
956
+ bp_activity_record( $item_id, $component_name, $component_action, $is_private, $secondary_item_id, $user_id, $secondary_user_id );
957
+ }
958
+ }
959
+
960
+ function groups_delete_activity( $args = true ) {
961
+ if ( function_exists('bp_activity_delete') ) {
962
+ extract($args);
963
+ bp_activity_delete( $item_id, $component_name, $component_action, $user_id, $secondary_item_id );
964
+ }
965
+ }
966
+
967
+
968
+ /**************************************************************************
969
+ groups_format_activity()
970
+
971
+ Selects and formats recorded groups component activity.
972
+ Example: Selects the groups details for a joined group, then
973
+ formats it to read "Andy Peatling joined the group 'A Cool Group'"
974
+ **************************************************************************/
975
+
976
+ function groups_format_activity( $item_id, $user_id, $action, $secondary_item_id = false, $for_secondary_user = false ) {
977
+ global $bp;
978
+
979
+ switch( $action ) {
980
+ case 'joined_group':
981
+ $group = new BP_Groups_Group( $item_id, false, false );
982
+
983
+ if ( !$group )
984
+ return false;
985
+
986
+ $user_link = bp_core_get_userlink( $user_id );
987
+ $group_link = bp_get_group_permalink( $group );
988
+
989
+ return array(
990
+ 'primary_link' => $group_link,
991
+ 'content' => apply_filters( 'bp_groups_joined_group_activity', sprintf( __('%s joined the group %s', 'buddypress'), $user_link, '<a href="' . $group_link . '">' . $group->name . '</a>' ) . ' <span class="time-since">%s</span>', $user_link, $group_link, $group->name )
992
+ );
993
+ break;
994
+ case 'created_group':
995
+ $group = new BP_Groups_Group( $item_id, false, false );
996
+
997
+ if ( !$group )
998
+ return false;
999
+
1000
+ $user_link = bp_core_get_userlink( $user_id );
1001
+ $group_link = bp_get_group_permalink( $group );
1002
+
1003
+ return array(
1004
+ 'primary_link' => $group_link,
1005
+ 'content' => apply_filters( 'bp_groups_created_group_activity', sprintf( __('%s created the group %s', 'buddypress'), $user_link, '<a href="' . $group_link . '">' . $group->name . '</a>') . ' <span class="time-since">%s</span>', $user_link, $group_link, $group->name )
1006
+ );
1007
+ break;
1008
+ case 'new_wire_post':
1009
+ $wire_post = new BP_Wire_Post( $bp->groups->table_name_wire, $item_id );
1010
+ $group = new BP_Groups_Group( $wire_post->item_id, false, false );
1011
+
1012
+ if ( !$group || !$wire_post || !$wire_post->content )
1013
+ return false;
1014
+
1015
+ $user_link = bp_core_get_userlink( $user_id );
1016
+ $group_link = bp_get_group_permalink( $group );
1017
+ $post_excerpt = bp_create_excerpt( $wire_post->content );
1018
+
1019
+ $content = sprintf ( __('%s wrote on the wire of the group %s', 'buddypress'), $user_link, '<a href="' . $group_link . '">' . $group->name . '</a>' ) . ' <span class="time-since">%s</span>';
1020
+ $content .= '<blockquote>' . $post_excerpt . '</blockquote>';
1021
+
1022
+ $content = apply_filters( 'bp_groups_new_wire_post_activity', $content, $user_link, $group_link, $group->name, $post_excerpt );
1023
+
1024
+ return array(
1025
+ 'primary_link' => $group_link,
1026
+ 'content' => $content
1027
+ );
1028
+ break;
1029
+ case 'new_forum_post':
1030
+ if ( function_exists('bp_forums_setup') ) {
1031
+ $group = new BP_Groups_Group( $item_id, false, false );
1032
+ $forum_post = bp_forums_get_post( $secondary_item_id );
1033
+ $forum_topic = bp_forums_get_topic_details( $forum_post['topic_id'] );
1034
+
1035
+ if ( !$group || !$forum_post || !$forum_topic )
1036
+ return false;
1037
+
1038
+ $user_link = bp_core_get_userlink($user_id);
1039
+ $group_link = bp_get_group_permalink( $group );
1040
+
1041
+ $post_content = apply_filters( 'bp_the_topic_post_content', bp_create_excerpt( stripslashes( $forum_post['post_text'] ), 55, false ) );
1042
+
1043
+ $content = sprintf ( __('%s posted on the forum topic %s in the group %s:', 'buddypress'), $user_link, '<a href="' . $group_link . '/forum/topic/' . $forum_topic['topic_id'] . '">' . $forum_topic['topic_title'] . '</a>', '<a href="' . $group_link . '">' . $group->name . '</a>' ) . ' <span class="time-since">%s</span>';
1044
+ $content .= '<blockquote>' . $post_content . '</blockquote>';
1045
+
1046
+ $content = apply_filters( 'bp_groups_new_forum_post_activity', $content, $user_link, $group_link, $forum_topic['topic_id'], $forum_topic['topic_title'], $group_link, $group->name, $post_content );
1047
+
1048
+ return array(
1049
+ 'primary_link' => $group_link,
1050
+ 'content' => $content
1051
+ );
1052
+ }
1053
+ break;
1054
+ case 'new_forum_topic':
1055
+ if ( function_exists('bp_forums_setup') ) {
1056
+ $group = new BP_Groups_Group( $item_id, false, false );
1057
+ $forum_topic = bp_forums_get_topic_details( $secondary_item_id );
1058
+ $forum_post = bp_forums_get_post( $forum_topic['topic_last_post_id'] );
1059
+
1060
+ if ( !$group || !$forum_post || !$forum_topic )
1061
+ return false;
1062
+
1063
+ $user_link = bp_core_get_userlink($user_id);
1064
+ $group_link = bp_get_group_permalink( $group );
1065
+
1066
+ $post_content = apply_filters( 'bp_the_topic_post_content', bp_create_excerpt( stripslashes( $forum_post['post_text'] ), 55, false ) );
1067
+
1068
+ $content = sprintf ( __('%s created the forum topic %s in the group %s:', 'buddypress'), $user_link, '<a href="' . $group_link . '/forum/topic/' . $forum_topic['topic_id'] . '">' . $forum_topic['topic_title'] . '</a>', '<a href="' . $group_link . '">' . $group->name . '</a>' ) . ' <span class="time-since">%s</span>';
1069
+ $content .= '<blockquote>' . $post_content . '</blockquote>';
1070
+
1071
+ $content = apply_filters( 'bp_groups_new_forum_topic_activity', $content, $user_link, $group_link, $forum_topic['topic_id'], $forum_topic['topic_title'], $group_link, $group->name, $post_content );
1072
+
1073
+ return array(
1074
+ 'primary_link' => $group_link,
1075
+ 'content' => $content
1076
+ );
1077
+ }
1078
+ break;
1079
+ }
1080
+
1081
+ do_action( 'groups_format_activity', $action, $item_id, $user_id, $action, $secondary_item_id, $for_secondary_user );
1082
+
1083
+ return false;
1084
+ }
1085
+
1086
+ function groups_format_notifications( $action, $item_id, $secondary_item_id, $total_items ) {
1087
+ global $bp;
1088
+
1089
+ switch ( $action ) {
1090
+ case 'new_membership_request':
1091
+ $group_id = $secondary_item_id;
1092
+ $requesting_user_id = $item_id;
1093
+
1094
+ $group = new BP_Groups_Group( $group_id, false, false );
1095
+
1096
+ $group_link = bp_get_group_permalink( $group );
1097
+
1098
+ if ( (int)$total_items > 1 ) {
1099
+ 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 );
1100
+ } else {
1101
+ $user_fullname = bp_core_global_user_fullname( $requesting_user_id );
1102
+ 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 );
1103
+ }
1104
+ break;
1105
+
1106
+ case 'membership_request_accepted':
1107
+ $group_id = $item_id;
1108
+
1109
+ $group = new BP_Groups_Group( $group_id, false, false );
1110
+ $group_link = bp_get_group_permalink( $group ) . '/?new';
1111
+
1112
+ if ( (int)$total_items > 1 ) {
1113
+ 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 );
1114
+ } else {
1115
+ 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 );
1116
+ }
1117
+ break;
1118
+
1119
+ case 'membership_request_rejected':
1120
+ $group_id = $item_id;
1121
+
1122
+ $group = new BP_Groups_Group( $group_id, false, false );
1123
+ $group_link = bp_get_group_permalink( $group ) . '/?new';
1124
+
1125
+ if ( (int)$total_items > 1 ) {
1126
+ 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 );
1127
+ } else {
1128
+ 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 );
1129
+ }
1130
+
1131
+ break;
1132
+
1133
+ case 'member_promoted_to_admin':
1134
+ $group_id = $item_id;
1135
+
1136
+ $group = new BP_Groups_Group( $group_id, false, false );
1137
+ $group_link = bp_get_group_permalink( $group ) . '/?new';
1138
+
1139
+ if ( (int)$total_items > 1 ) {
1140
+ 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 );
1141
+ } else {
1142
+ 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 );
1143
+ }
1144
+ break;
1145
+
1146
+ case 'member_promoted_to_mod':
1147
+ $group_id = $item_id;
1148
+
1149
+ $group = new BP_Groups_Group( $group_id, false, false );
1150
+ $group_link = bp_get_group_permalink( $group ) . '/?new';
1151
+
1152
+ if ( (int)$total_items > 1 ) {
1153
+ 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 );
1154
+ } else {
1155
+ 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 );
1156
+ }
1157
+ break;
1158
+
1159
+ case 'group_invite':
1160
+ $group_id = $item_id;
1161
+
1162
+ $group = new BP_Groups_Group( $group_id, false, false );
1163
+ $user_url = bp_core_get_userurl( $user_id );
1164
+
1165
+ if ( (int)$total_items > 1 ) {
1166
+ 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 );
1167
+ } else {
1168
+ 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 );
1169
+ }
1170
+ break;
1171
+ }
1172
+
1173
+ do_action( 'groups_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
1174
+
1175
+ return false;
1176
+ }
1177
+
1178
+
1179
+ /**************************************************************************
1180
+ groups_update_last_activity()
1181
+
1182
+ Sets groupmeta for the group with the last activity date for the group based
1183
+ on specific group activities.
1184
+ **************************************************************************/
1185
+
1186
+ function groups_update_last_activity( $group_id ) {
1187
+ groups_update_groupmeta( $group_id, 'last_activity', time() );
1188
+ }
1189
+ add_action( 'groups_deleted_wire_post', 'groups_update_last_activity' );
1190
+ add_action( 'groups_new_wire_post', 'groups_update_last_activity' );
1191
+ add_action( 'groups_joined_group', 'groups_update_last_activity' );
1192
+ add_action( 'groups_leave_group', 'groups_update_last_activity' );
1193
+ add_action( 'groups_created_group', 'groups_update_last_activity' );
1194
+ add_action( 'groups_new_forum_topic', 'groups_update_last_activity' );
1195
+ add_action( 'groups_new_forum_topic_post', 'groups_update_last_activity' );
1196
+
1197
+
1198
+ /**************************************************************************
1199
+ groups_get_user_groups()
1200
+
1201
+ Fetch the groups the current user is a member of.
1202
+ **************************************************************************/
1203
+
1204
+ function groups_get_user_groups( $pag_num, $pag_page ) {
1205
+ global $bp;
1206
+
1207
+ $groups = BP_Groups_Member::get_group_ids( $bp->displayed_user->id, $pag_num, $pag_page );
1208
+
1209
+ return array( 'groups' => $groups['ids'], 'total' => $groups['total'] );
1210
+ }
1211
+
1212
+ function groups_get_recently_joined_for_user( $user_id = false, $pag_num = false, $pag_page = false, $filter = false ) {
1213
+ global $bp;
1214
+
1215
+ if ( !$user_id )
1216
+ $user_id = $bp->displayed_user->id;
1217
+
1218
+ return BP_Groups_Member::get_recently_joined( $user_id, $pag_num, $pag_page, $filter );
1219
+ }
1220
+
1221
+ function groups_get_most_popular_for_user( $user_id = false, $pag_num = false, $pag_page = false, $filter = false ) {
1222
+ global $bp;
1223
+
1224
+ if ( !$user_id )
1225
+ $user_id = $bp->displayed_user->id;
1226
+
1227
+ return BP_Groups_Member::get_most_popular( $user_id, $pag_num, $pag_page, $filter );
1228
+ }
1229
+
1230
+ function groups_get_recently_active_for_user( $user_id = false, $pag_num = false, $pag_page = false, $filter = false ) {
1231
+ global $bp;
1232
+
1233
+ if ( !$user_id )
1234
+ $user_id = $bp->displayed_user->id;
1235
+
1236
+ return BP_Groups_Member::get_recently_active( $user_id, $pag_num, $pag_page, $filter );
1237
+ }
1238
+
1239
+ function groups_get_alphabetically_for_user( $user_id = false, $pag_num = false, $pag_page = false, $filter = false ) {
1240
+ global $bp;
1241
+
1242
+ if ( !$user_id )
1243
+ $user_id = $bp->displayed_user->id;
1244
+
1245
+ return BP_Groups_Member::get_alphabetically( $user_id, $pag_num, $pag_page, $filter );
1246
+ }
1247
+
1248
+ function groups_get_user_is_admin_of( $user_id = false, $pag_num = false, $pag_page = false, $filter = false ) {
1249
+ global $bp;
1250
+
1251
+ if ( !$user_id )
1252
+ $user_id = $bp->displayed_user->id;
1253
+
1254
+ return BP_Groups_Member::get_is_admin_of( $user_id, $pag_num, $pag_page, $filter );
1255
+ }
1256
+
1257
+ function groups_get_user_is_mod_of( $user_id = false, $pag_num = false, $pag_page = false, $filter = false ) {
1258
+ global $bp;
1259
+
1260
+ if ( !$user_id )
1261
+ $user_id = $bp->displayed_user->id;
1262
+
1263
+ return BP_Groups_Member::get_is_mod_of( $user_id, $pag_num, $pag_page, $filter );
1264
+ }
1265
+
1266
+ function groups_total_groups_for_user( $user_id = false ) {
1267
+ global $bp;
1268
+
1269
+ if ( !$user_id )
1270
+ $user_id = $bp->displayed_user->id;
1271
+
1272
+ return BP_Groups_Member::total_group_count( $user_id );
1273
+ }
1274
+
1275
+ function groups_get_random_groups_for_user( $user_id = false, $total_groups = 5 ) {
1276
+ global $bp;
1277
+
1278
+ if ( !$user_id )
1279
+ $user_id = $bp->displayed_user->id;
1280
+
1281
+ return BP_Groups_Member::get_random_groups( $user_id, $total_groups );
1282
+ }
1283
+
1284
+
1285
+ /**************************************************************************
1286
+ groups_avatar_upload()
1287
+
1288
+ Handle uploading of a group avatar
1289
+ **************************************************************************/
1290
+
1291
+ function groups_avatar_upload( $file ) {
1292
+ // validate the group avatar upload if there is one.
1293
+ $avatar_error = false;
1294
+
1295
+ // Set friendly error feedback.
1296
+ $uploadErrors = array(
1297
+ 0 => __("There is no error, the file uploaded with success", 'buddypress'),
1298
+ 1 => __("The uploaded file exceeds the upload_max_filesize directive in php.ini", 'buddypress'),
1299
+ 2 => __("The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form", 'buddypress'),
1300
+ 3 => __("The uploaded file was only partially uploaded", 'buddypress'),
1301
+ 4 => __("No file was uploaded", 'buddypress'),
1302
+ 6 => __("Missing a temporary folder", 'buddypress')
1303
+ );
1304
+
1305
+ if ( !bp_core_check_avatar_upload($file) ) {
1306
+ $avatar_error = true;
1307
+ $avatar_error_msg = __('Your group avatar upload failed, please try again. Error was: ' . $uploadErrors[$file['file']['error']] , 'buddypress');
1308
+ }
1309
+
1310
+ else if ( !bp_core_check_avatar_size($file) ) {
1311
+ $avatar_error = true;
1312
+ $avatar_size = size_format(1024 * CORE_MAX_FILE_SIZE);
1313
+ $avatar_error_msg = __('The file you uploaded is too big. Please upload a file under', 'buddypress') . size_format(CORE_MAX_FILE_SIZE);
1314
+ }
1315
+
1316
+ else if ( !bp_core_check_avatar_type($file) ) {
1317
+ $avatar_error = true;
1318
+ $avatar_error_msg = __('Please upload only JPG, GIF or PNG photos.', 'buddypress');
1319
+ }
1320
+
1321
+ // "Handle" upload into temporary location
1322
+ else if ( !$original = bp_core_handle_avatar_upload($file) ) {
1323
+ $avatar_error = true;
1324
+ $avatar_error_msg = __('Upload Failed! Please check the permissions on the group avatar upload directory.', 'buddypress');
1325
+ }
1326
+
1327
+ if ( !$canvas = bp_core_resize_avatar($original) )
1328
+ $canvas = $original;
1329
+
1330
+ if ( $avatar_error ) { ?>
1331
+ <div id="message" class="error">
1332
+ <p><?php echo $avatar_error_msg ?></p>
1333
+ </div>
1334
+ <?php
1335
+ bp_core_render_avatar_upload_form( '', true );
1336
+ } else {
1337
+ bp_core_render_avatar_cropper( $original, $canvas, null, null, false, $bp->loggedin_user->domain );
1338
+ }
1339
+ }
1340
+
1341
+
1342
+ /**************************************************************************
1343
+ groups_save_avatar()
1344
+
1345
+ Save the avatar location urls into the DB for the group.
1346
+ **************************************************************************/
1347
+
1348
+ function groups_get_avatar_hrefs( $avatars ) {
1349
+ global $bp;
1350
+
1351
+ $src = $bp->root_domain . '/';
1352
+
1353
+ $thumb_href = str_replace( ABSPATH, $src, stripslashes( $avatars['v1_out'] ) );
1354
+ $full_href = str_replace( ABSPATH, $src, stripslashes ( $avatars['v2_out'] ) );
1355
+
1356
+ return array( 'thumb_href' => $thumb_href, 'full_href' => $full_href );
1357
+ }
1358
+
1359
+ function groups_get_avatar_path( $avatar ) {
1360
+ global $bp;
1361
+
1362
+ $src = $bp->root_domain . '/';
1363
+
1364
+ $path = str_replace( $src, ABSPATH, stripslashes( $avatar ) );
1365
+ return $path;
1366
+ }
1367
+
1368
+ function groups_search_groups( $search_terms, $pag_num_per_page = 5, $pag_page = 1, $sort_by = false, $order = false ) {
1369
+ return BP_Groups_Group::search_groups( $search_terms, $pag_num_per_page, $pag_page, $sort_by, $order );
1370
+ }
1371
+
1372
+ function groups_filter_user_groups( $filter, $user_id = false, $order = false, $pag_num_per_page = 5, $pag_page = 1 ) {
1373
+ return BP_Groups_Group::filter_user_groups( $filter, $user_id, $order, $pag_num_per_page, $pag_page );
1374
+ }
1375
+
1376
+ /**************************************************************************
1377
+ groups_create_group()
1378
+
1379
+ Manage the creation of a group via the step by step wizard.
1380
+ **************************************************************************/
1381
+
1382
+ function groups_create_group( $step, $group_id ) {
1383
+ global $bp, $create_group_step, $group_obj, $bbpress_live;
1384
+
1385
+ if ( is_numeric( $step ) && ( 1 == (int)$step || 2 == (int)$step || 3 == (int)$step || 4 == (int)$step ) ) {
1386
+
1387
+ if ( !$group_obj )
1388
+ $group_obj = new BP_Groups_Group( $group_id );
1389
+
1390
+ switch ( $step ) {
1391
+ case '1':
1392
+ if ( !check_admin_referer( 'groups_step1_save' ) )
1393
+ return false;
1394
+
1395
+ if ( $_POST['group-name'] != '' && $_POST['group-desc'] != '' ) {
1396
+ $group_obj->creator_id = $bp->loggedin_user->id;
1397
+ $group_obj->name = stripslashes($_POST['group-name']);
1398
+ $group_obj->description = stripslashes($_POST['group-desc']);
1399
+ $group_obj->news = stripslashes($_POST['group-news']);
1400
+
1401
+ $slug = groups_check_slug( sanitize_title($_POST['group-name']) );
1402
+
1403
+ $group_obj->slug = $slug;
1404
+ $group_obj->status = 'public';
1405
+ $group_obj->is_invitation_only = 0;
1406
+ $group_obj->enable_wire = 1;
1407
+ $group_obj->enable_forum = 1;
1408
+ $group_obj->enable_photos = 1;
1409
+ $group_obj->photos_admin_only = 0;
1410
+ $group_obj->date_created = time();
1411
+
1412
+ if ( !$group_obj->save() )
1413
+ return false;
1414
+
1415
+ // Save the creator as the group administrator
1416
+ $admin = new BP_Groups_Member( $bp->loggedin_user->id, $group_obj->id );
1417
+ $admin->is_admin = 1;
1418
+ $admin->user_title = __('Group Admin', 'buddypress');
1419
+ $admin->date_modified = time();
1420
+ $admin->inviter_id = 0;
1421
+ $admin->is_confirmed = 1;
1422
+
1423
+ if ( !$admin->save() )
1424
+ return false;
1425
+
1426
+ do_action( 'groups_create_group_step1_save' );
1427
+
1428
+ /* Set groupmeta */
1429
+ groups_update_groupmeta( $group_obj->id, 'total_member_count', 1 );
1430
+ groups_update_groupmeta( $group_obj->id, 'last_activity', time() );
1431
+ groups_update_groupmeta( $group_obj->id, 'theme', 'buddypress' );
1432
+ groups_update_groupmeta( $group_obj->id, 'stylesheet', 'buddypress' );
1433
+
1434
+ return $group_obj->id;
1435
+ }
1436
+
1437
+ return false;
1438
+ break;
1439
+
1440
+ case '2':
1441
+ if ( !check_admin_referer( 'groups_step2_save' ) )
1442
+ return false;
1443
+
1444
+ $group_obj->status = 'public';
1445
+ $group_obj->is_invitation_only = 0;
1446
+ $group_obj->enable_wire = 1;
1447
+ $group_obj->enable_forum = 1;
1448
+ $group_obj->enable_photos = 1;
1449
+ $group_obj->photos_admin_only = 0;
1450
+
1451
+ if ( !isset($_POST['group-show-wire']) )
1452
+ $group_obj->enable_wire = 0;
1453
+
1454
+ if ( !isset($_POST['group-show-forum']) ) {
1455
+ $group_obj->enable_forum = 0;
1456
+ } else {
1457
+ /* Create the forum if enable_forum = 1 */
1458
+ if ( function_exists( 'bp_forums_setup' ) && '' == groups_get_groupmeta( $group_obj->id, 'forum_id' ) ) {
1459
+ groups_new_group_forum();
1460
+ }
1461
+ }
1462
+
1463
+ if ( !isset($_POST['group-show-photos']) )
1464
+ $group_obj->enable_photos = 0;
1465
+
1466
+ if ( $_POST['group-photos-status'] != 'all' )
1467
+ $group_obj->photos_admin_only = 1;
1468
+
1469
+ if ( 'private' == $_POST['group-status'] ) {
1470
+ $group_obj->status = 'private';
1471
+ } else if ( 'hidden' == $_POST['group-status'] ) {
1472
+ $group_obj->status = 'hidden';
1473
+ }
1474
+
1475
+ if ( !$group_obj->save() )
1476
+ return false;
1477
+
1478
+ /* Record in activity streams */
1479
+ groups_record_activity( array( 'item_id' => $group_obj->id, 'component_name' => $bp->groups->slug, 'component_action' => 'created_group', 'is_private' => 0 ) );
1480
+
1481
+ do_action( 'groups_create_group_step2_save' );
1482
+
1483
+ return $group_obj->id;
1484
+ break;
1485
+
1486
+ case '3':
1487
+ if ( !check_admin_referer( 'groups_step3_save' ) )
1488
+ return false;
1489
+
1490
+ if ( isset( $_POST['skip'] ) )
1491
+ return $group_obj->id;
1492
+
1493
+ // Image already cropped and uploaded, lets store a reference in the DB.
1494
+ if ( !wp_verify_nonce($_POST['nonce'], 'slick_avatars') || !$result = bp_core_avatar_cropstore( $_POST['orig'], $_POST['canvas'], $_POST['v1_x1'], $_POST['v1_y1'], $_POST['v1_w'], $_POST['v1_h'], $_POST['v2_x1'], $_POST['v2_y1'], $_POST['v2_w'], $_POST['v2_h'], false, 'groupavatar', $group_obj->id ) )
1495
+ return false;
1496
+
1497
+ // Success on group avatar cropping, now save the results.
1498
+ $avatar_hrefs = groups_get_avatar_hrefs($result);
1499
+
1500
+ $group_obj->avatar_thumb = stripslashes( $avatar_hrefs['thumb_href'] );
1501
+ $group_obj->avatar_full = stripslashes( $avatar_hrefs['full_href'] );
1502
+
1503
+ if ( !$group_obj->save() )
1504
+ return false;
1505
+
1506
+ do_action( 'groups_create_group_step3_save' );
1507
+
1508
+ return $group_obj->id;
1509
+ break;
1510
+
1511
+ case '4':
1512
+ if ( !check_admin_referer( 'groups_step4_save' ) )
1513
+ return false;
1514
+
1515
+ groups_send_invites( $group_obj, true );
1516
+
1517
+ do_action( 'groups_created_group', $group_obj->id );
1518
+
1519
+ return $group_obj->id;
1520
+ break;
1521
+ }
1522
+ }
1523
+
1524
+ return false;
1525
+ }
1526
+
1527
+ function groups_check_slug( $slug ) {
1528
+ global $bp;
1529
+
1530
+ if ( in_array( $slug, $bp->groups->forbidden_names ) ) {
1531
+ $slug = $slug . '-' . rand();
1532
+ }
1533
+
1534
+ if ( BP_Groups_Group::check_slug( $slug ) ) {
1535
+ do {
1536
+ $slug = $slug . '-' . rand();
1537
+ }
1538
+ while ( BP_Groups_Group::check_slug( $slug ) );
1539
+ }
1540
+
1541
+ if ( 'wp' == substr( $slug, 0, 2 ) )
1542
+ $slug = substr( $slug, 2, strlen( $slug ) - 2 );
1543
+
1544
+ return $slug;
1545
+ }
1546
+
1547
+ function groups_get_slug( $group_id ) {
1548
+ $group = new BP_Groups_Group( $group_id, false, false );
1549
+ return $group->slug;
1550
+ }
1551
+
1552
+ function groups_is_user_admin( $user_id, $group_id ) {
1553
+ return BP_Groups_Member::check_is_admin( $user_id, $group_id );
1554
+ }
1555
+
1556
+ function groups_is_user_mod( $user_id, $group_id ) {
1557
+ return BP_Groups_Member::check_is_mod( $user_id, $group_id );
1558
+ }
1559
+
1560
+ function groups_is_user_member( $user_id, $group_id ) {
1561
+ return BP_Groups_Member::check_is_member( $user_id, $group_id );
1562
+ }
1563
+
1564
+ function groups_is_user_banned( $user_id, $group_id ) {
1565
+ return BP_Groups_Member::check_is_banned( $user_id, $group_id );
1566
+ }
1567
+
1568
+ function groups_new_group_forum( $group_id = false, $group_name = false, $group_desc = false ) {
1569
+ global $group_obj;
1570
+
1571
+ if ( !$group_id )
1572
+ $group_id = $group_obj->id;
1573
+
1574
+ if ( !$group_name )
1575
+ $group_name = $group_obj->name;
1576
+
1577
+ if ( !$group_desc )
1578
+ $group_desc = $group_obj->description;
1579
+
1580
+ $forum = bp_forums_new_forum( apply_filters( 'groups_new_group_forum_name', $group_name . ' - ' . __( 'Forum', 'buddypress' ), $group_name ), apply_filters( 'groups_new_group_forum_desc', $group_desc ) );
1581
+
1582
+ groups_update_groupmeta( $group_id, 'forum_id', $forum['forum_id'] );
1583
+
1584
+ do_action( 'groups_new_group_forum', $forum, $group_id );
1585
+ }
1586
+
1587
+ function groups_new_group_forum_post( $post_text, $topic_id ) {
1588
+ global $group_obj;
1589
+
1590
+ /* Check the nonce */
1591
+ if ( !check_admin_referer( 'bp_forums_new_reply' ) )
1592
+ return false;
1593
+
1594
+ if ( $forum_post = bp_forums_new_post( $post_text, $topic_id ) ) {
1595
+ bp_core_add_message( __( 'Reply posted successfully!', 'buddypress') );
1596
+
1597
+ /* Record in activity streams */
1598
+ groups_record_activity( array( 'item_id' => $group_obj->id, 'component_name' => $bp->groups->slug, 'component_action' => 'new_forum_post', 'is_private' => 0, 'secondary_item_id' => $forum_post['post_id'] ) );
1599
+
1600
+ do_action( 'groups_new_forum_topic_post', $group_obj->id, $forum_post );
1601
+
1602
+ return $forum_post;
1603
+ }
1604
+
1605
+ bp_core_add_message( __( 'There was an error posting that reply.', 'buddypress'), 'error' );
1606
+ return false;
1607
+ }
1608
+
1609
+ function groups_new_group_forum_topic( $topic_title, $topic_text, $topic_tags, $forum_id ) {
1610
+ global $group_obj;
1611
+
1612
+ /* Check the nonce */
1613
+ if ( !check_admin_referer( 'bp_forums_new_topic' ) )
1614
+ return false;
1615
+
1616
+ if ( $topic = bp_forums_new_topic( $topic_title, $topic_text, $topic_tags, $forum_id ) ) {
1617
+ bp_core_add_message( __( 'Topic posted successfully!', 'buddypress') );
1618
+
1619
+ /* Record in activity streams */
1620
+ groups_record_activity( array( 'item_id' => $group_obj->id, 'component_name' => $bp->groups->slug, 'component_action' => 'new_forum_topic', 'is_private' => 0, 'secondary_item_id' => $topic['topic_id'] ) );
1621
+
1622
+ do_action( 'groups_new_forum_topic', $group_obj->id, $topic );
1623
+
1624
+ return $topic;
1625
+ }
1626
+
1627
+ bp_core_add_message( __( 'There was an error posting that topic.', 'buddypress'), 'error' );
1628
+ return false;
1629
+ }
1630
+
1631
+ function groups_invite_user( $user_id, $group_id ) {
1632
+ global $bp;
1633
+
1634
+ /* Check the nonce */
1635
+ if ( !check_admin_referer( 'groups_invite_uninvite_user' ) )
1636
+ return false;
1637
+
1638
+ if ( groups_is_user_member( $user_id, $group_id ) )
1639
+ return false;
1640
+
1641
+ $invite = new BP_Groups_Member;
1642
+ $invite->group_id = $group_id;
1643
+ $invite->user_id = $user_id;
1644
+ $invite->date_modified = time();
1645
+ $invite->inviter_id = $bp->loggedin_user->id;
1646
+ $invite->is_confirmed = 0;
1647
+
1648
+ if ( !$invite->save() )
1649
+ return false;
1650
+
1651
+ do_action( 'groups_invite_user', $group_id, $user_id );
1652
+
1653
+ return true;
1654
+ }
1655
+
1656
+ function groups_uninvite_user( $user_id, $group_id, $skip_check = false ) {
1657
+ global $bp;
1658
+
1659
+ /* Because this is called on groups_leave_group() and a nonce has already been
1660
+ * checked, we need a way of overriding a double check.
1661
+ */
1662
+ if ( !$skip_check ) {
1663
+ if ( !check_admin_referer( 'groups_invite_uninvite_user' ) )
1664
+ return false;
1665
+ }
1666
+
1667
+ if ( !BP_Groups_Member::delete( $user_id, $group_id ) )
1668
+ return false;
1669
+
1670
+ do_action( 'groups_uninvite_user', $group_id, $user_id );
1671
+
1672
+ return true;
1673
+ }
1674
+
1675
+ function groups_accept_invite( $user_id, $group_id ) {
1676
+ global $group_obj;
1677
+
1678
+ /* Check the nonce */
1679
+ if ( !check_admin_referer( 'groups_accept_invite' ) )
1680
+ return false;
1681
+
1682
+ if ( groups_is_user_member( $user_id, $group_id ) )
1683
+ return false;
1684
+
1685
+ $member = new BP_Groups_Member( $user_id, $group_id );
1686
+ $member->accept_invite();
1687
+
1688
+ if ( !$member->save() )
1689
+ return false;
1690
+
1691
+ do_action( 'groups_accept_invite', $user_id, $group_id );
1692
+ return true;
1693
+ }
1694
+
1695
+ function groups_reject_invite( $user_id, $group_id ) {
1696
+ if ( !BP_Groups_Member::delete( $user_id, $group_id ) )
1697
+ return false;
1698
+
1699
+ do_action( 'groups_reject_invite', $user_id, $group_id );
1700
+
1701
+ return true;
1702
+ }
1703
+
1704
+ function groups_get_invites_for_group( $user_id, $group_id ) {
1705
+ return BP_Groups_Group::get_invites( $user_id, $group_id );
1706
+ }
1707
+
1708
+ function groups_check_user_has_invite( $user_id, $group_id ) {
1709
+ return BP_Groups_Member::check_has_invite( $user_id, $group_id );
1710
+ }
1711
+
1712
+ function groups_delete_invite( $user_id, $group_id ) {
1713
+ global $bp;
1714
+
1715
+ $delete = BP_Groups_Member::delete_invite( $user_id, $group_id );
1716
+
1717
+ if ( $delete )
1718
+ bp_core_delete_notifications_for_user_by_item_id( $user_id, $group_id, $bp->groups->slug, 'group_invite' );
1719
+
1720
+ return $delete;
1721
+ }
1722
+
1723
+ function groups_get_invites_for_user( $user_id = false ) {
1724
+ global $bp;
1725
+
1726
+ if ( !$user_id )
1727
+ $user_id = $bp->loggedin_user->id;
1728
+
1729
+ return BP_Groups_Member::get_invites( $user_id );
1730
+ }
1731
+
1732
+ function groups_send_invites( $group_obj, $skip_check = false ) {
1733
+ global $bp;
1734
+
1735
+ if ( !$skip_check ) {
1736
+ if ( !check_admin_referer( 'groups_send_invites', '_wpnonce_send_invites' ) )
1737
+ return false;
1738
+ }
1739
+
1740
+ require_once ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' );
1741
+
1742
+ // Send friend invites.
1743
+ $invited_users = groups_get_invites_for_group( $bp->loggedin_user->id, $group_obj->id );
1744
+
1745
+ for ( $i = 0; $i < count( $invited_users ); $i++ ) {
1746
+ $member = new BP_Groups_Member( $invited_users[$i], $group_obj->id );
1747
+
1748
+ // Send the actual invite
1749
+ groups_notification_group_invites( $group_obj, $member, $bp->loggedin_user->id );
1750
+
1751
+ $member->invite_sent = 1;
1752
+ $member->save();
1753
+ }
1754
+
1755
+ do_action( 'groups_send_invites', $group_obj->id, $invited_users );
1756
+ }
1757
+
1758
+ function groups_delete_all_group_invites( $group_id ) {
1759
+ return BP_Groups_Group::delete_all_invites( $group_id );
1760
+ }
1761
+
1762
+ function groups_check_group_exists( $group_id ) {
1763
+ return BP_Groups_Group::group_exists( $group_id );
1764
+ }
1765
+
1766
+ function groups_leave_group( $group_id, $user_id = false ) {
1767
+ global $bp;
1768
+
1769
+ /* Check the nonce */
1770
+ if ( !check_admin_referer( 'groups_leave_group' ) )
1771
+ return false;
1772
+
1773
+ if ( !$user_id )
1774
+ $user_id = $bp->loggedin_user->id;
1775
+
1776
+ // Admins cannot leave a group, that is until promotion to admin support is implemented.
1777
+ if ( groups_is_group_admin( $user_id, $group_id ) )
1778
+ return false;
1779
+
1780
+ // This is exactly the same as deleting and invite, just is_confirmed = 1 NOT 0.
1781
+ if ( !groups_uninvite_user( $user_id, $group_id, true ) )
1782
+ return false;
1783
+
1784
+ do_action( 'groups_leave_group', $group_id, $bp->loggedin_user->id );
1785
+
1786
+ /* Modify group member count */
1787
+ groups_update_groupmeta( $group_id, 'total_member_count', (int) groups_get_groupmeta( $group_id, 'total_member_count') - 1 );
1788
+
1789
+ return true;
1790
+ }
1791
+
1792
+ function groups_join_group( $group_id, $user_id = false ) {
1793
+ global $bp;
1794
+
1795
+ /* Check the nonce */
1796
+ if ( !check_admin_referer( 'groups_join_group' ) )
1797
+ return false;
1798
+
1799
+ if ( !$user_id )
1800
+ $user_id = $bp->loggedin_user->id;
1801
+
1802
+ if ( groups_check_user_has_invite( $user_id, $group_id ) )
1803
+ groups_delete_invite( $user_id, $group_id );
1804
+
1805
+ $new_member = new BP_Groups_Member;
1806
+ $new_member->group_id = $group_id;
1807
+ $new_member->user_id = $user_id;
1808
+ $new_member->inviter_id = 0;
1809
+ $new_member->is_admin = 0;
1810
+ $new_member->user_title = '';
1811
+ $new_member->date_modified = time();
1812
+ $new_member->is_confirmed = 1;
1813
+
1814
+ if ( !$new_member->save() )
1815
+ return false;
1816
+
1817
+ /* Record this in activity streams */
1818
+ groups_record_activity( array( 'item_id' => $new_member->group_id, 'component_name' => $bp->groups->slug, 'component_action' => 'joined_group', 'is_private' => 0 ) );
1819
+
1820
+ /* Modify group meta */
1821
+ groups_update_groupmeta( $group_id, 'total_member_count', (int) groups_get_groupmeta( $group_id, 'total_member_count') + 1 );
1822
+ groups_update_groupmeta( $group_id, 'last_activity', time() );
1823
+
1824
+ do_action( 'groups_join_group', $group_id, $bp->loggedin_user->id );
1825
+
1826
+ return true;
1827
+ }
1828
+
1829
+ function groups_get_group_admins( $group_id ) {
1830
+ return BP_Groups_Member::get_group_administrator_ids( $group_id );
1831
+ }
1832
+
1833
+ function groups_get_group_mods( $group_id ) {
1834
+ return BP_Groups_Member::get_group_moderator_ids( $group_id );
1835
+ }
1836
+
1837
+ function groups_get_group_members( $group_id, $limit = false, $page = false ) {
1838
+ return BP_Groups_Member::get_all_for_group( $group_id, $limit, $page );
1839
+ }
1840
+ function groups_get_group_users( $group_id, $limit = false, $page = false, $deprecated_function = true ) {
1841
+ return groups_get_group_members( $group_id, $limit, $page );
1842
+ }
1843
+
1844
+ function groups_is_group_admin( $user_id, $group_id ) {
1845
+ return BP_Groups_Member::check_is_admin( $user_id, $group_id );
1846
+ }
1847
+
1848
+ function groups_is_group_mod( $user_id, $group_id ) {
1849
+ return BP_Groups_Member::check_is_mod( $user_id, $group_id );
1850
+ }
1851
+
1852
+ function groups_new_wire_post( $group_id, $content ) {
1853
+ global $group_obj, $bp;
1854
+
1855
+ /* Check the nonce first. */
1856
+ if ( !check_admin_referer( 'bp_wire_post' ) )
1857
+ return false;
1858
+
1859
+ $private = false;
1860
+ if ( $group_obj->status != 'public' )
1861
+ $private = true;
1862
+
1863
+ if ( $wire_post_id = bp_wire_new_post( $group_id, $content, $bp->groups->slug, $private ) ) {
1864
+ do_action( 'groups_new_wire_post', $group_id, $wire_post_id );
1865
+
1866
+ return true;
1867
+ }
1868
+
1869
+ return false;
1870
+ }
1871
+
1872
+ function groups_delete_wire_post( $wire_post_id, $table_name ) {
1873
+ global $bp;
1874
+
1875
+ /* Check the nonce first. */
1876
+ if ( !check_admin_referer( 'bp_wire_delete_link' ) )
1877
+ return false;
1878
+
1879
+ if ( bp_wire_delete_post( $wire_post_id, $bp->groups->slug, $table_name ) ) {
1880
+ do_action( 'groups_deleted_wire_post', $wire_post_id );
1881
+ return true;
1882
+ }
1883
+
1884
+ return false;
1885
+ }
1886
+
1887
+ function groups_edit_base_group_details( $group_id, $group_name, $group_desc, $group_news, $notify_members ) {
1888
+ global $bp;
1889
+
1890
+ /* Check the nonce first. */
1891
+ if ( !check_admin_referer( 'groups_edit_group_details' ) )
1892
+ return false;
1893
+
1894
+ if ( empty( $group_name ) || empty( $group_desc ) )
1895
+ return false;
1896
+
1897
+ $group = new BP_Groups_Group( $group_id, false, false );
1898
+ $group->name = $group_name;
1899
+ $group->description = $group_desc;
1900
+ $group->news = $group_news;
1901
+
1902
+ if ( !$group->save() )
1903
+ return false;
1904
+
1905
+ if ( $notify_members ) {
1906
+ require_once ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' );
1907
+ groups_notification_group_updated( $group->id );
1908
+ }
1909
+
1910
+ do_action( 'groups_details_updated', $group->id );
1911
+
1912
+ return true;
1913
+ }
1914
+
1915
+ function groups_edit_group_settings( $group_id, $enable_wire, $enable_forum, $enable_photos, $photos_admin_only, $status ) {
1916
+ global $bp;
1917
+
1918
+ /* Check the nonce first. */
1919
+ if ( !check_admin_referer( 'groups_edit_group_settings' ) )
1920
+ return false;
1921
+
1922
+ $group = new BP_Groups_Group( $group_id, false, false );
1923
+ $group->enable_wire = $enable_wire;
1924
+ $group->enable_forum = $enable_forum;
1925
+ $group->enable_photos = $enable_photos;
1926
+ $group->photos_admin_only = $photos_admin_only;
1927
+ $group->status = $status;
1928
+
1929
+ if ( !$group->save() )
1930
+ return false;
1931
+
1932
+ /* If forums have been enabled, and a forum does not yet exist, we need to create one. */
1933
+ if ( $group->enable_forum ) {
1934
+ if ( function_exists( 'bp_forums_setup' ) && '' == groups_get_groupmeta( $group->id, 'forum_id' ) ) {
1935
+ groups_new_group_forum( $group->id, $group->name, $group->description );
1936
+ }
1937
+ }
1938
+
1939
+ do_action( 'groups_settings_updated', $group->id );
1940
+
1941
+ return true;
1942
+ }
1943
+
1944
+ function groups_promote_member( $user_id, $group_id ) {
1945
+ global $bp;
1946
+
1947
+ /* Check the nonce first. */
1948
+ if ( !check_admin_referer( 'groups_promote_member' ) )
1949
+ return false;
1950
+
1951
+ if ( !$bp->is_item_admin )
1952
+ return false;
1953
+
1954
+ $member = new BP_Groups_Member( $user_id, $group_id );
1955
+
1956
+ do_action( 'groups_premote_member', $user_id, $group_id );
1957
+
1958
+ return $member->promote();
1959
+ }
1960
+
1961
+ function groups_demote_member( $user_id, $group_id ) {
1962
+ global $bp;
1963
+
1964
+ /* Check the nonce first. */
1965
+ if ( !check_admin_referer( 'groups_demote_member' ) )
1966
+ return false;
1967
+
1968
+ if ( !$bp->is_item_admin )
1969
+ return false;
1970
+
1971
+ $member = new BP_Groups_Member( $user_id, $group_id );
1972
+
1973
+ do_action( 'groups_demote_member', $user_id, $group_id );
1974
+
1975
+ return $member->demote();
1976
+ }
1977
+
1978
+ function groups_ban_member( $user_id, $group_id ) {
1979
+ global $bp;
1980
+
1981
+ /* Check the nonce first. */
1982
+ if ( !check_admin_referer( 'groups_ban_member' ) )
1983
+ return false;
1984
+
1985
+ if ( !$bp->is_item_admin )
1986
+ return false;
1987
+
1988
+ $member = new BP_Groups_Member( $user_id, $group_id );
1989
+
1990
+ do_action( 'groups_ban_member', $user_id, $group_id );
1991
+
1992
+ return $member->ban();
1993
+ }
1994
+
1995
+ function groups_unban_member( $user_id, $group_id ) {
1996
+ global $bp;
1997
+
1998
+ /* Check the nonce first. */
1999
+ if ( !check_admin_referer( 'groups_unban_member' ) )
2000
+ return false;
2001
+
2002
+ if ( !$bp->is_item_admin )
2003
+ return false;
2004
+
2005
+ $member = new BP_Groups_Member( $user_id, $group_id );
2006
+
2007
+ do_action( 'groups_unban_member', $user_id, $group_id );
2008
+
2009
+ return $member->unban();
2010
+ }
2011
+
2012
+ function groups_send_membership_request( $requesting_user_id, $group_id ) {
2013
+ global $bp;
2014
+
2015
+ /* Check the nonce first. */
2016
+ if ( !check_admin_referer( 'groups_request_membership' ) )
2017
+ return false;
2018
+
2019
+ $requesting_user = new BP_Groups_Member;
2020
+ $requesting_user->group_id = $group_id;
2021
+ $requesting_user->user_id = $requesting_user_id;
2022
+ $requesting_user->inviter_id = 0;
2023
+ $requesting_user->is_admin = 0;
2024
+ $requesting_user->user_title = '';
2025
+ $requesting_user->date_modified = time();
2026
+ $requesting_user->is_confirmed = 0;
2027
+ $requesting_user->comments = $_POST['group-request-membership-comments'];
2028
+
2029
+ if ( $requesting_user->save() ) {
2030
+ $admins = groups_get_group_admins( $group_id );
2031
+
2032
+ require_once ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' );
2033
+
2034
+ for ( $i = 0; $i < count( $admins ); $i++ ) {
2035
+ // Saved okay, now send the email notification
2036
+ groups_notification_new_membership_request( $requesting_user_id, $admins[$i]->user_id, $group_id, $requesting_user->id );
2037
+ }
2038
+
2039
+ do_action( 'groups_membership_requested', $requesting_user_id, $admins, $group_id, $requesting_user->id );
2040
+
2041
+ return true;
2042
+ }
2043
+
2044
+ return false;
2045
+ }
2046
+
2047
+ function groups_accept_membership_request( $membership_id ) {
2048
+ global $bp;
2049
+
2050
+ /* Check the nonce first. */
2051
+ if ( !check_admin_referer( 'groups_accept_membership_request' ) )
2052
+ return false;
2053
+
2054
+ $membership = new BP_Groups_Member( false, false, $membership_id );
2055
+ $membership->accept_request();
2056
+
2057
+ if ( !$membership->save() )
2058
+ return false;
2059
+
2060
+ /* Modify group member count */
2061
+ groups_update_groupmeta( $membership->group_id, 'total_member_count', (int) groups_get_groupmeta( $membership->group_id, 'total_member_count') + 1 );
2062
+
2063
+ /* Record this in activity streams */
2064
+ groups_record_activity( array( 'item_id' => $membership->group_id, 'component_name' => $bp->groups->slug, 'component_action' => 'joined_group', 'is_private' => 0 ) );
2065
+
2066
+ /* Send a notification to the user. */
2067
+ require_once ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' );
2068
+ groups_notification_membership_request_completed( $membership->user_id, $membership->group_id, true );
2069
+
2070
+ do_action( 'groups_membership_accepted', $membership->user_id, $membership->group_id );
2071
+
2072
+ return true;
2073
+ }
2074
+
2075
+ function groups_reject_membership_request( $membership_id ) {
2076
+
2077
+ /* Check the nonce first. */
2078
+ if ( !check_admin_referer( 'groups_reject_membership_request' ) )
2079
+ return false;
2080
+
2081
+ $membership = new BP_Groups_Member( false, false, $membership_id );
2082
+
2083
+ if ( !BP_Groups_Member::delete( $membership->user_id, $membership->group_id ) )
2084
+ return false;
2085
+
2086
+ // Send a notification to the user.
2087
+ require_once ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' );
2088
+ groups_notification_membership_request_completed( $membership->user_id, $membership->group_id, false );
2089
+
2090
+ do_action( 'groups_membership_rejected', $membership->user_id, $membership->group_id );
2091
+
2092
+ return true;
2093
+ }
2094
+
2095
+ function groups_redirect_to_random_group() {
2096
+ global $bp, $wpdb;
2097
+
2098
+ if ( $bp->current_component == $bp->groups->slug && isset( $_GET['random'] ) ) {
2099
+ $group = groups_get_random_group();
2100
+
2101
+ bp_core_redirect( $bp->root_domain . '/' . $bp->groups->slug . '/' . $group['groups'][0]->slug );
2102
+ }
2103
+ }
2104
+ add_action( 'wp', 'groups_redirect_to_random_group', 6 );
2105
+
2106
+ function groups_delete_group( $group_id ) {
2107
+ global $bp;
2108
+
2109
+ /* Check the nonce first. */
2110
+ if ( !check_admin_referer( 'groups_delete_group' ) )
2111
+ return false;
2112
+
2113
+ // Check the user is the group admin.
2114
+ if ( !$bp->is_item_admin )
2115
+ return false;
2116
+
2117
+ // Get the group object
2118
+ $group = new BP_Groups_Group( $group_id );
2119
+
2120
+ if ( !$group->delete() )
2121
+ return false;
2122
+
2123
+ // Remove the activity stream item
2124
+ groups_delete_activity( array( 'item_id' => $group_id, 'component_name' => $bp->groups->slug, 'component_action' => 'created_group', 'user_id' => $bp->loggedin_user->id ) );
2125
+
2126
+ // Remove all outstanding invites for this group
2127
+ groups_delete_all_group_invites( $group_id );
2128
+
2129
+ // Remove all notifications for any user belonging to this group
2130
+ bp_core_delete_all_notifications_by_type( $group_id, $bp->groups->slug );
2131
+
2132
+ do_action( 'groups_delete_group', $group_id );
2133
+
2134
+ return true;
2135
+ }
2136
+
2137
+ function groups_check_for_membership_request( $user_id, $group_id ) {
2138
+ return BP_Groups_Member::check_for_membership_request( $user_id, $group_id );
2139
+ }
2140
+
2141
+ function groups_get_newest( $limit = null, $page = 1 ) {
2142
+ return BP_Groups_Group::get_newest( $limit, $page );
2143
+ }
2144
+
2145
+ function groups_get_active( $limit = null, $page = 1 ) {
2146
+ return BP_Groups_Group::get_active( $limit, $page );
2147
+ }
2148
+
2149
+ function groups_get_popular( $limit = null, $page = 1 ) {
2150
+ return BP_Groups_Group::get_popular( $limit, $page );
2151
+ }
2152
+
2153
+ function groups_get_all( $limit = null, $page = 1, $only_public = true, $sort_by = false, $order = false ) {
2154
+ return BP_Groups_Group::get_all( $limit, $page, $only_public, $sort_by, $order );
2155
+ }
2156
+
2157
+ function groups_get_random_group() {
2158
+ return BP_Groups_Group::get_random();
2159
+ }
2160
+
2161
+ //
2162
+ // Group meta functions
2163
+ //
2164
+
2165
+ function groups_delete_groupmeta( $group_id, $meta_key = false, $meta_value = false ) {
2166
+ global $wpdb, $bp;
2167
+
2168
+ if ( !is_numeric( $group_id ) )
2169
+ return false;
2170
+
2171
+ $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
2172
+
2173
+ if ( is_array($meta_value) || is_object($meta_value) )
2174
+ $meta_value = serialize($meta_value);
2175
+
2176
+ $meta_value = trim( $meta_value );
2177
+
2178
+ if ( !$meta_key ) {
2179
+ $wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d", $group_id ) );
2180
+ } else if ( $meta_value ) {
2181
+ $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 ) );
2182
+ } else {
2183
+ $wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d AND meta_key = %s", $group_id, $meta_key ) );
2184
+ }
2185
+
2186
+ // TODO need to look into using this.
2187
+ // wp_cache_delete($group_id, 'groups');
2188
+
2189
+ return true;
2190
+ }
2191
+
2192
+ function groups_get_groupmeta( $group_id, $meta_key = '') {
2193
+ global $wpdb, $bp;
2194
+
2195
+ $group_id = (int) $group_id;
2196
+
2197
+ if ( !$group_id )
2198
+ return false;
2199
+
2200
+ if ( !empty($meta_key) ) {
2201
+ $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
2202
+
2203
+ // TODO need to look into using this.
2204
+ //$user = wp_cache_get($user_id, 'users');
2205
+
2206
+ // Check the cached user object
2207
+ //if ( false !== $user && isset($user->$meta_key) )
2208
+ // $metas = array($user->$meta_key);
2209
+ //else
2210
+ $metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d AND meta_key = %s", $group_id, $meta_key) );
2211
+ } else {
2212
+ $metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d", $group_id) );
2213
+ }
2214
+
2215
+ if ( empty($metas) ) {
2216
+ if ( empty($meta_key) )
2217
+ return array();
2218
+ else
2219
+ return '';
2220
+ }
2221
+
2222
+ $metas = array_map('maybe_unserialize', $metas);
2223
+
2224
+ if ( 1 == count($metas) )
2225
+ return $metas[0];
2226
+ else
2227
+ return $metas;
2228
+ }
2229
+
2230
+ function groups_update_groupmeta( $group_id, $meta_key, $meta_value ) {
2231
+ global $wpdb, $bp;
2232
+
2233
+ if ( !is_numeric( $group_id ) )
2234
+ return false;
2235
+
2236
+ $meta_key = preg_replace( '|[^a-z0-9_]|i', '', $meta_key );
2237
+ $meta_value = (string)$meta_value;
2238
+
2239
+ if ( is_string($meta_value) )
2240
+ $meta_value = stripslashes($wpdb->escape($meta_value));
2241
+
2242
+ $meta_value = maybe_serialize($meta_value);
2243
+
2244
+ if (empty($meta_value)) {
2245
+ return groups_delete_groupmeta( $group_id, $meta_key );
2246
+ }
2247
+
2248
+ $cur = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d AND meta_key = %s", $group_id, $meta_key ) );
2249
+
2250
+ if ( !$cur ) {
2251
+ $wpdb->query( $wpdb->prepare( "INSERT INTO " . $bp->groups->table_name_groupmeta . " ( group_id, meta_key, meta_value ) VALUES ( %d, %s, %s )", $group_id, $meta_key, $meta_value ) );
2252
+ } else if ( $cur->meta_value != $meta_value ) {
2253
+ $wpdb->query( $wpdb->prepare( "UPDATE " . $bp->groups->table_name_groupmeta . " SET meta_value = %s WHERE group_id = %d AND meta_key = %s", $meta_value, $group_id, $meta_key ) );
2254
+ } else {
2255
+ return false;
2256
+ }
2257
+
2258
+ // TODO need to look into using this.
2259
+ // wp_cache_delete($user_id, 'users');
2260
+
2261
+ return true;
2262
+ }
2263
+
2264
+ // The following two functions will force the active member theme for
2265
+ // groups pages, even though they are technically under the root "home" blog
2266
+ // from a WordPress point of view.
2267
+
2268
+ function groups_force_buddypress_theme( $template ) {
2269
+ global $bp;
2270
+
2271
+ if ( $bp->current_component != $bp->groups->slug )
2272
+ return $template;
2273
+
2274
+ $member_theme = get_site_option('active-member-theme');
2275
+
2276
+ if ( empty($member_theme) )
2277
+ $member_theme = 'bpmember';
2278
+
2279
+ add_filter( 'theme_root', 'bp_core_set_member_theme_root' );
2280
+ add_filter( 'theme_root_uri', 'bp_core_set_member_theme_root_uri' );
2281
+
2282
+ return $member_theme;
2283
+ }
2284
+ add_filter( 'template', 'groups_force_buddypress_theme' );
2285
+
2286
+ function groups_force_buddypress_stylesheet( $stylesheet ) {
2287
+ global $bp;
2288
+
2289
+ if ( $bp->current_component != $bp->groups->slug )
2290
+ return $stylesheet;
2291
+
2292
+ $member_theme = get_site_option('active-member-theme');
2293
+
2294
+ if ( empty( $member_theme ) )
2295
+ $member_theme = 'bpmember';
2296
+
2297
+ add_filter( 'theme_root', 'bp_core_set_member_theme_root' );
2298
+ add_filter( 'theme_root_uri', 'bp_core_set_member_theme_root_uri' );
2299
+
2300
+ return $member_theme;
2301
+ }
2302
+ add_filter( 'stylesheet', 'groups_force_buddypress_stylesheet', 1, 1 );
2303
+
2304
+ function groups_remove_data( $user_id ) {
2305
+ BP_Groups_Member::delete_all_for_user($user_id);
2306
+
2307
+ do_action( 'groups_remove_data', $user_id );
2308
+ }
2309
+ add_action( 'wpmu_delete_user', 'groups_remove_data', 1 );
2310
+ add_action( 'delete_user', 'groups_remove_data', 1 );
2311
+
2312
+
2313
+ function groups_clear_group_object_cache( $group_id ) {
2314
+ wp_cache_delete( 'groups_group_nouserdata_' . $group_id, 'bp' );
2315
+ wp_cache_delete( 'groups_group_' . $group_id, 'bp' );
2316
+ wp_cache_delete( 'newest_groups', 'bp' );
2317
+ wp_cache_delete( 'active_groups', 'bp' );
2318
+ wp_cache_delete( 'popular_groups', 'bp' );
2319
+ wp_cache_delete( 'groups_random_groups', 'bp' );
2320
+ }
2321
+
2322
+ // List actions to clear object caches on
2323
+ add_action( 'groups_group_deleted', 'groups_clear_group_object_cache' );
2324
+ add_action( 'groups_settings_updated', 'groups_clear_group_object_cache' );
2325
+ add_action( 'groups_details_updated', 'groups_clear_group_object_cache' );
2326
+ add_action( 'groups_group_avatar_updated', 'groups_clear_group_object_cache' );
2327
+
2328
+ // List actions to clear super cached pages on, if super cache is installed
2329
+ add_action( 'groups_new_wire_post', 'bp_core_clear_cache' );
2330
+ add_action( 'groups_deleted_wire_post', 'bp_core_clear_cache' );
2331
+ add_action( 'groups_join_group', 'bp_core_clear_cache' );
2332
+ add_action( 'groups_leave_group', 'bp_core_clear_cache' );
2333
+ add_action( 'groups_accept_invite', 'bp_core_clear_cache' );
2334
+ add_action( 'groups_reject_invite', 'bp_core_clear_cache' );
2335
+ add_action( 'groups_invite_user', 'bp_core_clear_cache' );
2336
+ add_action( 'groups_uninvite_user', 'bp_core_clear_cache' );
2337
+ add_action( 'groups_details_updated', 'bp_core_clear_cache' );
2338
+ add_action( 'groups_settings_updated', 'bp_core_clear_cache' );
2339
+ add_action( 'groups_unban_member', 'bp_core_clear_cache' );
2340
+ add_action( 'groups_ban_member', 'bp_core_clear_cache' );
2341
+ add_action( 'groups_demote_member', 'bp_core_clear_cache' );
2342
+ add_action( 'groups_premote_member', 'bp_core_clear_cache' );
2343
+ add_action( 'groups_membership_rejected', 'bp_core_clear_cache' );
2344
+ add_action( 'groups_membership_accepted', 'bp_core_clear_cache' );
2345
+ add_action( 'groups_membership_requested', 'bp_core_clear_cache' );
2346
+ add_action( 'groups_create_group_step1_save', 'bp_core_clear_cache' );
2347
+ add_action( 'groups_create_group_step2_save', 'bp_core_clear_cache' );
2348
+ add_action( 'groups_create_group_step3_save', 'bp_core_clear_cache' );
2349
+ add_action( 'groups_created_group', 'bp_core_clear_cache' );
2350
+ add_action( 'groups_group_avatar_updated', 'bp_core_clear_cache' );
2351
+
2352
+ ?>
bp-groups/bp-groups-admin.php ADDED
@@ -0,0 +1,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 );
12
+ if ( !$group->delete() ) {
13
+ $errors = true;
14
+ }
15
+ }
16
+
17
+ if ( $errors ) {
18
+ $message = __( 'There were errors when deleting groups, please try again', 'buddypress' );
19
+ $type = 'error';
20
+ } else {
21
+ $message = __( 'Groups deleted successfully', 'buddypress' );
22
+ $type = 'updated';
23
+ }
24
+ }
25
+ ?>
26
+ <?php if ( isset( $message ) ) { ?>
27
+ <div id="message" class="<?php echo $type ?> fade">
28
+ <p><?php echo $message ?></p>
29
+ </div>
30
+ <?php } ?>
31
+
32
+ <div class="wrap" style="position: relative">
33
+ <h2><?php _e( 'Groups', 'buddypress' ) ?></h2>
34
+
35
+ <form id="wpmu-search" method="post" action="<?php $_SERVER['PHP_SELF'] ?>">
36
+ <input type="text" size="17" value="<?php echo $_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="<?php $_SERVER['PHP_SELF'] ?>">
42
+ <div class="tablenav">
43
+ <div class="tablenav-pages">
44
+ <?php bp_site_groups_pagination_count() ?> <?php bp_site_groups_pagination_links() ?>
45
+ </div>
46
+ <div class="alignleft">
47
+ <input class="button-secondary delete" type="submit" name="groups_admin_delete" value="<?php _e( 'Delete', 'buddypress' ) ?>" onclick="if ( !confirm('<?php _e( 'Are you sure?', 'buddypress' ) ?>') ) return false"/>
48
+ <?php wp_nonce_field('bp-groups-admin') ?>
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 } ?>
58
+
59
+
60
+ <table class="widefat" cellspacing="3" cellpadding="3">
61
+ <thead>
62
+ <tr>
63
+ <th class="check-column" scope="col">
64
+ <input id="group_check_all" type="checkbox" value="0" name="group_check_all" onclick="if ( jQuery(this).attr('checked') ) { jQuery('#group-list input[@type=checkbox]').attr('checked', 'checked'); } else { jQuery('#group-list input[@type=checkbox]').attr('checked', ''); }" />
65
+ </th>
66
+ <th scope="col">
67
+ </th>
68
+ <th scope="col">
69
+ ID
70
+ </th>
71
+ <th scope="col">
72
+ <?php _e( 'Name', 'buddypress' ) ?>
73
+ </th>
74
+ <th scope="col">
75
+ <?php _e( 'Description', 'buddypress' ) ?>
76
+ </th>
77
+ <th scope="col">
78
+ <?php _e( 'Type', 'buddypress' ) ?>
79
+ </th>
80
+ <th scope="col">
81
+ <?php _e( 'Members', 'buddypress' ) ?>
82
+ </th>
83
+ <th scope="col">
84
+ <?php _e( 'Created', 'buddypress' ) ?>
85
+ </th>
86
+ <th scope="col">
87
+ <?php _e( 'Last Active', 'buddypress' ) ?>
88
+ </th>
89
+ <th scope="col">
90
+ </th>
91
+ </tr>
92
+ </thead>
93
+ <tbody id="group-list" class="list:groups group-list">
94
+ <?php $counter = 0 ?>
95
+ <?php while ( bp_site_groups() ) : bp_the_site_group(); ?>
96
+ <tr<?php if ( 1 == $counter % 2 ) { ?> class="alternate"<?php }?>>
97
+ <th class="check-column" scope="row">
98
+ <input id="group_<?php bp_the_site_group_id() ?>" type="checkbox" value="<?php bp_the_site_group_id() ?>" name="allgroups[<?php bp_the_site_group_id() ?>]" />
99
+ </th>
100
+ <td><?php bp_the_site_group_avatar_mini() ?></td>
101
+ <td><?php bp_the_site_group_id() ?></td>
102
+ <td><a href="<?php bp_the_site_group_link() ?>"><?php bp_the_site_group_name() ?></a></td>
103
+ <td><?php bp_the_site_group_description_excerpt() ?></td>
104
+ <td><?php bp_the_site_group_type() ?></td>
105
+ <td><?php bp_the_site_group_member_count() ?></td>
106
+ <td><?php bp_the_site_group_date_created() ?></td>
107
+ <td><?php bp_the_site_group_last_active() ?></td>
108
+ <td><a href="<?php bp_the_site_group_link() ?>/admin"><?php _e( 'Edit', 'buddypress') ?></a></td>
109
+ </tr>
110
+ <?php $counter++ ?>
111
+ <?php endwhile; ?>
112
+ </tbody>
113
+ </table>
114
+
115
+ <?php else: ?>
116
+
117
+ <div id="message" class="info">
118
+ <p><?php _e( 'No groups found.', 'buddypress' ) ?></p>
119
+ </div>
120
+
121
+ <?php endif; ?>
122
+
123
+ <?php bp_the_site_group_hidden_fields() ?>
124
+ </form>
125
+ </div>
126
+ <?php
127
+ }
128
+
129
+ ?>
bp-groups/bp-groups-ajax.php ADDED
@@ -0,0 +1,271 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ function groups_ajax_invite_user() {
3
+ global $bp;
4
+
5
+ check_ajax_referer( 'groups_invite_uninvite_user' );
6
+
7
+ if ( !$_POST['friend_id'] || !$_POST['friend_action'] || !$_POST['group_id'] )
8
+ return false;
9
+
10
+ if ( !groups_is_user_admin( $bp->loggedin_user->id, $_POST['group_id'] ) )
11
+ return false;
12
+
13
+ if ( !friends_check_friendship( $bp->loggedin_user->id, $_POST['friend_id'] ) )
14
+ return false;
15
+
16
+ if ( 'invite' == $_POST['friend_action'] ) {
17
+
18
+ if ( !groups_invite_user( $_POST['friend_id'], $_POST['group_id'] ) )
19
+ return false;
20
+
21
+ $user = new BP_Core_User( $_POST['friend_id'] );
22
+
23
+ echo '<li id="uid-' . $user->id . '">';
24
+ echo $user->avatar_thumb;
25
+ echo '<h4>' . $user->user_link . '</h4>';
26
+ echo '<span class="activity">' . $user->last_active . '</span>';
27
+ echo '<div class="action">
28
+ <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-' . $user->id . '">' . __( 'Remove Invite', 'buddypress' ) . '</a>
29
+ </div>';
30
+ echo '</li>';
31
+
32
+ } else if ( 'uninvite' == $_POST['friend_action'] ) {
33
+
34
+ if ( !groups_uninvite_user( $_POST['friend_id'], $_POST['group_id'] ) )
35
+ return false;
36
+
37
+ return true;
38
+
39
+ } else {
40
+ return false;
41
+ }
42
+ }
43
+ add_action( 'wp_ajax_groups_invite_user', 'groups_ajax_invite_user' );
44
+
45
+ function groups_ajax_group_filter() {
46
+ global $bp;
47
+
48
+ check_ajax_referer( 'group-filter-box' );
49
+
50
+ load_template( TEMPLATEPATH . '/groups/group-loop.php' );
51
+ }
52
+ add_action( 'wp_ajax_group_filter', 'groups_ajax_group_filter' );
53
+
54
+ function groups_ajax_widget_groups_list() {
55
+ global $bp;
56
+
57
+ check_ajax_referer('groups_widget_groups_list');
58
+
59
+ switch ( $_POST['filter'] ) {
60
+ case 'newest-groups':
61
+ if ( !$groups = wp_cache_get( 'newest_groups', 'bp' ) ) {
62
+ $groups = groups_get_newest( $_POST['max-groups'], 1 );
63
+ wp_cache_set( 'newest_groups', $groups, 'bp' );
64
+ }
65
+ break;
66
+ case 'recently-active-groups':
67
+ if ( !$groups = wp_cache_get( 'active_groups', 'bp' ) ) {
68
+ $groups = groups_get_active( $_POST['max-groups'], 1 );
69
+ wp_cache_set( 'active_groups', $groups, 'bp' );
70
+ }
71
+ break;
72
+ case 'popular-groups':
73
+ if ( !$groups = wp_cache_get( 'popular_groups', 'bp' ) ) {
74
+ $groups = groups_get_popular( $_POST['max-groups'], 1 );
75
+ wp_cache_set( 'popular_groups', $groups, 'bp' );
76
+ }
77
+ break;
78
+ }
79
+
80
+ if ( $groups['groups'] ) {
81
+ echo '0[[SPLIT]]'; // return valid result.
82
+
83
+ foreach ( (array) $groups['groups'] as $group_id ) {
84
+ if ( !$group = wp_cache_get( 'groups_group_nouserdata_' . $group_id->group_id, 'bp' ) ) {
85
+ $group = new BP_Groups_Group( $group_id->group_id, false, false );
86
+ wp_cache_set( 'groups_group_nouserdata_' . $group_id->group_id, $group, 'bp' );
87
+ }
88
+ ?>
89
+ <li>
90
+ <div class="item-avatar">
91
+ <img src="<?php echo $group->avatar_thumb ?>" class="avatar" alt="<?php echo $group->name ?> Avatar" />
92
+ </div>
93
+
94
+ <div class="item">
95
+ <div class="item-title"><a href="<?php echo bp_get_group_permalink( $group ) ?>" title="<?php echo $group->name ?>"><?php echo $group->name ?></a></div>
96
+ <div class="item-meta">
97
+ <span class="activity">
98
+ <?php
99
+ if ( 'newest-groups' == $_POST['filter'] ) {
100
+ echo bp_core_get_last_activity( $group->date_created, __('created %s ago', 'buddypress') );
101
+ } else if ( 'recently-active-groups' == $_POST['filter'] ) {
102
+ echo bp_core_get_last_activity( groups_get_groupmeta( $group->id, 'last_activity' ), __('active %s ago', 'buddypress') );
103
+ } else if ( 'popular-groups' == $_POST['filter'] ) {
104
+ if ( $group->total_member_count == 1 )
105
+ echo $group->total_member_count . __(' member', 'buddypress');
106
+ else
107
+ echo $group->total_member_count . __(' members', 'buddypress');
108
+ }
109
+ ?>
110
+ </span>
111
+ </div>
112
+ </div>
113
+ </li>
114
+ <?php
115
+ }
116
+ } else {
117
+ echo "-1[[SPLIT]]<li>" . __("No groups matched the current filter.", 'buddypress');
118
+ }
119
+ }
120
+ add_action( 'wp_ajax_widget_groups_list', 'groups_ajax_widget_groups_list' );
121
+
122
+ function groups_ajax_member_list() {
123
+ global $bp;
124
+ ?>
125
+
126
+ <?php if ( bp_group_has_members( 'group_id=' . $_REQUEST['group_id'] ) ) : ?>
127
+
128
+ <?php if ( bp_group_member_needs_pagination() ) : ?>
129
+ <div id="member-count" class="pag-count">
130
+ <?php bp_group_member_pagination_count() ?>
131
+ </div>
132
+
133
+ <div id="member-pagination" class="pagination-links">
134
+ <?php bp_group_member_pagination() ?>
135
+ </div>
136
+ <?php endif; ?>
137
+
138
+ <ul id="member-list" class="item-list">
139
+ <?php while ( bp_group_members() ) : bp_group_the_member(); ?>
140
+ <li>
141
+ <?php bp_group_member_avatar() ?>
142
+ <h5><?php bp_group_member_link() ?></h5>
143
+ <span class="activity"><?php bp_group_member_joined_since() ?></span>
144
+
145
+ <?php if ( function_exists( 'friends_install' ) ) : ?>
146
+ <div class="action">
147
+ <?php bp_add_friend_button( bp_group_member_id() ) ?>
148
+ </div>
149
+ <?php endif; ?>
150
+ </li>
151
+ <?php endwhile; ?>
152
+ </ul>
153
+ <?php else: ?>
154
+
155
+ <div id="message" class="info">
156
+ <p><?php _e( 'This group has no members.', 'buddypress' ) ?></p>
157
+ </div>
158
+
159
+ <?php endif; ?>
160
+ <input type="hidden" name="group_id" id="group_id" value="<?php echo $_REQUEST['group_id'] ?>" />
161
+ <?php
162
+ }
163
+ add_action( 'wp_ajax_get_group_members', 'groups_ajax_member_list' );
164
+
165
+
166
+ function groups_ajax_member_admin_list() {
167
+ global $bp;
168
+ ?>
169
+
170
+ <?php if ( bp_group_has_members( 'group_id=' . $_REQUEST['group_id'] . '&per_page=' . $_REQUEST['num'] ) ) : ?>
171
+
172
+ <?php if ( bp_group_member_needs_pagination() ) : ?>
173
+ <div id="member-count" class="pag-count">
174
+ <?php bp_group_member_pagination_count() ?>
175
+ </div>
176
+
177
+ <div id="member-admin-pagination" class="pagination-links">
178
+ <?php bp_group_member_admin_pagination() ?>
179
+ </div>
180
+ <?php endif; ?>
181
+
182
+ <ul id="members-list" class="item-list single-line">
183
+ <?php while ( bp_group_members() ) : bp_group_the_member(); ?>
184
+ <?php if ( bp_group_member_is_banned() ) : ?>
185
+ <li class="banned-user">
186
+ <?php bp_group_member_avatar_mini() ?>
187
+
188
+ <h5><?php bp_group_member_link() ?> <?php _e( '(banned)', 'buddypress' ) ?> <span class="small"> &mdash; <a href="<?php bp_group_member_unban_link() ?>" title="<?php _e( 'Kick and ban this member', 'buddypress' ) ?>"><?php _e( 'Remove Ban', 'buddypress' ) ?></a> </h5>
189
+ <?php else : ?>
190
+ <li>
191
+ <?php bp_group_member_avatar_mini() ?>
192
+ <h5><?php bp_group_member_link() ?> <span class="small"> &mdash; <a href="<?php bp_group_member_ban_link() ?>" title="<?php _e( 'Kick and ban this member', 'buddypress' ) ?>"><?php _e( 'Kick &amp; Ban', 'buddypress' ) ?></a> | <a href="<?php bp_group_member_promote_link() ?>" title="<?php _e( 'Promote this member', 'buddypress' ) ?>"><?php _e( 'Promote to Moderator', 'buddypress' ) ?></a></span></h5>
193
+
194
+ <?php endif; ?>
195
+ </li>
196
+ <?php endwhile; ?>
197
+ </ul>
198
+ <?php else: ?>
199
+
200
+ <div id="message" class="info">
201
+ <p><?php _e( 'This group has no members.', 'buddypress' ) ?></p>
202
+ </div>
203
+
204
+ <?php endif;?>
205
+ <input type="hidden" name="group_id" id="group_id" value="<?php echo $_REQUEST['group_id'] ?>" />
206
+ <?php
207
+ }
208
+ add_action( 'wp_ajax_get_group_members_admin', 'groups_ajax_member_admin_list' );
209
+
210
+ function bp_core_ajax_directory_groups() {
211
+ global $bp;
212
+
213
+ check_ajax_referer('directory_groups');
214
+
215
+ load_template( TEMPLATEPATH . '/directories/groups/groups-loop.php' );
216
+ }
217
+ add_action( 'wp_ajax_directory_groups', 'bp_core_ajax_directory_groups' );
218
+
219
+ function groups_ajax_joinleave_group() {
220
+ global $bp;
221
+
222
+ if ( groups_is_user_banned( $bp->loggedin_user->id, $_POST['gid'] ) )
223
+ return false;
224
+
225
+ if ( !$group = new BP_Groups_Group( $_POST['gid'], false, false ) )
226
+ return false;
227
+
228
+ if ( 'hidden' == $group->status )
229
+ return false;
230
+
231
+ if ( !groups_is_user_member( $bp->loggedin_user->id, $group->id ) ) {
232
+
233
+ if ( 'public' == $group->status ) {
234
+
235
+ check_ajax_referer( 'groups_join_group' );
236
+
237
+ if ( !groups_join_group( $group->id ) ) {
238
+ _e( 'Error joining group', 'buddypress' );
239
+ } else {
240
+ echo '<a id="group-' . $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>';
241
+ }
242
+
243
+ } else if ( 'private' == $group->status ) {
244
+
245
+ check_ajax_referer( 'groups_request_membership' );
246
+
247
+ if ( !groups_send_membership_request( $bp->loggedin_user->id, $group->id ) ) {
248
+ _e( 'Error requesting membership', 'buddypress' );
249
+ } else {
250
+ echo '<a id="group-' . $group->id . '" class="membership-requested" rel="membership-requested" title="' . __( 'Membership Requested', 'buddypress' ) . '" href="' . bp_get_group_permalink( $group ) . '">' . __( 'Membership Requested', 'buddypress' ) . '</a>';
251
+ }
252
+ }
253
+
254
+ } else {
255
+
256
+ check_ajax_referer( 'groups_leave_group' );
257
+
258
+ if ( !groups_leave_group( $group->id ) ) {
259
+ _e( 'Error leaving group', 'buddypress' );
260
+ } else {
261
+ if ( 'public' == $group->status ) {
262
+ echo '<a id="group-' . $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>';
263
+ } else if ( 'private' == $group->status ) {
264
+ echo '<a id="group-' . $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>';
265
+ }
266
+ }
267
+ }
268
+ }
269
+ add_action( 'wp_ajax_joinleave_group', 'groups_ajax_joinleave_group' );
270
+
271
+ ?>
bp-groups/bp-groups-classes.php ADDED
@@ -0,0 +1,951 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ Class BP_Groups_Group {
4
+ var $id;
5
+ var $creator_id;
6
+ var $name;
7
+ var $slug;
8
+ var $description;
9
+ var $news;
10
+ var $status;
11
+ var $is_invitation_only;
12
+ var $enable_wire;
13
+ var $enable_forum;
14
+ var $enable_photos;
15
+ var $photos_admin_only;
16
+ var $date_created;
17
+
18
+ var $avatar_thumb;
19
+ var $avatar_full;
20
+
21
+ var $user_dataset;
22
+
23
+ var $admins;
24
+ var $total_member_count;
25
+ var $random_members;
26
+ var $latest_wire_posts;
27
+ var $random_photos;
28
+
29
+ function bp_groups_group( $id = null, $single = false, $get_user_dataset = true ) {
30
+ if ( $id ) {
31
+ $this->id = $id;
32
+ $this->populate( $get_user_dataset );
33
+ }
34
+
35
+ if ( $single ) {
36
+ $this->populate_meta();
37
+ }
38
+ }
39
+
40
+ function populate( $get_user_dataset ) {
41
+ global $wpdb, $bp;
42
+
43
+ $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} WHERE id = %d", $this->id );
44
+ $group = $wpdb->get_row($sql);
45
+
46
+ if ( $group ) {
47
+ $this->creator_id = $group->creator_id;
48
+ $this->name = stripslashes($group->name);
49
+ $this->slug = $group->slug;
50
+ $this->description = stripslashes($group->description);
51
+ $this->news = stripslashes($group->news);
52
+ $this->status = $group->status;
53
+ $this->is_invitation_only = $group->is_invitation_only;
54
+ $this->enable_wire = $group->enable_wire;
55
+ $this->enable_forum = $group->enable_forum;
56
+ $this->enable_photos = $group->enable_photos;
57
+ $this->photos_admin_only = $group->photos_admin_only;
58
+ $this->date_created = strtotime($group->date_created);
59
+ $this->total_member_count = groups_get_groupmeta( $this->id, 'total_member_count' );
60
+
61
+ if ( !$group->avatar_thumb || strpos( $group->avatar_thumb, 'none-thumbnail' ) )
62
+ $this->avatar_thumb = 'http://www.gravatar.com/avatar/' . md5( $this->id . '@' . $bp->root_domain ) . '?d=identicon&amp;s=50';
63
+ else
64
+ $this->avatar_thumb = $group->avatar_thumb;
65
+
66
+ if ( !$group->avatar_full || strpos( $group->avatar_thumb, 'none-' ) )
67
+ $this->avatar_full = 'http://www.gravatar.com/avatar/' . md5( $this->id . '@' . $bp->root_domain ) . '?d=identicon&amp;s=150';
68
+ else
69
+ $this->avatar_full = $group->avatar_full;
70
+
71
+ if ( $get_user_dataset ) {
72
+ $this->user_dataset = $this->get_user_dataset();
73
+
74
+ //if ( !$this->total_member_count ) {
75
+ $this->total_member_count = count( $this->user_dataset );
76
+ groups_update_groupmeta( $this->id, 'total_member_count', $this->total_member_count );
77
+ //}
78
+ }
79
+ }
80
+ }
81
+
82
+ function populate_meta() {
83
+ if ( $this->id ) {
84
+ $this->admins = $this->get_administrators();
85
+ $this->random_members = $this->get_random_members();
86
+ $this->random_photos = $this->get_random_photos();
87
+ }
88
+ }
89
+
90
+ function save() {
91
+ global $wpdb, $bp;
92
+
93
+ $this->creator_id = apply_filters( 'groups_group_creator_id_before_save', $this->creator_id, $this->id );
94
+ $this->name = apply_filters( 'groups_group_name_before_save', $this->name, $this->id );
95
+ $this->slug = apply_filters( 'groups_group_slug_before_save', $this->slug, $this->id );
96
+ $this->description = apply_filters( 'groups_group_description_before_save', $this->description, $this->id );
97
+ $this->news = apply_filters( 'groups_group_news_before_save', $this->news, $this->id );
98
+ $this->status = apply_filters( 'groups_group_status_before_save', $this->status, $this->id );
99
+ $this->is_invitation_only = apply_filters( 'groups_group_is_invitation_only_before_save', $this->is_invitation_only, $this->id );
100
+ $this->enable_wire = apply_filters( 'groups_group_enable_wire_before_save', $this->enable_wire, $this->id );
101
+ $this->enable_forum = apply_filters( 'groups_group_enable_forum_before_save', $this->enable_forum, $this->id );
102
+ $this->enable_photos = apply_filters( 'groups_group_enable_photos_before_save', $this->enable_photos, $this->id );
103
+ $this->photos_admin_only = apply_filters( 'groups_group_photos_admin_only_before_save', $this->photos_admin_only, $this->id );
104
+ $this->date_created = apply_filters( 'groups_group_date_created_before_save', $this->date_created, $this->id );
105
+ $this->avatar_thumb = apply_filters( 'groups_group_avatar_thumb_before_save', $this->avatar_thumb, $this->id );
106
+ $this->avatar_full = apply_filters( 'groups_group_avatar_full_before_save', $this->avatar_full, $this->id );
107
+
108
+ do_action( 'groups_group_before_save', $this );
109
+
110
+ if ( $this->id ) {
111
+ $sql = $wpdb->prepare(
112
+ "UPDATE {$bp->groups->table_name} SET
113
+ creator_id = %d,
114
+ name = %s,
115
+ slug = %s,
116
+ description = %s,
117
+ news = %s,
118
+ status = %s,
119
+ is_invitation_only = %d,
120
+ enable_wire = %d,
121
+ enable_forum = %d,
122
+ enable_photos = %d,
123
+ photos_admin_only = %d,
124
+ date_created = FROM_UNIXTIME(%d),
125
+ avatar_thumb = %s,
126
+ avatar_full = %s
127
+ WHERE
128
+ id = %d
129
+ ",
130
+ $this->creator_id,
131
+ $this->name,
132
+ $this->slug,
133
+ $this->description,
134
+ $this->news,
135
+ $this->status,
136
+ $this->is_invitation_only,
137
+ $this->enable_wire,
138
+ $this->enable_forum,
139
+ $this->enable_photos,
140
+ $this->photos_admin_only,
141
+ $this->date_created,
142
+ $this->avatar_thumb,
143
+ $this->avatar_full,
144
+ $this->id
145
+ );
146
+ } else {
147
+ $sql = $wpdb->prepare(
148
+ "INSERT INTO {$bp->groups->table_name} (
149
+ creator_id,
150
+ name,
151
+ slug,
152
+ description,
153
+ news,
154
+ status,
155
+ is_invitation_only,
156
+ enable_wire,
157
+ enable_forum,
158
+ enable_photos,
159
+ photos_admin_only,
160
+ date_created,
161
+ avatar_thumb,
162
+ avatar_full
163
+ ) VALUES (
164
+ %d, %s, %s, %s, %s, %s, %d, %d, %d, %d, %d, FROM_UNIXTIME(%d), %s, %s
165
+ )",
166
+ $this->creator_id,
167
+ $this->name,
168
+ $this->slug,
169
+ $this->description,
170
+ $this->news,
171
+ $this->status,
172
+ $this->is_invitation_only,
173
+ $this->enable_wire,
174
+ $this->enable_forum,
175
+ $this->enable_photos,
176
+ $this->photos_admin_only,
177
+ $this->date_created,
178
+ $this->avatar_thumb,
179
+ $this->avatar_full
180
+ );
181
+ }
182
+
183
+ if ( false === $wpdb->query($sql) )
184
+ return false;
185
+
186
+ if ( !$this->id ) {
187
+ $this->id = $wpdb->insert_id;
188
+ }
189
+
190
+ do_action( 'groups_group_after_save', $this );
191
+
192
+ return true;
193
+ }
194
+
195
+ function make_private() {
196
+
197
+ }
198
+
199
+ function make_public() {
200
+
201
+ }
202
+
203
+ function get_user_dataset() {
204
+ global $wpdb, $bp;
205
+
206
+ 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 ) );
207
+ }
208
+
209
+ function get_administrators() {
210
+ for ( $i = 0; $i < count($this->user_dataset); $i++ ) {
211
+ if ( $this->user_dataset[$i]->is_admin )
212
+ $admins[] = new BP_Groups_Member( $this->user_dataset[$i]->user_id, $this->id );
213
+ }
214
+
215
+ return $admins;
216
+ }
217
+
218
+ function get_random_members() {
219
+ $total_randoms = ( $this->total_member_count > 5 ) ? 5 : $this->total_member_count;
220
+
221
+ for ( $i = 0; $i < $total_randoms; $i++ ) {
222
+ if ( !(int)$this->user_dataset[$i]->is_banned )
223
+ $users[] = new BP_Groups_Member( $this->user_dataset[$i]->user_id, $this->id );
224
+ }
225
+ return $users;
226
+ }
227
+
228
+ function get_random_photos() {
229
+ global $wpdb, $bp;
230
+
231
+
232
+ }
233
+
234
+ function is_member() {
235
+ global $bp;
236
+
237
+ for ( $i = 0; $i < count($this->user_dataset); $i++ ) {
238
+ if ( $this->user_dataset[$i]->user_id == $bp->loggedin_user->id ) {
239
+ return true;
240
+ }
241
+ }
242
+
243
+ return false;
244
+ }
245
+
246
+ function delete() {
247
+ global $wpdb, $bp;
248
+
249
+ // Delete groupmeta for the group
250
+ groups_delete_groupmeta( $this->id );
251
+
252
+ // Modify group count usermeta for members
253
+ for ( $i = 0; $i < count($this->user_dataset); $i++ ) {
254
+ $user = $this->user_dataset[$i];
255
+
256
+ $total_count = get_usermeta( $user->user_id, 'total_group_count' );
257
+
258
+ if ( $total_count != '' ) {
259
+ update_usermeta( $user->user_id, 'total_group_count', (int)$total_count - 1 );
260
+ }
261
+
262
+ // Now delete the group member record
263
+ BP_Groups_Member::delete( $user->user_id, $this->id, false );
264
+ }
265
+
266
+ // Delete the wire posts for this group if the wire is installed
267
+ if ( function_exists('bp_wire_install') ) {
268
+ BP_Wire_Post::delete_all_for_item( $this->id, $bp->groups->table_name_wire );
269
+ }
270
+
271
+ // Finally remove the group entry from the DB
272
+ if ( !$wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name} WHERE id = %d", $this->id ) ) )
273
+ return false;
274
+
275
+ return true;
276
+ }
277
+
278
+
279
+ /* Static Functions */
280
+
281
+ function group_exists( $slug, $table_name = false ) {
282
+ global $wpdb, $bp;
283
+
284
+ if ( !$table_name )
285
+ $table_name = $bp->groups->table_name;
286
+
287
+ if ( !$slug )
288
+ return false;
289
+
290
+ return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$table_name} WHERE slug = %s", $slug ) );
291
+ }
292
+
293
+ function get_id_from_slug( $slug ) {
294
+ return BP_Groups_Group::group_exists( $slug );
295
+ }
296
+
297
+ function get_invites( $user_id, $group_id ) {
298
+ global $wpdb, $bp;
299
+ 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 ) );
300
+ }
301
+
302
+ function filter_user_groups( $filter, $user_id = false, $order = false, $limit = null, $page = null ) {
303
+ global $wpdb, $bp;
304
+
305
+ if ( !$user_id )
306
+ $user_id = $bp->displayed_user->id;
307
+
308
+ like_escape($filter);
309
+
310
+ if ( $limit && $page )
311
+ $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
312
+
313
+ // Get all the group ids for the current user's groups.
314
+ $gids = BP_Groups_Member::get_group_ids( $user_id, false, false, false, true );
315
+
316
+ if ( !$gids['groups'] )
317
+ return false;
318
+
319
+ $gids = implode( ',', $gids['groups'] );
320
+
321
+ $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}" ) );
322
+ $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})" ) );
323
+
324
+ return array( 'groups' => $paged_groups, 'total' => $total_groups );
325
+ }
326
+
327
+ function search_groups( $filter, $limit = null, $page = null, $sort_by = false, $order = false ) {
328
+ global $wpdb, $bp;
329
+
330
+ like_escape($filter);
331
+
332
+ if ( $limit && $page )
333
+ $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
334
+
335
+ if ( $sort_by && $order ) {
336
+ $sort_by = $wpdb->escape( $sort_by );
337
+ $order = $wpdb->escape( $order );
338
+ $order_sql = "ORDER BY $sort_by $order";
339
+ }
340
+
341
+ $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT id as group_id FROM {$bp->groups->table_name} WHERE status != 'hidden' AND name LIKE '%%$filter%%' OR description LIKE '%%$filter%%' {$order_sql} {$pag_sql}" ) );
342
+ $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->groups->table_name} WHERE status != 'hidden' AND name LIKE '%%$filter%%' OR description LIKE '%%$filter%%'" ) );
343
+
344
+ return array( 'groups' => $paged_groups, 'total' => $total_groups );
345
+ }
346
+
347
+ function check_slug( $slug ) {
348
+ global $wpdb, $bp;
349
+
350
+ return $wpdb->get_var( $wpdb->prepare( "SELECT slug FROM {$bp->groups->table_name} WHERE slug = %s", $slug ) );
351
+ }
352
+
353
+ function get_slug( $group_id ) {
354
+ global $wpdb, $bp;
355
+
356
+ return $wpdb->get_var( $wpdb->prepare( "SELECT slug FROM {$bp->groups->table_name} WHERE id = %d", $group_id ) );
357
+ }
358
+
359
+ function has_members( $group_id ) {
360
+ global $wpdb, $bp;
361
+
362
+ $members = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->groups->table_name_members} WHERE group_id = %d", $group_id ) );
363
+
364
+ if ( !$members )
365
+ return false;
366
+
367
+ return true;
368
+ }
369
+
370
+ function has_membership_requests( $group_id ) {
371
+ global $wpdb, $bp;
372
+
373
+ 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 ) );
374
+ }
375
+
376
+ function get_membership_requests( $group_id, $limit = null, $page = null ) {
377
+ global $wpdb, $bp;
378
+
379
+ if ( $limit && $page ) {
380
+ $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
381
+ }
382
+
383
+ $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 ) );
384
+ $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 ) );
385
+
386
+ return array( 'requests' => $paged_requests, 'total' => $total_requests );
387
+ }
388
+
389
+ function get_newest( $limit = null, $page = null ) {
390
+ global $wpdb, $bp;
391
+
392
+ if ( $limit && $page ) {
393
+ $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
394
+ }
395
+
396
+ $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT id as group_id FROM {$bp->groups->table_name} WHERE status != 'hidden' ORDER BY date_created DESC {$pag_sql}" ) );
397
+ $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->groups->table_name} WHERE status != 'hidden' ORDER BY date_created DESC", $limit ) );
398
+
399
+ return array( 'groups' => $paged_groups, 'total' => $total_groups );
400
+ }
401
+
402
+ function get_active( $limit = null, $page = null ) {
403
+ global $wpdb, $bp;
404
+
405
+ if ( $limit && $page ) {
406
+ $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
407
+ }
408
+
409
+ $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 AND g.status != 'hidden' AND gm.meta_key = 'last_activity' ORDER BY CONVERT(gm.meta_value, SIGNED) DESC {$pag_sql}", $limit ) );
410
+ $total_groups = count( $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 AND g.status != 'hidden' AND gm.meta_key = 'last_activity' ORDER BY CONVERT(gm.meta_value, SIGNED) DESC", $limit ) ) );
411
+
412
+ return array( 'groups' => $paged_groups, 'total' => $total_groups );
413
+ }
414
+
415
+ function get_popular( $limit = null, $page = null ) {
416
+ global $wpdb, $bp;
417
+
418
+ if ( $limit && $page ) {
419
+ $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
420
+ }
421
+
422
+ $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 AND g.status != 'hidden' AND gm.meta_key = 'total_member_count' ORDER BY CONVERT(gm.meta_value, SIGNED) DESC {$pag_sql}", $limit ) );
423
+ $total_groups = count( $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 AND g.status != 'hidden' AND gm.meta_key = 'total_member_count' ORDER BY CONVERT(gm.meta_value, SIGNED) DESC", $limit ) ) );
424
+
425
+ return array( 'groups' => $paged_groups, 'total' => $total_groups );
426
+ }
427
+
428
+ function get_all( $limit = null, $page = null, $only_public = true, $sort_by = false, $order = false ) {
429
+ global $wpdb, $bp;
430
+
431
+ if ( $only_public )
432
+ $public_sql = $wpdb->prepare( " WHERE g.status = 'public'" );
433
+
434
+ if ( !is_site_admin() )
435
+ $hidden_sql = $wpdb->prepare( " AND g.status != 'hidden'");
436
+
437
+ if ( $limit && $page )
438
+ $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
439
+
440
+ if ( $sort_by && $order ) {
441
+ $sort_by = $wpdb->escape( $sort_by );
442
+ $order = $wpdb->escape( $order );
443
+ $order_sql = "ORDER BY g.$sort_by $order";
444
+
445
+ switch ( $sort_by ) {
446
+ default:
447
+ $sql = $wpdb->prepare( "SELECT g.id as group_id, g.slug FROM {$bp->groups->table_name} g {$public_sql} {$hidden_sql} {$order_sql} {$pag_sql}" );
448
+ break;
449
+ case 'members':
450
+ $sql = $wpdb->prepare( "SELECT g.id as group_id, g.slug 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}" );
451
+ break;
452
+ case 'last_active':
453
+ $sql = $wpdb->prepare( "SELECT g.id as group_id, g.slug 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}" );
454
+ break;
455
+ }
456
+ } else {
457
+ $sql = $wpdb->prepare( "SELECT g.id as group_id, g.slug FROM {$bp->groups->table_name} g {$public_sql} {$hidden_sql} {$order_sql} {$pag_sql}" );
458
+ }
459
+
460
+ return $wpdb->get_results($sql);
461
+ }
462
+
463
+ function get_by_letter( $letter, $limit = null, $page = null ) {
464
+ global $wpdb, $bp;
465
+
466
+ if ( strlen($letter) > 1 || is_numeric($letter) || !$letter )
467
+ return false;
468
+
469
+ if ( !is_site_admin() )
470
+ $hidden_sql = $wpdb->prepare( " AND status != 'hidden'");
471
+
472
+ like_escape($letter);
473
+
474
+ if ( $limit && $page ) {
475
+ $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
476
+ $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" ) );
477
+ }
478
+
479
+ $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}" ) );
480
+
481
+ return array( 'groups' => $paged_groups, 'total' => $total_groups );
482
+ }
483
+
484
+
485
+ function get_random( $limit = null, $page = null ) {
486
+ global $wpdb, $bp;
487
+
488
+ if ( !is_site_admin() )
489
+ $hidden_sql = $wpdb->prepare( " AND status != 'hidden'");
490
+
491
+ if ( $limit && $page ) {
492
+ $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
493
+ $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()" ) );
494
+ }
495
+
496
+ $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}" ) );
497
+
498
+ return array( 'groups' => $paged_groups, 'total' => $total_groups );
499
+ }
500
+
501
+ function delete_all_invites( $group_id ) {
502
+ global $wpdb, $bp;
503
+
504
+ return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE group_id = %d AND invite_sent = 1", $group_id ) );
505
+ }
506
+ }
507
+
508
+ Class BP_Groups_Member {
509
+ var $id;
510
+ var $group_id;
511
+ var $user_id;
512
+ var $inviter_id;
513
+ var $is_admin;
514
+ var $is_mod;
515
+ var $is_banned;
516
+ var $user_title;
517
+ var $date_modified;
518
+ var $is_confirmed;
519
+ var $comments;
520
+ var $invite_sent;
521
+
522
+ var $user;
523
+
524
+ function bp_groups_member( $user_id = false, $group_id = false, $id = false, $populate = true ) {
525
+ if ( $user_id && $group_id && !$id ) {
526
+ $this->user_id = $user_id;
527
+ $this->group_id = $group_id;
528
+
529
+ if ( $populate )
530
+ $this->populate();
531
+ }
532
+
533
+ if ( $id ) {
534
+ $this->id = $id;
535
+
536
+ if ( $populate )
537
+ $this->populate();
538
+ }
539
+ }
540
+
541
+ function populate() {
542
+ global $wpdb, $bp;
543
+
544
+ if ( $this->user_id && $this->group_id && !$this->id )
545
+ $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d", $this->user_id, $this->group_id );
546
+
547
+ if ( $this->id )
548
+ $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name_members} WHERE id = %d", $this->id );
549
+
550
+ $member = $wpdb->get_row($sql);
551
+
552
+ if ( $member ) {
553
+ $this->id = $member->id;
554
+ $this->group_id = $member->group_id;
555
+ $this->user_id = $member->user_id;
556
+ $this->inviter_id = $member->inviter_id;
557
+ $this->is_admin = $member->is_admin;
558
+ $this->is_mod = $member->is_mod;
559
+ $this->is_banned = $member->is_banned;
560
+ $this->user_title = $member->user_title;
561
+ $this->date_modified = strtotime($member->date_modified);
562
+ $this->is_confirmed = $member->is_confirmed;
563
+ $this->comments = $member->comments;
564
+ $this->invite_sent = $member->invite_sent;
565
+
566
+ $this->user = new BP_Core_User( $this->user_id );
567
+ }
568
+ }
569
+
570
+ function save() {
571
+ global $wpdb, $bp;
572
+
573
+ $this->user_id = apply_filters( 'groups_member_user_id_before_save', $this->user_id, $this->id );
574
+ $this->group_id = apply_filters( 'groups_member_group_id_before_save', $this->group_id, $this->id );
575
+ $this->inviter_id = apply_filters( 'groups_member_inviter_id_before_save', $this->inviter_id, $this->id );
576
+ $this->is_admin = apply_filters( 'groups_member_is_admin_before_save', $this->is_admin, $this->id );
577
+ $this->is_mod = apply_filters( 'groups_member_is_mod_before_save', $this->is_mod, $this->id );
578
+ $this->is_banned = apply_filters( 'groups_member_is_banned_before_save', $this->is_banned, $this->id );
579
+ $this->user_title = apply_filters( 'groups_member_user_title_before_save', $this->user_title, $this->id );
580
+ $this->date_modified = apply_filters( 'groups_member_date_modified_before_save', $this->date_modified, $this->id );
581
+ $this->is_confirmed = apply_filters( 'groups_member_is_confirmed_before_save', $this->is_confirmed, $this->id );
582
+ $this->comments = apply_filters( 'groups_member_comments_before_save', $this->comments, $this->id );
583
+ $this->invite_sent = apply_filters( 'groups_member_invite_sent_before_save', $this->invite_sent, $this->id );
584
+
585
+ do_action( 'groups_member_before_save', $this );
586
+
587
+ if ( $this->id ) {
588
+ $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 );
589
+ } else {
590
+ $sql = $wpdb->prepare( "INSERT INTO {$bp->groups->table_name_members} ( user_id, group_id, inviter_id, is_admin, is_mod, is_banned, user_title, date_modified, is_confirmed, comments, invite_sent ) VALUES ( %d, %d, %d, %d, %d, %d, %s, FROM_UNIXTIME(%d), %d, %s, %d )", $this->user_id, $this->group_id, $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 );
591
+ }
592
+
593
+ if ( !$wpdb->query($sql) )
594
+ return false;
595
+
596
+ $this->id = $wpdb->insert_id;
597
+
598
+ do_action( 'groups_member_after_save', $this );
599
+
600
+ return true;
601
+ }
602
+
603
+ function promote() {
604
+ // Check the users current status
605
+
606
+ // Not letting mods be promoted to admins right now. In the future though yes.
607
+ if ( $this->is_admin || $this->is_mod )
608
+ return false;
609
+
610
+ $this->is_mod = 1;
611
+ return $this->save();
612
+ }
613
+
614
+ function demote() {
615
+ if ( $this->is_admin )
616
+ return false;
617
+
618
+ if ( !$this->is_mod )
619
+ return false;
620
+
621
+ $this->is_mod = 0;
622
+ return $this->save();
623
+ }
624
+
625
+ function ban() {
626
+ if ( $this->is_admin )
627
+ return false;
628
+
629
+ $this->is_mod = 0;
630
+ $this->is_banned = 1;
631
+
632
+ groups_update_groupmeta( $this->group_id, 'total_member_count', ( (int) groups_get_groupmeta( $this->group_id, 'total_member_count' ) - 1 ) );
633
+
634
+ return $this->save();
635
+ }
636
+
637
+ function unban() {
638
+ if ( $this->is_admin )
639
+ return false;
640
+
641
+ $this->is_banned = 0;
642
+
643
+ groups_update_groupmeta( $this->group_id, 'total_member_count', ( (int) groups_get_groupmeta( $this->group_id, 'total_member_count' ) + 1 ) );
644
+
645
+ return $this->save();
646
+ }
647
+
648
+ function accept_invite() {
649
+ $this->inviter_id = 0;
650
+ $this->is_confirmed = 1;
651
+ $this->date_modified = time();
652
+ }
653
+
654
+ function accept_request() {
655
+ $this->is_confirmed = 1;
656
+ $this->date_modified = time();
657
+ }
658
+
659
+ /* Static Functions */
660
+
661
+ function delete( $user_id, $group_id, $check_empty = true ) {
662
+ global $wpdb, $bp;
663
+
664
+ $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 ) );
665
+
666
+ return $delete_result;
667
+ }
668
+
669
+ function get_group_ids( $user_id, $limit = false, $page = false, $get_total = true, $as_col = false ) {
670
+ global $wpdb, $bp;
671
+
672
+ if ( $limit && $page )
673
+ $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
674
+
675
+ // If the user is logged in and viewing their own groups, we can show hidden and private groupss
676
+ if ( bp_is_home() ) {
677
+ $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 );
678
+ $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 ) );
679
+ } else {
680
+ $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 );
681
+ $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 ) );
682
+ }
683
+
684
+ if ( $as_col )
685
+ $paged_groups = $wpdb->get_col( $group_sql );
686
+ else
687
+ $paged_groups = $wpdb->get_results( $group_sql );
688
+
689
+ return array( 'groups' => $paged_groups, 'total' => $total_groups );
690
+ }
691
+
692
+ function get_recently_joined( $user_id, $limit = false, $page = false, $filter = false ) {
693
+ global $wpdb, $bp;
694
+
695
+ if ( $limit && $page )
696
+ $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
697
+
698
+ if ( $filter ) {
699
+ like_escape($filter);
700
+ $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )";
701
+ }
702
+
703
+ if ( !bp_is_home() )
704
+ $hidden_sql = " AND g.status != 'hidden'";
705
+
706
+ $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 ) );
707
+ $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 ) );
708
+
709
+ return array( 'groups' => $paged_groups, 'total' => $total_groups );
710
+ }
711
+
712
+ function get_most_popular( $user_id, $limit = false, $page = false, $filter = false ) {
713
+ global $wpdb, $bp;
714
+
715
+ if ( $limit && $page )
716
+ $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
717
+
718
+ if ( $filter ) {
719
+ like_escape($filter);
720
+ $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )";
721
+ }
722
+
723
+ if ( !bp_is_home() )
724
+ $hidden_sql = " AND g.status != 'hidden'";
725
+
726
+ $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 ) );
727
+ $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 ) );
728
+
729
+ return array( 'groups' => $paged_groups, 'total' => $total_groups );
730
+ }
731
+
732
+ function get_recently_active( $user_id, $limit = false, $page = false, $filter = false ) {
733
+ global $wpdb, $bp;
734
+
735
+ if ( $limit && $page )
736
+ $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
737
+
738
+ if ( $filter ) {
739
+ like_escape($filter);
740
+ $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )";
741
+ }
742
+
743
+ if ( !bp_is_home() )
744
+ $hidden_sql = " AND g.status != 'hidden'";
745
+
746
+ $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 ) );
747
+ $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 ) );
748
+
749
+ return array( 'groups' => $paged_groups, 'total' => $total_groups );
750
+ }
751
+
752
+ function get_alphabetically( $user_id, $limit = false, $page = false, $filter = false ) {
753
+ global $wpdb, $bp;
754
+
755
+ if ( $limit && $page )
756
+ $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
757
+
758
+ if ( $filter ) {
759
+ like_escape($filter);
760
+ $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )";
761
+ }
762
+
763
+ if ( !bp_is_home() )
764
+ $hidden_sql = " AND g.status != 'hidden'";
765
+
766
+ $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 ) );
767
+ $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 ) );
768
+
769
+ return array( 'groups' => $paged_groups, 'total' => $total_groups );
770
+ }
771
+
772
+ function get_is_admin_of( $user_id, $limit = false, $page = false, $filter = false ) {
773
+ global $wpdb, $bp;
774
+
775
+ if ( $limit && $page )
776
+ $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
777
+
778
+ if ( $filter ) {
779
+ like_escape($filter);
780
+ $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )";
781
+ }
782
+
783
+ if ( !bp_is_home() )
784
+ $hidden_sql = " AND g.status != 'hidden'";
785
+
786
+ $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 ) );
787
+ $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 ) );
788
+
789
+ return array( 'groups' => $paged_groups, 'total' => $total_groups );
790
+ }
791
+
792
+ function get_is_mod_of( $user_id, $limit = false, $page = false, $filter = false ) {
793
+ global $wpdb, $bp;
794
+
795
+ if ( $limit && $page )
796
+ $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
797
+
798
+ if ( $filter ) {
799
+ like_escape($filter);
800
+ $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )";
801
+ }
802
+
803
+ if ( !bp_is_home() )
804
+ $hidden_sql = " AND g.status != 'hidden'";
805
+
806
+ $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 ) );
807
+ $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 ) );
808
+
809
+ return array( 'groups' => $paged_groups, 'total' => $total_groups );
810
+ }
811
+
812
+ function total_group_count( $user_id = false ) {
813
+ global $bp, $wpdb;
814
+
815
+ if ( !$user_id )
816
+ $user_id = $bp->displayed_user->id;
817
+
818
+ if ( bp_is_home() ) {
819
+ 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 ) );
820
+ } else {
821
+ 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 ) );
822
+ }
823
+ }
824
+
825
+ function get_invites( $user_id ) {
826
+ global $wpdb, $bp;
827
+
828
+ $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 ) );
829
+
830
+ return $group_ids;
831
+ }
832
+
833
+ function check_has_invite( $user_id, $group_id ) {
834
+ global $wpdb, $bp;
835
+
836
+ if ( !$user_id )
837
+ return false;
838
+
839
+ 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 ) );
840
+ }
841
+
842
+ function delete_invite( $user_id, $group_id ) {
843
+ global $wpdb, $bp;
844
+
845
+ if ( !$user_id )
846
+ return false;
847
+
848
+ 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 ) );
849
+ }
850
+
851
+ function check_is_admin( $user_id, $group_id ) {
852
+ global $wpdb, $bp;
853
+
854
+ if ( !$user_id )
855
+ return false;
856
+
857
+ 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 ) );
858
+ }
859
+
860
+ function check_is_mod( $user_id, $group_id ) {
861
+ global $wpdb, $bp;
862
+
863
+ if ( !$user_id )
864
+ return false;
865
+
866
+ 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 ) );
867
+ }
868
+
869
+ function check_is_member( $user_id, $group_id ) {
870
+ global $wpdb, $bp;
871
+
872
+ if ( !$user_id )
873
+ return false;
874
+
875
+ 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 ) );
876
+ }
877
+
878
+ function check_is_banned( $user_id, $group_id ) {
879
+ global $wpdb, $bp;
880
+
881
+ if ( !$user_id )
882
+ return false;
883
+
884
+ 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 ) );
885
+ }
886
+
887
+ function check_for_membership_request( $user_id, $group_id ) {
888
+ global $wpdb, $bp;
889
+
890
+ if ( !$user_id )
891
+ return false;
892
+
893
+ 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 ) );
894
+ }
895
+
896
+ function get_random_groups( $user_id, $total_groups = 5 ) {
897
+ global $wpdb, $bp;
898
+
899
+ // If the user is logged in and viewing their random groups, we can show hidden and private groups
900
+ if ( bp_is_home() ) {
901
+ 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 ) );
902
+ } else {
903
+ 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 ) );
904
+ }
905
+ }
906
+
907
+ function get_group_administrator_ids( $group_id ) {
908
+ global $bp, $wpdb;
909
+
910
+ 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 ) );
911
+ }
912
+
913
+ function get_group_moderator_ids( $group_id ) {
914
+ global $bp, $wpdb;
915
+
916
+ 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 ) );
917
+ }
918
+
919
+ function get_all_for_group( $group_id, $limit = false, $page = false, $exclude_admins_mods = true, $exclude_banned = true ) {
920
+ global $bp, $wpdb;
921
+
922
+ if ( $limit && $page )
923
+ $pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
924
+
925
+ if ( $exclude_admins_mods )
926
+ $exclude_sql = $wpdb->prepare( "AND is_admin = 0 AND is_mod = 0" );
927
+
928
+ if ( $exclude_banned )
929
+ $banned_sql = $wpdb->prepare( " AND is_banned = 0" );
930
+
931
+ $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 ) );
932
+
933
+ if ( !$members )
934
+ return false;
935
+
936
+ if ( !isset($pag_sql) )
937
+ $total_member_count = count($members);
938
+ else
939
+ $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 ) );
940
+
941
+ return array( 'members' => $members, 'count' => $total_member_count );
942
+ }
943
+
944
+ function delete_all_for_user( $user_id ) {
945
+ global $wpdb, $bp;
946
+
947
+ return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d", $user_id ) );
948
+ }
949
+ }
950
+
951
+ ?>
bp-groups/bp-groups-cssjs.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**************************************************************************
3
+ groups_add_js()
4
+
5
+ Inserts the Javascript needed for managing groups.
6
+ **************************************************************************/
7
+
8
+ function groups_add_js() {
9
+ global $bp;
10
+
11
+ if ( $bp->current_component == $bp->groups->slug )
12
+ wp_enqueue_script( 'bp-groups-js', BP_PLUGIN_URL . '/bp-groups/js/general.js' );
13
+ }
14
+ add_action( 'template_redirect', 'groups_add_js', 1 );
15
+
16
+ function groups_add_structure_css() {
17
+ /* Enqueue the structure CSS file to give basic positional formatting for components */
18
+ wp_enqueue_style( 'bp-groups-structure', BP_PLUGIN_URL . '/bp-groups/css/structure.css' );
19
+ }
20
+ add_action( 'bp_styles', 'groups_add_structure_css' );
21
+
22
+ function groups_add_cropper_js() {
23
+ global $bp, $create_group_step;
24
+
25
+ if ( 3 == (int)$create_group_step || ( $bp->current_component == $bp->groups->slug && $bp->action_variables[0] == 'group-avatar' ) ) {
26
+ wp_enqueue_script('jquery');
27
+ wp_enqueue_script('prototype');
28
+ wp_enqueue_script('scriptaculous-root');
29
+ wp_enqueue_script('cropper');
30
+ add_action( 'wp_head', 'bp_core_add_cropper_js' );
31
+ }
32
+ }
33
+ add_action( 'template_redirect', 'groups_add_cropper_js', 1 );
34
+
35
+
36
+ ?>
bp-groups/bp-groups-filters.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /* Apply WordPress defined filters */
4
+ add_filter( 'bp_get_group_description', 'wptexturize' );
5
+ add_filter( 'bp_get_group_description_excerpt', 'wptexturize' );
6
+ add_filter( 'bp_get_the_site_group_description', 'wptexturize' );
7
+ add_filter( 'bp_get_the_site_group_description_excerpt', 'wptexturize' );
8
+ add_filter( 'bp_get_group_news', 'wptexturize' );
9
+ add_filter( 'bp_get_group_name', 'wptexturize' );
10
+ add_filter( 'bp_get_the_site_group_name', 'wptexturize' );
11
+
12
+ add_filter( 'bp_get_group_description', 'convert_smilies' );
13
+ add_filter( 'bp_get_group_description_excerpt', 'convert_smilies' );
14
+ add_filter( 'bp_get_group_news', 'convert_smilies' );
15
+ add_filter( 'bp_get_the_site_group_description', 'convert_smilies' );
16
+ add_filter( 'bp_get_the_site_group_description_excerpt', 'convert_smilies' );
17
+
18
+ add_filter( 'bp_get_group_description', 'convert_chars' );
19
+ add_filter( 'bp_get_group_description_excerpt', 'convert_chars' );
20
+ add_filter( 'bp_get_group_news', 'convert_chars' );
21
+ add_filter( 'bp_get_group_name', 'convert_chars' );
22
+ add_filter( 'bp_get_the_site_group_name', 'convert_chars' );
23
+ add_filter( 'bp_get_the_site_group_description', 'convert_chars' );
24
+ add_filter( 'bp_get_the_site_group_description_excerpt', 'convert_chars' );
25
+
26
+ add_filter( 'bp_get_group_description', 'wpautop' );
27
+ add_filter( 'bp_get_group_description_excerpt', 'wpautop' );
28
+ add_filter( 'bp_get_group_news', 'wpautop' );
29
+ add_filter( 'bp_get_the_site_group_description', 'wpautop' );
30
+ add_filter( 'bp_get_the_site_group_description_excerpt', 'wpautop' );
31
+
32
+ add_filter( 'bp_get_group_description', 'make_clickable' );
33
+ add_filter( 'bp_get_group_description_excerpt', 'make_clickable' );
34
+ add_filter( 'bp_get_group_news', 'make_clickable' );
35
+
36
+ add_filter( 'bp_get_group_name', 'wp_filter_kses', 1 );
37
+ add_filter( 'bp_get_group_description', 'wp_filter_kses', 1 );
38
+ add_filter( 'bp_get_group_description_excerpt', 'wp_filter_kses', 1 );
39
+ add_filter( 'bp_get_group_news', 'wp_filter_kses', 1 );
40
+ add_filter( 'bp_get_the_site_group_name', 'wp_filter_kses', 1 );
41
+ add_filter( 'bp_get_the_site_group_description', 'wp_filter_kses', 1 );
42
+ add_filter( 'bp_get_the_site_group_description_excerpt', 'wp_filter_kses', 1 );
43
+ add_filter( 'groups_details_name_pre_save', 'wp_filter_kses', 1 );
44
+ add_filter( 'groups_details_description_pre_save', 'wp_filter_kses', 1 );
45
+ add_filter( 'groups_details_news_pre_save', 'wp_filter_kses', 1 );
46
+
47
+ add_filter( 'bp_get_group_description', 'stripslashes' );
48
+ add_filter( 'bp_get_group_description_excerpt', 'stripslashes' );
49
+ add_filter( 'bp_get_group_news', 'stripslashes' );
50
+ add_filter( 'bp_get_group_name', 'stripslashes' );
51
+
52
+ add_filter( 'groups_new_group_forum_desc', 'bp_create_excerpt' );
53
+
54
+ ?>
bp-groups/bp-groups-notifications.php ADDED
@@ -0,0 +1,271 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
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_fetch_user_fullname( $wire_post->user_id, false );
13
+ $poster_ud = get_userdata( $wire_post->user_id );
14
+ $poster_profile_link = site_url() . '/' . BP_MEMBERS_SLUG . '/' . $poster_ud->user_login;
15
+
16
+ $subject = '[' . get_blog_option( 1, 'blogname' ) . '] ' . sprintf( __( 'New wire post on group: %s', 'buddypress' ), stripslashes($group->name) );
17
+
18
+ foreach ( $group->user_dataset as $user ) {
19
+ if ( 'no' == get_usermeta( $user->user_id, 'notification_groups_wire_post' ) ) continue;
20
+
21
+ $ud = get_userdata( $user->user_id );
22
+
23
+ // Set up and send the message
24
+ $to = $ud->user_email;
25
+
26
+ $wire_link = site_url() . '/' . $bp->groups->slug . '/' . $group->slug . '/wire';
27
+ $group_link = site_url() . '/' . $bp->groups->slug . '/' . $group->slug;
28
+ $settings_link = site_url() . '/' . BP_MEMBERS_SLUG . '/' . $ud->user_login . '/settings/notifications';
29
+
30
+ $message = sprintf( __(
31
+ '%s posted on the wire of the group "%s":
32
+
33
+ "%s"
34
+
35
+ To view the group wire: %s
36
+
37
+ To view the group home: %s
38
+
39
+ To view %s\'s profile page: %s
40
+
41
+ ---------------------
42
+ ', 'buddypress' ), $poster_name, stripslashes($group->name), stripslashes($wire_post->content), $wire_link, $group_link, $poster_name, $poster_profile_link );
43
+
44
+ $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
45
+
46
+ // Send it
47
+ wp_mail( $to, $subject, $message );
48
+
49
+ unset( $message, $to );
50
+ }
51
+ }
52
+ add_action( 'groups_new_wire_post', 'groups_notification_new_wire_post', 10, 2 );
53
+
54
+
55
+ function groups_notification_group_updated( $group_id ) {
56
+ global $bp;
57
+
58
+ $group = new BP_Groups_Group( $group_id, false, true );
59
+ $subject = '[' . get_blog_option( 1, 'blogname' ) . '] ' . __( 'Group Details Updated', 'buddypress' );
60
+
61
+ foreach ( $group->user_dataset as $user ) {
62
+ if ( 'no' == get_usermeta( $user->user_id, 'notification_groups_group_updated' ) ) continue;
63
+
64
+ $ud = get_userdata( $user->user_id );
65
+
66
+ // Set up and send the message
67
+ $to = $ud->user_email;
68
+
69
+ $group_link = site_url() . '/' . $bp->groups->slug . '/' . $group->slug;
70
+ $settings_link = site_url() . '/' . BP_MEMBERS_SLUG . '/' . $ud->user_login . '/settings/notifications';
71
+
72
+ $message = sprintf( __(
73
+ 'Group details for the group "%s" were updated:
74
+
75
+ To view the group: %s
76
+
77
+ ---------------------
78
+ ', 'buddypress' ), stripslashes($group->name), $group_link );
79
+
80
+ $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
81
+
82
+ // Send it
83
+ wp_mail( $to, $subject, $message );
84
+
85
+ unset( $message, $to );
86
+ }
87
+ }
88
+
89
+ function groups_notification_new_membership_request( $requesting_user_id, $admin_id, $group_id, $membership_id ) {
90
+ global $bp;
91
+
92
+ bp_core_add_notification( $requesting_user_id, $admin_id, 'groups', 'new_membership_request', $group_id );
93
+
94
+ if ( 'no' == get_usermeta( $admin_id, 'notification_groups_membership_request' ) )
95
+ return false;
96
+
97
+ $requesting_user_name = bp_fetch_user_fullname( $requesting_user_id, false );
98
+ $group = new BP_Groups_Group( $group_id, false, false );
99
+
100
+ $ud = get_userdata($admin_id);
101
+ $requesting_ud = get_userdata($requesting_user_id);
102
+
103
+ $group_request_accept = wp_nonce_url( bp_get_group_permalink( $group ) . '/admin/membership-requests/accept/' . $membership_id, 'groups_accept_membership_request' );
104
+ $group_request_reject = wp_nonce_url( bp_get_group_permalink( $group ) . '/admin/membership-requests/reject/' . $membership_id, 'groups_reject_membership_request' );
105
+ $profile_link = site_url() . '/' . BP_MEMBERS_SLUG . '/' . $requesting_ud->user_login . '/profile';
106
+ $settings_link = site_url() . '/' . BP_MEMBERS_SLUG . '/' . $ud->user_login . '/settings/notifications';
107
+
108
+ // Set up and send the message
109
+ $to = $ud->user_email;
110
+ $subject = '[' . get_blog_option( 1, 'blogname' ) . '] ' . sprintf( __( 'Membership request for group: %s', 'buddypress' ), stripslashes($group->name) );
111
+
112
+ $message = sprintf( __(
113
+ '%s wants to join the group "%s".
114
+
115
+ Because you are the administrator of this group, you must either accept or reject the membership request.
116
+
117
+ To accept the membership request: %s
118
+
119
+ To reject the membership request: %s
120
+
121
+ To view %s\'s profile: %s
122
+
123
+ ---------------------
124
+ ', 'buddypress' ), $requesting_user_name, stripslashes($group->name), $group_request_accept, $group_request_reject, $requesting_user_name, $profile_link );
125
+
126
+ $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
127
+
128
+ // Send it
129
+ wp_mail( $to, $subject, $message );
130
+ }
131
+
132
+ function groups_notification_membership_request_completed( $requesting_user_id, $group_id, $accepted = true ) {
133
+ global $bp;
134
+
135
+ // Post a screen notification first.
136
+ if ( $accepted )
137
+ bp_core_add_notification( $group_id, $requesting_user_id, 'groups', 'membership_request_accepted' );
138
+ else
139
+ bp_core_add_notification( $group_id, $requesting_user_id, 'groups', 'membership_request_rejected' );
140
+
141
+ if ( 'no' == get_usermeta( $requesting_user_id, 'notification_membership_request_completed' ) )
142
+ return false;
143
+
144
+ $group = new BP_Groups_Group( $group_id, false, false );
145
+
146
+ $ud = get_userdata($requesting_user_id);
147
+
148
+ $group_link = bp_get_group_permalink( $group );
149
+ $settings_link = site_url() . '/' . BP_MEMBERS_SLUG . '/' . $ud->user_login . '/settings/notifications';
150
+
151
+ // Set up and send the message
152
+ $to = $ud->user_email;
153
+
154
+ if ( $accepted ) {
155
+ $subject = '[' . get_blog_option( 1, 'blogname' ) . '] ' . sprintf( __( 'Membership request for group "%s" accepted', 'buddypress' ), stripslashes($group->name) );
156
+ $message = sprintf( __(
157
+ 'Your membership request for the group "%s" has been accepted.
158
+
159
+ To view the group please login and visit: %s
160
+
161
+ ---------------------
162
+ ', 'buddypress' ), stripslashes($group->name), $group_link );
163
+
164
+ } else {
165
+ $subject = '[' . get_blog_option( 1, 'blogname' ) . '] ' . sprintf( __( 'Membership request for group "%s" rejected', 'buddypress' ), stripslashes($group->name) );
166
+ $message = sprintf( __(
167
+ 'Your membership request for the group "%s" has been rejected.
168
+
169
+ To submit another request please log in and visit: %s
170
+
171
+ ---------------------
172
+ ', 'buddypress' ), stripslashes($group->name), $group_link );
173
+ }
174
+
175
+ $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
176
+
177
+ // Send it
178
+ wp_mail( $to, $subject, $message );
179
+ }
180
+
181
+ function groups_notification_promoted_member( $user_id, $group_id ) {
182
+ global $bp;
183
+
184
+ if ( groups_is_user_admin( $user_id, $group_id ) ) {
185
+ $promoted_to = __( 'an administrator', 'buddypress' );
186
+ $type = 'member_promoted_to_admin';
187
+ } else {
188
+ $promoted_to = __( 'a moderator', 'buddypress' );
189
+ $type = 'member_promoted_to_mod';
190
+ }
191
+
192
+ // Post a screen notification first.
193
+ bp_core_add_notification( $group_id, $user_id, 'groups', $type );
194
+
195
+ if ( 'no' == get_usermeta( $user_id, 'notification_groups_admin_promotion' ) )
196
+ return false;
197
+
198
+ $group = new BP_Groups_Group( $group_id, false, false );
199
+ $ud = get_userdata($user_id);
200
+
201
+ $group_link = bp_get_group_permalink( $group );
202
+ $settings_link = site_url() . '/' . BP_MEMBERS_SLUG . '/' . $ud->user_login . '/settings/notifications';
203
+
204
+ // Set up and send the message
205
+ $to = $ud->user_email;
206
+
207
+ $subject = '[' . get_blog_option( 1, 'blogname' ) . '] ' . sprintf( __( 'You have been promoted in the group: "%s"', 'buddypress' ), stripslashes($group->name) );
208
+
209
+ $message = sprintf( __(
210
+ 'You have been promoted to %s for the group: "%s".
211
+
212
+ To view the group please visit: %s
213
+
214
+ ---------------------
215
+ ', 'buddypress' ), $promoted_to, stripslashes($group->name), $group_link );
216
+
217
+ $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
218
+
219
+ // Send it
220
+ wp_mail( $to, $subject, $message );
221
+ }
222
+ add_action( 'groups_promoted_member', 'groups_notification_promoted_member', 10, 2 );
223
+
224
+ function groups_notification_group_invites( &$group, &$member, $inviter_user_id ) {
225
+ global $bp;
226
+
227
+ $inviter_ud = get_userdata($inviter_user_id);
228
+ $inviter_name = bp_core_get_userlink( $inviter_user_id, true, false, true );
229
+ $inviter_link = site_url() . '/' . BP_MEMBERS_SLUG . '/' . $inviter_ud->user_login;
230
+
231
+ $group_link = bp_get_group_permalink( $group );
232
+
233
+ if ( !$member->invite_sent ) {
234
+ $invited_user_id = $member->user_id;
235
+
236
+ // Post a screen notification first.
237
+ bp_core_add_notification( $group->id, $invited_user_id, 'groups', 'group_invite' );
238
+
239
+ if ( 'no' == get_usermeta( $invited_user_id, 'notification_groups_invite' ) )
240
+ return false;
241
+
242
+ $invited_ud = get_userdata($invited_user_id);
243
+ $settings_link = site_url() . '/' . BP_MEMBERS_SLUG . '/' . $invited_ud->user_login . '/settings/notifications';
244
+ $invited_link = site_url() . '/' . BP_MEMBERS_SLUG . '/' . $invited_ud->user_login;
245
+ $invites_link = $invited_link . '/' . $bp->groups->slug . '/invites';
246
+
247
+ // Set up and send the message
248
+ $to = $invited_ud->user_email;
249
+
250
+ $subject = '[' . get_blog_option( 1, 'blogname' ) . '] ' . sprintf( __( 'You have an invitation to the group: "%s"', 'buddypress' ), stripslashes($group->name) );
251
+
252
+ $message = sprintf( __(
253
+ 'One of your friends %s has invited you to the group: "%s".
254
+
255
+ To view your group invites visit: %s
256
+
257
+ To view the group visit: %s
258
+
259
+ To view %s\'s profile visit: %s
260
+
261
+ ---------------------
262
+ ', 'buddypress' ), $inviter_name, stripslashes($group->name), $invites_link, $group_link, $inviter_name, $inviter_link );
263
+
264
+ $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
265
+
266
+ // Send it
267
+ wp_mail( $to, $subject, $message );
268
+ }
269
+ }
270
+
271
+ ?>
bp-groups/bp-groups-templatetags.php ADDED
@@ -0,0 +1,2361 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function bp_groups_header_tabs() {
4
+ global $bp, $create_group_step, $completed_to_step;
5
+ ?>
6
+ <li<?php if ( !isset($bp->action_variables[0]) || 'recently-active' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/recently-active"><?php _e( 'Recently Active', 'buddypress' ) ?></a></li>
7
+ <li<?php if ( 'recently-joined' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/recently-joined"><?php _e( 'Recently Joined', 'buddypress' ) ?></a></li>
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
+
13
+ <?php
14
+ do_action( 'groups_header_tabs' );
15
+ }
16
+
17
+ function bp_group_creation_tabs() {
18
+ global $bp, $create_group_step, $completed_to_step;
19
+ ?>
20
+ <li<?php if ( 1 == (int)$create_group_step ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/create/step/1">1. <?php _e('Group Details', 'buddypress') ?></a></li>
21
+ <li<?php if ( 2 == (int)$create_group_step ) : ?> class="current"<?php endif; ?>><?php if ( $completed_to_step > 0 ) { ?><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/create/step/2">2. <?php _e('Group Settings', 'buddypress') ?></a><?php } else { ?><span>2. <?php _e('Group Settings', 'buddypress') ?></span><?php } ?></li>
22
+ <li<?php if ( 3 == (int)$create_group_step ) : ?> class="current"<?php endif; ?>><?php if ( $completed_to_step > 1 ) { ?><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/create/step/3">3. <?php _e('Group Avatar', 'buddypress') ?></a><?php } else { ?><span>3. <?php _e('Group Avatar', 'buddypress') ?></span><?php } ?></li>
23
+ <li<?php if ( 4 == (int)$create_group_step ) : ?> class="current"<?php endif; ?>><?php if ( $completed_to_step > 2 ) { ?><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/create/step/4">4. <?php _e('Invite Members', 'buddypress') ?></a><?php } else { ?><span>4. <?php _e('Invite Members', 'buddypress') ?></span><?php } ?></li>
24
+ <?php
25
+ do_action( 'groups_creation_tabs' );
26
+ }
27
+
28
+ function bp_group_creation_stage_title() {
29
+ global $create_group_step;
30
+
31
+ switch( (int) $create_group_step ) {
32
+ case 1:
33
+ echo '<span>&mdash; ' . __('Group Details', 'buddypress') . '</span>';
34
+ break;
35
+
36
+ case 2:
37
+ echo '<span>&mdash; ' . __('Group Settings', 'buddypress') . '</span>';
38
+ break;
39
+
40
+ case 3:
41
+ echo '<span>&mdash; ' . __('Group Avatar', 'buddypress') . '</span>';
42
+ break;
43
+
44
+ case 4:
45
+ echo '<span>&mdash; ' . __('Invite Members', 'buddypress') . '</span>';
46
+ break;
47
+ }
48
+ }
49
+
50
+ function bp_group_create_form() {
51
+ global $bp, $create_group_step, $completed_to_step;
52
+ global $group_obj, $invites;
53
+
54
+ ?>
55
+ <form action="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/create/step/<?php echo $create_group_step ?>" method="post" id="create-group-form" class="standard-form" enctype="multipart/form-data">
56
+ <?php switch( (int) $create_group_step ) {
57
+ case 1: ?>
58
+ <label for="group-name">* <?php _e('Group Name', 'buddypress') ?></label>
59
+ <input type="text" name="group-name" id="group-name" value="<?php echo ( $group_obj ) ? $group_obj->name : $_POST['group-name']; ?>" />
60
+
61
+ <label for="group-desc">* <?php _e('Group Description', 'buddypress') ?></label>
62
+ <textarea name="group-desc" id="group-desc"><?php echo ( $group_obj ) ? $group_obj->description : $_POST['group-desc']; ?></textarea>
63
+
64
+ <label for="group-news"><?php _e('Recent News', 'buddypress') ?></label>
65
+ <textarea name="group-news" id="group-news"><?php echo ( $group_obj ) ? $group_obj->news : $_POST['group-news']; ?></textarea>
66
+
67
+ <?php do_action( 'groups_custom_group_fields_editable' ) ?>
68
+
69
+ <p><input type="submit" value="<?php _e('Create Group and Continue', 'buddypress') ?> &raquo;" id="save" name="save"/></p>
70
+
71
+ <?php wp_nonce_field( 'groups_step1_save' ) ?>
72
+ <?php break; ?>
73
+
74
+ <?php case 2: ?>
75
+ <?php if ( $completed_to_step > 0 ) { ?>
76
+ <?php if ( function_exists('bp_wire_install') ) : ?>
77
+ <div class="checkbox">
78
+ <label><input type="checkbox" name="group-show-wire" id="group-show-wire" value="1"<?php if ( $group_obj->enable_wire ) { ?> checked="checked"<?php } ?> /> <?php _e('Enable comment wire', 'buddypress') ?></label>
79
+ </div>
80
+ <?php endif; ?>
81
+
82
+ <?php if ( function_exists('bp_forums_setup') ) : ?>
83
+ <?php if ( bp_forums_is_installed_correctly() ) { ?>
84
+ <div class="checkbox">
85
+ <label><input type="checkbox" name="group-show-forum" id="group-show-forum" value="1"<?php if ( $group_obj->enable_forum ) { ?> checked="checked"<?php } ?> /> <?php _e('Enable discussion forum', 'buddypress') ?></label>
86
+ </div>
87
+ <?php } else {
88
+ if ( is_site_admin() ) {
89
+ ?>
90
+ <div class="checkbox">
91
+ <label><input type="checkbox" disabled="disabled" name="disabled" id="disabled" value="0" /> <?php printf( __('<strong>Attention Site Admin:</strong> Group forums require the <a href="%s">correct setup and configuration</a> of a bbPress installation.', 'buddypress' ), $bp->root_domain . '/wp-admin/admin.php?page=' . BP_PLUGIN_DIR . '/bp-forums/bp-forums-admin.php' ) ?></label>
92
+ </div>
93
+ <?php
94
+ }
95
+ }?>
96
+ <?php endif; ?>
97
+
98
+ <?php if ( function_exists('bp_albums_install') ) : ?>
99
+ <div class="checkbox with-suboptions">
100
+ <label><input type="checkbox" name="group-show-photos" id="group-show-photos" value="1"<?php if ( $group_obj->enable_photos ) { ?> checked="checked"<?php } ?> /> <?php _e('Enable photo gallery', 'buddypress') ?></label>
101
+ <div class="sub-options"<?php if ( !$group_obj->enable_photos ) { ?> style="display: none;"<?php } ?>>
102
+ <label><input type="radio" name="group-photos-status" value="all"<?php if ( !$group_obj->photos_admin_only ) { ?> checked="checked"<?php } ?> /> <?php _e('All members can upload photos', 'buddypress') ?></label>
103
+ <label><input type="radio" name="group-photos-status" value="admins"<?php if ( $group_obj->photos_admin_only ) { ?> checked="checked"<?php } ?> /> <?php _e('Only group admins can upload photos', 'buddypress') ?></label>
104
+ </div>
105
+ </div>
106
+ <?php endif; ?>
107
+
108
+ <h3><?php _e( 'Privacy Options', 'buddypress' ); ?></h3>
109
+
110
+ <div class="radio">
111
+ <label><input type="radio" name="group-status" value="public"<?php if ( 'public' == $group_obj->status ) { ?> checked="checked"<?php } ?> />
112
+ <strong><?php _e( 'This is a public group', 'buddypress' ) ?></strong>
113
+ <ul>
114
+ <li><?php _e( 'Any site member can join this group.', 'buddypress' ) ?></li>
115
+ <li><?php _e( 'This group will be listed in the groups directory and in search results.', 'buddypress' ) ?></li>
116
+ <li><?php _e( 'Group content and activity will be visible to any site member.', 'buddypress' ) ?></li>
117
+ </ul>
118
+ </label>
119
+
120
+ <label><input type="radio" name="group-status" value="private"<?php if ( 'private' == $group_obj->status ) { ?> checked="checked"<?php } ?> />
121
+ <strong><?php _e( 'This is a private group', 'buddypress' ) ?></strong>
122
+ <ul>
123
+ <li><?php _e( 'Only users who request membership and are accepted can join the group.', 'buddypress' ) ?></li>
124
+ <li><?php _e( 'This group will be listed in the groups directory and in search results.', 'buddypress' ) ?></li>
125
+ <li><?php _e( 'Group content and activity will only be visible to members of the group.', 'buddypress' ) ?></li>
126
+ </ul>
127
+ </label>
128
+
129
+ <label><input type="radio" name="group-status" value="hidden"<?php if ( 'hidden' == $group_obj->status ) { ?> checked="checked"<?php } ?> />
130
+ <strong><?php _e('This is a hidden group', 'buddypress') ?></strong>
131
+ <ul>
132
+ <li><?php _e( 'Only users who are invited can join the group.', 'buddypress' ) ?></li>
133
+ <li><?php _e( 'This group will not be listed in the groups directory or search results.', 'buddypress' ) ?></li>
134
+ <li><?php _e( 'Group content and activity will only be visible to members of the group.', 'buddypress' ) ?></li>
135
+ </ul>
136
+ </label>
137
+ </div>
138
+
139
+ <p><input type="submit" value="<?php _e('Save and Continue', 'buddypress') ?> &raquo;" id="save" name="save"/></p>
140
+
141
+ <?php wp_nonce_field( 'groups_step2_save' ) ?>
142
+ <?php } else { ?>
143
+ <div id="message" class="info">
144
+ <p><?php _e('Please complete all previous steps first.', 'buddypress'); ?></p>
145
+ </div>
146
+ <?php } ?>
147
+ <?php break; ?>
148
+
149
+ <?php case 3: ?>
150
+ <?php if ( $completed_to_step > 1 ) { ?>
151
+ <div class="left-menu">
152
+ <?php bp_group_current_avatar() ?>
153
+ </div>
154
+
155
+ <div class="main-column">
156
+ <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>
157
+
158
+ <?php
159
+ if ( !empty($_FILES) || ( isset($_POST['orig']) && isset($_POST['canvas']) ) ) {
160
+ groups_avatar_upload($_FILES);
161
+ } else {
162
+ bp_core_render_avatar_upload_form( '', true );
163
+ }
164
+ ?>
165
+
166
+ <div id="skip-continue">
167
+ <input type="submit" value="<?php _e('Skip', 'buddypress') ?> &raquo;" id="skip" name="skip"/>
168
+ </div>
169
+ </div>
170
+
171
+ <?php wp_nonce_field( 'groups_step3_save' ) ?>
172
+ <?php } else { ?>
173
+ <div id="message" class="info">
174
+ <p><?php _e('Please complete all previous steps first.', 'buddypress'); ?></p>
175
+ </div>
176
+ <?php } ?>
177
+ <?php break; ?>
178
+ <?php case 4: ?>
179
+ <?php
180
+ if ( $completed_to_step > 2 ) {
181
+ $group_link = bp_get_group_permalink( $group_obj );
182
+
183
+ if ( function_exists('friends_install') ) {
184
+ if ( friends_get_friend_count_for_user( $bp->loggedin_user->id ) ) {
185
+ bp_group_send_invite_form( $group_obj );
186
+ } else {
187
+ ?>
188
+ <div id="message" class="info">
189
+ <p><?php _e( 'Once you build up your friends list you will be able to invite friends to join your group.', 'buddypress' ) ?></p>
190
+ </div>
191
+ <?php
192
+ }
193
+ } ?>
194
+
195
+ <p class="clear"><input type="submit" value="<?php _e('Finish', 'buddypress') ?> &raquo;" id="save" name="save" /></p>
196
+
197
+ <?php wp_nonce_field( 'groups_step4_save' ) ?>
198
+
199
+ <?php
200
+ } else { ?>
201
+ <div id="message" class="info">
202
+ <p><?php _e('Please complete all previous steps first.', 'buddypress'); ?></p>
203
+ </div>
204
+ <?php } ?>
205
+ <?php break; ?>
206
+ <?php } ?>
207
+ </form>
208
+ <?php
209
+ }
210
+ function bp_group_list_invite_friends() {
211
+ global $bp, $group_obj, $invites;
212
+
213
+ if ( !function_exists('friends_install') )
214
+ return false;
215
+
216
+ $friends = friends_get_friends_invite_list( $bp->loggedin_user->id, $group_obj->id );
217
+
218
+ if ( $friends ) {
219
+ $invites = groups_get_invites_for_group( $bp->loggedin_user->id, $group_obj->id );
220
+
221
+ ?>
222
+ <div id="invite-list">
223
+ <ul>
224
+ <?php
225
+ for ( $i = 0; $i < count( $friends ); $i++ ) {
226
+ if ( $invites ) {
227
+ if ( in_array( $friends[$i]['id'], $invites ) ) {
228
+ $checked = ' checked="checked"';
229
+ } else {
230
+ $checked = '';
231
+ }
232
+ }
233
+ ?>
234
+
235
+ <li><input<?php echo $checked ?> type="checkbox" name="friends[]" id="f-<?php echo $friends[$i]['id'] ?>" value="<?php echo $friends[$i]['id'] ?>" /> <?php echo $friends[$i]['full_name']; ?></li>
236
+ <?php } ?>
237
+ </ul>
238
+ </div>
239
+ <?php
240
+ } else {
241
+ _e( 'No friends to invite.', 'buddypress' );
242
+ }
243
+ }
244
+
245
+ function bp_groups_filter_title() {
246
+ global $bp;
247
+
248
+ $current_filter = $bp->action_variables[0];
249
+
250
+ switch ( $current_filter ) {
251
+ case 'recently-active': default:
252
+ _e( 'Recently Active', 'buddypress' );
253
+ break;
254
+ case 'recently-joined':
255
+ _e( 'Recently Joined', 'buddypress' );
256
+ break;
257
+ case 'most-popular':
258
+ _e( 'Most Popular', 'buddypress' );
259
+ break;
260
+ case 'admin-of':
261
+ _e( 'Administrator Of', 'buddypress' );
262
+ break;
263
+ case 'mod-of':
264
+ _e( 'Moderator Of', 'buddypress' );
265
+ break;
266
+ case 'alphabetically':
267
+ _e( 'Alphabetically', 'buddypress' );
268
+ break;
269
+ }
270
+ }
271
+
272
+ function bp_group_current_avatar() {
273
+ global $group_obj;
274
+
275
+ if ( $group_obj->avatar_full ) { ?>
276
+ <img src="<?php echo $group_obj->avatar_full ?>" alt="<?php _e( 'Group Avatar', 'buddypress' ) ?>" class="avatar" />
277
+ <?php } else { ?>
278
+ <img src="<?php echo $bp->groups->image_base . '/none.gif' ?>" alt="<?php _e( 'No Group Avatar', 'buddypress' ) ?>" class="avatar" />
279
+ <?php }
280
+ }
281
+
282
+ function bp_group_avatar_edit_form() {
283
+ if ( !empty($_FILES) || ( isset($_POST['orig']) && isset($_POST['canvas']) ) ) {
284
+ groups_avatar_upload($_FILES);
285
+ } else {
286
+ bp_core_render_avatar_upload_form( '', true );
287
+ }
288
+ }
289
+
290
+ function bp_groups_random_selection( $total_groups = 5 ) {
291
+ global $bp;
292
+
293
+ if ( !$group_ids = wp_cache_get( 'groups_random_groups', 'bp' ) ) {
294
+ $group_ids = BP_Groups_Group::get_random( $total_groups, 1 );
295
+ wp_cache_set( 'groups_random_groups', $group_ids, 'bp' );
296
+ }
297
+ ?>
298
+ <?php if ( $group_ids['groups'] ) { ?>
299
+ <ul class="item-list" id="random-groups-list">
300
+ <?php
301
+ for ( $i = 0; $i < count( $group_ids['groups'] ); $i++ ) {
302
+ if ( !$group = wp_cache_get( 'groups_group_nouserdata_' . $group_ids['groups'][$i]->group_id, 'bp' ) ) {
303
+ $group = new BP_Groups_Group( $group_ids['groups'][$i]->group_id, false, false );
304
+ wp_cache_set( 'groups_group_nouserdata_' . $group_ids['groups'][$i]->group_id, $group, 'bp' );
305
+ }
306
+ ?>
307
+ <li>
308
+ <div class="item-avatar">
309
+ <a href="<?php echo bp_get_group_permalink( $group ) ?>" title="<?php echo $group->name ?>"><img src="<?php echo $group->avatar_thumb ?>" class="avatar" alt="<?php printf( __( '%s Avatar', 'buddypress' ), $group->name ) ?>" /></a>
310
+ </div>
311
+
312
+ <div class="item">
313
+ <div class="item-title"><a href="<?php echo bp_get_group_permalink( $group ) ?>" title="<?php echo $group->name ?>"><?php echo $group->name ?></a></div>
314
+ <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>
315
+ <div class="item-meta desc"><?php echo bp_create_excerpt( $group->description ) ?></div>
316
+ </div>
317
+
318
+ <div class="action">
319
+ <?php bp_group_join_button( $group ) ?>
320
+ <div class="meta">
321
+ <?php $member_count = groups_get_groupmeta( $group->id, 'total_member_count' ) ?>
322
+ <?php echo ucwords($group->status) ?> <?php _e( 'Group', 'buddypress' ) ?> /
323
+ <?php if ( 1 == $member_count ) : ?>
324
+ <?php printf( __( '%d member', 'buddypress' ), $member_count ) ?>
325
+ <?php else : ?>
326
+ <?php printf( __( '%d members', 'buddypress' ), $member_count ) ?>
327
+ <?php endif; ?>
328
+ </div>
329
+ </div>
330
+
331
+ <div class="clear"></div>
332
+ </li>
333
+ <?php } ?>
334
+ </ul>
335
+ <?php } else { ?>
336
+ <div id="message" class="info">
337
+ <p><?php _e( "There aren't enough groups to show a random sample just yet.", 'buddypress' ) ?></p>
338
+ </div>
339
+ <?php } ?>
340
+ <?php
341
+ }
342
+
343
+ function bp_groups_random_groups( $total_groups = 5 ) {
344
+ global $bp;
345
+
346
+ if ( !$group_ids = wp_cache_get( 'groups_random_user_groups_' . $bp->displayed_user->id . '_' . $total_groups, 'bp' ) ) {
347
+ $group_ids = groups_get_random_groups_for_user( $bp->displayed_user->id, $total_groups, 1 );
348
+ wp_cache_set( 'groups_random_user_groups_' . $bp->displayed_user->id . '_' . $total_groups, $group_ids, 'bp' );
349
+ }
350
+
351
+ ?>
352
+ <div class="info-group">
353
+ <h4><?php bp_word_or_name( __( "My Groups", 'buddypress' ), __( "%s's Groups", 'buddypress' ) ) ?> (<?php echo BP_Groups_Member::total_group_count() ?>) <a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>"><?php _e('See All', 'buddypress') ?> &raquo;</a></h4>
354
+ <?php if ( $group_ids ) { ?>
355
+ <ul class="horiz-gallery">
356
+ <?php
357
+ for ( $i = 0; $i < count( $group_ids ); $i++ ) {
358
+ if ( !$group = wp_cache_get( 'groups_group_nouserdata_' . $group_ids[$i], 'bp' ) ) {
359
+ $group = new BP_Groups_Group( $group_ids[$i], false, false );
360
+ wp_cache_set( 'groups_group_nouserdata_' . $group_ids[$i], $group, 'bp' );
361
+ }
362
+ ?> <li>
363
+ <a href="<?php echo bp_get_group_permalink( $group ) ?>"><img src="<?php echo $group->avatar_thumb; ?>" class="avatar" alt="<?php _e( 'Group Avatar', 'buddypress' ) ?>" /></a>
364
+ <h5><a href="<?php echo bp_get_group_permalink( $group ) ?>"><?php echo $group->name ?></a></h5>
365
+ </li>
366
+ <?php } ?>
367
+ </ul>
368
+ <?php } else { ?>
369
+ <div id="message" class="info">
370
+ <p><?php bp_word_or_name( __( "You haven't joined any groups yet.", 'buddypress' ), __( "%s hasn't joined any groups yet.", 'buddypress' ) ) ?></p>
371
+ </div>
372
+ <?php } ?>
373
+ <div class="clear"></div>
374
+ </div>
375
+ <?php
376
+ }
377
+
378
+ function bp_custom_group_boxes() {
379
+ do_action( 'groups_custom_group_boxes' );
380
+ }
381
+
382
+ function bp_custom_group_admin_tabs() {
383
+ do_action( 'groups_custom_group_admin_tabs' );
384
+ }
385
+
386
+ function bp_custom_group_fields_editable() {
387
+ do_action( 'groups_custom_group_fields_editable' );
388
+ }
389
+
390
+ function bp_custom_group_fields() {
391
+ do_action( 'groups_custom_group_fields' );
392
+ }
393
+
394
+
395
+ /*****************************************************************************
396
+ * User Groups Template Class/Tags
397
+ **/
398
+
399
+ class BP_Groups_User_Groups_Template {
400
+ var $current_group = -1;
401
+ var $group_count;
402
+ var $groups;
403
+ var $group;
404
+
405
+ var $in_the_loop;
406
+
407
+ var $pag_page;
408
+ var $pag_num;
409
+ var $pag_links;
410
+ var $total_group_count;
411
+
412
+ var $single_group = false;
413
+
414
+ var $sort_by;
415
+ var $order;
416
+
417
+ function bp_groups_user_groups_template( $user_id, $type, $per_page, $max, $slug, $filter ) {
418
+ global $bp;
419
+
420
+ if ( !$user_id )
421
+ $user_id = $bp->displayed_user->id;
422
+
423
+ $this->pag_page = isset( $_REQUEST['grpage'] ) ? intval( $_REQUEST['grpage'] ) : 1;
424
+ $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
425
+
426
+ switch ( $type ) {
427
+ case 'recently-joined':
428
+ $this->groups = groups_get_recently_joined_for_user( $user_id, $this->pag_num, $this->pag_page, $filter );
429
+ break;
430
+
431
+ case 'popular':
432
+ $this->groups = groups_get_most_popular_for_user( $user_id, $this->pag_num, $this->pag_page, $filter );
433
+ break;
434
+
435
+ case 'admin-of':
436
+ $this->groups = groups_get_user_is_admin_of( $user_id, $this->pag_num, $this->pag_page, $filter );
437
+ break;
438
+
439
+ case 'mod-of':
440
+ $this->groups = groups_get_user_is_mod_of( $user_id, $this->pag_num, $this->pag_page, $filter );
441
+ break;
442
+
443
+ case 'alphabetical':
444
+ $this->groups = groups_get_alphabetically_for_user( $user_id, $this->pag_num, $this->pag_page, $filter );
445
+ break;
446
+
447
+ case 'invites':
448
+ $this->groups = groups_get_invites_for_user();
449
+ break;
450
+
451
+ case 'single-group':
452
+ $group = new stdClass;
453
+ $group->group_id = BP_Groups_Group::get_id_from_slug($slug);
454
+ $this->groups = array( $group );
455
+ break;
456
+
457
+ case 'active': default:
458
+ $this->groups = groups_get_recently_active_for_user( $user_id, $this->pag_num, $this->pag_page, $filter );
459
+ break;
460
+ }
461
+
462
+ if ( 'invites' == $type ) {
463
+ $this->total_group_count = count($this->groups);
464
+ $this->group_count = count($this->groups);
465
+ } else if ( 'single-group' == $type ) {
466
+ $this->single_group = true;
467
+ $this->total_group_count = 1;
468
+ $this->group_count = 1;
469
+ } else {
470
+ if ( !$max )
471
+ $this->total_group_count = (int)$this->groups['total'];
472
+ else
473
+ $this->total_group_count = (int)$max;
474
+
475
+ $this->groups = $this->groups['groups'];
476
+
477
+ if ( $max ) {
478
+ if ( $max >= count($this->groups) )
479
+ $this->group_count = count($this->groups);
480
+ else
481
+ $this->group_count = (int)$max;
482
+ } else {
483
+ $this->group_count = count($this->groups);
484
+ }
485
+ }
486
+
487
+ $this->pag_links = paginate_links( array(
488
+ 'base' => add_query_arg( array( 'grpage' => '%#%', 'num' => $this->pag_num, 's' => $_REQUEST['s'], 'sortby' => $this->sort_by, 'order' => $this->order ) ),
489
+ 'format' => '',
490
+ 'total' => ceil($this->total_group_count / $this->pag_num),
491
+ 'current' => $this->pag_page,
492
+ 'prev_text' => '&laquo;',
493
+ 'next_text' => '&raquo;',
494
+ 'mid_size' => 1
495
+ ));
496
+ }
497
+
498
+ function has_groups() {
499
+ if ( $this->group_count )
500
+ return true;
501
+
502
+ return false;
503
+ }
504
+
505
+ function next_group() {
506
+ $this->current_group++;
507
+ $this->group = $this->groups[$this->current_group];
508
+
509
+ return $this->group;
510
+ }
511
+
512
+ function rewind_groups() {
513
+ $this->current_group = -1;
514
+ if ( $this->group_count > 0 ) {
515
+ $this->group = $this->groups[0];
516
+ }
517
+ }
518
+
519
+ function user_groups() {
520
+ if ( $this->current_group + 1 < $this->group_count ) {
521
+ return true;
522
+ } elseif ( $this->current_group + 1 == $this->group_count ) {
523
+ do_action('loop_end');
524
+ // Do some cleaning up after the loop
525
+ $this->rewind_groups();
526
+ }
527
+
528
+ $this->in_the_loop = false;
529
+ return false;
530
+ }
531
+
532
+ function the_group() {
533
+ global $group;
534
+
535
+ $this->in_the_loop = true;
536
+ $this->group = $this->next_group();
537
+
538
+ // If this is a single group then instantiate group meta when creating the object.
539
+ if ( $this->single_group ) {
540
+ if ( !$group = wp_cache_get( 'groups_group_' . $this->group->group_id, 'bp' ) ) {
541
+ $group = new BP_Groups_Group( $this->group->group_id, true );
542
+ wp_cache_set( 'groups_group_' . $this->group->group_id, $group, 'bp' );
543
+ }
544
+ } else {
545
+ if ( !$group = wp_cache_get( 'groups_group_nouserdata_' . $this->group->group_id, 'bp' ) ) {
546
+ $group = new BP_Groups_Group( $this->group->group_id, false, false );
547
+ wp_cache_set( 'groups_group_nouserdata_' . $this->group->group_id, $group, 'bp' );
548
+ }
549
+ }
550
+
551
+ $this->group = $group;
552
+
553
+ if ( 0 == $this->current_group ) // loop has just started
554
+ do_action('loop_start');
555
+ }
556
+ }
557
+
558
+ function bp_has_groups( $args = '' ) {
559
+ global $groups_template, $bp;
560
+ global $group_obj;
561
+
562
+ $defaults = array(
563
+ 'type' => 'active',
564
+ 'user_id' => false,
565
+ 'per_page' => 10,
566
+ 'max' => false,
567
+ 'slug' => false,
568
+ 'filter' => false
569
+ );
570
+
571
+ $r = wp_parse_args( $args, $defaults );
572
+ extract( $r, EXTR_SKIP );
573
+
574
+ /* The following code will auto set parameters based on the page being viewed.
575
+ * for example on example.com/members/andy/groups/my-groups/most-popular/
576
+ * $type = 'most-popular'
577
+ */
578
+ if ( 'my-groups' == $bp->current_action ) {
579
+ $order = $bp->action_variables[0];
580
+ if ( 'recently-joined' == $order )
581
+ $type = 'recently-joined';
582
+ else if ( 'most-popular' == $order )
583
+ $type = 'popular';
584
+ else if ( 'admin-of' == $order )
585
+ $type = 'admin-of';
586
+ else if ( 'mod-of' == $order )
587
+ $type = 'mod-of';
588
+ else if ( 'alphabetically' == $order )
589
+ $type = 'alphabetical';
590
+ } else if ( 'invites' == $bp->current_action ) {
591
+ $type = 'invites';
592
+ } else if ( $group_obj->slug ) {
593
+ $type = 'single-group';
594
+ $slug = $group_obj->slug;
595
+ }
596
+
597
+ if ( isset( $_REQUEST['group-filter-box'] ) )
598
+ $filter = $_REQUEST['group-filter-box'];
599
+
600
+ $groups_template = new BP_Groups_User_Groups_Template( $user_id, $type, $per_page, $max, $slug, $filter );
601
+ return $groups_template->has_groups();
602
+ }
603
+
604
+ function bp_groups() {
605
+ global $groups_template;
606
+ return $groups_template->user_groups();
607
+ }
608
+
609
+ function bp_the_group() {
610
+ global $groups_template;
611
+ return $groups_template->the_group();
612
+ }
613
+
614
+ function bp_group_is_visible( $group = false ) {
615
+ global $bp, $groups_template;
616
+
617
+ if ( !$group )
618
+ $group =& $groups_template->group;
619
+
620
+ if ( 'public' == $group->status ) {
621
+ return true;
622
+ } else {
623
+ if ( groups_is_user_member( $bp->loggedin_user->id, $group->id ) ) {
624
+ return true;
625
+ }
626
+ }
627
+
628
+ return false;
629
+ }
630
+
631
+ function bp_group_has_news( $group = false ) {
632
+ global $groups_template;
633
+
634
+ if ( !$group )
635
+ $group =& $groups_template->group;
636
+
637
+ if ( empty( $group->news ) )
638
+ return false;
639
+
640
+ return true;
641
+ }
642
+
643
+ function bp_group_id( $deprecated = true, $deprecated2 = false ) {
644
+ global $groups_template;
645
+
646
+ if ( !$deprecated )
647
+ return bp_get_group_id();
648
+ else
649
+ echo bp_get_group_id();
650
+ }
651
+ function bp_get_group_id( $group = false ) {
652
+ global $groups_template;
653
+
654
+ if ( !$group )
655
+ $group =& $groups_template->group;
656
+
657
+ return apply_filters( 'bp_get_group_id', $group->id );
658
+ }
659
+
660
+ function bp_group_name( $deprecated = true, $deprecated2 = false ) {
661
+ global $groups_template;
662
+
663
+ if ( !$deprecated )
664
+ return bp_get_group_name();
665
+ else
666
+ echo bp_get_group_name();
667
+ }
668
+ function bp_get_group_name( $group = false ) {
669
+ global $groups_template;
670
+
671
+ if ( !$group )
672
+ $group =& $groups_template->group;
673
+
674
+ return apply_filters( 'bp_get_group_name', $group->name );
675
+ }
676
+
677
+ function bp_group_type() {
678
+ echo bp_get_group_type();
679
+ }
680
+ function bp_get_group_type( $group = false ) {
681
+ global $groups_template;
682
+
683
+ if ( !$group )
684
+ $group =& $groups_template->group;
685
+
686
+ if ( 'public' == $group->status ) {
687
+ $type = __( "Public Group", "buddypress" );
688
+ } else if ( 'hidden' == $group->status ) {
689
+ $type = __( "Hidden Group", "buddypress" );
690
+ } else if ( 'private' == $group->status ) {
691
+ $type = __( "Private Group", "buddypress" );
692
+ } else {
693
+ $type = ucwords( $group->status ) . ' ' . __( 'Group', 'buddypress' );
694
+ }
695
+
696
+ return apply_filters( 'bp_get_group_type', $type );
697
+ }
698
+
699
+ function bp_group_avatar() {
700
+ echo bp_get_group_avatar();
701
+ }
702
+ function bp_get_group_avatar( $group = false ) {
703
+ global $groups_template;
704
+
705
+ if ( !$group )
706
+ $group =& $groups_template->group;
707
+
708
+ return apply_filters( 'bp_get_group_avatar', '<img src="' . $group->avatar_full . '" class="avatar" alt="' . $group->name . '" />', $group->avatar_full, $group->avatar_name );
709
+ }
710
+
711
+ function bp_group_avatar_thumb() {
712
+ echo bp_get_group_avatar_thumb();
713
+ }
714
+ function bp_get_group_avatar_thumb( $group = false ) {
715
+ global $groups_template;
716
+
717
+ if ( !$group )
718
+ $group =& $groups_template->group;
719
+
720
+ return apply_filters( 'bp_get_group_avatar_thumb', '<img src="' . $group->avatar_thumb . '" class="avatar" alt="' . $group->name . '" />', $group->avatar_thumb, $group->avatar_name );
721
+ }
722
+
723
+ function bp_group_avatar_mini() {
724
+ echo bp_get_group_avatar_mini();
725
+ }
726
+ function bp_get_group_avatar_mini( $group = false ) {
727
+ global $groups_template;
728
+
729
+ if ( !$group )
730
+ $group =& $groups_template->group;
731
+
732
+ return apply_filters( 'bp_get_group_avatar_mini', '<img src="' . $group->avatar_thumb . '" class="avatar" width="30" height="30" alt="' . $group->name . '" />', $group->avatar_thumb, $group->avatar_name );
733
+ }
734
+
735
+ function bp_group_last_active( $deprecated = true, $deprecated2 = false ) {
736
+ if ( !$deprecated )
737
+ return bp_get_group_last_active();
738
+ else
739
+ echo bp_get_group_last_active();
740
+ }
741
+ function bp_get_group_last_active( $group = false ) {
742
+ global $groups_template;
743
+
744
+ if ( !$group )
745
+ $group =& $groups_template->group;
746
+
747
+ $last_active = groups_get_groupmeta( $group->id, 'last_activity' );
748
+
749
+ if ( empty( $last_active ) ) {
750
+ return __( 'not yet active', 'buddypress' );
751
+ } else {
752
+ return apply_filters( 'bp_get_group_last_active', bp_core_time_since( $last_active ) );
753
+ }
754
+ }
755
+
756
+ function bp_group_permalink( $deprecated = false, $deprecated2 = true ) {
757
+ if ( !$deprecated2 )
758
+ return bp_get_group_permalink();
759
+ else
760
+ echo bp_get_group_permalink();
761
+ }
762
+ function bp_get_group_permalink( $group = false ) {
763
+ global $groups_template, $bp;
764
+
765
+ if ( !$group )
766
+ $group =& $groups_template->group;
767
+
768
+ return apply_filters( 'bp_get_group_permalink', $bp->root_domain . '/' . $bp->groups->slug . '/' . $group->slug );
769
+ }
770
+
771
+ function bp_group_admin_permalink( $deprecated = true, $deprecated2 = false ) {
772
+ if ( !$deprecated )
773
+ return bp_get_group_admin_permalink();
774
+ else
775
+ echo bp_get_group_admin_permalink();
776
+ }
777
+ function bp_get_group_admin_permalink( $group = false ) {
778
+ global $groups_template, $bp;
779
+
780
+ if ( !$group )
781
+ $group =& $groups_template->group;
782
+
783
+ return apply_filters( 'bp_get_group_admin_permalink', $bp->root_domain . '/' . $bp->groups->slug . '/' . $group->slug . '/admin' );
784
+ }
785
+
786
+ function bp_group_slug() {
787
+ echo bp_get_group_slug();
788
+ }
789
+ function bp_get_group_slug( $group = false ) {
790
+ global $groups_template;
791
+
792
+ if ( !$group )
793
+ $group =& $groups_template->group;
794
+
795
+ return apply_filters( 'bp_get_group_slug', $group->slug );
796
+ }
797
+
798
+ function bp_group_description( $deprecated = false, $deprecated2 = true ) {
799
+ if ( !$deprecated2 )
800
+ return bp_get_group_description();
801
+ else
802
+ echo bp_get_group_description();
803
+ }
804
+ function bp_get_group_description( $group = false ) {
805
+ global $groups_template;
806
+
807
+ if ( !$group )
808
+ $group =& $groups_template->group;
809
+
810
+ return apply_filters( 'bp_get_group_description', stripslashes($group->description) );
811
+ }
812
+
813
+ function bp_group_description_editable( $deprecated = false ) {
814
+ echo bp_get_group_description_editable();
815
+ }
816
+ function bp_get_group_description_editable( $group = false ) {
817
+ global $groups_template;
818
+
819
+ if ( !$group )
820
+ $group =& $groups_template->group;
821
+
822
+ return apply_filters( 'bp_get_group_description_editable', $group->description );
823
+ }
824
+
825
+ function bp_group_description_excerpt( $deprecated = false ) {
826
+ echo bp_get_group_description_excerpt();
827
+ }
828
+ function bp_get_group_description_excerpt( $group = false ) {
829
+ global $groups_template;
830
+
831
+ if ( !$group )
832
+ $group =& $groups_template->group;
833
+
834
+ return apply_filters( 'bp_get_group_description_excerpt', bp_create_excerpt( $group->description, 20 ) );
835
+ }
836
+
837
+ function bp_group_news( $deprecated = false ) {
838
+ echo bp_get_group_news();
839
+ }
840
+ function bp_get_group_news( $group = false ) {
841
+ global $groups_template;
842
+
843
+ if ( !$group )
844
+ $group =& $groups_template->group;
845
+
846
+ return apply_filters( 'bp_get_group_news', stripslashes($groups_template->group->news) );
847
+ }
848
+
849
+ function bp_group_news_editable( $deprecated = false ) {
850
+ echo bp_get_group_news_editable();
851
+ }
852
+ function bp_get_group_news_editable( $group = false ) {
853
+ global $groups_template;
854
+
855
+ if ( !$group )
856
+ $group =& $groups_template->group;
857
+
858
+ return apply_filters( 'bp_get_group_news_editable', $group->news );
859
+ }
860
+
861
+ function bp_group_public_status( $deprecated = false ) {
862
+ echo bp_get_group_public_status();
863
+ }
864
+ function bp_get_group_public_status( $group = false ) {
865
+ global $groups_template;
866
+
867
+ if ( !$group )
868
+ $group =& $groups_template->group;
869
+
870
+ if ( $group->is_public ) {
871
+ return __( 'Public', 'buddypress' );
872
+ } else {
873
+ return __( 'Private', 'buddypress' );
874
+ }
875
+ }
876
+
877
+ function bp_group_is_public( $deprecated = false ) {
878
+ echo bp_get_group_is_public();
879
+ }
880
+ function bp_get_group_is_public( $group = false ) {
881
+ global $groups_template;
882
+
883
+ if ( !$group )
884
+ $group =& $groups_template->group;
885
+
886
+ return apply_filters( 'bp_get_group_is_public', $group->is_public );
887
+ }
888
+
889
+ function bp_group_date_created( $deprecated = false ) {
890
+ echo bp_get_group_date_created();
891
+ }
892
+ function bp_get_group_date_created( $group = false ) {
893
+ global $groups_template;
894
+
895
+ if ( !$group )
896
+ $group =& $groups_template->group;
897
+
898
+ return apply_filters( 'bp_get_group_date_created', date( get_option( 'date_format' ), $group->date_created ) );
899
+ }
900
+
901
+ function bp_group_list_admins( $full_list = true, $group = false ) {
902
+ global $groups_template;
903
+
904
+ if ( !$group )
905
+ $group =& $groups_template->group;
906
+
907
+ if ( !$admins = &$group->admins )
908
+ $admins = $group->get_administrators();
909
+
910
+ if ( $admins ) {
911
+ if ( $full_list ) { ?>
912
+ <ul id="group-admins">
913
+ <?php for ( $i = 0; $i < count($admins); $i++ ) { ?>
914
+ <li>
915
+ <a href="<?php echo $admins[$i]->user->user_url ?>" title="<?php echo $admins[$i]->user->fullname ?>"><?php echo $admins[$i]->user->avatar_thumb ?></a>
916
+ <h5><?php echo $admins[$i]->user->user_link ?></h5>
917
+ <span class="activity"><?php echo $admins[$i]->user_title ?></span>
918
+ <hr />
919
+ </li>
920
+ <?php } ?>
921
+ </ul>
922
+ <?php } else { ?>
923
+ <?php for ( $i = 0; $i < count($admins); $i++ ) { ?>
924
+ <?php echo $admins[$i]->user->user_link ?>
925
+ <?php } ?>
926
+ <?php } ?>
927
+ <?php } else { ?>
928
+ <span class="activity"><?php _e( 'No Admins', 'buddypress' ) ?></span>
929
+ <?php } ?>
930
+
931
+ <?php
932
+ }
933
+
934
+ function bp_group_list_mods( $full_list = true, $group = false ) {
935
+ global $groups_template;
936
+
937
+ if ( !$group )
938
+ $group =& $groups_template->group;
939
+
940
+ $group_mods = groups_get_group_mods( $group->id );
941
+
942
+ if ( $group_mods ) {
943
+ if ( $full_list ) { ?>
944
+ <ul id="group-mods" class="mods-list">
945
+ <?php for ( $i = 0; $i < count($group_mods); $i++ ) { ?>
946
+ <li>
947
+ <a href="<?php echo bp_core_get_userlink( $group_mods[$i]->user_id, false, true ) ?>" title="<?php echo bp_fetch_user_fullname( $group_mods[$i]->user->user_id ) ?>"><?php echo bp_core_get_avatar( $group_mods[$i]->user_id, 1, 50, 50 ) ?></a>
948
+ <h5><?php echo bp_core_get_userlink( $group_mods[$i]->user_id ) ?></h5>
949
+ <span class="activity"><?php _e( 'Group Mod', 'buddypress' ) ?></span>
950
+ <div class="clear"></div>
951
+ </li>
952
+ <?php } ?>
953
+ </ul>
954
+ <?php } else { ?>
955
+ <?php for ( $i = 0; $i < count($admins); $i++ ) { ?>
956
+ <?php echo bp_core_get_userlink( $group_mods[$i]->user_id ) . ' ' ?>
957
+ <?php } ?>
958
+ <?php } ?>
959
+ <?php } else { ?>
960
+ <span class="activity"><?php _e( 'No Mods', 'buddypress' ) ?></span>
961
+ <?php } ?>
962
+
963
+ <?php
964
+ }
965
+
966
+ function bp_group_all_members_permalink( $deprecated = true, $deprecated2 = false ) {
967
+ global $groups_template, $bp;
968
+
969
+ if ( !$group )
970
+ $group =& $groups_template->group;
971
+
972
+ if ( !$deprecated )
973
+ return bp_get_group_all_members_permalink();
974
+ else
975
+ echo bp_get_group_all_members_permalink();
976
+ }
977
+ function bp_get_group_all_members_permalink( $group = false ) {
978
+ global $groups_template, $bp;
979
+
980
+ if ( !$group )
981
+ $group =& $groups_template->group;
982
+
983
+ return apply_filters( 'bp_get_group_all_members_permalink', bp_get_group_permalink( $group ) . '/' . BP_MEMBERS_SLUG );
984
+ }
985
+
986
+ function bp_group_random_members( $group = false ) {
987
+ global $groups_template;
988
+
989
+ if ( !$group )
990
+ $group =& $groups_template->group;
991
+
992
+ $members = &$group->random_members;
993
+ ?>
994
+ <ul class="horiz-gallery">
995
+ <?php for ( $i = 0; $i < count( $members ); $i++ ) { ?>
996
+ <li>
997
+ <a href="<?php echo $members[$i]->user->user_url ?>"><?php echo $members[$i]->user->avatar_thumb ?></a>
998
+ <h5><?php echo $members[$i]->user->user_link ?></h5>
999
+ </li>
1000
+ <?php } ?>
1001
+ </ul>
1002
+ <div class="clear"></div>
1003
+ <?php
1004
+ }
1005
+
1006
+ function bp_group_active_forum_topics( $total_topics = 3, $group = false ) {
1007
+ global $groups_template, $forum_template;
1008
+
1009
+ if ( !$group )
1010
+ $group =& $groups_template->group;
1011
+
1012
+ $forum_id = groups_get_groupmeta( $group->id, 'forum_id' );
1013
+
1014
+ if ( $forum_id && $forum_id != '' ) {
1015
+ if ( function_exists( 'bp_forums_setup' ) ) {
1016
+ $latest_topics = bp_forums_get_topics( $forum_id, $total_topics, 1 );
1017
+
1018
+ if ( $latest_topics ) { ?>
1019
+ <ul class="item-list" id="recent-forum-topics"><?php
1020
+
1021
+ $counter = 0;
1022
+
1023
+ foreach( $latest_topics as $topic ) {
1024
+ $alt = ( $counter % 2 == 1 ) ? ' class="alt"' : '';
1025
+ $forum_template->topic = (object)$topic; ?>
1026
+
1027
+ <li<?php echo $alt ?>>
1028
+ <div class="avatar">
1029
+ <?php bp_the_topic_poster_avatar() ?>
1030
+ </div>
1031
+
1032
+ <a href="<?php bp_the_topic_permalink() ?>" title="<?php bp_the_topic_title() ?> - <?php _e( 'Permalink', 'buddypress' ) ?>"><?php bp_the_topic_title() ?></a>
1033
+ <span class="small">- <?php bp_the_topic_total_post_count() ?> </span>
1034
+ <p><span class="activity"><?php echo sprintf( __( 'updated %s ago', 'buddypress' ), bp_the_topic_time_since_last_post( false ) ) ?></span></p>
1035
+
1036
+ <div class="latest-post">
1037
+ <?php _e( 'Latest by', 'buddypress' ) ?> <?php bp_the_topic_last_poster_name() ?>:
1038
+ <?php bp_the_topic_latest_post_excerpt() ?>
1039
+ </div>
1040
+ </li>
1041
+ <?php $counter++ ?>
1042
+
1043
+ <?php } ?>
1044
+ </ul>
1045
+ <?php
1046
+ } else {
1047
+ ?>
1048
+ <div id="message" class="info">
1049
+ <p><?php _e( 'There are no active forum topics for this group', 'buddypress' ) ?></p>
1050
+ </div>
1051
+ <?php
1052
+ }
1053
+ }
1054
+ }
1055
+ }
1056
+
1057
+ function bp_group_search_form() {
1058
+ global $groups_template, $bp;
1059
+
1060
+ $action = $bp->loggedin_user->domain . $bp->groups->slug . '/my-groups/search/';
1061
+ $label = __('Filter Groups', 'buddypress');
1062
+ $name = 'group-filter-box';
1063
+ ?>
1064
+ <form action="<?php echo $action ?>" id="group-search-form" method="post">
1065
+ <label for="<?php echo $name ?>" id="<?php echo $name ?>-label"><?php echo $label ?> <img id="ajax-loader" src="<?php echo $bp->groups->image_base ?>/ajax-loader.gif" height="7" alt="<?php _e( 'Loading', 'buddypress' ) ?>" style="display: none;" /></label>
1066
+ <input type="search" name="<?php echo $name ?>" id="<?php echo $name ?>" value="<?php echo $value ?>"<?php echo $disabled ?> />
1067
+
1068
+ <?php wp_nonce_field( 'group-filter-box', '_wpnonce_group_filter' ) ?>
1069
+ </form>
1070
+ <?php
1071
+ }
1072
+
1073
+ function bp_group_show_no_groups_message() {
1074
+ global $bp;
1075
+
1076
+ if ( !groups_total_groups_for_user( $bp->displayed_user->id ) )
1077
+ return true;
1078
+
1079
+ return false;
1080
+ }
1081
+
1082
+ function bp_group_pagination() {
1083
+ echo bp_get_group_pagination();
1084
+ }
1085
+ function bp_get_group_pagination() {
1086
+ global $groups_template;
1087
+
1088
+ return apply_filters( 'bp_get_group_pagination', $groups_template->pag_links );
1089
+ }
1090
+
1091
+ function bp_group_pagination_count() {
1092
+ global $bp, $groups_template;
1093
+
1094
+ $from_num = intval( ( $groups_template->pag_page - 1 ) * $groups_template->pag_num ) + 1;
1095
+ $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) ;
1096
+
1097
+ echo sprintf( __( 'Viewing group %d to %d (of %d groups)', 'buddypress' ), $from_num, $to_num, $groups_template->total_group_count ); ?> &nbsp;
1098
+ <img id="ajax-loader-groups" src="<?php echo $bp->core->image_base ?>/ajax-loader.gif" height="7" alt="<?php _e( "Loading", "buddypress" ) ?>" style="display: none;" /><?php
1099
+ }
1100
+
1101
+ function bp_total_group_count() {
1102
+ echo bp_get_total_group_count();
1103
+ }
1104
+ function bp_get_total_group_count() {
1105
+ global $groups_template;
1106
+
1107
+ return apply_filters( 'bp_get_total_group_count', $groups_template->total_group_count );
1108
+ }
1109
+
1110
+ function bp_group_total_members( $deprecated = true, $deprecated2 = false ) {
1111
+ if ( !$deprecated )
1112
+ return bp_get_group_total_members();
1113
+ else
1114
+ echo bp_get_group_total_members();
1115
+ }
1116
+ function bp_get_group_total_members( $echo = true, $group = false ) {
1117
+ global $groups_template;
1118
+
1119
+ if ( !$group )
1120
+ $group =& $groups_template->group;
1121
+
1122
+ return apply_filters( 'bp_get_group_total_members', $group->total_member_count );
1123
+ }
1124
+
1125
+ function bp_group_show_wire_setting( $group = false ) {
1126
+ global $groups_template;
1127
+
1128
+ if ( !$group )
1129
+ $group =& $groups_template->group;
1130
+
1131
+ if ( $group->enable_wire )
1132
+ echo ' checked="checked"';
1133
+ }
1134
+
1135
+ function bp_group_is_wire_enabled( $group = false ) {
1136
+ global $groups_template;
1137
+
1138
+ if ( !$group )
1139
+ $group =& $groups_template->group;
1140
+
1141
+ if ( $group->enable_wire )
1142
+ return true;
1143
+
1144
+ return false;
1145
+ }
1146
+
1147
+ function bp_group_forum_permalink( $deprecated = false ) {
1148
+ echo bp_get_group_forum_permalink();
1149
+ }
1150
+ function bp_get_group_forum_permalink( $group = false ) {
1151
+ global $groups_template;
1152
+
1153
+ if ( !$group )
1154
+ $group =& $groups_template->group;
1155
+
1156
+ return apply_filters( 'bp_get_group_forum_permalink', bp_get_group_permalink( $group ) . '/forum' );
1157
+ }
1158
+
1159
+ function bp_group_is_forum_enabled( $group = false ) {
1160
+ global $groups_template;
1161
+
1162
+ if ( !$group )
1163
+ $group =& $groups_template->group;
1164
+
1165
+ if ( function_exists( 'bp_forums_is_installed_correctly' ) ) {
1166
+ if ( bp_forums_is_installed_correctly() ) {
1167
+ if ( $group->enable_forum )
1168
+ return true;
1169
+
1170
+ return false;
1171
+ } else {
1172
+ return false;
1173
+ }
1174
+ }
1175
+
1176
+ return false;
1177
+ }
1178
+
1179
+ function bp_group_show_forum_setting( $group = false ) {
1180
+ global $groups_template;
1181
+
1182
+ if ( !$group )
1183
+ $group =& $groups_template->group;
1184
+
1185
+ if ( $group->enable_forum )
1186
+ echo ' checked="checked"';
1187
+ }
1188
+
1189
+ function bp_group_show_status_setting( $setting, $group = false ) {
1190
+ global $groups_template;
1191
+
1192
+ if ( !$group )
1193
+ $group =& $groups_template->group;
1194
+
1195
+ if ( $setting == $group->status )
1196
+ echo ' checked="checked"';
1197
+ }
1198
+
1199
+ function bp_group_admin_memberlist( $admin_list = false, $group = false ) {
1200
+ global $groups_template;
1201
+
1202
+ if ( !$group )
1203
+ $group =& $groups_template->group;
1204
+
1205
+ $admins = groups_get_group_admins( $group->id );
1206
+ ?>
1207
+ <?php if ( $admins ) { ?>
1208
+ <ul id="admins-list" class="item-list<?php if ( $admin_list ) { ?> single-line<?php } ?>">
1209
+ <?php foreach ( $admins as $admin ) { ?>
1210
+ <?php if ( $admin_list ) { ?>
1211
+ <li>
1212
+ <?php echo bp_core_get_avatar( $admin->user_id, 1, 30, 30 ) ?>
1213
+ <h5><?php echo bp_core_get_userlink( $admin->user_id ) ?></h5>
1214
+ </li>
1215
+ <?php } else { ?>
1216
+ <li>
1217
+ <?php echo bp_core_get_avatar( $admin->user_id, 1 ) ?>
1218
+ <h5><?php echo bp_core_get_userlink( $admin->user_id ) ?></h5>
1219
+ <span class="activity"><?php echo bp_core_get_last_activity( strtotime( $admin->date_modified ), __( 'joined %s ago', 'buddypress') ); ?></span>
1220
+
1221
+ <?php if ( function_exists( 'friends_install' ) ) : ?>
1222
+ <div class="action">
1223
+ <?php bp_add_friend_button( $admin->user_id ) ?>
1224
+ </div>
1225
+ <?php endif; ?>
1226
+ </li>
1227
+ <?php } ?>
1228
+ <?php } ?>
1229
+ </ul>
1230
+ <?php } else { ?>
1231
+ <div id="message" class="info">
1232
+ <p><?php _e( 'This group has no administrators', 'buddypress' ); ?></p>
1233
+ </div>
1234
+ <?php }
1235
+ }
1236
+
1237
+ function bp_group_mod_memberlist( $admin_list = false, $group = false ) {
1238
+ global $groups_template, $group_mods;
1239
+
1240
+ if ( !$group )
1241
+ $group =& $groups_template->group;
1242
+
1243
+ $group_mods = groups_get_group_mods( $group->id );
1244
+ ?>
1245
+ <?php if ( $group_mods ) { ?>
1246
+ <ul id="mods-list" class="item-list<?php if ( $admin_list ) { ?> single-line<?php } ?>">
1247
+ <?php foreach ( $group_mods as $mod ) { ?>
1248
+ <?php if ( $admin_list ) { ?>
1249
+ <li>
1250
+ <?php echo bp_core_get_avatar( $mod->user_id, 1, 30, 30 ) ?>
1251
+ <h5><?php echo bp_core_get_userlink( $mod->user_id ) ?> <span class="small"> &mdash; <a href="<?php bp_group_member_ban_link() ?>"><?php _e( 'Kick &amp; Ban', 'buddypress' ) ?></a> | <a href="<?php bp_group_member_demote_link($mod->user_id) ?>"><?php _e( 'Demote to Member', 'buddypress' ) ?></a></span></h5>
1252
+ </li>
1253
+ <?php } else { ?>
1254
+ <li>
1255
+ <?php echo bp_core_get_avatar( $mod->user_id, 1 ) ?>
1256
+ <h5><?php echo bp_core_get_userlink( $mod->user_id ) ?></h5>
1257
+ <span class="activity"><?php echo bp_core_get_last_activity( strtotime( $mod->date_modified ), __( 'joined %s ago', 'buddypress') ); ?></span>
1258
+
1259
+ <?php if ( function_exists( 'friends_install' ) ) : ?>
1260
+ <div class="action">
1261
+ <?php bp_add_friend_button( $mod->user_id ) ?>
1262
+ </div>
1263
+ <?php endif; ?>
1264
+ </li>
1265
+ <?php } ?>
1266
+ <?php } ?>
1267
+ </ul>
1268
+ <?php } else { ?>
1269
+ <div id="message" class="info">
1270
+ <p><?php _e( 'This group has no moderators', 'buddypress' ); ?></p>
1271
+ </div>
1272
+ <?php }
1273
+ }
1274
+
1275
+ function bp_group_has_moderators( $group = false ) {
1276
+ global $group_mods, $groups_template;
1277
+
1278
+ if ( !$group )
1279
+ $group =& $groups_template->group;
1280
+
1281
+ return apply_filters( 'bp_group_has_moderators', groups_get_group_mods( $group->id ) );
1282
+ }
1283
+
1284
+ function bp_group_member_promote_link( $user_id = false, $deprecated = false ) {
1285
+ global $members_template;
1286
+
1287
+ if ( !$user_id )
1288
+ $user_id = $members_template->member->user_id;
1289
+
1290
+ echo bp_get_group_member_promote_link( $user_id );
1291
+ }
1292
+ function bp_get_group_member_promote_link( $user_id = false, $group = false ) {
1293
+ global $members_template, $groups_template, $bp;
1294
+
1295
+ if ( !$user_id )
1296
+ $user_id = $members_template->member->user_id;
1297
+
1298
+ if ( !$group )
1299
+ $group =& $groups_template->group;
1300
+
1301
+ return apply_filters( 'bp_get_group_member_promote_link', wp_nonce_url( bp_get_group_permalink( $group ) . '/admin/manage-members/promote/' . $user_id, 'groups_promote_member' ) );
1302
+ }
1303
+
1304
+ function bp_group_member_demote_link( $user_id = false, $deprecated = false ) {
1305
+ global $members_template;
1306
+
1307
+ if ( !$user_id )
1308
+ $user_id = $members_template->member->user_id;
1309
+
1310
+ echo bp_get_group_member_demote_link( $user_id );
1311
+ }
1312
+ function bp_get_group_member_demote_link( $user_id = false, $group = false ) {
1313
+ global $members_template, $groups_template, $bp;
1314
+
1315
+ if ( !$group )
1316
+ $group =& $groups_template->group;
1317
+
1318
+ if ( !$user_id )
1319
+ $user_id = $members_template->member->user_id;
1320
+
1321
+ 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' ) );
1322
+ }
1323
+
1324
+ function bp_group_member_ban_link( $user_id = false, $deprecated = false ) {
1325
+ global $members_template;
1326
+
1327
+ if ( !$user_id )
1328
+ $user_id = $members_template->member->user_id;
1329
+
1330
+ echo bp_get_group_member_ban_link( $user_id );
1331
+ }
1332
+ function bp_get_group_member_ban_link( $user_id = false, $group = false ) {
1333
+ global $members_template, $groups_template, $bp;
1334
+
1335
+ if ( !$group )
1336
+ $group =& $groups_template->group;
1337
+
1338
+ return apply_filters( 'bp_get_group_member_ban_link', wp_nonce_url( bp_get_group_permalink( $group ) . '/admin/manage-members/ban/' . $user_id, 'groups_ban_member' ) );
1339
+ }
1340
+
1341
+ function bp_group_member_unban_link( $user_id = false, $deprecated = false ) {
1342
+ global $members_template;
1343
+
1344
+ if ( !$user_id )
1345
+ $user_id = $members_template->member->user_id;
1346
+
1347
+ echo bp_get_group_member_unban_link( $user_id );
1348
+ }
1349
+ function bp_get_group_member_unban_link( $user_id = false, $group = false ) {
1350
+ global $members_template;
1351
+
1352
+ if ( !$user_id )
1353
+ $user_id = $members_template->member->user_id;
1354
+
1355
+ if ( !$group )
1356
+ $group =& $groups_template->group;
1357
+
1358
+ 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' ) );
1359
+ }
1360
+
1361
+ function bp_group_admin_tabs( $group = false ) {
1362
+ global $bp, $groups_template;
1363
+
1364
+ if ( !$group )
1365
+ $group =& $groups_template->group;
1366
+
1367
+ $current_tab = $bp->action_variables[0];
1368
+ ?>
1369
+ <?php if ( $bp->is_item_admin || $bp->is_item_mod ) { ?>
1370
+ <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>
1371
+ <?php } ?>
1372
+
1373
+ <?php if ( $bp->is_item_admin ) { ?>
1374
+ <li<?php if ( 'group-settings' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/group-settings"><?php _e('Group Settings', 'buddypress') ?></a></li>
1375
+ <?php } ?>
1376
+
1377
+ <?php if ( $bp->is_item_admin ) { ?>
1378
+ <li<?php if ( 'group-avatar' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/group-avatar"><?php _e('Group Avatar', 'buddypress') ?></a></li>
1379
+ <?php } ?>
1380
+
1381
+ <?php if ( $bp->is_item_admin ) { ?>
1382
+ <li<?php if ( 'manage-members' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/manage-members"><?php _e('Manage Members', 'buddypress') ?></a></li>
1383
+ <?php } ?>
1384
+
1385
+ <?php if ( $bp->is_item_admin && $groups_template->group->status == 'private' ) : ?>
1386
+ <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>
1387
+ <?php endif; ?>
1388
+
1389
+ <?php if ( $bp->is_item_admin ) { ?>
1390
+ <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>
1391
+ <?php } ?>
1392
+
1393
+ <?php
1394
+ do_action( 'groups_admin_tabs' );
1395
+ }
1396
+
1397
+ function bp_group_form_action( $page, $deprecated = false ) {
1398
+ echo bp_get_group_form_action( $page );
1399
+ }
1400
+ function bp_get_group_form_action( $page, $group = false ) {
1401
+ global $bp, $groups_template;
1402
+
1403
+ if ( !$group )
1404
+ $group =& $groups_template->group;
1405
+
1406
+ return apply_filters( 'bp_group_form_action', bp_get_group_permalink( $group ) . '/' . $page );
1407
+ }
1408
+
1409
+ function bp_group_admin_form_action( $page, $deprecated = false ) {
1410
+ echo bp_get_group_admin_form_action( $page );
1411
+ }
1412
+ function bp_get_group_admin_form_action( $page, $group = false ) {
1413
+ global $bp, $groups_template;
1414
+
1415
+ if ( !$group )
1416
+ $group =& $groups_template->group;
1417
+
1418
+ return apply_filters( 'bp_group_admin_form_action', bp_get_group_permalink( $group ) . '/admin/' . $page );
1419
+ }
1420
+
1421
+ function bp_group_has_requested_membership( $group = false ) {
1422
+ global $bp, $groups_template;
1423
+
1424
+ if ( !$group )
1425
+ $group =& $groups_template->group;
1426
+
1427
+ if ( groups_check_for_membership_request( $bp->loggedin_user->id, $group->id ) )
1428
+ return true;
1429
+
1430
+ return false;
1431
+ }
1432
+
1433
+ function bp_group_is_member( $group = false ) {
1434
+ global $bp, $groups_template;
1435
+
1436
+ if ( !$group )
1437
+ $group =& $groups_template->group;
1438
+
1439
+ if ( groups_is_user_member( $bp->loggedin_user->id, $group->id ) )
1440
+ return true;
1441
+
1442
+ return false;
1443
+ }
1444
+
1445
+ function bp_group_accept_invite_link( $deprecated = false ) {
1446
+ echo bp_get_group_accept_invite_link();
1447
+ }
1448
+ function bp_get_group_accept_invite_link( $group = false ) {
1449
+ global $groups_template, $bp;
1450
+
1451
+ if ( !$group )
1452
+ $group =& $groups_template->group;
1453
+
1454
+ 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' ) );
1455
+ }
1456
+
1457
+ function bp_group_reject_invite_link( $deprecated = false ) {
1458
+ echo bp_get_group_reject_invite_link();
1459
+ }
1460
+ function bp_get_group_reject_invite_link( $group = false ) {
1461
+ global $groups_template, $bp;
1462
+
1463
+ if ( !$group )
1464
+ $group =& $groups_template->group;
1465
+
1466
+ return apply_filters( 'bp_get_group_reject_invite_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->groups->slug . '/invites/reject/' . $group->id, 'groups_reject_invite' ) );
1467
+ }
1468
+
1469
+ function bp_group_leave_confirm_link( $deprecated = false ) {
1470
+ echo bp_group_leave_confirm_link();
1471
+ }
1472
+ function bp_get_group_leave_confirm_link( $group = false ) {
1473
+ global $groups_template, $bp;
1474
+
1475
+ if ( !$group )
1476
+ $group =& $groups_template->group;
1477
+
1478
+ return apply_filters( 'bp_group_leave_confirm_link', wp_nonce_url( bp_get_group_permalink( $group ) . '/leave-group/yes', 'groups_leave_group' ) );
1479
+ }
1480
+
1481
+ function bp_group_leave_reject_link( $deprecated = false ) {
1482
+ echo bp_get_group_leave_reject_link();
1483
+ }
1484
+ function bp_get_group_leave_reject_link( $group = false ) {
1485
+ global $groups_template, $bp;
1486
+
1487
+ if ( !$group )
1488
+ $group =& $groups_template->group;
1489
+
1490
+ return apply_filters( 'bp_get_group_leave_reject_link', bp_get_group_permalink( $group ) );
1491
+ }
1492
+
1493
+ function bp_group_send_invite_form_action( $deprecated = false ) {
1494
+ echo bp_get_group_send_invite_form_action();
1495
+ }
1496
+ function bp_get_group_send_invite_form_action( $group = false ) {
1497
+ global $groups_template, $bp;
1498
+
1499
+ if ( !$group )
1500
+ $group =& $groups_template->group;
1501
+
1502
+ return apply_filters( 'bp_group_send_invite_form_action', bp_get_group_permalink( $group ) . '/send-invites/send' );
1503
+ }
1504
+
1505
+ function bp_group_send_invite_form( $group = false ) {
1506
+ global $bp, $groups_template, $invites;
1507
+
1508
+ if ( !$group )
1509
+ $group =& $groups_template->group;
1510
+ ?>
1511
+ <div class="left-menu">
1512
+ <h4><?php _e( 'Select Friends', 'buddypress' ) ?> <img id="ajax-loader" src="<?php echo $bp->groups->image_base ?>/ajax-loader.gif" height="7" alt="Loading" style="display: none;" /></h4>
1513
+ <?php bp_group_list_invite_friends() ?>
1514
+ <?php wp_nonce_field( 'groups_invite_uninvite_user', '_wpnonce_invite_uninvite_user' ) ?>
1515
+ <input type="hidden" name="group_id" id="group_id" value="<?php echo $group->id ?>" />
1516
+ </div>
1517
+
1518
+ <div class="main-column">
1519
+
1520
+ <div id="message" class="info">
1521
+ <p><?php _e('Select people to invite from your friends list.', 'buddypress'); ?></p>
1522
+ </div>
1523
+
1524
+ <?php $invites = groups_get_invites_for_group( $bp->loggedin_user->id, $group_obj->id ) ?>
1525
+
1526
+ <ul id="friend-list" class="item-list">
1527
+ <?php for ( $i = 0; $i < count($invites); $i++ ) {
1528
+ if ( !$user = wp_cache_get( 'bp_user_' . $invites[$i], 'bp' ) ) {
1529
+ $user = new BP_Core_User( $invites[$i] );
1530
+ wp_cache_set( 'bp_user_' . $invites[$i], $user, 'bp' );
1531
+ }
1532
+ ?>
1533
+ <li id="uid-<?php echo $user->id ?>">
1534
+ <?php echo $user->avatar_thumb ?>
1535
+ <h4><?php echo $user->user_link ?></h4>
1536
+ <span class="activity"><?php echo $user->last_active ?></span>
1537
+ <div class="action">
1538
+ <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>
1539
+ </div>
1540
+ </li>
1541
+ <?php } // end for ?>
1542
+ </ul>
1543
+
1544
+ <?php wp_nonce_field( 'groups_send_invites', '_wpnonce_send_invites' ) ?>
1545
+ </div>
1546
+ <?php
1547
+ }
1548
+
1549
+ function bp_has_friends_to_invite( $group = false ) {
1550
+ global $groups_template, $bp;
1551
+
1552
+ if ( !function_exists('friends_install') )
1553
+ return false;
1554
+
1555
+ if ( !$group )
1556
+ $group =& $groups_template->group;
1557
+
1558
+ if ( !friends_check_user_has_friends( $bp->loggedin_user->id ) || !friends_count_invitable_friends( $bp->loggedin_user->id, $group->id ) )
1559
+ return false;
1560
+
1561
+ return true;
1562
+ }
1563
+
1564
+ function bp_group_join_button( $group = false ) {
1565
+ global $bp, $groups_template;
1566
+
1567
+ if ( !$group )
1568
+ $group =& $groups_template->group;
1569
+
1570
+ // If they're not logged in or are banned from the group, no join button.
1571
+ if ( !is_user_logged_in() || groups_is_user_banned( $bp->loggedin_user->id, $group->id ) )
1572
+ return false;
1573
+
1574
+ echo '<div class="group-button ' . $group->status . '" id="groupbutton-' . $group->id . '">';
1575
+
1576
+ switch ( $group->status ) {
1577
+ case 'public':
1578
+ if ( BP_Groups_Member::check_is_member( $bp->loggedin_user->id, $group->id ) )
1579
+ echo '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>';
1580
+ else
1581
+ echo '<a class="join-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/join', 'groups_join_group' ) . '">' . __( 'Join Group', 'buddypress' ) . '</a>';
1582
+ break;
1583
+
1584
+ case 'private':
1585
+ if ( BP_Groups_Member::check_is_member( $bp->loggedin_user->id, $group->id ) ) {
1586
+ echo '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>';
1587
+ } else {
1588
+ if ( !bp_group_has_requested_membership( $group ) )
1589
+ echo '<a class="request-membership" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/request-membership', 'groups_request_membership' ) . '">' . __('Request Membership', 'buddypress') . '</a>';
1590
+ else
1591
+ echo '<a class="membership-requested" href="' . bp_get_group_permalink( $group ) . '">' . __( 'Request Sent', 'buddypress' ) . '</a>';
1592
+ }
1593
+ break;
1594
+ }
1595
+
1596
+ echo '</div>';
1597
+ }
1598
+
1599
+ function bp_group_status_message( $group = false ) {
1600
+ global $groups_template;
1601
+
1602
+ if ( !$group )
1603
+ $group =& $groups_template->group;
1604
+
1605
+ if ( 'private' == $group->status ) {
1606
+ if ( !bp_group_has_requested_membership() )
1607
+ if ( is_user_logged_in() )
1608
+ _e( 'This is a private group and you must request group membership in order to join.', 'buddypress' );
1609
+ else
1610
+ _e( 'This is a private group. To join you must be a registered site member and request group membership.', 'buddypress' );
1611
+ else
1612
+ _e( 'This is a private group. Your membership request is awaiting approval from the group administrator.', 'buddypress' );
1613
+ } else {
1614
+ _e( 'This is a hidden group and only invited members can join.', 'buddypress' );
1615
+ }
1616
+ }
1617
+
1618
+
1619
+ /***************************************************************************
1620
+ * Group Members Template Tags
1621
+ **/
1622
+
1623
+ class BP_Groups_Group_Members_Template {
1624
+ var $current_member = -1;
1625
+ var $member_count;
1626
+ var $members;
1627
+ var $member;
1628
+
1629
+ var $in_the_loop;
1630
+
1631
+ var $pag_page;
1632
+ var $pag_num;
1633
+ var $pag_links;
1634
+ var $total_group_count;
1635
+
1636
+ function bp_groups_group_members_template( $group_id, $per_page, $max, $exclude_admins_mods, $exclude_banned ) {
1637
+ global $bp;
1638
+
1639
+ $this->pag_page = isset( $_REQUEST['mlpage'] ) ? intval( $_REQUEST['mlpage'] ) : 1;
1640
+ $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
1641
+
1642
+ $this->members = BP_Groups_Member::get_all_for_group( $group_id, $this->pag_num, $this->pag_page, $exclude_admins_mods, $exclude_banned );
1643
+
1644
+ if ( !$max )
1645
+ $this->total_member_count = (int)$this->members['count'];
1646
+ else
1647
+ $this->total_member_count = (int)$max;
1648
+
1649
+ $this->members = $this->members['members'];
1650
+
1651
+ if ( $max ) {
1652
+ if ( $max >= count($this->members) )
1653
+ $this->member_count = count($this->members);
1654
+ else
1655
+ $this->member_count = (int)$max;
1656
+ } else {
1657
+ $this->member_count = count($this->members);
1658
+ }
1659
+
1660
+ $this->pag_links = paginate_links( array(
1661
+ 'base' => add_query_arg( 'mlpage', '%#%' ),
1662
+ 'format' => '',
1663
+ 'total' => ceil( $this->total_member_count / $this->pag_num ),
1664
+ 'current' => $this->pag_page,
1665
+ 'prev_text' => '&laquo;',
1666
+ 'next_text' => '&raquo;',
1667
+ 'mid_size' => 1
1668
+ ));
1669
+ }
1670
+
1671
+ function has_members() {
1672
+ if ( $this->member_count )
1673
+ return true;
1674
+
1675
+ return false;
1676
+ }
1677
+
1678
+ function next_member() {
1679
+ $this->current_member++;
1680
+ $this->member = $this->members[$this->current_member];
1681
+
1682
+ return $this->member;
1683
+ }
1684
+
1685
+ function rewind_members() {
1686
+ $this->current_member = -1;
1687
+ if ( $this->member_count > 0 ) {
1688
+ $this->member = $this->members[0];
1689
+ }
1690
+ }
1691
+
1692
+ function members() {
1693
+ if ( $this->current_member + 1 < $this->member_count ) {
1694
+ return true;
1695
+ } elseif ( $this->current_member + 1 == $this->member_count ) {
1696
+ do_action('loop_end');
1697
+ // Do some cleaning up after the loop
1698
+ $this->rewind_members();
1699
+ }
1700
+
1701
+ $this->in_the_loop = false;
1702
+ return false;
1703
+ }
1704
+
1705
+ function the_member() {
1706
+ global $member;
1707
+
1708
+ $this->in_the_loop = true;
1709
+ $this->member = $this->next_member();
1710
+
1711
+ if ( 0 == $this->current_member ) // loop has just started
1712
+ do_action('loop_start');
1713
+ }
1714
+ }
1715
+
1716
+ function bp_group_has_members( $args = '' ) {
1717
+ global $members_template, $groups_template, $group_obj;
1718
+
1719
+ $defaults = array(
1720
+ 'group_id' => $group_obj->id,
1721
+ 'per_page' => 10,
1722
+ 'max' => false,
1723
+ 'exclude_admins_mods' => true,
1724
+ 'exclude_banned' => true
1725
+ );
1726
+
1727
+ $r = wp_parse_args( $args, $defaults );
1728
+ extract( $r, EXTR_SKIP );
1729
+
1730
+ if ( !$groups_template )
1731
+ $groups_template->group = new BP_Groups_Group( $group_id );
1732
+
1733
+ $members_template = new BP_Groups_Group_Members_Template( $group_id, $per_page, $max, $exclude_admins_mods, $exclude_banned );
1734
+
1735
+ return $members_template->has_members();
1736
+ }
1737
+
1738
+ function bp_group_members() {
1739
+ global $members_template;
1740
+
1741
+ return $members_template->members();
1742
+ }
1743
+
1744
+ function bp_group_the_member() {
1745
+ global $members_template;
1746
+
1747
+ return $members_template->the_member();
1748
+ }
1749
+
1750
+ function bp_group_member_avatar() {
1751
+ echo bp_get_group_member_avatar();
1752
+ }
1753
+ function bp_get_group_member_avatar() {
1754
+ global $members_template;
1755
+
1756
+ return apply_filters( 'bp_get_group_member_avatar', bp_core_get_avatar( $members_template->member->user_id, 1 ) );
1757
+ }
1758
+
1759
+ function bp_group_member_avatar_mini( $width = 30, $height = 30 ) {
1760
+ echo bp_get_group_member_avatar_mini( $width, $height );
1761
+ }
1762
+ function bp_get_group_member_avatar_mini( $width = 30, $height = 30 ) {
1763
+ global $members_template;
1764
+
1765
+ return apply_filters( 'bp_get_group_member_avatar_mini', bp_core_get_avatar( $members_template->member->user_id, 1, $width, $height ) );
1766
+ }
1767
+
1768
+ function bp_group_member_name() {
1769
+ echo bp_get_group_member_name();
1770
+ }
1771
+ function bp_get_group_member_name() {
1772
+ global $members_template;
1773
+
1774
+ return apply_filters( 'bp_get_group_member_name', bp_fetch_user_fullname( $members_template->member->user_id, false ) );
1775
+ }
1776
+
1777
+ function bp_group_member_url() {
1778
+ echo bp_get_group_member_url();
1779
+ }
1780
+ function bp_get_group_member_url() {
1781
+ global $members_template;
1782
+
1783
+ return apply_filters( 'bp_get_group_member_url', bp_core_get_userlink( $members_template->member->user_id, false, true ) );
1784
+ }
1785
+
1786
+ function bp_group_member_link() {
1787
+ echo bp_get_group_member_link();
1788
+ }
1789
+ function bp_get_group_member_link() {
1790
+ global $members_template;
1791
+
1792
+ return apply_filters( 'bp_get_group_member_link', bp_core_get_userlink( $members_template->member->user_id ) );
1793
+ }
1794
+
1795
+ function bp_group_member_is_banned() {
1796
+ echo bp_get_group_member_is_banned();
1797
+ }
1798
+ function bp_get_group_member_is_banned() {
1799
+ global $members_template, $groups_template;
1800
+
1801
+ return apply_filters( 'bp_get_group_member_is_banned', groups_is_user_banned( $members_template->member->user_id, $groups_template->group->id ) );
1802
+ }
1803
+
1804
+ function bp_group_member_joined_since() {
1805
+ echo bp_get_group_member_joined_since();
1806
+ }
1807
+ function bp_get_group_member_joined_since() {
1808
+ global $members_template;
1809
+
1810
+ return apply_filters( 'bp_get_group_member_joined_since', bp_core_get_last_activity( strtotime( $members_template->member->date_modified ), __( 'joined %s ago', 'buddypress') ) );
1811
+ }
1812
+
1813
+
1814
+ function bp_group_member_id() {
1815
+ echo bp_get_group_member_id();
1816
+ }
1817
+ function bp_get_group_member_id() {
1818
+ global $members_template;
1819
+
1820
+ return apply_filters( 'bp_get_group_member_id', $members_template->member->user_id );
1821
+ }
1822
+
1823
+ function bp_group_member_needs_pagination() {
1824
+ global $members_template;
1825
+
1826
+ if ( $members_template->total_member_count > $members_template->pag_num )
1827
+ return true;
1828
+
1829
+ return false;
1830
+ }
1831
+
1832
+ function bp_group_pag_id() {
1833
+ echo bp_get_group_pag_id();
1834
+ }
1835
+ function bp_get_group_pag_id() {
1836
+ global $bp;
1837
+
1838
+ return apply_filters( 'bp_get_group_pag_id', 'pag' );
1839
+ }
1840
+
1841
+
1842
+ function bp_group_member_pagination() {
1843
+ echo bp_get_group_member_pagination();
1844
+ wp_nonce_field( 'bp_groups_member_list', '_member_pag_nonce' );
1845
+ }
1846
+ function bp_get_group_member_pagination() {
1847
+ global $members_template;
1848
+ return apply_filters( 'bp_get_group_member_pagination', $members_template->pag_links );
1849
+ }
1850
+
1851
+ function bp_group_member_pagination_count() {
1852
+ echo bp_get_group_member_pagination_count();
1853
+ }
1854
+ function bp_get_group_member_pagination_count() {
1855
+ global $members_template;
1856
+
1857
+ $from_num = intval( ( $members_template->pag_page - 1 ) * $members_template->pag_num ) + 1;
1858
+ $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 );
1859
+
1860
+ 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 ) );
1861
+ }
1862
+
1863
+ function bp_group_member_admin_pagination() {
1864
+ echo bp_get_group_member_admin_pagination();
1865
+ wp_nonce_field( 'bp_groups_member_admin_list', '_member_admin_pag_nonce' );
1866
+ }
1867
+ function bp_get_group_member_admin_pagination() {
1868
+ global $members_template;
1869
+
1870
+ return $members_template->pag_links;
1871
+ }
1872
+
1873
+ /********************************************************************************
1874
+ * Site Groups Template Tags
1875
+ **/
1876
+
1877
+ class BP_Groups_Site_Groups_Template {
1878
+ var $current_group = -1;
1879
+ var $group_count;
1880
+ var $groups;
1881
+ var $group;
1882
+
1883
+ var $in_the_loop;
1884
+
1885
+ var $pag_page;
1886
+ var $pag_num;
1887
+ var $pag_links;
1888
+ var $total_group_count;
1889
+
1890
+ function bp_groups_site_groups_template( $type, $per_page, $max ) {
1891
+ global $bp;
1892
+
1893
+ $this->pag_page = isset( $_REQUEST['gpage'] ) ? intval( $_REQUEST['gpage'] ) : 1;
1894
+ $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
1895
+
1896
+ if ( isset( $_REQUEST['s'] ) && '' != $_REQUEST['s'] && $type != 'random' ) {
1897
+ $this->groups = BP_Groups_Group::search_groups( $_REQUEST['s'], $this->pag_num, $this->pag_page );
1898
+ } else if ( isset( $_REQUEST['letter'] ) && '' != $_REQUEST['letter'] ) {
1899
+ $this->groups = BP_Groups_Group::get_by_letter( $_REQUEST['letter'], $this->pag_num, $this->pag_page );
1900
+ } else {
1901
+ switch ( $type ) {
1902
+ case 'random':
1903
+ $this->groups = BP_Groups_Group::get_random( $this->pag_num, $this->pag_page );
1904
+ break;
1905
+
1906
+ case 'newest':
1907
+ $this->groups = BP_Groups_Group::get_newest( $this->pag_num, $this->pag_page );
1908
+ break;
1909
+
1910
+ case 'popular':
1911
+ $this->groups = BP_Groups_Group::get_popular( $this->pag_num, $this->pag_page );
1912
+ break;
1913
+
1914
+ case 'active': default:
1915
+ $this->groups = BP_Groups_Group::get_active( $this->pag_num, $this->pag_page );
1916
+ break;
1917
+ }
1918
+ }
1919
+
1920
+ if ( !$max )
1921
+ $this->total_group_count = (int)$this->groups['total'];
1922
+ else
1923
+ $this->total_group_count = (int)$max;
1924
+
1925
+ $this->groups = $this->groups['groups'];
1926
+
1927
+ if ( $max ) {
1928
+ if ( $max >= count($this->groups) )
1929
+ $this->group_count = count($this->groups);
1930
+ else
1931
+ $this->group_count = (int)$max;
1932
+ } else {
1933
+ $this->group_count = count($this->groups);
1934
+ }
1935
+
1936
+ $this->pag_links = paginate_links( array(
1937
+ 'base' => add_query_arg( 'gpage', '%#%' ),
1938
+ 'format' => '',
1939
+ 'total' => ceil( (int) $this->total_group_count / (int) $this->pag_num ),
1940
+ 'current' => (int) $this->pag_page,
1941
+ 'prev_text' => '&laquo;',
1942
+ 'next_text' => '&raquo;',
1943
+ 'mid_size' => 1
1944
+ ));
1945
+ }
1946
+
1947
+ function has_groups() {
1948
+ if ( $this->group_count )
1949
+ return true;
1950
+
1951
+ return false;
1952
+ }
1953
+
1954
+ function next_group() {
1955
+ $this->current_group++;
1956
+ $this->group = $this->groups[$this->current_group];
1957
+
1958
+ return $this->group;
1959
+ }
1960
+
1961
+ function rewind_groups() {
1962
+ $this->current_group = -1;
1963
+ if ( $this->group_count > 0 ) {
1964
+ $this->group = $this->groups[0];
1965
+ }
1966
+ }
1967
+
1968
+ function groups() {
1969
+ if ( $this->current_group + 1 < $this->group_count ) {
1970
+ return true;
1971
+ } elseif ( $this->current_group + 1 == $this->group_count ) {
1972
+ do_action('loop_end');
1973
+ // Do some cleaning up after the loop
1974
+ $this->rewind_groups();
1975
+ }
1976
+
1977
+ $this->in_the_loop = false;
1978
+ return false;
1979
+ }
1980
+
1981
+ function the_group() {
1982
+ global $group;
1983
+
1984
+ $this->in_the_loop = true;
1985
+ $this->group = $this->next_group();
1986
+
1987
+ if ( !$group = wp_cache_get( 'groups_group_nouserdata_' . $this->group->group_id, 'bp' ) ) {
1988
+ $group = new BP_Groups_Group( $this->group->group_id, false, false );
1989
+ wp_cache_set( 'groups_group_nouserdata_' . $this->group->group_id, $group, 'bp' );
1990
+ }
1991
+
1992
+ $this->group = $group;
1993
+
1994
+ if ( 0 == $this->current_group ) // loop has just started
1995
+ do_action('loop_start');
1996
+ }
1997
+ }
1998
+
1999
+ function bp_rewind_site_groups() {
2000
+ global $site_groups_template;
2001
+
2002
+ $site_groups_template->rewind_groups();
2003
+ }
2004
+
2005
+ function bp_has_site_groups( $args = '' ) {
2006
+ global $site_groups_template;
2007
+
2008
+ $defaults = array(
2009
+ 'type' => 'active',
2010
+ 'per_page' => 10,
2011
+ 'max' => false
2012
+ );
2013
+
2014
+ $r = wp_parse_args( $args, $defaults );
2015
+ extract( $r, EXTR_SKIP );
2016
+
2017
+ // type: active ( default ) | random | newest | popular
2018
+
2019
+ if ( $max ) {
2020
+ if ( $per_page > $max )
2021
+ $per_page = $max;
2022
+ }
2023
+
2024
+ $site_groups_template = new BP_Groups_Site_Groups_Template( $type, $per_page, $max );
2025
+
2026
+ return $site_groups_template->has_groups();
2027
+ }
2028
+
2029
+ function bp_site_groups() {
2030
+ global $site_groups_template;
2031
+
2032
+ return $site_groups_template->groups();
2033
+ }
2034
+
2035
+ function bp_the_site_group() {
2036
+ global $site_groups_template;
2037
+
2038
+ return $site_groups_template->the_group();
2039
+ }
2040
+
2041
+ function bp_site_groups_pagination_count() {
2042
+ global $bp, $site_groups_template;
2043
+
2044
+ $from_num = intval( ( $site_groups_template->pag_page - 1 ) * $site_groups_template->pag_num ) + 1;
2045
+ $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) ;
2046
+
2047
+ echo sprintf( __( 'Viewing group %d to %d (of %d groups)', 'buddypress' ), $from_num, $to_num, $site_groups_template->total_group_count ); ?> &nbsp;
2048
+ <img id="ajax-loader-groups" src="<?php echo $bp->core->image_base ?>/ajax-loader.gif" height="7" alt="<?php _e( "Loading", "buddypress" ) ?>" style="display: none;" /><?php
2049
+ }
2050
+
2051
+ function bp_site_groups_pagination_links() {
2052
+ echo bp_get_site_groups_pagination_links();
2053
+ }
2054
+ function bp_get_site_groups_pagination_links() {
2055
+ global $site_groups_template;
2056
+
2057
+ return apply_filters( 'bp_get_site_groups_pagination_links', $site_groups_template->pag_links );
2058
+ }
2059
+
2060
+ function bp_the_site_group_id() {
2061
+ echo bp_get_the_site_group_id();
2062
+ }
2063
+ function bp_get_the_site_group_id() {
2064
+ global $site_groups_template;
2065
+
2066
+ return apply_filters( 'bp_get_the_site_group_id', $site_groups_template->group->id );
2067
+ }
2068
+
2069
+ function bp_the_site_group_avatar() {
2070
+ echo bp_get_the_site_group_avatar();
2071
+ }
2072
+ function bp_get_the_site_group_avatar() {
2073
+ global $site_groups_template;
2074
+
2075
+ return apply_filters( 'bp_the_site_group_avatar', bp_get_group_avatar( $site_groups_template->group ) );
2076
+ }
2077
+
2078
+ function bp_the_site_group_avatar_thumb() {
2079
+ echo bp_get_the_site_group_avatar_thumb();
2080
+ }
2081
+ function bp_get_the_site_group_avatar_thumb() {
2082
+ global $site_groups_template;
2083
+
2084
+ return apply_filters( 'bp_get_the_site_group_avatar_thumb', bp_get_group_avatar_thumb( $site_groups_template->group ) );
2085
+ }
2086
+
2087
+ function bp_the_site_group_avatar_mini() {
2088
+ echo bp_get_the_site_group_avatar_mini();
2089
+ }
2090
+ function bp_get_the_site_group_avatar_mini() {
2091
+ global $site_groups_template;
2092
+
2093
+ return apply_filters( 'bp_get_the_site_group_avatar_mini', bp_get_group_avatar_mini( $site_groups_template->group ) );
2094
+ }
2095
+
2096
+ function bp_the_site_group_link() {
2097
+ echo bp_get_the_site_group_link();
2098
+ }
2099
+ function bp_get_the_site_group_link() {
2100
+ global $site_groups_template;
2101
+
2102
+ return apply_filters( 'bp_get_the_site_group_link', bp_get_group_permalink( $site_groups_template->group ) );
2103
+ }
2104
+
2105
+ function bp_the_site_group_name() {
2106
+ echo bp_get_the_site_group_name();
2107
+ }
2108
+ function bp_get_the_site_group_name() {
2109
+ global $site_groups_template;
2110
+
2111
+ return apply_filters( 'bp_get_the_site_group_name', bp_get_group_name( $site_groups_template->group ) );
2112
+ }
2113
+
2114
+ function bp_the_site_group_last_active() {
2115
+ echo bp_get_the_site_group_last_active();
2116
+ }
2117
+ function bp_get_the_site_group_last_active() {
2118
+ global $site_groups_template;
2119
+
2120
+ return apply_filters( 'bp_get_the_site_group_last_active', sprintf( __( 'active %s ago', 'buddypress' ), bp_get_group_last_active( $site_groups_template->group ) ) );
2121
+ }
2122
+
2123
+ function bp_the_site_group_join_button() {
2124
+ global $site_groups_template;
2125
+
2126
+ echo bp_group_join_button( $site_groups_template->group );
2127
+ }
2128
+
2129
+ function bp_the_site_group_description() {
2130
+ echo bp_get_the_site_group_description();
2131
+ }
2132
+ function bp_get_the_site_group_description() {
2133
+ global $site_groups_template;
2134
+
2135
+ return apply_filters( 'bp_get_the_site_group_description', bp_get_group_description( $site_groups_template->group ) );
2136
+ }
2137
+
2138
+ function bp_the_site_group_description_excerpt() {
2139
+ echo bp_get_the_site_group_description_excerpt();
2140
+ }
2141
+ function bp_get_the_site_group_description_excerpt() {
2142
+ global $site_groups_template;
2143
+
2144
+ return apply_filters( 'bp_get_the_site_group_description_excerpt', bp_create_excerpt( bp_get_group_description( $site_groups_template->group, false ), 35 ) );
2145
+ }
2146
+
2147
+ function bp_the_site_group_date_created() {
2148
+ echo bp_get_the_site_group_date_created();
2149
+ }
2150
+ function bp_get_the_site_group_date_created() {
2151
+ global $site_groups_template;
2152
+
2153
+ return apply_filters( 'bp_get_the_site_group_date_created', date( get_option( 'date_format' ), $site_groups_template->group->date_created ) );
2154
+ }
2155
+
2156
+ function bp_the_site_group_member_count() {
2157
+ echo bp_get_the_site_group_member_count();
2158
+ }
2159
+ function bp_get_the_site_group_member_count() {
2160
+ global $site_groups_template;
2161
+
2162
+ if ( 1 == (int) $site_groups_template->group->total_member_count )
2163
+ return apply_filters( 'bp_get_the_site_group_member_count', sprintf( __( '%d member', 'buddypress' ), (int) $site_groups_template->group->total_member_count ) );
2164
+ else
2165
+ return apply_filters( 'bp_get_the_site_group_member_count', sprintf( __( '%d members', 'buddypress' ), (int) $site_groups_template->group->total_member_count ) );
2166
+ }
2167
+
2168
+ function bp_the_site_group_type() {
2169
+ echo bp_get_the_site_group_type();
2170
+ }
2171
+ function bp_get_the_site_group_type() {
2172
+ global $site_groups_template;
2173
+
2174
+ return apply_filters( 'bp_get_the_site_group_type', bp_get_group_type( $site_groups_template->group ) );
2175
+ }
2176
+
2177
+ function bp_the_site_group_hidden_fields() {
2178
+ if ( isset( $_REQUEST['s'] ) ) {
2179
+ echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['s'] ) . '" name="search_terms" />';
2180
+ }
2181
+
2182
+ if ( isset( $_REQUEST['letter'] ) ) {
2183
+ echo '<input type="hidden" id="selected_letter" value="' . attribute_escape( $_REQUEST['letter'] ) . '" name="selected_letter" />';
2184
+ }
2185
+
2186
+ if ( isset( $_REQUEST['groups_search'] ) ) {
2187
+ echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['groups_search'] ) . '" name="search_terms" />';
2188
+ }
2189
+ }
2190
+
2191
+ function bp_directory_groups_search_form() {
2192
+ global $bp; ?>
2193
+ <form action="<?php echo $bp->root_domain . '/' . groups_SLUG . '/search/' ?>" method="post" id="search-groups-form">
2194
+ <label><input type="text" name="groups_search" id="groups_search" value="<?php if ( isset( $_GET['s'] ) ) { echo attribute_escape( $_GET['s'] ); } else { _e( 'Search anything...', 'buddypress' ); } ?>" onfocus="if (this.value == '<?php _e( 'Search anything...', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Search anything...', 'buddypress' ) ?>';}" /></label>
2195
+ <input type="submit" id="groups_search_submit" name="groups_search_submit" value="<?php _e( 'Search', 'buddypress' ) ?>" />
2196
+ </form>
2197
+ <?php
2198
+ }
2199
+
2200
+ /************************************************************************************
2201
+ * Membership Requests Template Tags
2202
+ **/
2203
+
2204
+ class BP_Groups_Membership_Requests_Template {
2205
+ var $current_request = -1;
2206
+ var $request_count;
2207
+ var $requests;
2208
+ var $request;
2209
+
2210
+ var $in_the_loop;
2211
+
2212
+ var $pag_page;
2213
+ var $pag_num;
2214
+ var $pag_links;
2215
+ var $total_request_count;
2216
+
2217
+ function bp_groups_membership_requests_template( $group_id, $per_page, $max ) {
2218
+ global $bp;
2219
+
2220
+ $this->pag_page = isset( $_REQUEST['mrpage'] ) ? intval( $_REQUEST['mrpage'] ) : 1;
2221
+ $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
2222
+
2223
+ $this->requests = BP_Groups_Group::get_membership_requests( $group_id, $this->pag_num, $this->pag_page );
2224
+
2225
+ if ( !$max )
2226
+ $this->total_request_count = (int)$this->requests['total'];
2227
+ else
2228
+ $this->total_request_count = (int)$max;
2229
+
2230
+ $this->requests = $this->requests['requests'];
2231
+
2232
+ if ( $max ) {
2233
+ if ( $max >= count($this->requests) )
2234
+ $this->request_count = count($this->requests);
2235
+ else
2236
+ $this->request_count = (int)$max;
2237
+ } else {
2238
+ $this->request_count = count($this->requests);
2239
+ }
2240
+
2241
+ $this->pag_links = paginate_links( array(
2242
+ 'base' => add_query_arg( 'mrpage', '%#%' ),
2243
+ 'format' => '',
2244
+ 'total' => ceil( $this->total_request_count / $this->pag_num ),
2245
+ 'current' => $this->pag_page,
2246
+ 'prev_text' => '&laquo;',
2247
+ 'next_text' => '&raquo;',
2248
+ 'mid_size' => 1
2249
+ ));
2250
+ }
2251
+
2252
+ function has_requests() {
2253
+ if ( $this->request_count )
2254
+ return true;
2255
+
2256
+ return false;
2257
+ }
2258
+
2259
+ function next_request() {
2260
+ $this->current_request++;
2261
+ $this->request = $this->requests[$this->current_request];
2262
+
2263
+ return $this->request;
2264
+ }
2265
+
2266
+ function rewind_requests() {
2267
+ $this->current_request = -1;
2268
+ if ( $this->request_count > 0 ) {
2269
+ $this->request = $this->requests[0];
2270
+ }
2271
+ }
2272
+
2273
+ function requests() {
2274
+ if ( $this->current_request + 1 < $this->request_count ) {
2275
+ return true;
2276
+ } elseif ( $this->current_request + 1 == $this->request_count ) {
2277
+ do_action('loop_end');
2278
+ // Do some cleaning up after the loop
2279
+ $this->rewind_requests();
2280
+ }
2281
+
2282
+ $this->in_the_loop = false;
2283
+ return false;
2284
+ }
2285
+
2286
+ function the_request() {
2287
+ global $request;
2288
+
2289
+ $this->in_the_loop = true;
2290
+ $this->request = $this->next_request();
2291
+
2292
+ if ( 0 == $this->current_request ) // loop has just started
2293
+ do_action('loop_start');
2294
+ }
2295
+ }
2296
+
2297
+ function bp_group_has_membership_requests( $args = '' ) {
2298
+ global $requests_template, $groups_template;
2299
+
2300
+ $defaults = array(
2301
+ 'group_id' => $groups_template->group->id,
2302
+ 'per_page' => 10,
2303
+ 'max' => false
2304
+ );
2305
+
2306
+ $r = wp_parse_args( $args, $defaults );
2307
+ extract( $r, EXTR_SKIP );
2308
+
2309
+ $requests_template = new BP_Groups_Membership_Requests_Template( $group_id, $per_page, $max );
2310
+ return $requests_template->has_requests();
2311
+ }
2312
+
2313
+ function bp_group_membership_requests() {
2314
+ global $requests_template;
2315
+
2316
+ return $requests_template->requests();
2317
+ }
2318
+
2319
+ function bp_group_the_membership_request() {
2320
+ global $requests_template;
2321
+
2322
+ return $requests_template->the_request();
2323
+ }
2324
+
2325
+ function bp_group_request_user_avatar_thumb() {
2326
+ global $requests_template;
2327
+
2328
+ echo apply_filters( 'bp_group_request_user_avatar_thumb', bp_core_get_avatar( $requests_template->request->user_id, 1 ) );
2329
+ }
2330
+
2331
+ function bp_group_request_reject_link() {
2332
+ global $requests_template, $groups_template;
2333
+
2334
+ 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' ) );
2335
+ }
2336
+
2337
+ function bp_group_request_accept_link() {
2338
+ global $requests_template, $groups_template;
2339
+
2340
+ 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' ) );
2341
+ }
2342
+
2343
+ function bp_group_request_time_since_requested() {
2344
+ global $requests_template;
2345
+
2346
+ echo apply_filters( 'bp_group_request_time_since_requested', sprintf( __( 'requested %s ago', 'buddypress' ), bp_core_time_since( strtotime( $requests_template->request->date_modified ) ) ) );
2347
+ }
2348
+
2349
+ function bp_group_request_comment() {
2350
+ global $requests_template;
2351
+
2352
+ echo apply_filters( 'bp_group_request_comment', strip_tags( stripslashes( $requests_template->request->comments ) ) );
2353
+ }
2354
+
2355
+ function bp_group_request_user_link() {
2356
+ global $requests_template;
2357
+
2358
+ echo apply_filters( 'bp_group_request_user_link', bp_core_get_userlink( $requests_template->request->user_id ) );
2359
+ }
2360
+
2361
+ ?>
bp-groups/bp-groups-widgets.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /* Register widgets for groups component */
4
+ function groups_register_widgets() {
5
+ global $current_blog;
6
+
7
+ /* Site welcome widget */
8
+ wp_register_sidebar_widget( 'buddypress-groups', __( 'Groups', 'buddypress' ), 'groups_widget_groups_list' );
9
+ wp_register_widget_control( 'buddypress-groups', __( 'Groups', 'buddypress' ), 'groups_widget_groups_list_control' );
10
+
11
+ /* Include the javascript needed for activated widgets only */
12
+ if ( is_active_widget( 'groups_widget_groups_list' ) ) {
13
+ wp_enqueue_script( 'groups_widget_groups_list-js', BP_PLUGIN_URL . '/bp-groups/js/widget-groups.js', array('jquery', 'jquery-livequery-pack') );
14
+ wp_enqueue_style( 'groups_widget_members-css', BP_PLUGIN_URL . '/bp-groups/css/widget-groups.css' );
15
+ }
16
+ }
17
+ add_action( 'plugins_loaded', 'groups_register_widgets' );
18
+
19
+
20
+ /*** GROUPS WIDGET *****************/
21
+
22
+ function groups_widget_groups_list($args) {
23
+ global $current_blog, $bp;
24
+
25
+ extract($args);
26
+ $options = get_blog_option( $current_blog->blog_id, 'groups_widget_groups_list' );
27
+ ?>
28
+ <?php echo $before_widget; ?>
29
+ <?php echo $before_title
30
+ . $widget_name
31
+ . $after_title; ?>
32
+
33
+ <?php
34
+ if ( !$groups = wp_cache_get( 'popular_groups', 'bp' ) ) {
35
+ $groups = groups_get_popular( $options['max_groups'], 1 );
36
+ wp_cache_set( 'popular_groups', $groups, 'bp' );
37
+ }
38
+ ?>
39
+
40
+ <?php if ( $groups['groups'] ) : ?>
41
+ <div class="item-options" id="groups-list-options">
42
+ <img id="ajax-loader-groups" src="<?php echo $bp->groups->image_base ?>/ajax-loader.gif" height="7" alt="<?php _e( 'Loading', 'buddypress' ) ?>" style="display: none;" />
43
+ <a href="<?php echo site_url() . '/groups' ?>" id="newest-groups"><?php _e("Newest", 'buddypress') ?></a> |
44
+ <a href="<?php echo site_url() . '/groups' ?>" id="recently-active-groups"><?php _e("Active", 'buddypress') ?></a> |
45
+ <a href="<?php echo site_url() . '/groups' ?>" id="popular-groups" class="selected"><?php _e("Popular", 'buddypress') ?></a>
46
+ </div>
47
+ <ul id="groups-list" class="item-list">
48
+ <?php foreach ( $groups['groups'] as $group_id ) : ?>
49
+ <?php
50
+ if ( !$group = wp_cache_get( 'groups_group_nouserdata_' . $group_id->group_id, 'bp' ) ) {
51
+ $group = new BP_Groups_Group( $group_id->group_id, false, false );
52
+ wp_cache_set( 'groups_group_nouserdata_' . $group_id->group_id, $group, 'bp' );
53
+ }
54
+ ?>
55
+ <li>
56
+ <div class="item-avatar">
57
+ <a href="<?php echo bp_get_group_permalink( $group ) ?>" title="<?php echo $group->name ?>"><img src="<?php echo $group->avatar_thumb; ?>" alt="<?php echo $group->name ?> Avatar" class="avatar" /></a>
58
+ </div>
59
+
60
+ <div class="item">
61
+ <div class="item-title"><a href="<?php echo bp_get_group_permalink( $group ) ?>" title="<?php echo $group->name ?>"><?php echo $group->name ?></a></div>
62
+ <div class="item-meta">
63
+ <span class="activity">
64
+ <?php
65
+ if ( 1 == $group->total_member_count )
66
+ echo $group->total_member_count . __(' member', 'buddypress');
67
+ else
68
+ echo $group->total_member_count . __(' members', 'buddypress');
69
+ ?>
70
+ </span></div>
71
+ </div>
72
+ </li>
73
+ <?php $counter++; ?>
74
+ <?php endforeach; ?>
75
+ </ul>
76
+
77
+ <?php
78
+ if ( function_exists('wp_nonce_field') )
79
+ wp_nonce_field( 'groups_widget_groups_list', '_wpnonce-groups' );
80
+ ?>
81
+
82
+ <input type="hidden" name="groups_widget_max" id="groups_widget_max" value="<?php echo $options['max_groups'] ?>" />
83
+
84
+ <?php else: ?>
85
+ <div class="widget-error">
86
+ <?php _e('There are no groups to display.', 'buddypress') ?>
87
+ </div>
88
+ <?php endif; ?>
89
+
90
+ <?php echo $after_widget; ?>
91
+ <?php
92
+ }
93
+
94
+ function groups_widget_groups_list_control() {
95
+ global $current_blog;
96
+
97
+ $options = $newoptions = get_blog_option( $current_blog->blog_id, 'groups_widget_groups_list');
98
+
99
+ if ( $_POST['groups-widget-groups-list-submit'] ) {
100
+ $newoptions['max_groups'] = strip_tags( stripslashes( $_POST['groups-widget-groups-list-max'] ) );
101
+ }
102
+
103
+ if ( $options != $newoptions ) {
104
+ $options = $newoptions;
105
+ update_blog_option( $current_blog->blog_id, 'groups_widget_groups_list', $options );
106
+ }
107
+
108
+ $max_groups = attribute_escape( $options['max_groups'] );
109
+ ?>
110
+ <p><label for="groups-widget-groups-list-max"><?php _e('Maximum number of groups to show:', 'buddypress'); ?><br /> <input class="widefat" id="groups-widget-groups-list-max" name="groups-widget-groups-list-max" type="text" value="<?php echo $max_groups; ?>" style="width: 30%" /></label></p>
111
+ <input type="hidden" id="groups-widget-groups-list-submit" name="groups-widget-groups-list-submit" value="1" />
112
+ <?php
113
+ }
bp-groups/css/structure.css ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Basic layout structure styles for BuddyPress Friends. Formats BuddyPress friend pages within any WordPress theme.
3
+ No colors, fonts or pretty stuff. The only exception is buttons.
4
+
5
+ These structure styles can be overridden by the theme CSS file if needed.
6
+ */
7
+
8
+ .group-button {
9
+ background: url(../../bp-core/images/button_back.gif) top left no-repeat;
10
+ display: inline-block;
11
+ margin: 10px 0;
12
+ }
13
+
14
+ .group-button a {
15
+ display: block;
16
+ height: 19px;
17
+ color: #777;
18
+ font-size: 11px;
19
+ padding: 0 33px 0 11px;
20
+ margin-right: -7px;
21
+ text-shadow: 0 1px 0 #fff;
22
+ }
23
+ .group-button a:hover {
24
+ color: #555;
25
+ text-decoration: none;
26
+ }
27
+
28
+ .group-button a.join-group, .group-button a.request-membership {
29
+ background: url(../../bp-core/images/add_button_side.gif) top right no-repeat;
30
+ }
31
+
32
+ .group-button a.leave-group {
33
+ background: url(../../bp-core/images/remove_button_side.gif) top right no-repeat;
34
+ }
35
+
36
+ .group-button a.membership-requested {
37
+ background: url(../../bp-core/images/check_button_side.gif) top right no-repeat;
38
+ }
bp-groups/css/widget-groups.css ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .groups_widget_groups_list ul#groups-list {
2
+ margin: 15px 0 0 0;
3
+ padding: 0;
4
+ list-style: none;
5
+ }
6
+
7
+ .groups_widget_groups_list ul#groups-list li {
8
+ min-height: 60px;
9
+ }
10
+
11
+ .groups_widget_groups_list ul#groups-list li img.avatar {
12
+ float: left;
13
+ margin: 0 10px 0 0;
14
+ }
15
+
16
+ .groups_widget_groups_list ul#groups-list li span.activity {
17
+ font-size: 11px;
18
+ }
19
+
20
+ .groups_widget_groups_list img#ajax-loader-groups {
21
+ float: right;
22
+ }
bp-groups/images/ajax-loader.gif ADDED
Binary file
bp-groups/images/none-thumbnail.gif ADDED
Binary file
bp-groups/images/none.gif ADDED
Binary file
bp-groups/js/directory-groups.js ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready( function() {
2
+ jQuery("ul#letter-list li a").livequery('click',
3
+ function() {
4
+ jQuery('#ajax-loader-groups').toggle();
5
+
6
+ jQuery("div#groups-list-options a").removeClass("selected");
7
+ jQuery(this).addClass('selected');
8
+ jQuery("input#groups_search").val('');
9
+
10
+ var letter = jQuery(this).attr('id')
11
+ letter = letter.split('-');
12
+
13
+ jQuery.post( ajaxurl, {
14
+ action: 'directory_groups',
15
+ 'cookie': encodeURIComponent(document.cookie),
16
+ '_wpnonce': jQuery("input#_wpnonce-group-filter").val(),
17
+ 'letter': letter[1],
18
+ 'page': 1
19
+ },
20
+ function(response)
21
+ {
22
+ response = response.substr(0, response.length-1);
23
+ jQuery("#group-dir-list").fadeOut(200,
24
+ function() {
25
+ jQuery('#ajax-loader-groups').toggle();
26
+ jQuery("#group-dir-list").html(response);
27
+ jQuery("#group-dir-list").fadeIn(200);
28
+ }
29
+ );
30
+ });
31
+
32
+ return false;
33
+ }
34
+ );
35
+
36
+ jQuery("form#search-groups-form").submit( function() {
37
+ jQuery('#ajax-loader-groups').toggle();
38
+
39
+ jQuery.post( ajaxurl, {
40
+ action: 'directory_groups',
41
+ 'cookie': encodeURIComponent(document.cookie),
42
+ '_wpnonce': jQuery("input#_wpnonce-group-filter").val(),
43
+ 's': jQuery("input#groups_search").val(),
44
+ 'page': 1
45
+ },
46
+ function(response)
47
+ {
48
+ response = response.substr(0, response.length-1);
49
+ jQuery("#group-dir-list").fadeOut(200,
50
+ function() {
51
+ jQuery('#ajax-loader-groups').toggle();
52
+ jQuery("#group-dir-list").html(response);
53
+ jQuery("#group-dir-list").fadeIn(200);
54
+ }
55
+ );
56
+ });
57
+
58
+ return false;
59
+ }
60
+ );
61
+
62
+ jQuery("div#group-dir-pag a").livequery('click',
63
+ function() {
64
+ jQuery('#ajax-loader-groups').toggle();
65
+
66
+ var page = jQuery(this).attr('href');
67
+ page = page.split('gpage=');
68
+
69
+ if ( !jQuery("input#selected_letter").val() )
70
+ var letter = '';
71
+ else
72
+ var letter = jQuery("input#selected_letter").val();
73
+
74
+ if ( !jQuery("input#search_terms").val() )
75
+ var search_terms = '';
76
+ else
77
+ var search_terms = jQuery("input#search_terms").val();
78
+
79
+ jQuery.post( ajaxurl, {
80
+ action: 'directory_groups',
81
+ 'cookie': encodeURIComponent(document.cookie),
82
+ '_wpnonce': jQuery("input#_wpnonce").val(),
83
+ 'gpage': page[1],
84
+ '_wpnonce': jQuery("input#_wpnonce-group-filter").val(),
85
+
86
+ 'letter': letter,
87
+ 's': search_terms
88
+ },
89
+ function(response)
90
+ {
91
+ response = response.substr(0, response.length-1);
92
+ jQuery("#group-dir-list").fadeOut(200,
93
+ function() {
94
+ jQuery('#ajax-loader-groups').toggle();
95
+ jQuery("#group-dir-list").html(response);
96
+ jQuery("#group-dir-list").fadeIn(200);
97
+ }
98
+ );
99
+ });
100
+
101
+ return false;
102
+ }
103
+ );
104
+
105
+ jQuery("div.group-button a").livequery('click',
106
+ function() {
107
+ var gid = jQuery(this).parent().attr('id');
108
+ gid = gid.split('-');
109
+ gid = gid[1];
110
+
111
+ var nonce = jQuery(this).attr('href');
112
+ nonce = nonce.split('?_wpnonce=');
113
+ nonce = nonce[1].split('&');
114
+ nonce = nonce[0];
115
+
116
+ var thelink = jQuery(this);
117
+
118
+ jQuery.post( ajaxurl, {
119
+ action: 'joinleave_group',
120
+ 'cookie': encodeURIComponent(document.cookie),
121
+ 'gid': gid,
122
+ '_wpnonce': nonce
123
+ },
124
+ function(response)
125
+ {
126
+ response = response.substr(0, response.length-1);
127
+ var parentdiv = thelink.parent();
128
+
129
+ jQuery(parentdiv).fadeOut(200,
130
+ function() {
131
+ parentdiv.fadeIn(200).html(response);
132
+ }
133
+ );
134
+ });
135
+ return false;
136
+ }
137
+ );
138
+ });
bp-groups/js/general.js ADDED
@@ -0,0 +1,197 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready( function() {
2
+ jQuery("form#group-search-form").submit(
3
+ function() {
4
+ return false;
5
+ }
6
+ );
7
+
8
+ jQuery("div#invite-list input").click(
9
+ function() {
10
+ jQuery('#ajax-loader').toggle();
11
+
12
+ var friend_id = jQuery(this).val();
13
+
14
+ if ( jQuery(this).attr('checked') == true ) {
15
+ var friend_action = 'invite';
16
+ } else {
17
+ var friend_action = 'uninvite';
18
+ }
19
+
20
+ jQuery.post( ajaxurl, {
21
+ action: 'groups_invite_user',
22
+ 'friend_action': friend_action,
23
+ 'cookie': encodeURIComponent(document.cookie),
24
+ '_wpnonce': jQuery("input#_wpnonce_invite_uninvite_user").val(),
25
+ 'friend_id': friend_id,
26
+ 'group_id': jQuery("input#group_id").val()
27
+ },
28
+ function(response)
29
+ {
30
+ if ( jQuery("#message") )
31
+ jQuery("#message").hide();
32
+
33
+ jQuery('#ajax-loader').toggle();
34
+ response = response.substr(0, response.length-1);
35
+
36
+ if ( friend_action == 'invite' ) {
37
+ jQuery('#friend-list').append(response);
38
+ } else if ( friend_action == 'uninvite' ) {
39
+ jQuery('#friend-list li#uid-' + friend_id).remove();
40
+ }
41
+ });
42
+ }
43
+ );
44
+
45
+ jQuery("#friend-list li a.remove").livequery('click',
46
+ function() {
47
+ jQuery('#ajax-loader').toggle();
48
+
49
+ var friend_id = jQuery(this).attr('id');
50
+ friend_id = friend_id.split('-');
51
+ friend_id = friend_id[1];
52
+
53
+ jQuery.post( ajaxurl, {
54
+ action: 'groups_invite_user',
55
+ 'friend_action': 'uninvite',
56
+ 'cookie': encodeURIComponent(document.cookie),
57
+ '_wpnonce': jQuery("input#_wpnonce_invite_uninvite_user").val(),
58
+ 'friend_id': friend_id,
59
+ 'group_id': jQuery("input#group_id").val()
60
+ },
61
+ function(response)
62
+ {
63
+ jQuery('#ajax-loader').toggle();
64
+ jQuery('#friend-list li#uid-' + friend_id).remove();
65
+ jQuery('#invite-list input#f-' + friend_id).attr('checked', false);
66
+ });
67
+
68
+ return false;
69
+ }
70
+ );
71
+
72
+ jQuery("div#pag a").livequery('click',
73
+ function() {
74
+ jQuery('#ajax-loader').toggle();
75
+
76
+ var grpage = jQuery(this).attr('href');
77
+ grpage = grpage.split('=');
78
+
79
+ jQuery.post( ajaxurl, {
80
+ action: 'group_filter',
81
+ 'cookie': encodeURIComponent(document.cookie),
82
+ '_wpnonce': jQuery("input#_wpnonce_group_filter").val(),
83
+ 'grpage': grpage[1],
84
+
85
+ 'group-filter-box': jQuery("#group-filter-box").val()
86
+ },
87
+ function(response)
88
+ {
89
+ response = response.substr( 0, response.length - 1 );
90
+
91
+ jQuery("div#group-loop").fadeOut(200,
92
+ function() {
93
+ jQuery('#ajax-loader').toggle();
94
+ jQuery("div#group-loop").html(response);
95
+ jQuery("div#group-loop").fadeIn(200);
96
+ }
97
+ );
98
+ });
99
+
100
+ return false;
101
+ }
102
+ );
103
+
104
+ jQuery("input#group-filter-box").keyup(
105
+ function(e) {
106
+ if ( e.which == 13 ) {
107
+ jQuery('#ajax-loader').toggle();
108
+
109
+ jQuery.post( ajaxurl, {
110
+ action: 'group_filter',
111
+ 'cookie': encodeURIComponent(document.cookie),
112
+ '_wpnonce': jQuery("input#_wpnonce_group_filter").val(),
113
+
114
+ 'group-filter-box': jQuery("#group-filter-box").val()
115
+ },
116
+ function(response)
117
+ {
118
+ response = response.substr( 0, response.length - 1 );
119
+
120
+ jQuery("div#group-loop").fadeOut(200,
121
+ function() {
122
+ jQuery('#ajax-loader').toggle();
123
+ jQuery("div#group-loop").html(response);
124
+ jQuery("div#group-loop").fadeIn(200);
125
+ }
126
+ );
127
+ });
128
+
129
+ return false;
130
+ }
131
+ }
132
+ );
133
+
134
+ jQuery("div#member-pagination a").livequery('click',
135
+ function() {
136
+ jQuery('#ajax-loader').toggle();
137
+
138
+ var mlpage = jQuery(this).attr('href');
139
+ mlpage = mlpage.split('=');
140
+
141
+ jQuery.post( ajaxurl, {
142
+ action: 'get_group_members',
143
+ 'cookie': encodeURIComponent(document.cookie),
144
+ '_wpnonce': jQuery("input#_member_pag_nonce").val(),
145
+ 'group_id': jQuery("#group_id").val(),
146
+ 'mlpage': mlpage[1]
147
+ },
148
+ function(response)
149
+ {
150
+ response = response.substr(0, response.length-1);
151
+
152
+ jQuery("form#group-members-form").fadeOut(200,
153
+ function() {
154
+ jQuery("form#group-members-form").html(response);
155
+ jQuery("form#group-members-form").fadeIn(200);
156
+ }
157
+ );
158
+
159
+ return false;
160
+ });
161
+
162
+ return false;
163
+ }
164
+ );
165
+
166
+ jQuery("div#member-admin-pagination a").livequery('click',
167
+ function() {
168
+ jQuery('#ajax-loader').toggle();
169
+
170
+ var mlpage = jQuery(this).attr('href');
171
+ mlpage = mlpage.split('=');
172
+
173
+ jQuery.post( ajaxurl, {
174
+ action: 'get_group_members_admin',
175
+ 'cookie': encodeURIComponent(document.cookie),
176
+ '_wpnonce': jQuery("input#_member_admin_pag_nonce").val(),
177
+ 'group_id': jQuery("#group_id").val(),
178
+ 'mlpage': mlpage[1]
179
+ },
180
+ function(response)
181
+ {
182
+ response = response.substr(0, response.length-1);
183
+
184
+ jQuery("form#group-members-form").fadeOut(200,
185
+ function() {
186
+ jQuery("form#group-members-form").html(response);
187
+ jQuery("form#group-members-form").fadeIn(200);
188
+ }
189
+ );
190
+
191
+ return false;
192
+ });
193
+
194
+ return false;
195
+ }
196
+ );
197
+ });
bp-groups/js/widget-groups.js ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready( function() {
2
+ jQuery("div#groups-list-options a").livequery('click',
3
+ function() {
4
+ jQuery('#ajax-loader-groups').toggle();
5
+
6
+ jQuery("div#groups-list-options a").removeClass("selected");
7
+ jQuery(this).addClass('selected');
8
+
9
+ jQuery.post( ajaxurl, {
10
+ action: 'widget_groups_list',
11
+ 'cookie': encodeURIComponent(document.cookie),
12
+ '_wpnonce': jQuery("input#_wpnonce-groups").val(),
13
+ 'max-groups': jQuery("input#groups_widget_max").val(),
14
+ 'filter': jQuery(this).attr('id')
15
+ },
16
+ function(response)
17
+ {
18
+ groups_wiget_response(response);
19
+ });
20
+
21
+ return false;
22
+ }
23
+ );
24
+ });
25
+
26
+ function groups_wiget_response(response) {
27
+ response = response.substr(0, response.length-1);
28
+ response = response.split('[[SPLIT]]');
29
+
30
+ if ( response[0] != "-1" ) {
31
+ jQuery("ul#groups-list").fadeOut(200,
32
+ function() {
33
+ jQuery('#ajax-loader-groups').toggle();
34
+ jQuery("ul#groups-list").html(response[1]);
35
+ jQuery("ul#groups-list").fadeIn(200);
36
+ }
37
+ );
38
+
39
+ } else {
40
+ jQuery("ul#groups-list").fadeOut(200,
41
+ function() {
42
+ jQuery('#ajax-loader-groups').toggle();
43
+ var message = '<p>' + response[1] + '</p>';
44
+ jQuery("ul#groups-list").html(message);
45
+ jQuery("ul#groups-list").fadeIn(200);
46
+ }
47
+ );
48
+ }
49
+ }
bp-languages/buddypress.pot ADDED
@@ -0,0 +1,4501 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SOME DESCRIPTIVE TITLE.
2
+ # Copyright (C) YEAR BuddyPress
3
+ # This file is distributed under the same license as the PACKAGE package.
4
+ # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
+ #
6
+ #, fuzzy
7
+ msgid ""
8
+ msgstr ""
9
+ "Project-Id-Version: PACKAGE VERSION\n"
10
+ "Report-Msgid-Bugs-To: wp-polyglots@lists.automattic.com\n"
11
+ "POT-Creation-Date: 2009-04-30 14:11+0000\n"
12
+ "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
+ "Language-Team: LANGUAGE <LL@li.org>\n"
15
+ "MIME-Version: 1.0\n"
16
+ "Content-Type: text/plain; charset=CHARSET\n"
17
+ "Content-Transfer-Encoding: 8bit\n"
18
+
19
+ #: bp-activity.php:146 bp-activity/feeds/bp-activity-personal-feed.php:21
20
+ msgid "Activity"
21
+ msgstr ""
22
+
23
+ #: bp-activity.php:152
24
+ msgid "Just Me"
25
+ msgstr ""
26
+
27
+ #: bp-activity.php:153 bp-friends.php:95 bp-friends.php:100 bp-friends.php:257
28
+ #: bp-friends/bp-friends-templatetags.php:404
29
+ #: bp-themes/bpmember/friends/index.php:10
30
+ #: bp-themes/bpskeletonmember/friends/index.php:23
31
+ msgid "My Friends"
32
+ msgstr ""
33
+
34
+ #: bp-activity.php:157 bp-themes/bpmember/activity/just-me.php:31
35
+ #: bp-themes/bpmember/profile/index.php:38
36
+ #: bp-themes/bpskeletonmember/activity/just-me.php:43
37
+ #: bp-themes/bpskeletonmember/profile/index.php:51
38
+ msgid "My Activity"
39
+ msgstr ""
40
+
41
+ #: bp-activity/bp-activity-templatetags.php:181
42
+ #, php-format
43
+ msgid "Viewing item %d to %d (of %d items)"
44
+ msgstr ""
45
+
46
+ #: bp-activity/bp-activity-templatetags.php:182
47
+ #: bp-blogs/bp-blogs-templatetags.php:329
48
+ #: bp-blogs/bp-blogs-templatetags.php:505
49
+ #: bp-blogs/bp-blogs-templatetags.php:1208
50
+ #: bp-core/bp-core-templatetags.php:941 bp-core/bp-core-widgets.php:102
51
+ #: bp-forums/bp-forums-templatetags.php:356
52
+ #: bp-forums/bp-forums-templatetags.php:570
53
+ #: bp-friends/bp-friends-templatetags.php:291
54
+ #: bp-friends/bp-friends-templatetags.php:303
55
+ #: bp-groups/bp-groups-templatetags.php:1065
56
+ #: bp-groups/bp-groups-templatetags.php:1098
57
+ #: bp-groups/bp-groups-templatetags.php:2048
58
+ #: bp-groups/bp-groups-widgets.php:42
59
+ #: bp-messages/bp-messages-templatetags.php:270
60
+ #: bp-themes/bpmember/wire/post-list.php:10
61
+ #: bp-themes/bpskeletonmember/wire/post-list.php:22
62
+ #: bp-wire/bp-wire-ajax.php:12
63
+ msgid "Loading"
64
+ msgstr ""
65
+
66
+ #: bp-activity/bp-activity-templatetags.php:275
67
+ #, php-format
68
+ msgid "&nbsp; %s ago"
69
+ msgstr ""
70
+
71
+ #: bp-activity/bp-activity-widgets.php:8 bp-activity/bp-activity-widgets.php:9
72
+ #: bp-activity/feeds/bp-activity-sitewide-feed.php:22
73
+ msgid "Site Wide Activity"
74
+ msgstr ""
75
+
76
+ #: bp-activity/bp-activity-widgets.php:44
77
+ #: bp-themes/bpmember/activity/just-me.php:36
78
+ #: bp-themes/bpmember/activity/my-friends.php:28
79
+ #: bp-themes/bpmember/profile/index.php:43
80
+ #: bp-themes/bpskeletonmember/activity/activity-list.php:17
81
+ msgid "RSS Feed"
82
+ msgstr ""
83
+
84
+ #: bp-activity/bp-activity-widgets.php:44 bp-themes/bphome/header.php:14
85
+ #: bp-themes/bpmember/header.php:18
86
+ msgid "Site Wide Activity RSS Feed"
87
+ msgstr ""
88
+
89
+ #: bp-activity/bp-activity-widgets.php:55
90
+ msgid "There has been no recent site activity."
91
+ msgstr ""
92
+
93
+ #: bp-activity/bp-activity-widgets.php:79
94
+ msgid "Max Number of Items:"
95
+ msgstr ""
96
+
97
+ #: bp-activity/feeds/bp-activity-friends-feed.php:21
98
+ msgid "Friends Activity"
99
+ msgstr ""
100
+
101
+ #: bp-activity/feeds/bp-activity-friends-feed.php:24
102
+ #, php-format
103
+ msgid "%s - Friends Activity Feed"
104
+ msgstr ""
105
+
106
+ #: bp-activity/feeds/bp-activity-personal-feed.php:24
107
+ #, php-format
108
+ msgid "%s - Activity Feed"
109
+ msgstr ""
110
+
111
+ #: bp-activity/feeds/bp-activity-sitewide-feed.php:25
112
+ msgid "Site Wide Activity Feed"
113
+ msgstr ""
114
+
115
+ #: bp-blogs.php:158 bp-core/bp-core-templatetags.php:583
116
+ #: bp-core/bp-core-templatetags.php:675 bp-themes/bphome/header.php:55
117
+ #: bp-themes/bpmember/header.php:54 bp-themes/bpskeletonmember/header.php:56
118
+ msgid "Blogs"
119
+ msgstr ""
120
+
121
+ #: bp-blogs.php:166 bp-blogs.php:175 bp-core/bp-core-adminbar.php:139
122
+ #: bp-themes/bpmember/blogs/my-blogs.php:8
123
+ #: bp-themes/bpskeletonmember/blogs/my-blogs.php:20
124
+ msgid "My Blogs"
125
+ msgstr ""
126
+
127
+ #: bp-blogs.php:167 bp-themes/bpmember/blogs/recent-posts.php:8
128
+ #: bp-themes/bpskeletonmember/blogs/recent-posts.php:19
129
+ msgid "Recent Posts"
130
+ msgstr ""
131
+
132
+ #: bp-blogs.php:168 bp-themes/bpmember/blogs/recent-comments.php:8
133
+ #: bp-themes/bpskeletonmember/blogs/recent-comments.php:18
134
+ msgid "Recent Comments"
135
+ msgstr ""
136
+
137
+ #: bp-blogs.php:169 bp-blogs/bp-blogs-templatetags.php:171
138
+ #: bp-themes/bpmember/blogs/create.php:8
139
+ #: bp-themes/bpskeletonmember/blogs/create.php:16
140
+ msgid "Create a Blog"
141
+ msgstr ""
142
+
143
+ #: bp-blogs.php:274
144
+ #, php-format
145
+ msgid "%s created a new blog: %s"
146
+ msgstr ""
147
+
148
+ #: bp-blogs.php:291
149
+ #, php-format
150
+ msgid "%s wrote a new blog post: %s"
151
+ msgstr ""
152
+
153
+ #: bp-blogs.php:319
154
+ #, php-format
155
+ msgid "%s commented on the blog post %s"
156
+ msgstr ""
157
+
158
+ #: bp-blogs/bp-blogs-templatetags.php:39
159
+ msgid "There was a problem, please correct the form below and try again."
160
+ msgstr ""
161
+
162
+ #: bp-blogs/bp-blogs-templatetags.php:42
163
+ msgid ""
164
+ "By filling out the form below, you can <strong>add a blog to your account</"
165
+ "strong>. There is no limit to the number of blogs you can have, so create to "
166
+ "your heart's content, but blog responsibly."
167
+ msgstr ""
168
+
169
+ #: bp-blogs/bp-blogs-templatetags.php:44
170
+ msgid ""
171
+ "If you&#8217;re not going to use a great blog domain, leave it for a new "
172
+ "user. Now have at it!"
173
+ msgstr ""
174
+
175
+ #: bp-blogs/bp-blogs-templatetags.php:52 bp-core/bp-core-signup.php:154
176
+ msgid "Create Blog &raquo;"
177
+ msgstr ""
178
+
179
+ #: bp-blogs/bp-blogs-templatetags.php:66 bp-core/bp-core-signup.php:36
180
+ msgid "Blog Name:"
181
+ msgstr ""
182
+
183
+ #: bp-blogs/bp-blogs-templatetags.php:68 bp-core/bp-core-signup.php:38
184
+ msgid "Blog Domain:"
185
+ msgstr ""
186
+
187
+ #: bp-blogs/bp-blogs-templatetags.php:80 bp-core/bp-core-signup.php:52
188
+ msgid "Your address will be "
189
+ msgstr ""
190
+
191
+ #: bp-blogs/bp-blogs-templatetags.php:82 bp-core/bp-core-signup.php:54
192
+ msgid "blogname"
193
+ msgstr ""
194
+
195
+ #: bp-blogs/bp-blogs-templatetags.php:84 bp-core/bp-core-signup.php:56
196
+ msgid "domain."
197
+ msgstr ""
198
+
199
+ #: bp-blogs/bp-blogs-templatetags.php:86 bp-core/bp-core-signup.php:58
200
+ msgid ""
201
+ "Must be at least 4 characters, letters and numbers only. It cannot be "
202
+ "changed so choose carefully!)"
203
+ msgstr ""
204
+
205
+ #: bp-blogs/bp-blogs-templatetags.php:91 bp-core/bp-core-signup.php:64
206
+ msgid "Blog Title:"
207
+ msgstr ""
208
+
209
+ #: bp-blogs/bp-blogs-templatetags.php:99 bp-core/bp-core-signup.php:72
210
+ msgid "Privacy:"
211
+ msgstr ""
212
+
213
+ #: bp-blogs/bp-blogs-templatetags.php:100 bp-core/bp-core-signup.php:73
214
+ msgid ""
215
+ "I would like my blog to appear in search engines like Google and Technorati, "
216
+ "and in public listings around this site."
217
+ msgstr ""
218
+
219
+ #: bp-blogs/bp-blogs-templatetags.php:104 bp-core/bp-core-admin.php:60
220
+ #: bp-core/bp-core-admin.php:68 bp-core/bp-core-admin.php:75
221
+ #: bp-core/bp-core-admin.php:83 bp-core/bp-core-signup.php:76
222
+ #: bp-friends.php:161 bp-groups.php:868 bp-messages.php:248
223
+ #: bp-themes/bpmember/groups/admin/edit-details.php:31
224
+ #: bp-themes/bpskeletonmember/groups/admin/edit-details.php:41
225
+ #: bp-xprofile.php:299 bp-xprofile/bp-xprofile-admin.php:85
226
+ msgid "Yes"
227
+ msgstr ""
228
+
229
+ #: bp-blogs/bp-blogs-templatetags.php:108 bp-core/bp-core-admin.php:61
230
+ #: bp-core/bp-core-admin.php:69 bp-core/bp-core-admin.php:76
231
+ #: bp-core/bp-core-admin.php:84 bp-core/bp-core-signup.php:80
232
+ #: bp-friends.php:162 bp-groups.php:869 bp-messages.php:249
233
+ #: bp-themes/bpmember/groups/admin/edit-details.php:32
234
+ #: bp-themes/bpskeletonmember/groups/admin/edit-details.php:42
235
+ #: bp-xprofile.php:300
236
+ msgid "No"
237
+ msgstr ""
238
+
239
+ #: bp-blogs/bp-blogs-templatetags.php:159
240
+ msgid "Congratulations! You have successfully registered a new blog."
241
+ msgstr ""
242
+
243
+ #: bp-blogs/bp-blogs-templatetags.php:161 bp-core/bp-core-signup.php:187
244
+ #, php-format
245
+ msgid ""
246
+ "<a href=\"http://%1$s\">http://%2$s</a> is your new blog. <a href=\"%3$s"
247
+ "\">Login</a> as \"%4$s\" using your existing password."
248
+ msgstr ""
249
+
250
+ #: bp-blogs/bp-blogs-templatetags.php:185
251
+ #: bp-themes/bpmember/blogs/my-blogs.php:8
252
+ #: bp-themes/bpskeletonmember/blogs/my-blogs.php:20
253
+ #, php-format
254
+ msgid "%s's Blogs"
255
+ msgstr ""
256
+
257
+ #: bp-blogs/bp-blogs-templatetags.php:186
258
+ #, php-format
259
+ msgid "%s's Recent Posts"
260
+ msgstr ""
261
+
262
+ #: bp-blogs/bp-blogs-templatetags.php:187
263
+ #, php-format
264
+ msgid "%s's Recent Comments"
265
+ msgstr ""
266
+
267
+ #: bp-blogs/bp-blogs-templatetags.php:328
268
+ #: bp-blogs/bp-blogs-templatetags.php:1207
269
+ #, php-format
270
+ msgid "Viewing blog %d to %d (of %d blogs)"
271
+ msgstr ""
272
+
273
+ #: bp-blogs/bp-blogs-templatetags.php:504
274
+ #, php-format
275
+ msgid "Viewing post %d to %d (of %d posts)"
276
+ msgstr ""
277
+
278
+ #: bp-blogs/bp-blogs-templatetags.php:608
279
+ msgid "Enter your password to view comments"
280
+ msgstr ""
281
+
282
+ #: bp-blogs/bp-blogs-templatetags.php:628
283
+ #, php-format
284
+ msgid "Comment on %s"
285
+ msgstr ""
286
+
287
+ #: bp-blogs/bp-blogs-templatetags.php:1230
288
+ #: bp-blogs/bp-blogs-templatetags.php:1239
289
+ #: bp-blogs/bp-blogs-templatetags.php:1248
290
+ msgid "Blog Avatar"
291
+ msgstr ""
292
+
293
+ #: bp-blogs/bp-blogs-templatetags.php:1284 bp-core/bp-core-ajax.php:47
294
+ #: bp-core/bp-core-classes.php:67 bp-core/bp-core-templatetags.php:269
295
+ #: bp-groups/bp-groups-ajax.php:102 bp-groups/bp-groups-templatetags.php:314
296
+ #: bp-groups/bp-groups-templatetags.php:2120
297
+ #, php-format
298
+ msgid "active %s ago"
299
+ msgstr ""
300
+
301
+ #: bp-blogs/bp-blogs-templatetags.php:1294
302
+ #, php-format
303
+ msgid "Latest Post: %s"
304
+ msgstr ""
305
+
306
+ #: bp-blogs/bp-blogs-templatetags.php:1315
307
+ #: bp-core/bp-core-templatetags.php:1054
308
+ #: bp-groups/bp-groups-templatetags.php:2194
309
+ msgid "Search anything..."
310
+ msgstr ""
311
+
312
+ #: bp-blogs/bp-blogs-templatetags.php:1316
313
+ #: bp-core/bp-core-templatetags.php:597 bp-core/bp-core-templatetags.php:1055
314
+ #: bp-groups/bp-groups-templatetags.php:2195 bp-themes/bphome/searchform.php:3
315
+ msgid "Search"
316
+ msgstr ""
317
+
318
+ #: bp-blogs/bp-blogs-widgets.php:8 bp-blogs/bp-blogs-widgets.php:9
319
+ msgid "Recent Blog Posts"
320
+ msgstr ""
321
+
322
+ #: bp-blogs/bp-blogs-widgets.php:34
323
+ msgid "Site Wide"
324
+ msgstr ""
325
+
326
+ #: bp-blogs/bp-blogs-widgets.php:48
327
+ #, php-format
328
+ msgid "by %s from the blog <a href=\"%s\">%s</a>"
329
+ msgstr ""
330
+
331
+ #: bp-blogs/bp-blogs-widgets.php:56
332
+ msgid "There are no recent blog posts, why not write one?"
333
+ msgstr ""
334
+
335
+ #: bp-blogs/bp-blogs-widgets.php:80
336
+ msgid "Max Number of Posts:"
337
+ msgstr ""
338
+
339
+ #: bp-core.php:265 bp-core/bp-core-adminbar.php:29
340
+ msgid "BuddyPress"
341
+ msgstr ""
342
+
343
+ #: bp-core.php:266 bp-core/bp-core-settings.php:56
344
+ msgid "General Settings"
345
+ msgstr ""
346
+
347
+ #: bp-core.php:267
348
+ msgid "Component Setup"
349
+ msgstr ""
350
+
351
+ #: bp-core.php:304 bp-xprofile.php:201 bp-xprofile.php:298
352
+ msgid "Profile"
353
+ msgstr ""
354
+
355
+ #: bp-core.php:310 bp-groups/bp-groups-templatetags.php:871
356
+ #: bp-xprofile.php:207
357
+ msgid "Public"
358
+ msgstr ""
359
+
360
+ #: bp-core.php:314 bp-core/bp-core-templatetags.php:312 bp-xprofile.php:213
361
+ msgid "My Profile"
362
+ msgstr ""
363
+
364
+ #: bp-core.php:669 bp-wire/bp-wire-templatetags.php:340
365
+ msgid "You"
366
+ msgstr ""
367
+
368
+ #: bp-core.php:750
369
+ #, php-format
370
+ msgid "%s's"
371
+ msgstr ""
372
+
373
+ #: bp-core.php:840 bp-core/bp-core-templatetags.php:395
374
+ #: bp-themes/bphome/comments.php:42
375
+ msgid "at"
376
+ msgstr ""
377
+
378
+ #: bp-core.php:898
379
+ msgid "year"
380
+ msgstr ""
381
+
382
+ #: bp-core.php:898
383
+ msgid "years"
384
+ msgstr ""
385
+
386
+ #: bp-core.php:899
387
+ msgid "month"
388
+ msgstr ""
389
+
390
+ #: bp-core.php:899
391
+ msgid "months"
392
+ msgstr ""
393
+
394
+ #: bp-core.php:900
395
+ msgid "week"
396
+ msgstr ""
397
+
398
+ #: bp-core.php:900
399
+ msgid "weeks"
400
+ msgstr ""
401
+
402
+ #: bp-core.php:901
403
+ msgid "day"
404
+ msgstr ""
405
+
406
+ #: bp-core.php:901
407
+ msgid "days"
408
+ msgstr ""
409
+
410
+ #: bp-core.php:902
411
+ msgid "hour"
412
+ msgstr ""
413
+
414
+ #: bp-core.php:902
415
+ msgid "hours"
416
+ msgstr ""
417
+
418
+ #: bp-core.php:903
419
+ msgid "minute"
420
+ msgstr ""
421
+
422
+ #: bp-core.php:903
423
+ msgid "minutes"
424
+ msgstr ""
425
+
426
+ #: bp-core.php:904
427
+ msgid "second"
428
+ msgstr ""
429
+
430
+ #: bp-core.php:904 bp-core.php:950
431
+ msgid "seconds"
432
+ msgstr ""
433
+
434
+ #: bp-core.php:915
435
+ msgid "[Adjust Time Zone]"
436
+ msgstr ""
437
+
438
+ #: bp-core.php:945
439
+ msgid ",|Separator in time since"
440
+ msgstr ""
441
+
442
+ #: bp-core.php:993
443
+ msgid "not recently active"
444
+ msgstr ""
445
+
446
+ #: bp-core/bp-core-activation.php:21
447
+ msgid "Activation Key Required"
448
+ msgstr ""
449
+
450
+ #: bp-core/bp-core-activation.php:23
451
+ msgid ""
452
+ "This is the key contained in the email you were sent after registering for "
453
+ "this site."
454
+ msgstr ""
455
+
456
+ #: bp-core/bp-core-activation.php:28
457
+ msgid "Activation Key:"
458
+ msgstr ""
459
+
460
+ #: bp-core/bp-core-activation.php:32
461
+ msgid "Activate &raquo;"
462
+ msgstr ""
463
+
464
+ #: bp-core/bp-core-activation.php:47 bp-core/bp-core-activation.php:65
465
+ msgid "Your account is now active!"
466
+ msgstr ""
467
+
468
+ #: bp-core/bp-core-activation.php:50
469
+ msgid ""
470
+ "Your account has already been activated. You can now log in with the account "
471
+ "details that were emailed to you."
472
+ msgstr ""
473
+
474
+ #: bp-core/bp-core-activation.php:54
475
+ msgid "An error occurred during the activation"
476
+ msgstr ""
477
+
478
+ #: bp-core/bp-core-activation.php:67
479
+ #, php-format
480
+ msgid ""
481
+ "Your account is now activated. <a href=\"%1$s\">Login</a> or go back to the "
482
+ "<a href=\"%2$s\">homepage</a>."
483
+ msgstr ""
484
+
485
+ #: bp-core/bp-core-activation.php:70 bp-core/bp-core-signup.php:99
486
+ msgid "Username:"
487
+ msgstr ""
488
+
489
+ #: bp-core/bp-core-activation.php:71
490
+ msgid "Password:"
491
+ msgstr ""
492
+
493
+ #: bp-core/bp-core-activation.php:99
494
+ #, php-format
495
+ msgid ""
496
+ "To activate your blog, please click the following link:\n"
497
+ "\n"
498
+ "%s\n"
499
+ "\n"
500
+ "After you activate, you will receive *another email* with your login.\n"
501
+ "\n"
502
+ "After you activate, you can visit your blog here:\n"
503
+ "\n"
504
+ "%s"
505
+ msgstr ""
506
+
507
+ #: bp-core/bp-core-activation.php:100 bp-core/bp-core-activation.php:121
508
+ #, php-format
509
+ msgid "Activate %s"
510
+ msgstr ""
511
+
512
+ #: bp-core/bp-core-activation.php:120
513
+ #, php-format
514
+ msgid ""
515
+ "To activate your user, please click the following link:\n"
516
+ "\n"
517
+ "%s\n"
518
+ "\n"
519
+ "After you activate, you will receive *another email* with your login.\n"
520
+ "\n"
521
+ msgstr ""
522
+
523
+ #: bp-core/bp-core-admin.php:32
524
+ msgid "BuddyPress Settings"
525
+ msgstr ""
526
+
527
+ #: bp-core/bp-core-admin.php:36 bp-core/bp-core-admin.php:168
528
+ msgid "Settings Saved"
529
+ msgstr ""
530
+
531
+ #: bp-core/bp-core-admin.php:46
532
+ msgid "Base profile group name"
533
+ msgstr ""
534
+
535
+ #: bp-core/bp-core-admin.php:52
536
+ msgid "Full Name field name"
537
+ msgstr ""
538
+
539
+ #: bp-core/bp-core-admin.php:58
540
+ msgid "Disable BuddyPress to WordPress profile syncing?"
541
+ msgstr ""
542
+
543
+ #: bp-core/bp-core-admin.php:66
544
+ msgid "Hide admin bar for logged out users?"
545
+ msgstr ""
546
+
547
+ #: bp-core/bp-core-admin.php:73
548
+ msgid "Disable avatar uploads? (Gravatars will still work)"
549
+ msgstr ""
550
+
551
+ #: bp-core/bp-core-admin.php:81
552
+ msgid "Allow non-friends to post on profile wires?"
553
+ msgstr ""
554
+
555
+ #: bp-core/bp-core-admin.php:89
556
+ msgid "Select theme to use for BuddyPress generated pages"
557
+ msgstr ""
558
+
559
+ #: bp-core/bp-core-admin.php:107
560
+ #, php-format
561
+ msgid ""
562
+ "<strong>You do not have any BuddyPress themes installed.</strong><p style="
563
+ "\"line-height: 150%%\">Please move the default BuddyPress themes to their "
564
+ "correct location (move %s to %s) and reload this page. You can <a href="
565
+ "\"http://buddypress.org/extend/themes\" title=\"Download\">download more "
566
+ "themes here</a>.</p>"
567
+ msgstr ""
568
+
569
+ #: bp-core/bp-core-admin.php:109
570
+ msgid "No Themes Installed."
571
+ msgstr ""
572
+
573
+ #: bp-core/bp-core-admin.php:114
574
+ msgid "Default User Avatar"
575
+ msgstr ""
576
+
577
+ #: bp-core/bp-core-admin.php:116
578
+ msgid ""
579
+ "For users without a custom avatar of their own, you can either display a "
580
+ "generic logo or a generated one based on their email address"
581
+ msgstr ""
582
+
583
+ #: bp-core/bp-core-admin.php:118
584
+ msgid "Mystery Man"
585
+ msgstr ""
586
+
587
+ #: bp-core/bp-core-admin.php:119
588
+ msgid "Identicon (Generated)"
589
+ msgstr ""
590
+
591
+ #: bp-core/bp-core-admin.php:120
592
+ msgid "Wavatar (Generated)"
593
+ msgstr ""
594
+
595
+ #: bp-core/bp-core-admin.php:121
596
+ msgid "MonsterID (Generated)"
597
+ msgstr ""
598
+
599
+ #: bp-core/bp-core-admin.php:132 bp-core/bp-core-admin.php:263
600
+ #: bp-forums/bp-forums-admin.php:114
601
+ msgid "Save Settings"
602
+ msgstr ""
603
+
604
+ #: bp-core/bp-core-admin.php:164
605
+ msgid "BuddyPress Component Setup"
606
+ msgstr ""
607
+
608
+ #: bp-core/bp-core-admin.php:176
609
+ msgid ""
610
+ "By default, all BuddyPress components are enabled. You can selectively "
611
+ "disable any of the \n"
612
+ "\t\t\t\tcomponents by using the form below. Your BuddyPress installation "
613
+ "will continue to function, however\n"
614
+ "\t\t\t\tthe features of the disabled components will no longer be accessible "
615
+ "to\n"
616
+ "\t\t\t\tanyone using the site.\n"
617
+ "\t\t\t\t"
618
+ msgstr ""
619
+
620
+ #: bp-core/bp-core-admin.php:189
621
+ msgid "Activity Streams"
622
+ msgstr ""
623
+
624
+ #: bp-core/bp-core-admin.php:189
625
+ msgid "Tracks user activity across the entire site."
626
+ msgstr ""
627
+
628
+ #: bp-core/bp-core-admin.php:191 bp-core/bp-core-admin.php:200
629
+ #: bp-core/bp-core-admin.php:209 bp-core/bp-core-admin.php:218
630
+ #: bp-core/bp-core-admin.php:227 bp-core/bp-core-admin.php:236
631
+ #: bp-core/bp-core-admin.php:245 bp-core/bp-core-admin.php:254
632
+ msgid "Enabled"
633
+ msgstr ""
634
+
635
+ #: bp-core/bp-core-admin.php:192 bp-core/bp-core-admin.php:201
636
+ #: bp-core/bp-core-admin.php:210 bp-core/bp-core-admin.php:219
637
+ #: bp-core/bp-core-admin.php:228 bp-core/bp-core-admin.php:237
638
+ #: bp-core/bp-core-admin.php:246 bp-core/bp-core-admin.php:255
639
+ msgid "Disabled"
640
+ msgstr ""
641
+
642
+ #: bp-core/bp-core-admin.php:198
643
+ msgid "Blog Tracking"
644
+ msgstr ""
645
+
646
+ #: bp-core/bp-core-admin.php:198
647
+ msgid ""
648
+ "Tracks blogs, blog posts and blogs comments for a user across a WPMU "
649
+ "installation."
650
+ msgstr ""
651
+
652
+ #: bp-core/bp-core-admin.php:207
653
+ msgid "bbPress Forums"
654
+ msgstr ""
655
+
656
+ #: bp-core/bp-core-admin.php:207
657
+ msgid ""
658
+ "Activates bbPress forum support within BuddyPress groups or any other custom "
659
+ "component."
660
+ msgstr ""
661
+
662
+ #: bp-core/bp-core-admin.php:216 bp-friends.php:89 bp-friends.php:160
663
+ msgid "Friends"
664
+ msgstr ""
665
+
666
+ #: bp-core/bp-core-admin.php:216
667
+ msgid "Allows the creation of friend connections between users."
668
+ msgstr ""
669
+
670
+ #: bp-core/bp-core-admin.php:225 bp-core/bp-core-templatetags.php:579
671
+ #: bp-core/bp-core-templatetags.php:671 bp-groups.php:167 bp-groups.php:205
672
+ #: bp-groups.php:867 bp-groups.php:1113 bp-groups.php:1126 bp-groups.php:1140
673
+ #: bp-groups.php:1153 bp-groups/bp-groups-admin.php:33
674
+ #: bp-groups/bp-groups-widgets.php:8 bp-groups/bp-groups-widgets.php:9
675
+ #: bp-themes/bphome/header.php:51 bp-themes/bpmember/header.php:50
676
+ #: bp-themes/bpskeletonmember/header.php:50
677
+ msgid "Groups"
678
+ msgstr ""
679
+
680
+ #: bp-core/bp-core-admin.php:225
681
+ msgid "Let users create, join and participate in groups."
682
+ msgstr ""
683
+
684
+ #: bp-core/bp-core-admin.php:234
685
+ msgid "Private Messaging"
686
+ msgstr ""
687
+
688
+ #: bp-core/bp-core-admin.php:234
689
+ msgid ""
690
+ "Let users send private messages to one another. Site admins can also send "
691
+ "site-wide notices."
692
+ msgstr ""
693
+
694
+ #: bp-core/bp-core-admin.php:243
695
+ msgid "Comment Wire"
696
+ msgstr ""
697
+
698
+ #: bp-core/bp-core-admin.php:243
699
+ msgid "Let users leave a comment on groups, profiles and custom components."
700
+ msgstr ""
701
+
702
+ #: bp-core/bp-core-admin.php:252
703
+ msgid "Extended Profiles"
704
+ msgstr ""
705
+
706
+ #: bp-core/bp-core-admin.php:252
707
+ msgid "Activates customizable profiles and avatars for site users."
708
+ msgstr ""
709
+
710
+ #: bp-core/bp-core-adminbar.php:37 bp-core/bp-core-templatetags.php:616
711
+ #: bp-themes/bpmember/userbar.php:37 bp-themes/bpskeletonmember/userbar.php:50
712
+ msgid "Log In"
713
+ msgstr ""
714
+
715
+ #: bp-core/bp-core-adminbar.php:41 bp-core/bp-core-templatetags.php:617
716
+ msgid "Sign Up"
717
+ msgstr ""
718
+
719
+ #: bp-core/bp-core-adminbar.php:60
720
+ msgid "My Account"
721
+ msgstr ""
722
+
723
+ #: bp-core/bp-core-adminbar.php:90 bp-core/bp-core-adminbar.php:92
724
+ #: bp-core/bp-core-templatetags.php:53 bp-core/bp-core-templatetags.php:55
725
+ #: bp-core/bp-core-templatetags.php:632 bp-core/bp-core-templatetags.php:634
726
+ msgid "Log Out"
727
+ msgstr ""
728
+
729
+ #: bp-core/bp-core-adminbar.php:105 bp-core/bp-core-adminbar.php:118
730
+ #: bp-groups.php:261
731
+ msgid "Admin"
732
+ msgstr ""
733
+
734
+ #: bp-core/bp-core-adminbar.php:110
735
+ msgid "Subscriber"
736
+ msgstr ""
737
+
738
+ #: bp-core/bp-core-adminbar.php:112
739
+ msgid "Contributor"
740
+ msgstr ""
741
+
742
+ #: bp-core/bp-core-adminbar.php:114
743
+ msgid "Author"
744
+ msgstr ""
745
+
746
+ #: bp-core/bp-core-adminbar.php:116
747
+ msgid "Editor"
748
+ msgstr ""
749
+
750
+ #: bp-core/bp-core-adminbar.php:155
751
+ msgid "Dashboard"
752
+ msgstr ""
753
+
754
+ #: bp-core/bp-core-adminbar.php:156
755
+ msgid "New Post"
756
+ msgstr ""
757
+
758
+ #: bp-core/bp-core-adminbar.php:157
759
+ msgid "Manage Posts"
760
+ msgstr ""
761
+
762
+ #: bp-core/bp-core-adminbar.php:158
763
+ msgid "Manage Comments"
764
+ msgstr ""
765
+
766
+ #: bp-core/bp-core-adminbar.php:160
767
+ msgid "Switch Theme"
768
+ msgstr ""
769
+
770
+ #: bp-core/bp-core-adminbar.php:172
771
+ msgid "Create a Blog!"
772
+ msgstr ""
773
+
774
+ #: bp-core/bp-core-adminbar.php:187 bp-core/bp-core-settings.php:10
775
+ msgid "Notifications"
776
+ msgstr ""
777
+
778
+ #: bp-core/bp-core-adminbar.php:205
779
+ msgid "No new notifications."
780
+ msgstr ""
781
+
782
+ #: bp-core/bp-core-adminbar.php:224
783
+ msgid "Blog Authors"
784
+ msgstr ""
785
+
786
+ #: bp-core/bp-core-adminbar.php:250
787
+ msgid "Visit"
788
+ msgstr ""
789
+
790
+ #: bp-core/bp-core-adminbar.php:252
791
+ msgid "Random Member"
792
+ msgstr ""
793
+
794
+ #: bp-core/bp-core-adminbar.php:255
795
+ msgid "Random Group"
796
+ msgstr ""
797
+
798
+ #: bp-core/bp-core-adminbar.php:259
799
+ msgid "Random Blog"
800
+ msgstr ""
801
+
802
+ #: bp-core/bp-core-ajax.php:45 bp-core/bp-core-widgets.php:116
803
+ #, php-format
804
+ msgid "registered %s ago"
805
+ msgstr ""
806
+
807
+ #: bp-core/bp-core-ajax.php:50
808
+ msgid " friend"
809
+ msgstr ""
810
+
811
+ #: bp-core/bp-core-ajax.php:52
812
+ msgid " friends"
813
+ msgstr ""
814
+
815
+ #: bp-core/bp-core-ajax.php:62
816
+ msgid "No members matched the current filter."
817
+ msgstr ""
818
+
819
+ #: bp-core/bp-core-avatars.php:102
820
+ msgid "Your avatar will be used on your profile and throughout the site."
821
+ msgstr ""
822
+
823
+ #: bp-core/bp-core-avatars.php:103
824
+ msgid ""
825
+ "Click below to select a JPG, GIF or PNG format photo from your computer and "
826
+ "then click 'Upload Photo' to proceed."
827
+ msgstr ""
828
+
829
+ #: bp-core/bp-core-avatars.php:111
830
+ msgid "This is your current avatar"
831
+ msgstr ""
832
+
833
+ #: bp-core/bp-core-avatars.php:114 bp-groups/bp-groups-admin.php:47
834
+ #: bp-themes/bpmember/messages/index.php:38
835
+ #: bp-themes/bpmember/messages/notices.php:33
836
+ #: bp-themes/bpmember/messages/sentbox.php:33
837
+ #: bp-themes/bpskeletonmember/messages/index.php:57
838
+ #: bp-themes/bpskeletonmember/messages/notices.php:44
839
+ #: bp-themes/bpskeletonmember/messages/sentbox.php:51
840
+ #: bp-wire/bp-wire-templatetags.php:366 bp-wire/bp-wire-templatetags.php:368
841
+ #: bp-xprofile/bp-xprofile-admin.php:64 bp-xprofile/bp-xprofile-admin.php:87
842
+ msgid "Delete"
843
+ msgstr ""
844
+
845
+ #: bp-core/bp-core-avatars.php:125 bp-groups.php:1297
846
+ #: bp-xprofile/bp-xprofile-signup.php:158
847
+ msgid "There is no error, the file uploaded with success"
848
+ msgstr ""
849
+
850
+ #: bp-core/bp-core-avatars.php:126 bp-core/bp-core-avatars.php:127
851
+ #: bp-xprofile/bp-xprofile-signup.php:159
852
+ #: bp-xprofile/bp-xprofile-signup.php:160
853
+ msgid "Your image was bigger than the maximum allowed file size of: "
854
+ msgstr ""
855
+
856
+ #: bp-core/bp-core-avatars.php:128 bp-groups.php:1300
857
+ #: bp-xprofile/bp-xprofile-signup.php:161
858
+ msgid "The uploaded file was only partially uploaded"
859
+ msgstr ""
860
+
861
+ #: bp-core/bp-core-avatars.php:129 bp-groups.php:1301
862
+ msgid "No file was uploaded"
863
+ msgstr ""
864
+
865
+ #: bp-core/bp-core-avatars.php:130 bp-groups.php:1302
866
+ #: bp-xprofile/bp-xprofile-signup.php:162
867
+ msgid "Missing a temporary folder"
868
+ msgstr ""
869
+
870
+ #: bp-core/bp-core-avatars.php:134
871
+ #, php-format
872
+ msgid "Your upload failed, please try again. Error was: %s"
873
+ msgstr ""
874
+
875
+ #: bp-core/bp-core-avatars.php:137 bp-xprofile/bp-xprofile-signup.php:176
876
+ #, php-format
877
+ msgid "The file you uploaded is too big. Please upload a file under %s"
878
+ msgstr ""
879
+
880
+ #: bp-core/bp-core-avatars.php:140 bp-groups.php:1318
881
+ #: bp-xprofile/bp-xprofile-signup.php:181
882
+ msgid "Please upload only JPG, GIF or PNG photos."
883
+ msgstr ""
884
+
885
+ #: bp-core/bp-core-avatars.php:144 bp-xprofile/bp-xprofile-signup.php:187
886
+ #, php-format
887
+ msgid "Upload Failed! Error was: %s"
888
+ msgstr ""
889
+
890
+ #: bp-core/bp-core-avatars.php:158
891
+ msgid "Security error."
892
+ msgstr ""
893
+
894
+ #: bp-core/bp-core-avatars.php:161
895
+ msgid "Error when cropping, please go back and try again"
896
+ msgstr ""
897
+
898
+ #: bp-core/bp-core-avatars.php:164
899
+ msgid "Error when saving avatars, please go back and try again."
900
+ msgstr ""
901
+
902
+ #: bp-core/bp-core-avatars.php:167
903
+ msgid "Your new avatar was successfully created!"
904
+ msgstr ""
905
+
906
+ #: bp-core/bp-core-avatars.php:183
907
+ msgid "Avatar successfully removed."
908
+ msgstr ""
909
+
910
+ #: bp-core/bp-core-avatars.php:294
911
+ msgid "Please Crop Your Avatar!"
912
+ msgstr ""
913
+
914
+ #: bp-core/bp-core-avatars.php:295
915
+ msgid "Thumbnail Avatar"
916
+ msgstr ""
917
+
918
+ #: bp-core/bp-core-avatars.php:296
919
+ msgid "Please crop a small version of your avatar to use for thumbnails."
920
+ msgstr ""
921
+
922
+ #: bp-core/bp-core-avatars.php:299 bp-core/bp-core-avatars.php:324
923
+ msgid "Select the area to crop"
924
+ msgstr ""
925
+
926
+ #: bp-core/bp-core-avatars.php:302 bp-core/bp-core-avatars.php:327
927
+ msgid "Crop Preview"
928
+ msgstr ""
929
+
930
+ #: bp-core/bp-core-avatars.php:316
931
+ msgid "Crop Thumbnail &amp; Continue"
932
+ msgstr ""
933
+
934
+ #: bp-core/bp-core-avatars.php:320
935
+ msgid "Full Size Avatar"
936
+ msgstr ""
937
+
938
+ #: bp-core/bp-core-avatars.php:321
939
+ msgid "Please crop a full size version of your avatar."
940
+ msgstr ""
941
+
942
+ #: bp-core/bp-core-avatars.php:339 bp-core/bp-core-avatars.php:346
943
+ msgid "Crop Full Size &amp; Save"
944
+ msgstr ""
945
+
946
+ #: bp-core/bp-core-avatars.php:453
947
+ msgid "Upload Photo"
948
+ msgstr ""
949
+
950
+ #: bp-core/bp-core-avatars.php:485
951
+ msgid "Try Again"
952
+ msgstr ""
953
+
954
+ #: bp-core/bp-core-catchuri.php:220
955
+ msgid ""
956
+ "<strong>You do not have any BuddyPress themes installed.</strong><br /"
957
+ ">Please move \"/wp-content/plugins/buddypress/bp-themes/\" to \"/wp-content/"
958
+ "bp-themes/\" and refresh this page. You can <a href=\"http://buddypress.org/"
959
+ "extend/themes/\">download more themes here</a>."
960
+ msgstr ""
961
+
962
+ #: bp-core/bp-core-classes.php:82
963
+ msgid "friend"
964
+ msgstr ""
965
+
966
+ #: bp-core/bp-core-classes.php:84
967
+ msgid "friends"
968
+ msgstr ""
969
+
970
+ #: bp-core/bp-core-classes.php:86
971
+ #, php-format
972
+ msgid "%s's friend list"
973
+ msgstr ""
974
+
975
+ #: bp-core/bp-core-classes.php:93
976
+ msgid "blog"
977
+ msgstr ""
978
+
979
+ #: bp-core/bp-core-classes.php:95
980
+ msgid "blogs"
981
+ msgstr ""
982
+
983
+ #: bp-core/bp-core-classes.php:97
984
+ #, php-format
985
+ msgid "%s's blog list"
986
+ msgstr ""
987
+
988
+ #: bp-core/bp-core-classes.php:106
989
+ msgid "group"
990
+ msgstr ""
991
+
992
+ #: bp-core/bp-core-classes.php:108
993
+ msgid "groups"
994
+ msgstr ""
995
+
996
+ #: bp-core/bp-core-classes.php:110
997
+ #, php-format
998
+ msgid "%s's group list"
999
+ msgstr ""
1000
+
1001
+ #: bp-core/bp-core-settings.php:6
1002
+ msgid "Settings"
1003
+ msgstr ""
1004
+
1005
+ #: bp-core/bp-core-settings.php:9
1006
+ msgid "General"
1007
+ msgstr ""
1008
+
1009
+ #: bp-core/bp-core-settings.php:11 bp-core/bp-core-settings.php:184
1010
+ msgid "Delete Account"
1011
+ msgstr ""
1012
+
1013
+ #: bp-core/bp-core-settings.php:64 bp-core/bp-core-settings.php:120
1014
+ msgid "Changes Saved."
1015
+ msgstr ""
1016
+
1017
+ #: bp-core/bp-core-settings.php:70
1018
+ msgid "Your passwords did not match"
1019
+ msgstr ""
1020
+
1021
+ #: bp-core/bp-core-settings.php:75
1022
+ msgid "Account Email"
1023
+ msgstr ""
1024
+
1025
+ #: bp-core/bp-core-settings.php:78
1026
+ msgid "Change Password <span>(leave blank for no change)</span>"
1027
+ msgstr ""
1028
+
1029
+ #: bp-core/bp-core-settings.php:79
1030
+ msgid "New Password"
1031
+ msgstr ""
1032
+
1033
+ #: bp-core/bp-core-settings.php:80
1034
+ msgid "Repeat New Password"
1035
+ msgstr ""
1036
+
1037
+ #: bp-core/bp-core-settings.php:82 bp-core/bp-core-settings.php:130
1038
+ #: bp-themes/bpmember/groups/admin/edit-details.php:37
1039
+ #: bp-themes/bpmember/groups/admin/group-settings.php:82
1040
+ #: bp-themes/bpskeletonmember/groups/admin/edit-details.php:48
1041
+ #: bp-themes/bpskeletonmember/groups/admin/group-settings.php:99
1042
+ msgid "Save Changes"
1043
+ msgstr ""
1044
+
1045
+ #: bp-core/bp-core-settings.php:112
1046
+ msgid "Notification Settings"
1047
+ msgstr ""
1048
+
1049
+ #: bp-core/bp-core-settings.php:125
1050
+ msgid "Email Notifications"
1051
+ msgstr ""
1052
+
1053
+ #: bp-core/bp-core-settings.php:126
1054
+ msgid "Send a notification by email when:"
1055
+ msgstr ""
1056
+
1057
+ #: bp-core/bp-core-settings.php:193
1058
+ msgid ""
1059
+ "WARNING: Deleting your account will completely remove ALL content associated "
1060
+ "with it. There is no way back, please be careful with this option."
1061
+ msgstr ""
1062
+
1063
+ #: bp-core/bp-core-settings.php:196
1064
+ msgid "I understand the consequences of deleting my account."
1065
+ msgstr ""
1066
+
1067
+ #: bp-core/bp-core-settings.php:197
1068
+ msgid "Delete My Account"
1069
+ msgstr ""
1070
+
1071
+ #: bp-core/bp-core-signup.php:26
1072
+ msgid "Blog Details"
1073
+ msgstr ""
1074
+
1075
+ #: bp-core/bp-core-signup.php:28
1076
+ msgid ""
1077
+ "To register your first blog, just fill in the details below and your "
1078
+ "registration is complete."
1079
+ msgstr ""
1080
+
1081
+ #: bp-core/bp-core-signup.php:105
1082
+ msgid "(Must be at least 4 characters, letters and numbers only.)"
1083
+ msgstr ""
1084
+
1085
+ #: bp-core/bp-core-signup.php:109
1086
+ msgid "Email&nbsp;Address:"
1087
+ msgstr ""
1088
+
1089
+ #: bp-core/bp-core-signup.php:113
1090
+ msgid ""
1091
+ "(We&#8217;ll send your password to this address, so <strong>triple-check it</"
1092
+ "strong>.)"
1093
+ msgstr ""
1094
+
1095
+ #: bp-core/bp-core-signup.php:143
1096
+ msgid "You're already registered!"
1097
+ msgstr ""
1098
+
1099
+ #: bp-core/bp-core-signup.php:144
1100
+ msgid ""
1101
+ "You can still create another blog however. Fill in the form below to add "
1102
+ "another blog to your account."
1103
+ msgstr ""
1104
+
1105
+ #: bp-core/bp-core-signup.php:147
1106
+ msgid ""
1107
+ "There is no limit to the number of blogs you can have, so create to your "
1108
+ "heart's content, but blog responsibly. If you&#8217;re not going to use a "
1109
+ "great blog domain, leave it for a new user. Now have at it!"
1110
+ msgstr ""
1111
+
1112
+ #: bp-core/bp-core-signup.php:185
1113
+ #, php-format
1114
+ msgid "The blog %s is yours."
1115
+ msgstr ""
1116
+
1117
+ #: bp-core/bp-core-signup.php:215
1118
+ msgid ""
1119
+ "Registering for a new account is easy, just fill in the form below and "
1120
+ "you'll be a new member in no time at all."
1121
+ msgstr ""
1122
+
1123
+ #: bp-core/bp-core-signup.php:227
1124
+ msgid "Create a Blog?"
1125
+ msgstr ""
1126
+
1127
+ #: bp-core/bp-core-signup.php:228
1128
+ msgid ""
1129
+ "If you want to create your first blog, select the option below and you'll be "
1130
+ "asked for a few more details."
1131
+ msgstr ""
1132
+
1133
+ #: bp-core/bp-core-signup.php:233
1134
+ msgid "Gimme a blog!"
1135
+ msgstr ""
1136
+
1137
+ #: bp-core/bp-core-signup.php:238
1138
+ msgid "Just a username, please."
1139
+ msgstr ""
1140
+
1141
+ #: bp-core/bp-core-signup.php:244
1142
+ msgid "Next &raquo;"
1143
+ msgstr ""
1144
+
1145
+ #: bp-core/bp-core-signup.php:271
1146
+ msgid "Congratulations, you are now registered!"
1147
+ msgstr ""
1148
+
1149
+ #: bp-core/bp-core-signup.php:272
1150
+ #, php-format
1151
+ msgid "Your new username is: %s"
1152
+ msgstr ""
1153
+
1154
+ #: bp-core/bp-core-signup.php:274
1155
+ #, php-format
1156
+ msgid ""
1157
+ "Before you can start using your new username, <strong>you must activate it</"
1158
+ "strong>. Check your inbox at <strong>%1$s</strong> and click the link given."
1159
+ msgstr ""
1160
+
1161
+ #: bp-core/bp-core-signup.php:275
1162
+ msgid ""
1163
+ "If you do not activate your username within two days, you will have to sign "
1164
+ "up again."
1165
+ msgstr ""
1166
+
1167
+ #: bp-core/bp-core-signup.php:302
1168
+ msgid "Signup &raquo;"
1169
+ msgstr ""
1170
+
1171
+ #: bp-core/bp-core-signup.php:336
1172
+ msgid "Congratulations, You are now registered!"
1173
+ msgstr ""
1174
+
1175
+ #: bp-core/bp-core-signup.php:338
1176
+ #, php-format
1177
+ msgid ""
1178
+ "But, before you can start using your blog, <strong>you must activate it</"
1179
+ "strong>. Check your inbox at <strong>%s</strong> and click the link given. "
1180
+ "It should arrive within 30 minutes."
1181
+ msgstr ""
1182
+
1183
+ #: bp-core/bp-core-signup.php:341
1184
+ msgid "Still waiting for your email?"
1185
+ msgstr ""
1186
+
1187
+ #: bp-core/bp-core-signup.php:343
1188
+ msgid ""
1189
+ "If you haven't received your email yet, there are a number of things you can "
1190
+ "do:"
1191
+ msgstr ""
1192
+
1193
+ #: bp-core/bp-core-signup.php:345
1194
+ msgid ""
1195
+ "Wait a little longer. Sometimes delivery of email can be delayed by "
1196
+ "processes outside of our control."
1197
+ msgstr ""
1198
+
1199
+ #: bp-core/bp-core-signup.php:346
1200
+ msgid ""
1201
+ "Check the junk email or spam folder of your email client. Sometime emails "
1202
+ "wind up there by mistake."
1203
+ msgstr ""
1204
+
1205
+ #: bp-core/bp-core-signup.php:347
1206
+ #, php-format
1207
+ msgid ""
1208
+ "Have you entered your email correctly? We think it's %s but if you've "
1209
+ "entered it incorrectly, you won't receive it."
1210
+ msgstr ""
1211
+
1212
+ #: bp-core/bp-core-signup.php:363
1213
+ #, php-format
1214
+ msgid ""
1215
+ "Greetings Site Administrator! You are currently allowing '%s' registrations. "
1216
+ "To change or disable registration go to your <a href='wp-admin/wpmu-options."
1217
+ "php'>Options page</a>."
1218
+ msgstr ""
1219
+
1220
+ #: bp-core/bp-core-signup.php:369
1221
+ msgid "Registration has been disabled."
1222
+ msgstr ""
1223
+
1224
+ #: bp-core/bp-core-signup.php:377
1225
+ #, php-format
1226
+ msgid ""
1227
+ "You must first <a href=\"%s\">login</a>, and then you can create a new blog."
1228
+ msgstr ""
1229
+
1230
+ #: bp-core/bp-core-signup.php:384
1231
+ msgid "User registration has been disabled."
1232
+ msgstr ""
1233
+
1234
+ #: bp-core/bp-core-signup.php:390
1235
+ msgid "Blog registration has been disabled."
1236
+ msgstr ""
1237
+
1238
+ #: bp-core/bp-core-signup.php:403
1239
+ msgid "I'm sorry. We're not accepting new registrations at this time."
1240
+ msgstr ""
1241
+
1242
+ #: bp-core/bp-core-signup.php:405
1243
+ msgid "You're logged in already. No need to register again!"
1244
+ msgstr ""
1245
+
1246
+ #: bp-core/bp-core-signup.php:413
1247
+ #, php-format
1248
+ msgid ""
1249
+ "<p><em>The blog you were looking for, <strong>%s</strong> doesn't exist but "
1250
+ "you can create it now!</em></p>"
1251
+ msgstr ""
1252
+
1253
+ #: bp-core/bp-core-signup.php:415
1254
+ #, php-format
1255
+ msgid ""
1256
+ "<p><em>The blog you were looking for, <strong>%s</strong> doesn't exist.</"
1257
+ "em></p>"
1258
+ msgstr ""
1259
+
1260
+ #: bp-core/bp-core-templatetags.php:177
1261
+ msgid "Options"
1262
+ msgstr ""
1263
+
1264
+ #: bp-core/bp-core-templatetags.php:318 bp-groups/bp-groups-admin.php:72
1265
+ #: bp-themes/bphome/comments-popup.php:64 bp-themes/bphome/comments.php:90
1266
+ msgid "Name"
1267
+ msgstr ""
1268
+
1269
+ #: bp-core/bp-core-templatetags.php:328
1270
+ msgid "About Me"
1271
+ msgstr ""
1272
+
1273
+ #: bp-core/bp-core-templatetags.php:338 bp-themes/bphome/comments.php:96
1274
+ msgid "Website"
1275
+ msgstr ""
1276
+
1277
+ #: bp-core/bp-core-templatetags.php:348
1278
+ msgid "Jabber"
1279
+ msgstr ""
1280
+
1281
+ #: bp-core/bp-core-templatetags.php:358
1282
+ msgid "AOL Messenger"
1283
+ msgstr ""
1284
+
1285
+ #: bp-core/bp-core-templatetags.php:368
1286
+ msgid "Yahoo Messenger"
1287
+ msgstr ""
1288
+
1289
+ #: bp-core/bp-core-templatetags.php:472 bp-core/bp-core-templatetags.php:666
1290
+ #: bp-groups.php:257 bp-themes/bphome/header.php:43
1291
+ #: bp-themes/bphome/header.php:46 bp-themes/bpmember/header.php:42
1292
+ #: bp-themes/bpmember/header.php:45 bp-themes/bpskeletonmember/header.php:36
1293
+ #: bp-themes/bpskeletonmember/header.php:41
1294
+ msgid "Home"
1295
+ msgstr ""
1296
+
1297
+ #: bp-core/bp-core-templatetags.php:475
1298
+ msgid "Blog &#8212; "
1299
+ msgstr ""
1300
+
1301
+ #: bp-core/bp-core-templatetags.php:477
1302
+ msgid "Blog &#8212; Categories &#8212; "
1303
+ msgstr ""
1304
+
1305
+ #: bp-core/bp-core-templatetags.php:479
1306
+ msgid "Blog &#8212; Tags &#8212; "
1307
+ msgstr ""
1308
+
1309
+ #: bp-core/bp-core-templatetags.php:481 bp-core/bp-core-templatetags.php:667
1310
+ #: bp-themes/bphome/archive.php:5 bp-themes/bphome/attachment.php:6
1311
+ #: bp-themes/bphome/header.php:47 bp-themes/bphome/index.php:6
1312
+ #: bp-themes/bphome/search.php:6 bp-themes/bphome/single.php:6
1313
+ #: bp-themes/bpmember/header.php:46
1314
+ msgid "Blog"
1315
+ msgstr ""
1316
+
1317
+ #: bp-core/bp-core-templatetags.php:489 bp-core/bp-core-templatetags.php:491
1318
+ #, php-format
1319
+ msgid "%s Directory"
1320
+ msgstr ""
1321
+
1322
+ #: bp-core/bp-core-templatetags.php:575 bp-core/bp-core-templatetags.php:668
1323
+ #: bp-core/bp-core-widgets.php:12 bp-core/bp-core-widgets.php:13
1324
+ #: bp-groups.php:277 bp-groups/bp-groups-admin.php:81
1325
+ #: bp-themes/bphome/header.php:48
1326
+ #: bp-themes/bpmember/groups/admin/manage-members.php:30
1327
+ #: bp-themes/bpmember/header.php:47
1328
+ #: bp-themes/bpskeletonmember/groups/admin/manage-members.php:42
1329
+ #: bp-themes/bpskeletonmember/header.php:45
1330
+ msgid "Members"
1331
+ msgstr ""
1332
+
1333
+ #: bp-core/bp-core-templatetags.php:611 bp-themes/bpmember/userbar.php:28
1334
+ #: bp-themes/bpskeletonmember/userbar.php:38
1335
+ msgid "Username"
1336
+ msgstr ""
1337
+
1338
+ #: bp-core/bp-core-templatetags.php:614 bp-themes/bpmember/userbar.php:35
1339
+ #: bp-themes/bpskeletonmember/userbar.php:47
1340
+ msgid "Remember Me"
1341
+ msgstr ""
1342
+
1343
+ #: bp-core/bp-core-templatetags.php:940
1344
+ #, php-format
1345
+ msgid "Viewing member %d to %d (of %d members)"
1346
+ msgstr ""
1347
+
1348
+ #: bp-core/bp-core-templatetags.php:1022
1349
+ #, php-format
1350
+ msgid "%d friend"
1351
+ msgstr ""
1352
+
1353
+ #: bp-core/bp-core-templatetags.php:1024
1354
+ #, php-format
1355
+ msgid "%d friends"
1356
+ msgstr ""
1357
+
1358
+ #: bp-core/bp-core-widgets.php:8 bp-core/bp-core-widgets.php:9
1359
+ msgid "Welcome"
1360
+ msgstr ""
1361
+
1362
+ #: bp-core/bp-core-widgets.php:21 bp-core/bp-core-widgets.php:22
1363
+ msgid "Who's Online"
1364
+ msgstr ""
1365
+
1366
+ #: bp-core/bp-core-widgets.php:45
1367
+ msgid "Create Account"
1368
+ msgstr ""
1369
+
1370
+ #: bp-core/bp-core-widgets.php:70 bp-forums/bp-forums-bbpress-live.php:166
1371
+ #: bp-forums/bp-forums-bbpress-live.php:370
1372
+ #: bp-themes/bpmember/groups/forum/index.php:73
1373
+ #: bp-themes/bpskeletonmember/groups/forum/index.php:84
1374
+ msgid "Title:"
1375
+ msgstr ""
1376
+
1377
+ #: bp-core/bp-core-widgets.php:72
1378
+ msgid "Welcome Text:"
1379
+ msgstr ""
1380
+
1381
+ #: bp-core/bp-core-widgets.php:103 bp-friends/bp-friends-templatetags.php:371
1382
+ #: bp-friends/bp-friends-templatetags.php:387
1383
+ #: bp-groups/bp-groups-widgets.php:43
1384
+ msgid "Newest"
1385
+ msgstr ""
1386
+
1387
+ #: bp-core/bp-core-widgets.php:104 bp-groups/bp-groups-widgets.php:44
1388
+ msgid "Active"
1389
+ msgstr ""
1390
+
1391
+ #: bp-core/bp-core-widgets.php:105 bp-groups/bp-groups-widgets.php:45
1392
+ msgid "Popular"
1393
+ msgstr ""
1394
+
1395
+ #: bp-core/bp-core-widgets.php:132
1396
+ msgid "No one has signed up yet!"
1397
+ msgstr ""
1398
+
1399
+ #: bp-core/bp-core-widgets.php:156
1400
+ msgid "Max Members to show:"
1401
+ msgstr ""
1402
+
1403
+ #: bp-core/bp-core-widgets.php:201
1404
+ msgid "There are no users currently online."
1405
+ msgstr ""
1406
+
1407
+ #: bp-core/bp-core-widgets.php:228
1408
+ msgid "Maximum number of members to show:"
1409
+ msgstr ""
1410
+
1411
+ #: bp-forums/bp-forums-admin.php:7 bp-forums/bp-forums-admin.php:54
1412
+ msgid "Forums Setup"
1413
+ msgstr ""
1414
+
1415
+ #: bp-forums/bp-forums-admin.php:58
1416
+ msgid "Settings Saved."
1417
+ msgstr ""
1418
+
1419
+ #: bp-forums/bp-forums-admin.php:65
1420
+ msgid ""
1421
+ "To enable forums for each group in a BuddyPress installation, you must first "
1422
+ "download, install, and setup bbPress and integrate it with WordPress MU."
1423
+ msgstr ""
1424
+
1425
+ #: bp-forums/bp-forums-admin.php:66
1426
+ msgid ""
1427
+ "Once you have bbPress set up correctly, enter the options below so that "
1428
+ "BuddyPress can connect."
1429
+ msgstr ""
1430
+
1431
+ #: bp-forums/bp-forums-admin.php:73
1432
+ msgid "bbPress URL"
1433
+ msgstr ""
1434
+
1435
+ #: bp-forums/bp-forums-admin.php:76
1436
+ msgid ""
1437
+ "The URL of the location you installed bbPress. For example, http://example."
1438
+ "com/forums/"
1439
+ msgstr ""
1440
+
1441
+ #: bp-forums/bp-forums-admin.php:80
1442
+ msgid "bbPress username"
1443
+ msgstr ""
1444
+
1445
+ #: bp-forums/bp-forums-admin.php:83
1446
+ msgid ""
1447
+ "The username for the user (with admin rights) that you created for "
1448
+ "BuddyPress integration"
1449
+ msgstr ""
1450
+
1451
+ #: bp-forums/bp-forums-admin.php:87
1452
+ msgid "bbPress password"
1453
+ msgstr ""
1454
+
1455
+ #: bp-forums/bp-forums-admin.php:90
1456
+ msgid ""
1457
+ "The password for the user (with admin rights) that you created for "
1458
+ "BuddyPress integration"
1459
+ msgstr ""
1460
+
1461
+ #: bp-forums/bp-forums-admin.php:95
1462
+ msgid "Cache requests"
1463
+ msgstr ""
1464
+
1465
+ #: bp-forums/bp-forums-admin.php:98
1466
+ msgid "Caching enabled"
1467
+ msgstr ""
1468
+
1469
+ #: bp-forums/bp-forums-admin.php:101
1470
+ msgid "Turn on caching of requests to reduce latency and load."
1471
+ msgstr ""
1472
+
1473
+ #: bp-forums/bp-forums-admin.php:105
1474
+ msgid "Cache timeout"
1475
+ msgstr ""
1476
+
1477
+ #: bp-forums/bp-forums-admin.php:107
1478
+ msgid "(seconds)"
1479
+ msgstr ""
1480
+
1481
+ #: bp-forums/bp-forums-admin.php:108
1482
+ msgid "The amount of time in seconds that a cached request is valid for."
1483
+ msgstr ""
1484
+
1485
+ #: bp-forums/bp-forums-bbpress-live.php:20
1486
+ msgid "Forum lists from your bbPress forums"
1487
+ msgstr ""
1488
+
1489
+ #: bp-forums/bp-forums-bbpress-live.php:36
1490
+ #: bp-forums/bp-forums-bbpress-live.php:44
1491
+ msgid "bbPress Forum list"
1492
+ msgstr ""
1493
+
1494
+ #: bp-forums/bp-forums-bbpress-live.php:89 bp-groups.php:268
1495
+ #: bp-groups.php:1580 bp-themes/bpmember/groups/forum/index.php:25
1496
+ #: bp-themes/bpmember/groups/forum/topic.php:28
1497
+ #: bp-themes/bpmember/groups/forum/topic.php:40
1498
+ #: bp-themes/bpskeletonmember/groups/forum/index.php:29
1499
+ #: bp-themes/bpskeletonmember/groups/forum/topic.php:33
1500
+ #: bp-themes/bpskeletonmember/groups/forum/topic.php:45
1501
+ msgid "Forum"
1502
+ msgstr ""
1503
+
1504
+ #: bp-forums/bp-forums-bbpress-live.php:90
1505
+ msgid "Topics"
1506
+ msgstr ""
1507
+
1508
+ #: bp-forums/bp-forums-bbpress-live.php:91
1509
+ #: bp-forums/bp-forums-bbpress-live.php:292
1510
+ msgid "Posts"
1511
+ msgstr ""
1512
+
1513
+ #: bp-forums/bp-forums-bbpress-live.php:172
1514
+ msgid "Parent forum id or slug (optional):"
1515
+ msgstr ""
1516
+
1517
+ #: bp-forums/bp-forums-bbpress-live.php:178
1518
+ msgid "Hierarchy depth:"
1519
+ msgstr ""
1520
+
1521
+ #: bp-forums/bp-forums-bbpress-live.php:184
1522
+ #: bp-forums/bp-forums-bbpress-live.php:388
1523
+ msgid "Layout style:"
1524
+ msgstr ""
1525
+
1526
+ #: bp-forums/bp-forums-bbpress-live.php:188
1527
+ #: bp-forums/bp-forums-bbpress-live.php:392
1528
+ msgid "ordered list"
1529
+ msgstr ""
1530
+
1531
+ #: bp-forums/bp-forums-bbpress-live.php:193
1532
+ #: bp-forums/bp-forums-bbpress-live.php:397
1533
+ msgid "table"
1534
+ msgstr ""
1535
+
1536
+ #: bp-forums/bp-forums-bbpress-live.php:221
1537
+ msgid "The latest topics from your bbPress forums"
1538
+ msgstr ""
1539
+
1540
+ #: bp-forums/bp-forums-bbpress-live.php:237
1541
+ #: bp-forums/bp-forums-bbpress-live.php:245
1542
+ msgid "bbPress latest topics"
1543
+ msgstr ""
1544
+
1545
+ #: bp-forums/bp-forums-bbpress-live.php:282
1546
+ #, php-format
1547
+ msgid "%1$s posted %2$s ago"
1548
+ msgstr ""
1549
+
1550
+ #: bp-forums/bp-forums-bbpress-live.php:291
1551
+ msgid "Topic"
1552
+ msgstr ""
1553
+
1554
+ #: bp-forums/bp-forums-bbpress-live.php:293
1555
+ msgid "Last Poster"
1556
+ msgstr ""
1557
+
1558
+ #: bp-forums/bp-forums-bbpress-live.php:294
1559
+ msgid "Freshness"
1560
+ msgstr ""
1561
+
1562
+ #: bp-forums/bp-forums-bbpress-live.php:376
1563
+ msgid "Forum id or slug (optional):"
1564
+ msgstr ""
1565
+
1566
+ #: bp-forums/bp-forums-bbpress-live.php:382
1567
+ msgid "Number of topics to show:"
1568
+ msgstr ""
1569
+
1570
+ #: bp-forums/bp-forums-templatetags.php:281
1571
+ #, php-format
1572
+ msgid "%d post"
1573
+ msgstr ""
1574
+
1575
+ #: bp-forums/bp-forums-templatetags.php:283
1576
+ #, php-format
1577
+ msgid "%d posts"
1578
+ msgstr ""
1579
+
1580
+ #: bp-forums/bp-forums-templatetags.php:354
1581
+ #, php-format
1582
+ msgid "Viewing topic %d to %d (%d total topics)"
1583
+ msgstr ""
1584
+
1585
+ #: bp-forums/bp-forums-templatetags.php:568
1586
+ #: bp-wire/bp-wire-templatetags.php:248
1587
+ #, php-format
1588
+ msgid "Viewing post %d to %d (%d total posts)"
1589
+ msgstr ""
1590
+
1591
+ #: bp-friends.php:96
1592
+ msgid "Requests"
1593
+ msgstr ""
1594
+
1595
+ #: bp-friends.php:129
1596
+ msgid "Friendship accepted"
1597
+ msgstr ""
1598
+
1599
+ #: bp-friends.php:131
1600
+ msgid "Friendship could not be accepted"
1601
+ msgstr ""
1602
+
1603
+ #: bp-friends.php:138
1604
+ msgid "Friendship rejected"
1605
+ msgstr ""
1606
+
1607
+ #: bp-friends.php:140
1608
+ msgid "Friendship could not be rejected"
1609
+ msgstr ""
1610
+
1611
+ #: bp-friends.php:166
1612
+ msgid "A member sends you a friendship request"
1613
+ msgstr ""
1614
+
1615
+ #: bp-friends.php:172
1616
+ msgid "A member accepts your friendship request"
1617
+ msgstr ""
1618
+
1619
+ #: bp-friends.php:231 bp-friends.php:240
1620
+ #, php-format
1621
+ msgid "%s and %s are now friends"
1622
+ msgstr ""
1623
+
1624
+ #: bp-friends.php:257
1625
+ #, php-format
1626
+ msgid "%d friends accepted your friendship requests"
1627
+ msgstr ""
1628
+
1629
+ #: bp-friends.php:261 bp-friends/bp-friends-notifications.php:58
1630
+ #, php-format
1631
+ msgid "%s accepted your friendship request"
1632
+ msgstr ""
1633
+
1634
+ #: bp-friends.php:267 bp-friends.php:271
1635
+ msgid "Friendship requests"
1636
+ msgstr ""
1637
+
1638
+ #: bp-friends.php:267
1639
+ #, php-format
1640
+ msgid "You have %d pending friendship requests"
1641
+ msgstr ""
1642
+
1643
+ #: bp-friends.php:271
1644
+ #, php-format
1645
+ msgid "You have a friendship request from %s"
1646
+ msgstr ""
1647
+
1648
+ #: bp-friends/bp-friends-ajax.php:20
1649
+ msgid "Friendship could not be canceled."
1650
+ msgstr ""
1651
+
1652
+ #: bp-friends/bp-friends-ajax.php:22
1653
+ #: bp-friends/bp-friends-templatetags.php:361
1654
+ msgid "Add Friend"
1655
+ msgstr ""
1656
+
1657
+ #: bp-friends/bp-friends-ajax.php:29
1658
+ msgid "Friendship could not be requested."
1659
+ msgstr ""
1660
+
1661
+ #: bp-friends/bp-friends-ajax.php:31
1662
+ #: bp-friends/bp-friends-templatetags.php:357
1663
+ msgid "Friendship Requested"
1664
+ msgstr ""
1665
+
1666
+ #: bp-friends/bp-friends-ajax.php:34
1667
+ msgid "Request Pending"
1668
+ msgstr ""
1669
+
1670
+ #: bp-friends/bp-friends-notifications.php:21
1671
+ #, php-format
1672
+ msgid "New friendship request from %s"
1673
+ msgstr ""
1674
+
1675
+ #: bp-friends/bp-friends-notifications.php:24
1676
+ #, php-format
1677
+ msgid ""
1678
+ "%s wants to add you as a friend.\n"
1679
+ "\n"
1680
+ "To view all of your pending friendship requests: %s\n"
1681
+ "\n"
1682
+ "To view %s's profile: %s\n"
1683
+ "\n"
1684
+ "---------------------\n"
1685
+ msgstr ""
1686
+
1687
+ #: bp-friends/bp-friends-notifications.php:33
1688
+ #: bp-friends/bp-friends-notifications.php:68
1689
+ #: bp-groups/bp-groups-notifications.php:44
1690
+ #: bp-groups/bp-groups-notifications.php:80
1691
+ #: bp-groups/bp-groups-notifications.php:126
1692
+ #: bp-groups/bp-groups-notifications.php:175
1693
+ #: bp-groups/bp-groups-notifications.php:217
1694
+ #: bp-groups/bp-groups-notifications.php:264
1695
+ #: bp-messages/bp-messages-notifications.php:34
1696
+ #: bp-xprofile/bp-xprofile-notifications.php:49
1697
+ #, php-format
1698
+ msgid "To disable these notifications please log in and go to: %s"
1699
+ msgstr ""
1700
+
1701
+ #: bp-friends/bp-friends-notifications.php:61
1702
+ #, php-format
1703
+ msgid ""
1704
+ "%s accepted your friend request.\n"
1705
+ "\n"
1706
+ "To view %s's profile: %s\n"
1707
+ "\n"
1708
+ "---------------------\n"
1709
+ msgstr ""
1710
+
1711
+ #: bp-friends/bp-friends-templatetags.php:251
1712
+ #: bp-groups/bp-groups-templatetags.php:2346
1713
+ #, php-format
1714
+ msgid "requested %s ago"
1715
+ msgstr ""
1716
+
1717
+ #: bp-friends/bp-friends-templatetags.php:290
1718
+ #, php-format
1719
+ msgid "Viewing friend %d to %d (of %d friends)"
1720
+ msgstr ""
1721
+
1722
+ #: bp-friends/bp-friends-templatetags.php:299
1723
+ msgid "Filter Friends"
1724
+ msgstr ""
1725
+
1726
+ #: bp-friends/bp-friends-templatetags.php:359
1727
+ msgid "Cancel Friendship"
1728
+ msgstr ""
1729
+
1730
+ #: bp-friends/bp-friends-templatetags.php:370
1731
+ #: bp-friends/bp-friends-templatetags.php:384
1732
+ #: bp-groups/bp-groups-templatetags.php:6
1733
+ #: bp-groups/bp-groups-templatetags.php:252
1734
+ msgid "Recently Active"
1735
+ msgstr ""
1736
+
1737
+ #: bp-friends/bp-friends-templatetags.php:372
1738
+ #: bp-friends/bp-friends-templatetags.php:390
1739
+ #: bp-groups/bp-groups-templatetags.php:11
1740
+ #: bp-groups/bp-groups-templatetags.php:267
1741
+ msgid "Alphabetically"
1742
+ msgstr ""
1743
+
1744
+ #: bp-friends/bp-friends-templatetags.php:404
1745
+ #: bp-themes/bpmember/friends/index.php:10
1746
+ #: bp-themes/bpskeletonmember/friends/index.php:23
1747
+ #, php-format
1748
+ msgid "%s's Friends"
1749
+ msgstr ""
1750
+
1751
+ #: bp-friends/bp-friends-templatetags.php:404
1752
+ #: bp-groups/bp-groups-templatetags.php:353
1753
+ msgid "See All"
1754
+ msgstr ""
1755
+
1756
+ #: bp-friends/bp-friends-templatetags.php:417
1757
+ msgid "You haven't added any friend connections yet."
1758
+ msgstr ""
1759
+
1760
+ #: bp-friends/bp-friends-templatetags.php:417
1761
+ #, php-format
1762
+ msgid "%s hasn't created any friend connections yet."
1763
+ msgstr ""
1764
+
1765
+ #: bp-friends/bp-friends-templatetags.php:457
1766
+ msgid "There aren't enough site members to show a random sample just yet."
1767
+ msgstr ""
1768
+
1769
+ #: bp-groups.php:213 bp-groups.php:221
1770
+ #: bp-groups/bp-groups-templatetags.php:353
1771
+ #: bp-themes/bpmember/groups/index.php:10
1772
+ #: bp-themes/bpskeletonmember/groups/index.php:24
1773
+ msgid "My Groups"
1774
+ msgstr ""
1775
+
1776
+ #: bp-groups.php:214 bp-themes/bpmember/groups/create.php:10
1777
+ #: bp-themes/bpskeletonmember/groups/create.php:22
1778
+ msgid "Create a Group"
1779
+ msgstr ""
1780
+
1781
+ #: bp-groups.php:215
1782
+ msgid "Invites"
1783
+ msgstr ""
1784
+
1785
+ #: bp-groups.php:265 bp-groups/bp-groups-ajax.php:264
1786
+ #: bp-groups/bp-groups-templatetags.php:1589
1787
+ #: bp-themes/bpmember/groups/request-membership.php:22
1788
+ #: bp-themes/bpskeletonmember/groups/request-membership.php:31
1789
+ msgid "Request Membership"
1790
+ msgstr ""
1791
+
1792
+ #: bp-groups.php:271 bp-wire.php:47 bp-wire/bp-wire-templatetags.php:146
1793
+ #: bp-xprofile.php:577 bp-xprofile.php:580
1794
+ msgid "Wire"
1795
+ msgstr ""
1796
+
1797
+ #: bp-groups.php:274
1798
+ msgid "Photos"
1799
+ msgstr ""
1800
+
1801
+ #: bp-groups.php:281 bp-themes/bpmember/groups/send-invite.php:15
1802
+ #: bp-themes/bpmember/groups/send-invite.php:24
1803
+ #: bp-themes/bpskeletonmember/groups/send-invite.php:21
1804
+ #: bp-themes/bpskeletonmember/groups/send-invite.php:30
1805
+ msgid "Send Invites"
1806
+ msgstr ""
1807
+
1808
+ #: bp-groups.php:283 bp-groups/bp-groups-ajax.php:240
1809
+ #: bp-groups/bp-groups-templatetags.php:1579
1810
+ #: bp-groups/bp-groups-templatetags.php:1586
1811
+ msgid "Leave Group"
1812
+ msgstr ""
1813
+
1814
+ #: bp-groups.php:324
1815
+ msgid "Group invite could not be accepted"
1816
+ msgstr ""
1817
+
1818
+ #: bp-groups.php:326
1819
+ msgid "Group invite accepted"
1820
+ msgstr ""
1821
+
1822
+ #: bp-groups.php:337
1823
+ msgid "Group invite could not be rejected"
1824
+ msgstr ""
1825
+
1826
+ #: bp-groups.php:339
1827
+ msgid "Group invite rejected"
1828
+ msgstr ""
1829
+
1830
+ #: bp-groups.php:379
1831
+ msgid "There was an error saving group details. Please try again."
1832
+ msgstr ""
1833
+
1834
+ #: bp-groups.php:462
1835
+ msgid "Wire message could not be posted."
1836
+ msgstr ""
1837
+
1838
+ #: bp-groups.php:464 bp-xprofile.php:375
1839
+ msgid "Wire message successfully posted."
1840
+ msgstr ""
1841
+
1842
+ #: bp-groups.php:477
1843
+ msgid "There was an error deleting the wire message."
1844
+ msgstr ""
1845
+
1846
+ #: bp-groups.php:479 bp-xprofile.php:420
1847
+ msgid "Wire message successfully deleted."
1848
+ msgstr ""
1849
+
1850
+ #: bp-groups.php:516
1851
+ msgid "Group invites sent."
1852
+ msgstr ""
1853
+
1854
+ #: bp-groups.php:537
1855
+ msgid "As the only group administrator, you cannot leave this group."
1856
+ msgstr ""
1857
+
1858
+ #: bp-groups.php:543
1859
+ msgid "There was an error leaving the group. Please try again."
1860
+ msgstr ""
1861
+
1862
+ #: bp-groups.php:546
1863
+ msgid "You left the group successfully."
1864
+ msgstr ""
1865
+
1866
+ #: bp-groups.php:575
1867
+ msgid ""
1868
+ "There was an error sending your group membership request, please try again."
1869
+ msgstr ""
1870
+
1871
+ #: bp-groups.php:577
1872
+ msgid ""
1873
+ "Your membership request was sent to the group administrator successfully. "
1874
+ "You will be notified when the group administrator responds to your request."
1875
+ msgstr ""
1876
+
1877
+ #: bp-groups.php:610
1878
+ msgid "There was an error updating group details, please try again."
1879
+ msgstr ""
1880
+
1881
+ #: bp-groups.php:612
1882
+ msgid "Group details were successfully updated."
1883
+ msgstr ""
1884
+
1885
+ #: bp-groups.php:647
1886
+ msgid "There was an error updating group settings, please try again."
1887
+ msgstr ""
1888
+
1889
+ #: bp-groups.php:649
1890
+ msgid "Group settings were successfully updated."
1891
+ msgstr ""
1892
+
1893
+ #: bp-groups.php:692
1894
+ msgid "There was an error updating the group avatar, please try again."
1895
+ msgstr ""
1896
+
1897
+ #: bp-groups.php:694
1898
+ msgid "The group avatar was successfully updated."
1899
+ msgstr ""
1900
+
1901
+ #: bp-groups.php:722
1902
+ msgid "There was an error when promoting that user, please try again"
1903
+ msgstr ""
1904
+
1905
+ #: bp-groups.php:724
1906
+ msgid "User promoted successfully"
1907
+ msgstr ""
1908
+
1909
+ #: bp-groups.php:737
1910
+ msgid "There was an error when demoting that user, please try again"
1911
+ msgstr ""
1912
+
1913
+ #: bp-groups.php:739
1914
+ msgid "User demoted successfully"
1915
+ msgstr ""
1916
+
1917
+ #: bp-groups.php:752
1918
+ msgid "There was an error when banning that user, please try again"
1919
+ msgstr ""
1920
+
1921
+ #: bp-groups.php:754
1922
+ msgid "User banned successfully"
1923
+ msgstr ""
1924
+
1925
+ #: bp-groups.php:767
1926
+ msgid "There was an error when unbanning that user, please try again"
1927
+ msgstr ""
1928
+
1929
+ #: bp-groups.php:769
1930
+ msgid "User ban removed successfully"
1931
+ msgstr ""
1932
+
1933
+ #: bp-groups.php:804
1934
+ msgid "There was an error accepting the membership request, please try again."
1935
+ msgstr ""
1936
+
1937
+ #: bp-groups.php:806
1938
+ msgid "Group membership request accepted"
1939
+ msgstr ""
1940
+
1941
+ #: bp-groups.php:813
1942
+ msgid "There was an error rejecting the membership request, please try again."
1943
+ msgstr ""
1944
+
1945
+ #: bp-groups.php:815
1946
+ msgid "Group membership request rejected"
1947
+ msgstr ""
1948
+
1949
+ #: bp-groups.php:843
1950
+ msgid "There was an error deleting the group, please try again."
1951
+ msgstr ""
1952
+
1953
+ #: bp-groups.php:845
1954
+ msgid "The group was deleted successfully"
1955
+ msgstr ""
1956
+
1957
+ #: bp-groups.php:873
1958
+ msgid "A member invites you to join a group"
1959
+ msgstr ""
1960
+
1961
+ #: bp-groups.php:879
1962
+ msgid "Group information is updated"
1963
+ msgstr ""
1964
+
1965
+ #: bp-groups.php:886
1966
+ msgid "A member posts on the wire of a group you belong to"
1967
+ msgstr ""
1968
+
1969
+ #: bp-groups.php:893
1970
+ msgid "You are promoted to a group administrator or moderator"
1971
+ msgstr ""
1972
+
1973
+ #: bp-groups.php:899
1974
+ msgid "A member requests to join a private group for which you are an admin"
1975
+ msgstr ""
1976
+
1977
+ #: bp-groups.php:923
1978
+ msgid "There was an error joining the group."
1979
+ msgstr ""
1980
+
1981
+ #: bp-groups.php:925
1982
+ msgid "You joined the group!"
1983
+ msgstr ""
1984
+
1985
+ #: bp-groups.php:991
1986
+ #, php-format
1987
+ msgid "%s joined the group %s"
1988
+ msgstr ""
1989
+
1990
+ #: bp-groups.php:1005
1991
+ #, php-format
1992
+ msgid "%s created the group %s"
1993
+ msgstr ""
1994
+
1995
+ #: bp-groups.php:1019
1996
+ #, php-format
1997
+ msgid "%s wrote on the wire of the group %s"
1998
+ msgstr ""
1999
+
2000
+ #: bp-groups.php:1043
2001
+ #, php-format
2002
+ msgid "%s posted on the forum topic %s in the group %s:"
2003
+ msgstr ""
2004
+
2005
+ #: bp-groups.php:1068
2006
+ #, php-format
2007
+ msgid "%s created the forum topic %s in the group %s:"
2008
+ msgstr ""
2009
+
2010
+ #: bp-groups.php:1099
2011
+ msgid "Group Membership Requests"
2012
+ msgstr ""
2013
+
2014
+ #: bp-groups.php:1099
2015
+ #, php-format
2016
+ msgid "%d new membership requests for the group \"%s\""
2017
+ msgstr ""
2018
+
2019
+ #: bp-groups.php:1102
2020
+ #, php-format
2021
+ msgid "%s requests membership for the group \"%s\""
2022
+ msgstr ""
2023
+
2024
+ #: bp-groups.php:1113
2025
+ #, php-format
2026
+ msgid "%d accepted group membership requests"
2027
+ msgstr ""
2028
+
2029
+ #: bp-groups.php:1115
2030
+ #, php-format
2031
+ msgid "Membership for group \"%s\" accepted"
2032
+ msgstr ""
2033
+
2034
+ #: bp-groups.php:1126
2035
+ #, php-format
2036
+ msgid "%d rejected group membership requests"
2037
+ msgstr ""
2038
+
2039
+ #: bp-groups.php:1128
2040
+ #, php-format
2041
+ msgid "Membership for group \"%s\" rejected"
2042
+ msgstr ""
2043
+
2044
+ #: bp-groups.php:1140
2045
+ #, php-format
2046
+ msgid "You were promoted to an admin in %d groups"
2047
+ msgstr ""
2048
+
2049
+ #: bp-groups.php:1142
2050
+ #, php-format
2051
+ msgid "You were promoted to an admin in the group %s"
2052
+ msgstr ""
2053
+
2054
+ #: bp-groups.php:1153
2055
+ #, php-format
2056
+ msgid "You were promoted to a mod in %d groups"
2057
+ msgstr ""
2058
+
2059
+ #: bp-groups.php:1155
2060
+ #, php-format
2061
+ msgid "You were promoted to a mod in the group %s"
2062
+ msgstr ""
2063
+
2064
+ #: bp-groups.php:1166 bp-groups.php:1168
2065
+ #: bp-themes/bpmember/groups/list-invites.php:12
2066
+ #: bp-themes/bpskeletonmember/groups/list-invites.php:15
2067
+ msgid "Group Invites"
2068
+ msgstr ""
2069
+
2070
+ #: bp-groups.php:1166
2071
+ #, php-format
2072
+ msgid "You have %d new group invitations"
2073
+ msgstr ""
2074
+
2075
+ #: bp-groups.php:1168
2076
+ #, php-format
2077
+ msgid "You have an invitation to the group: %s"
2078
+ msgstr ""
2079
+
2080
+ #: bp-groups.php:1298
2081
+ msgid "The uploaded file exceeds the upload_max_filesize directive in php.ini"
2082
+ msgstr ""
2083
+
2084
+ #: bp-groups.php:1299
2085
+ msgid ""
2086
+ "The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in "
2087
+ "the HTML form"
2088
+ msgstr ""
2089
+
2090
+ #: bp-groups.php:1307
2091
+ msgid "Your group avatar upload failed, please try again. Error was: "
2092
+ msgstr ""
2093
+
2094
+ #: bp-groups.php:1313
2095
+ msgid "The file you uploaded is too big. Please upload a file under"
2096
+ msgstr ""
2097
+
2098
+ #: bp-groups.php:1324
2099
+ msgid ""
2100
+ "Upload Failed! Please check the permissions on the group avatar upload "
2101
+ "directory."
2102
+ msgstr ""
2103
+
2104
+ #: bp-groups.php:1418
2105
+ msgid "Group Admin"
2106
+ msgstr ""
2107
+
2108
+ #: bp-groups.php:1595
2109
+ msgid "Reply posted successfully!"
2110
+ msgstr ""
2111
+
2112
+ #: bp-groups.php:1605
2113
+ msgid "There was an error posting that reply."
2114
+ msgstr ""
2115
+
2116
+ #: bp-groups.php:1617
2117
+ msgid "Topic posted successfully!"
2118
+ msgstr ""
2119
+
2120
+ #: bp-groups.php:1627
2121
+ msgid "There was an error posting that topic."
2122
+ msgstr ""
2123
+
2124
+ #: bp-groups/bp-groups-admin.php:18
2125
+ msgid "There were errors when deleting groups, please try again"
2126
+ msgstr ""
2127
+
2128
+ #: bp-groups/bp-groups-admin.php:21
2129
+ msgid "Groups deleted successfully"
2130
+ msgstr ""
2131
+
2132
+ #: bp-groups/bp-groups-admin.php:37
2133
+ msgid "Search Groups"
2134
+ msgstr ""
2135
+
2136
+ #: bp-groups/bp-groups-admin.php:47
2137
+ msgid "Are you sure?"
2138
+ msgstr ""
2139
+
2140
+ #: bp-groups/bp-groups-admin.php:56
2141
+ #, php-format
2142
+ msgid "Groups matching: \"%s\""
2143
+ msgstr ""
2144
+
2145
+ #: bp-groups/bp-groups-admin.php:75
2146
+ #: bp-themes/bpmember/groups/group-home.php:31
2147
+ #: bp-themes/bpskeletonmember/groups/group-home.php:41
2148
+ msgid "Description"
2149
+ msgstr ""
2150
+
2151
+ #: bp-groups/bp-groups-admin.php:78
2152
+ msgid "Type"
2153
+ msgstr ""
2154
+
2155
+ #: bp-groups/bp-groups-admin.php:84
2156
+ msgid "Created"
2157
+ msgstr ""
2158
+
2159
+ #: bp-groups/bp-groups-admin.php:87
2160
+ msgid "Last Active"
2161
+ msgstr ""
2162
+
2163
+ #: bp-groups/bp-groups-admin.php:108 bp-themes/bphome/archive.php:45
2164
+ #: bp-themes/bphome/search.php:23 bp-xprofile/bp-xprofile-admin.php:63
2165
+ #: bp-xprofile/bp-xprofile-admin.php:86
2166
+ msgid "Edit"
2167
+ msgstr ""
2168
+
2169
+ #: bp-groups/bp-groups-admin.php:118
2170
+ #: bp-themes/bpmember/directories/groups/index.php:106
2171
+ #: bp-themes/bpskeletonmember/directories/groups/groups-loop.php:57
2172
+ #: bp-themes/bpskeletonmember/directories/groups/index.php:118
2173
+ msgid "No groups found."
2174
+ msgstr ""
2175
+
2176
+ #: bp-groups/bp-groups-ajax.php:28 bp-groups/bp-groups-templatetags.php:1538
2177
+ msgid "Remove Invite"
2178
+ msgstr ""
2179
+
2180
+ #: bp-groups/bp-groups-ajax.php:100
2181
+ #, php-format
2182
+ msgid "created %s ago"
2183
+ msgstr ""
2184
+
2185
+ #: bp-groups/bp-groups-ajax.php:105 bp-groups/bp-groups-widgets.php:66
2186
+ msgid " member"
2187
+ msgstr ""
2188
+
2189
+ #: bp-groups/bp-groups-ajax.php:107 bp-groups/bp-groups-widgets.php:68
2190
+ msgid " members"
2191
+ msgstr ""
2192
+
2193
+ #: bp-groups/bp-groups-ajax.php:117
2194
+ msgid "No groups matched the current filter."
2195
+ msgstr ""
2196
+
2197
+ #: bp-groups/bp-groups-ajax.php:156 bp-groups/bp-groups-ajax.php:201
2198
+ #: bp-themes/bpmember/groups/admin/manage-members.php:64
2199
+ #: bp-themes/bpmember/groups/list-members.php:68
2200
+ #: bp-themes/bpskeletonmember/groups/admin/manage-members.php:85
2201
+ #: bp-themes/bpskeletonmember/groups/list-members.php:87
2202
+ msgid "This group has no members."
2203
+ msgstr ""
2204
+
2205
+ #: bp-groups/bp-groups-ajax.php:188
2206
+ #: bp-themes/bpmember/groups/admin/manage-members.php:51
2207
+ #: bp-themes/bpskeletonmember/groups/admin/manage-members.php:67
2208
+ msgid "(banned)"
2209
+ msgstr ""
2210
+
2211
+ #: bp-groups/bp-groups-ajax.php:188 bp-groups/bp-groups-ajax.php:192
2212
+ #: bp-themes/bpmember/groups/admin/manage-members.php:51
2213
+ #: bp-themes/bpmember/groups/admin/manage-members.php:55
2214
+ #: bp-themes/bpskeletonmember/groups/admin/manage-members.php:67
2215
+ #: bp-themes/bpskeletonmember/groups/admin/manage-members.php:74
2216
+ msgid "Kick and ban this member"
2217
+ msgstr ""
2218
+
2219
+ #: bp-groups/bp-groups-ajax.php:188
2220
+ #: bp-themes/bpmember/groups/admin/manage-members.php:51
2221
+ #: bp-themes/bpskeletonmember/groups/admin/manage-members.php:67
2222
+ msgid "Remove Ban"
2223
+ msgstr ""
2224
+
2225
+ #: bp-groups/bp-groups-ajax.php:192 bp-groups/bp-groups-templatetags.php:1251
2226
+ #: bp-themes/bpmember/groups/admin/manage-members.php:55
2227
+ #: bp-themes/bpskeletonmember/groups/admin/manage-members.php:74
2228
+ msgid "Kick &amp; Ban"
2229
+ msgstr ""
2230
+
2231
+ #: bp-groups/bp-groups-ajax.php:192
2232
+ #: bp-themes/bpmember/groups/admin/manage-members.php:55
2233
+ #: bp-themes/bpskeletonmember/groups/admin/manage-members.php:74
2234
+ msgid "Promote this member"
2235
+ msgstr ""
2236
+
2237
+ #: bp-groups/bp-groups-ajax.php:192
2238
+ #: bp-themes/bpmember/groups/admin/manage-members.php:55
2239
+ #: bp-themes/bpskeletonmember/groups/admin/manage-members.php:74
2240
+ msgid "Promote to Moderator"
2241
+ msgstr ""
2242
+
2243
+ #: bp-groups/bp-groups-ajax.php:238
2244
+ msgid "Error joining group"
2245
+ msgstr ""
2246
+
2247
+ #: bp-groups/bp-groups-ajax.php:248
2248
+ msgid "Error requesting membership"
2249
+ msgstr ""
2250
+
2251
+ #: bp-groups/bp-groups-ajax.php:250
2252
+ msgid "Membership Requested"
2253
+ msgstr ""
2254
+
2255
+ #: bp-groups/bp-groups-ajax.php:259
2256
+ msgid "Error leaving group"
2257
+ msgstr ""
2258
+
2259
+ #: bp-groups/bp-groups-ajax.php:262 bp-groups/bp-groups-templatetags.php:1581
2260
+ msgid "Join Group"
2261
+ msgstr ""
2262
+
2263
+ #: bp-groups/bp-groups-notifications.php:16
2264
+ #, php-format
2265
+ msgid "New wire post on group: %s"
2266
+ msgstr ""
2267
+
2268
+ #: bp-groups/bp-groups-notifications.php:31
2269
+ #, php-format
2270
+ msgid ""
2271
+ "%s posted on the wire of the group \"%s\":\n"
2272
+ "\n"
2273
+ "\"%s\"\n"
2274
+ "\n"
2275
+ "To view the group wire: %s\n"
2276
+ "\n"
2277
+ "To view the group home: %s\n"
2278
+ "\n"
2279
+ "To view %s's profile page: %s\n"
2280
+ "\n"
2281
+ "---------------------\n"
2282
+ msgstr ""
2283
+
2284
+ #: bp-groups/bp-groups-notifications.php:59
2285
+ msgid "Group Details Updated"
2286
+ msgstr ""
2287
+
2288
+ #: bp-groups/bp-groups-notifications.php:73
2289
+ #, php-format
2290
+ msgid ""
2291
+ "Group details for the group \"%s\" were updated:\n"
2292
+ "\n"
2293
+ "To view the group: %s\n"
2294
+ "\n"
2295
+ "---------------------\n"
2296
+ msgstr ""
2297
+
2298
+ #: bp-groups/bp-groups-notifications.php:110
2299
+ #, php-format
2300
+ msgid "Membership request for group: %s"
2301
+ msgstr ""
2302
+
2303
+ #: bp-groups/bp-groups-notifications.php:113
2304
+ #, php-format
2305
+ msgid ""
2306
+ "%s wants to join the group \"%s\".\n"
2307
+ "\n"
2308
+ "Because you are the administrator of this group, you must either accept or "
2309
+ "reject the membership request.\n"
2310
+ "\n"
2311
+ "To accept the membership request: %s\n"
2312
+ "\n"
2313
+ "To reject the membership request: %s\n"
2314
+ "\n"
2315
+ "To view %s's profile: %s\n"
2316
+ "\n"
2317
+ "---------------------\n"
2318
+ msgstr ""
2319
+
2320
+ #: bp-groups/bp-groups-notifications.php:155
2321
+ #, php-format
2322
+ msgid "Membership request for group \"%s\" accepted"
2323
+ msgstr ""
2324
+
2325
+ #: bp-groups/bp-groups-notifications.php:157
2326
+ #, php-format
2327
+ msgid ""
2328
+ "Your membership request for the group \"%s\" has been accepted.\n"
2329
+ "\n"
2330
+ "To view the group please login and visit: %s\n"
2331
+ "\n"
2332
+ "---------------------\n"
2333
+ msgstr ""
2334
+
2335
+ #: bp-groups/bp-groups-notifications.php:165
2336
+ #, php-format
2337
+ msgid "Membership request for group \"%s\" rejected"
2338
+ msgstr ""
2339
+
2340
+ #: bp-groups/bp-groups-notifications.php:167
2341
+ #, php-format
2342
+ msgid ""
2343
+ "Your membership request for the group \"%s\" has been rejected.\n"
2344
+ "\n"
2345
+ "To submit another request please log in and visit: %s\n"
2346
+ "\n"
2347
+ "---------------------\n"
2348
+ msgstr ""
2349
+
2350
+ #: bp-groups/bp-groups-notifications.php:185
2351
+ msgid "an administrator"
2352
+ msgstr ""
2353
+
2354
+ #: bp-groups/bp-groups-notifications.php:188
2355
+ msgid "a moderator"
2356
+ msgstr ""
2357
+
2358
+ #: bp-groups/bp-groups-notifications.php:207
2359
+ #, php-format
2360
+ msgid "You have been promoted in the group: \"%s\""
2361
+ msgstr ""
2362
+
2363
+ #: bp-groups/bp-groups-notifications.php:210
2364
+ #, php-format
2365
+ msgid ""
2366
+ "You have been promoted to %s for the group: \"%s\".\n"
2367
+ "\n"
2368
+ "To view the group please visit: %s\n"
2369
+ "\n"
2370
+ "---------------------\n"
2371
+ msgstr ""
2372
+
2373
+ #: bp-groups/bp-groups-notifications.php:250
2374
+ #, php-format
2375
+ msgid "You have an invitation to the group: \"%s\""
2376
+ msgstr ""
2377
+
2378
+ #: bp-groups/bp-groups-notifications.php:253
2379
+ #, php-format
2380
+ msgid ""
2381
+ "One of your friends %s has invited you to the group: \"%s\".\n"
2382
+ "\n"
2383
+ "To view your group invites visit: %s\n"
2384
+ "\n"
2385
+ "To view the group visit: %s\n"
2386
+ "\n"
2387
+ "To view %s's profile visit: %s\n"
2388
+ "\n"
2389
+ "---------------------\n"
2390
+ msgstr ""
2391
+
2392
+ #: bp-groups/bp-groups-templatetags.php:7
2393
+ #: bp-groups/bp-groups-templatetags.php:255
2394
+ msgid "Recently Joined"
2395
+ msgstr ""
2396
+
2397
+ #: bp-groups/bp-groups-templatetags.php:8
2398
+ #: bp-groups/bp-groups-templatetags.php:258
2399
+ msgid "Most Popular"
2400
+ msgstr ""
2401
+
2402
+ #: bp-groups/bp-groups-templatetags.php:9
2403
+ #: bp-groups/bp-groups-templatetags.php:261
2404
+ msgid "Administrator Of"
2405
+ msgstr ""
2406
+
2407
+ #: bp-groups/bp-groups-templatetags.php:10
2408
+ #: bp-groups/bp-groups-templatetags.php:264
2409
+ msgid "Moderator Of"
2410
+ msgstr ""
2411
+
2412
+ #: bp-groups/bp-groups-templatetags.php:20
2413
+ #: bp-groups/bp-groups-templatetags.php:33
2414
+ msgid "Group Details"
2415
+ msgstr ""
2416
+
2417
+ #: bp-groups/bp-groups-templatetags.php:21
2418
+ #: bp-groups/bp-groups-templatetags.php:37
2419
+ #: bp-groups/bp-groups-templatetags.php:1374
2420
+ #: bp-themes/bpmember/groups/admin/group-settings.php:13
2421
+ #: bp-themes/bpskeletonmember/groups/admin/group-settings.php:23
2422
+ msgid "Group Settings"
2423
+ msgstr ""
2424
+
2425
+ #: bp-groups/bp-groups-templatetags.php:22
2426
+ #: bp-groups/bp-groups-templatetags.php:41
2427
+ #: bp-groups/bp-groups-templatetags.php:276
2428
+ #: bp-groups/bp-groups-templatetags.php:363
2429
+ #: bp-groups/bp-groups-templatetags.php:1378
2430
+ #: bp-themes/bpmember/groups/admin/group-avatar.php:13
2431
+ #: bp-themes/bpskeletonmember/groups/admin/group-avatar.php:23
2432
+ msgid "Group Avatar"
2433
+ msgstr ""
2434
+
2435
+ #: bp-groups/bp-groups-templatetags.php:23
2436
+ #: bp-groups/bp-groups-templatetags.php:45
2437
+ msgid "Invite Members"
2438
+ msgstr ""
2439
+
2440
+ #: bp-groups/bp-groups-templatetags.php:58
2441
+ #: bp-themes/bpmember/groups/admin/edit-details.php:18
2442
+ #: bp-themes/bpskeletonmember/groups/admin/edit-details.php:28
2443
+ msgid "Group Name"
2444
+ msgstr ""
2445
+
2446
+ #: bp-groups/bp-groups-templatetags.php:61
2447
+ #: bp-themes/bpmember/groups/admin/edit-details.php:21
2448
+ #: bp-themes/bpskeletonmember/groups/admin/edit-details.php:31
2449
+ msgid "Group Description"
2450
+ msgstr ""
2451
+
2452
+ #: bp-groups/bp-groups-templatetags.php:64
2453
+ #: bp-themes/bpmember/groups/admin/edit-details.php:24
2454
+ #: bp-themes/bpskeletonmember/groups/admin/edit-details.php:34
2455
+ msgid "Recent News"
2456
+ msgstr ""
2457
+
2458
+ #: bp-groups/bp-groups-templatetags.php:69
2459
+ msgid "Create Group and Continue"
2460
+ msgstr ""
2461
+
2462
+ #: bp-groups/bp-groups-templatetags.php:78
2463
+ #: bp-themes/bpmember/groups/admin/group-settings.php:21
2464
+ #: bp-themes/bpskeletonmember/groups/admin/group-settings.php:32
2465
+ msgid "Enable comment wire"
2466
+ msgstr ""
2467
+
2468
+ #: bp-groups/bp-groups-templatetags.php:85
2469
+ #: bp-themes/bpmember/groups/admin/group-settings.php:28
2470
+ #: bp-themes/bpskeletonmember/groups/admin/group-settings.php:40
2471
+ msgid "Enable discussion forum"
2472
+ msgstr ""
2473
+
2474
+ #: bp-groups/bp-groups-templatetags.php:91
2475
+ #, php-format
2476
+ msgid ""
2477
+ "<strong>Attention Site Admin:</strong> Group forums require the <a href=\"%s"
2478
+ "\">correct setup and configuration</a> of a bbPress installation."
2479
+ msgstr ""
2480
+
2481
+ #: bp-groups/bp-groups-templatetags.php:100
2482
+ #: bp-themes/bpmember/groups/admin/group-settings.php:35
2483
+ #: bp-themes/bpskeletonmember/groups/admin/group-settings.php:48
2484
+ msgid "Enable photo gallery"
2485
+ msgstr ""
2486
+
2487
+ #: bp-groups/bp-groups-templatetags.php:102
2488
+ #: bp-themes/bpmember/groups/admin/group-settings.php:39
2489
+ #: bp-themes/bpskeletonmember/groups/admin/group-settings.php:53
2490
+ msgid "All members can upload photos"
2491
+ msgstr ""
2492
+
2493
+ #: bp-groups/bp-groups-templatetags.php:103
2494
+ #: bp-themes/bpmember/groups/admin/group-settings.php:40
2495
+ #: bp-themes/bpskeletonmember/groups/admin/group-settings.php:54
2496
+ msgid "Only group admins can upload photos"
2497
+ msgstr ""
2498
+
2499
+ #: bp-groups/bp-groups-templatetags.php:108
2500
+ #: bp-themes/bpmember/groups/admin/group-settings.php:46
2501
+ #: bp-themes/bpskeletonmember/groups/admin/group-settings.php:62
2502
+ msgid "Privacy Options"
2503
+ msgstr ""
2504
+
2505
+ #: bp-groups/bp-groups-templatetags.php:112
2506
+ #: bp-themes/bpmember/groups/admin/group-settings.php:51
2507
+ #: bp-themes/bpskeletonmember/groups/admin/group-settings.php:67
2508
+ msgid "This is a public group"
2509
+ msgstr ""
2510
+
2511
+ #: bp-groups/bp-groups-templatetags.php:114
2512
+ #: bp-themes/bpmember/groups/admin/group-settings.php:53
2513
+ #: bp-themes/bpskeletonmember/groups/admin/group-settings.php:69
2514
+ msgid "Any site member can join this group."
2515
+ msgstr ""
2516
+
2517
+ #: bp-groups/bp-groups-templatetags.php:115
2518
+ #: bp-groups/bp-groups-templatetags.php:124
2519
+ #: bp-themes/bpmember/groups/admin/group-settings.php:54
2520
+ #: bp-themes/bpmember/groups/admin/group-settings.php:64
2521
+ #: bp-themes/bpskeletonmember/groups/admin/group-settings.php:70
2522
+ #: bp-themes/bpskeletonmember/groups/admin/group-settings.php:80
2523
+ msgid ""
2524
+ "This group will be listed in the groups directory and in search results."
2525
+ msgstr ""
2526
+
2527
+ #: bp-groups/bp-groups-templatetags.php:116
2528
+ #: bp-themes/bpmember/groups/admin/group-settings.php:55
2529
+ #: bp-themes/bpskeletonmember/groups/admin/group-settings.php:71
2530
+ msgid "Group content and activity will be visible to any site member."
2531
+ msgstr ""
2532
+
2533
+ #: bp-groups/bp-groups-templatetags.php:121
2534
+ #: bp-themes/bpmember/groups/admin/group-settings.php:61
2535
+ #: bp-themes/bpskeletonmember/groups/admin/group-settings.php:77
2536
+ msgid "This is a private group"
2537
+ msgstr ""
2538
+
2539
+ #: bp-groups/bp-groups-templatetags.php:123
2540
+ #: bp-themes/bpmember/groups/admin/group-settings.php:63
2541
+ #: bp-themes/bpskeletonmember/groups/admin/group-settings.php:79
2542
+ msgid "Only users who request membership and are accepted can join the group."
2543
+ msgstr ""
2544
+
2545
+ #: bp-groups/bp-groups-templatetags.php:125
2546
+ #: bp-groups/bp-groups-templatetags.php:134
2547
+ #: bp-themes/bpmember/groups/admin/group-settings.php:65
2548
+ #: bp-themes/bpmember/groups/admin/group-settings.php:75
2549
+ #: bp-themes/bpskeletonmember/groups/admin/group-settings.php:81
2550
+ #: bp-themes/bpskeletonmember/groups/admin/group-settings.php:91
2551
+ msgid ""
2552
+ "Group content and activity will only be visible to members of the group."
2553
+ msgstr ""
2554
+
2555
+ #: bp-groups/bp-groups-templatetags.php:130
2556
+ #: bp-themes/bpmember/groups/admin/group-settings.php:71
2557
+ #: bp-themes/bpskeletonmember/groups/admin/group-settings.php:87
2558
+ msgid "This is a hidden group"
2559
+ msgstr ""
2560
+
2561
+ #: bp-groups/bp-groups-templatetags.php:132
2562
+ #: bp-themes/bpmember/groups/admin/group-settings.php:73
2563
+ #: bp-themes/bpskeletonmember/groups/admin/group-settings.php:89
2564
+ msgid "Only users who are invited can join the group."
2565
+ msgstr ""
2566
+
2567
+ #: bp-groups/bp-groups-templatetags.php:133
2568
+ #: bp-themes/bpmember/groups/admin/group-settings.php:74
2569
+ #: bp-themes/bpskeletonmember/groups/admin/group-settings.php:90
2570
+ msgid ""
2571
+ "This group will not be listed in the groups directory or search results."
2572
+ msgstr ""
2573
+
2574
+ #: bp-groups/bp-groups-templatetags.php:139
2575
+ msgid "Save and Continue"
2576
+ msgstr ""
2577
+
2578
+ #: bp-groups/bp-groups-templatetags.php:144
2579
+ #: bp-groups/bp-groups-templatetags.php:174
2580
+ #: bp-groups/bp-groups-templatetags.php:202
2581
+ msgid "Please complete all previous steps first."
2582
+ msgstr ""
2583
+
2584
+ #: bp-groups/bp-groups-templatetags.php:156
2585
+ #: bp-themes/bpmember/groups/admin/group-avatar.php:24
2586
+ #: bp-themes/bpskeletonmember/groups/admin/group-avatar.php:34
2587
+ msgid ""
2588
+ "Upload an image to use as an avatar for this group. The image will be shown "
2589
+ "on the main group page, and in search results."
2590
+ msgstr ""
2591
+
2592
+ #: bp-groups/bp-groups-templatetags.php:167
2593
+ msgid "Skip"
2594
+ msgstr ""
2595
+
2596
+ #: bp-groups/bp-groups-templatetags.php:189
2597
+ msgid ""
2598
+ "Once you build up your friends list you will be able to invite friends to "
2599
+ "join your group."
2600
+ msgstr ""
2601
+
2602
+ #: bp-groups/bp-groups-templatetags.php:195
2603
+ msgid "Finish"
2604
+ msgstr ""
2605
+
2606
+ #: bp-groups/bp-groups-templatetags.php:241
2607
+ msgid "No friends to invite."
2608
+ msgstr ""
2609
+
2610
+ #: bp-groups/bp-groups-templatetags.php:278
2611
+ msgid "No Group Avatar"
2612
+ msgstr ""
2613
+
2614
+ #: bp-groups/bp-groups-templatetags.php:309
2615
+ #, php-format
2616
+ msgid "%s Avatar"
2617
+ msgstr ""
2618
+
2619
+ #: bp-groups/bp-groups-templatetags.php:322
2620
+ #: bp-groups/bp-groups-templatetags.php:693
2621
+ msgid "Group"
2622
+ msgstr ""
2623
+
2624
+ #: bp-groups/bp-groups-templatetags.php:324
2625
+ #: bp-groups/bp-groups-templatetags.php:2163
2626
+ #, php-format
2627
+ msgid "%d member"
2628
+ msgstr ""
2629
+
2630
+ #: bp-groups/bp-groups-templatetags.php:326
2631
+ #: bp-groups/bp-groups-templatetags.php:2165
2632
+ #, php-format
2633
+ msgid "%d members"
2634
+ msgstr ""
2635
+
2636
+ #: bp-groups/bp-groups-templatetags.php:337
2637
+ msgid "There aren't enough groups to show a random sample just yet."
2638
+ msgstr ""
2639
+
2640
+ #: bp-groups/bp-groups-templatetags.php:353
2641
+ #: bp-themes/bpmember/groups/index.php:10
2642
+ #: bp-themes/bpskeletonmember/groups/index.php:24
2643
+ #, php-format
2644
+ msgid "%s's Groups"
2645
+ msgstr ""
2646
+
2647
+ #: bp-groups/bp-groups-templatetags.php:370
2648
+ #: bp-themes/bpmember/groups/group-loop.php:28
2649
+ #: bp-themes/bpskeletonmember/groups/group-loop.php:42
2650
+ msgid "You haven't joined any groups yet."
2651
+ msgstr ""
2652
+
2653
+ #: bp-groups/bp-groups-templatetags.php:370
2654
+ #: bp-themes/bpmember/groups/group-loop.php:28
2655
+ #: bp-themes/bpskeletonmember/groups/group-loop.php:42
2656
+ #, php-format
2657
+ msgid "%s hasn't joined any groups yet."
2658
+ msgstr ""
2659
+
2660
+ #: bp-groups/bp-groups-templatetags.php:687
2661
+ msgid "Public Group"
2662
+ msgstr ""
2663
+
2664
+ #: bp-groups/bp-groups-templatetags.php:689
2665
+ msgid "Hidden Group"
2666
+ msgstr ""
2667
+
2668
+ #: bp-groups/bp-groups-templatetags.php:691
2669
+ msgid "Private Group"
2670
+ msgstr ""
2671
+
2672
+ #: bp-groups/bp-groups-templatetags.php:750
2673
+ msgid "not yet active"
2674
+ msgstr ""
2675
+
2676
+ #: bp-groups/bp-groups-templatetags.php:873
2677
+ msgid "Private"
2678
+ msgstr ""
2679
+
2680
+ #: bp-groups/bp-groups-templatetags.php:928
2681
+ msgid "No Admins"
2682
+ msgstr ""
2683
+
2684
+ #: bp-groups/bp-groups-templatetags.php:949
2685
+ msgid "Group Mod"
2686
+ msgstr ""
2687
+
2688
+ #: bp-groups/bp-groups-templatetags.php:960
2689
+ msgid "No Mods"
2690
+ msgstr ""
2691
+
2692
+ #: bp-groups/bp-groups-templatetags.php:1032
2693
+ #: bp-themes/bpmember/groups/forum/index.php:45
2694
+ #: bp-themes/bpskeletonmember/groups/forum/index.php:53
2695
+ msgid "Permalink"
2696
+ msgstr ""
2697
+
2698
+ #: bp-groups/bp-groups-templatetags.php:1034
2699
+ #: bp-themes/bpmember/groups/forum/index.php:47
2700
+ #: bp-themes/bpskeletonmember/groups/forum/index.php:56
2701
+ #, php-format
2702
+ msgid "updated %s ago"
2703
+ msgstr ""
2704
+
2705
+ #: bp-groups/bp-groups-templatetags.php:1037
2706
+ #: bp-themes/bpmember/groups/forum/index.php:50
2707
+ #: bp-themes/bpskeletonmember/groups/forum/index.php:59
2708
+ msgid "Latest by"
2709
+ msgstr ""
2710
+
2711
+ #: bp-groups/bp-groups-templatetags.php:1049
2712
+ msgid "There are no active forum topics for this group"
2713
+ msgstr ""
2714
+
2715
+ #: bp-groups/bp-groups-templatetags.php:1061
2716
+ msgid "Filter Groups"
2717
+ msgstr ""
2718
+
2719
+ #: bp-groups/bp-groups-templatetags.php:1097
2720
+ #: bp-groups/bp-groups-templatetags.php:2047
2721
+ #, php-format
2722
+ msgid "Viewing group %d to %d (of %d groups)"
2723
+ msgstr ""
2724
+
2725
+ #: bp-groups/bp-groups-templatetags.php:1219
2726
+ #: bp-groups/bp-groups-templatetags.php:1257
2727
+ #: bp-groups/bp-groups-templatetags.php:1810
2728
+ #, php-format
2729
+ msgid "joined %s ago"
2730
+ msgstr ""
2731
+
2732
+ #: bp-groups/bp-groups-templatetags.php:1232
2733
+ msgid "This group has no administrators"
2734
+ msgstr ""
2735
+
2736
+ #: bp-groups/bp-groups-templatetags.php:1251
2737
+ msgid "Demote to Member"
2738
+ msgstr ""
2739
+
2740
+ #: bp-groups/bp-groups-templatetags.php:1270
2741
+ msgid "This group has no moderators"
2742
+ msgstr ""
2743
+
2744
+ #: bp-groups/bp-groups-templatetags.php:1370
2745
+ #: bp-themes/bpmember/groups/admin/edit-details.php:13
2746
+ #: bp-themes/bpskeletonmember/groups/admin/edit-details.php:23
2747
+ msgid "Edit Details"
2748
+ msgstr ""
2749
+
2750
+ #: bp-groups/bp-groups-templatetags.php:1382
2751
+ #: bp-themes/bpmember/groups/admin/manage-members.php:13
2752
+ #: bp-themes/bpskeletonmember/groups/admin/manage-members.php:23
2753
+ msgid "Manage Members"
2754
+ msgstr ""
2755
+
2756
+ #: bp-groups/bp-groups-templatetags.php:1386
2757
+ #: bp-themes/bpmember/groups/admin/membership-requests.php:13
2758
+ #: bp-themes/bpskeletonmember/groups/admin/membership-requests.php:23
2759
+ msgid "Membership Requests"
2760
+ msgstr ""
2761
+
2762
+ #: bp-groups/bp-groups-templatetags.php:1390
2763
+ #: bp-themes/bpmember/groups/admin/delete-group.php:13
2764
+ #: bp-themes/bpmember/groups/admin/delete-group.php:24
2765
+ #: bp-themes/bpskeletonmember/groups/admin/delete-group.php:23
2766
+ #: bp-themes/bpskeletonmember/groups/admin/delete-group.php:34
2767
+ msgid "Delete Group"
2768
+ msgstr ""
2769
+
2770
+ #: bp-groups/bp-groups-templatetags.php:1512
2771
+ msgid "Select Friends"
2772
+ msgstr ""
2773
+
2774
+ #: bp-groups/bp-groups-templatetags.php:1521
2775
+ msgid "Select people to invite from your friends list."
2776
+ msgstr ""
2777
+
2778
+ #: bp-groups/bp-groups-templatetags.php:1591
2779
+ msgid "Request Sent"
2780
+ msgstr ""
2781
+
2782
+ #: bp-groups/bp-groups-templatetags.php:1608
2783
+ msgid ""
2784
+ "This is a private group and you must request group membership in order to "
2785
+ "join."
2786
+ msgstr ""
2787
+
2788
+ #: bp-groups/bp-groups-templatetags.php:1610
2789
+ msgid ""
2790
+ "This is a private group. To join you must be a registered site member and "
2791
+ "request group membership."
2792
+ msgstr ""
2793
+
2794
+ #: bp-groups/bp-groups-templatetags.php:1612
2795
+ msgid ""
2796
+ "This is a private group. Your membership request is awaiting approval from "
2797
+ "the group administrator."
2798
+ msgstr ""
2799
+
2800
+ #: bp-groups/bp-groups-templatetags.php:1614
2801
+ msgid "This is a hidden group and only invited members can join."
2802
+ msgstr ""
2803
+
2804
+ #: bp-groups/bp-groups-templatetags.php:1860
2805
+ #, php-format
2806
+ msgid "Viewing members %d to %d (of %d members)"
2807
+ msgstr ""
2808
+
2809
+ #: bp-groups/bp-groups-widgets.php:86
2810
+ msgid "There are no groups to display."
2811
+ msgstr ""
2812
+
2813
+ #: bp-groups/bp-groups-widgets.php:110
2814
+ msgid "Maximum number of groups to show:"
2815
+ msgstr ""
2816
+
2817
+ #: bp-messages.php:143 bp-messages.php:247
2818
+ msgid "Messages"
2819
+ msgstr ""
2820
+
2821
+ #: bp-messages.php:149 bp-themes/bpmember/messages/index.php:12
2822
+ #: bp-themes/bpskeletonmember/messages/index.php:26
2823
+ msgid "Inbox"
2824
+ msgstr ""
2825
+
2826
+ #: bp-messages.php:150 bp-themes/bpmember/messages/sentbox.php:10
2827
+ #: bp-themes/bpskeletonmember/messages/sentbox.php:23
2828
+ msgid "Sent Messages"
2829
+ msgstr ""
2830
+
2831
+ #: bp-messages.php:151
2832
+ msgid "Compose"
2833
+ msgstr ""
2834
+
2835
+ #: bp-messages.php:152
2836
+ msgid "Notices"
2837
+ msgstr ""
2838
+
2839
+ #: bp-messages.php:156
2840
+ msgid "My Messages"
2841
+ msgstr ""
2842
+
2843
+ #: bp-messages.php:217
2844
+ msgid "There was a problem deactivating that notice."
2845
+ msgstr ""
2846
+
2847
+ #: bp-messages.php:219
2848
+ msgid "Notice deactivated."
2849
+ msgstr ""
2850
+
2851
+ #: bp-messages.php:223
2852
+ msgid "There was a problem activating that notice."
2853
+ msgstr ""
2854
+
2855
+ #: bp-messages.php:225
2856
+ msgid "Notice activated."
2857
+ msgstr ""
2858
+
2859
+ #: bp-messages.php:229
2860
+ msgid "There was a problem deleting that notice."
2861
+ msgstr ""
2862
+
2863
+ #: bp-messages.php:231
2864
+ msgid "Notice deleted."
2865
+ msgstr ""
2866
+
2867
+ #: bp-messages.php:253
2868
+ msgid "A member sends you a new message"
2869
+ msgstr ""
2870
+
2871
+ #: bp-messages.php:259
2872
+ msgid "A new site notice is posted"
2873
+ msgstr ""
2874
+
2875
+ #: bp-messages.php:284
2876
+ #, php-format
2877
+ msgid "From: %s"
2878
+ msgstr ""
2879
+
2880
+ #: bp-messages.php:308
2881
+ msgid "There was an error deleting that message."
2882
+ msgstr ""
2883
+
2884
+ #: bp-messages.php:310
2885
+ msgid "Message deleted."
2886
+ msgstr ""
2887
+
2888
+ #: bp-messages.php:330
2889
+ msgid "There was an error deleting messages."
2890
+ msgstr ""
2891
+
2892
+ #: bp-messages.php:332 bp-messages/bp-messages-ajax.php:71
2893
+ msgid "Messages deleted."
2894
+ msgstr ""
2895
+
2896
+ #: bp-messages.php:366
2897
+ #, php-format
2898
+ msgid "You have %d new messages"
2899
+ msgstr ""
2900
+
2901
+ #: bp-messages.php:368
2902
+ #, php-format
2903
+ msgid "You have %d new message"
2904
+ msgstr ""
2905
+
2906
+ #: bp-messages.php:395
2907
+ msgid "Notice posted successfully."
2908
+ msgstr ""
2909
+
2910
+ #: bp-messages.php:397
2911
+ msgid "There was an error posting that notice."
2912
+ msgstr ""
2913
+
2914
+ #: bp-messages.php:408
2915
+ msgid "Please enter at least one valid user to send this message to."
2916
+ msgstr ""
2917
+
2918
+ #: bp-messages.php:411
2919
+ msgid "There was an error sending the reply, please try again."
2920
+ msgstr ""
2921
+
2922
+ #: bp-messages.php:416
2923
+ msgid "You must send your message to one or more users not including yourself."
2924
+ msgstr ""
2925
+
2926
+ #: bp-messages.php:422
2927
+ msgid "Please make sure you fill in all the fields."
2928
+ msgstr ""
2929
+
2930
+ #: bp-messages.php:425
2931
+ msgid "Please make sure you have typed a message before sending a reply."
2932
+ msgstr ""
2933
+
2934
+ #: bp-messages.php:454 bp-messages.php:488
2935
+ msgid "Message could not be sent, please try again."
2936
+ msgstr ""
2937
+
2938
+ #: bp-messages.php:464
2939
+ msgid "Message sent successfully!"
2940
+ msgstr ""
2941
+
2942
+ #: bp-messages.php:464 bp-themes/bpmember/messages/index.php:34
2943
+ #: bp-themes/bpmember/messages/sentbox.php:29
2944
+ #: bp-themes/bpskeletonmember/messages/index.php:52
2945
+ #: bp-themes/bpskeletonmember/messages/sentbox.php:46
2946
+ msgid "View Message"
2947
+ msgstr ""
2948
+
2949
+ #: bp-messages/bp-messages-ajax.php:33
2950
+ msgid "There was a problem marking messages as unread."
2951
+ msgstr ""
2952
+
2953
+ #: bp-messages/bp-messages-ajax.php:48
2954
+ msgid "There was a problem marking messages as read."
2955
+ msgstr ""
2956
+
2957
+ #: bp-messages/bp-messages-ajax.php:63
2958
+ msgid "There was a problem deleting messages."
2959
+ msgstr ""
2960
+
2961
+ #: bp-messages/bp-messages-ajax.php:80
2962
+ msgid "There was a problem closing the notice."
2963
+ msgstr ""
2964
+
2965
+ #: bp-messages/bp-messages-classes.php:284
2966
+ msgid " Recipients"
2967
+ msgstr ""
2968
+
2969
+ #: bp-messages/bp-messages-notifications.php:20
2970
+ #, php-format
2971
+ msgid "New message from %s"
2972
+ msgstr ""
2973
+
2974
+ #: bp-messages/bp-messages-notifications.php:23
2975
+ #, php-format
2976
+ msgid ""
2977
+ "%s sent you a new message:\n"
2978
+ "\n"
2979
+ "Subject: %s\n"
2980
+ "\n"
2981
+ "\"%s\"\n"
2982
+ "\n"
2983
+ "To view the message: %s\n"
2984
+ "\n"
2985
+ "---------------------\n"
2986
+ msgstr ""
2987
+
2988
+ #: bp-messages/bp-messages-templatetags.php:269
2989
+ #, php-format
2990
+ msgid "Viewing message %d to %d (of %d messages)"
2991
+ msgstr ""
2992
+
2993
+ #: bp-messages/bp-messages-templatetags.php:312
2994
+ msgid "Select:"
2995
+ msgstr ""
2996
+
2997
+ #: bp-messages/bp-messages-templatetags.php:315
2998
+ msgid "Read"
2999
+ msgstr ""
3000
+
3001
+ #: bp-messages/bp-messages-templatetags.php:316
3002
+ msgid "Unread"
3003
+ msgstr ""
3004
+
3005
+ #: bp-messages/bp-messages-templatetags.php:317
3006
+ msgid "All"
3007
+ msgstr ""
3008
+
3009
+ #: bp-messages/bp-messages-templatetags.php:319
3010
+ msgid "Mark as Read"
3011
+ msgstr ""
3012
+
3013
+ #: bp-messages/bp-messages-templatetags.php:320
3014
+ msgid "Mark as Unread"
3015
+ msgstr ""
3016
+
3017
+ #: bp-messages/bp-messages-templatetags.php:322
3018
+ msgid "Delete Selected"
3019
+ msgstr ""
3020
+
3021
+ #: bp-messages/bp-messages-templatetags.php:331
3022
+ msgid "Currently Active"
3023
+ msgstr ""
3024
+
3025
+ #: bp-messages/bp-messages-templatetags.php:398
3026
+ msgid "Deactivate"
3027
+ msgstr ""
3028
+
3029
+ #: bp-messages/bp-messages-templatetags.php:400
3030
+ msgid "Activate"
3031
+ msgstr ""
3032
+
3033
+ #: bp-messages/bp-messages-templatetags.php:420
3034
+ msgid "Close"
3035
+ msgstr ""
3036
+
3037
+ #: bp-messages/bp-messages-templatetags.php:436
3038
+ msgid "Send Message"
3039
+ msgstr ""
3040
+
3041
+ #: bp-messages/bp-messages-templatetags.php:484
3042
+ msgid "There was an error when viewing that message"
3043
+ msgstr ""
3044
+
3045
+ #: bp-messages/bp-messages-templatetags.php:498
3046
+ msgid "Sent between "
3047
+ msgstr ""
3048
+
3049
+ #: bp-messages/bp-messages-templatetags.php:499
3050
+ msgid "and"
3051
+ msgstr ""
3052
+
3053
+ #: bp-messages/bp-messages-templatetags.php:540
3054
+ msgid "Reply: "
3055
+ msgstr ""
3056
+
3057
+ #: bp-messages/bp-messages-templatetags.php:548
3058
+ msgid "Send Reply"
3059
+ msgstr ""
3060
+
3061
+ #: bp-messages/bp-messages-templatetags.php:551
3062
+ msgid "Re: "
3063
+ msgstr ""
3064
+
3065
+ #: bp-themes/bphome/404.php:10 bp-themes/bphome/404.php:21
3066
+ #: bp-themes/bphome/activate.php:10 bp-themes/bphome/home.php:9
3067
+ #: bp-themes/bphome/home.php:20 bp-themes/bphome/home.php:31
3068
+ #: bp-themes/bphome/register.php:10 bp-themes/bphome/register.php:21
3069
+ #: bp-themes/bphome/sidebar.php:6
3070
+ msgid "Please log in and add widgets to this column."
3071
+ msgstr ""
3072
+
3073
+ #: bp-themes/bphome/404.php:10 bp-themes/bphome/404.php:21
3074
+ #: bp-themes/bphome/activate.php:10 bp-themes/bphome/home.php:9
3075
+ #: bp-themes/bphome/home.php:20 bp-themes/bphome/home.php:31
3076
+ #: bp-themes/bphome/register.php:10 bp-themes/bphome/register.php:21
3077
+ #: bp-themes/bphome/sidebar.php:6
3078
+ msgid "Add Widgets"
3079
+ msgstr ""
3080
+
3081
+ #: bp-themes/bphome/404.php:29
3082
+ msgid "Sorry, that page was not found"
3083
+ msgstr ""
3084
+
3085
+ #: bp-themes/bphome/404.php:32
3086
+ msgid "The page you were looking for was not found."
3087
+ msgstr ""
3088
+
3089
+ #: bp-themes/bphome/activate.php:18
3090
+ msgid "Activate your Account"
3091
+ msgstr ""
3092
+
3093
+ #: bp-themes/bphome/archive.php:11
3094
+ msgid "Archive for the"
3095
+ msgstr ""
3096
+
3097
+ #: bp-themes/bphome/archive.php:11
3098
+ msgid "Category"
3099
+ msgstr ""
3100
+
3101
+ #: bp-themes/bphome/archive.php:14 bp-themes/bphome/archive.php:17
3102
+ #: bp-themes/bphome/archive.php:20
3103
+ msgid "Archive for"
3104
+ msgstr ""
3105
+
3106
+ #: bp-themes/bphome/archive.php:23
3107
+ msgid "Author Archive"
3108
+ msgstr ""
3109
+
3110
+ #: bp-themes/bphome/archive.php:26
3111
+ msgid "Blog Archives"
3112
+ msgstr ""
3113
+
3114
+ #: bp-themes/bphome/archive.php:32 bp-themes/bphome/archive.php:52
3115
+ #: bp-themes/bphome/index.php:26 bp-themes/bphome/search.php:13
3116
+ #: bp-themes/bphome/search.php:29 bp-themes/bphome/single.php:11
3117
+ msgid "&laquo; Previous Entries"
3118
+ msgstr ""
3119
+
3120
+ #: bp-themes/bphome/archive.php:33 bp-themes/bphome/archive.php:53
3121
+ #: bp-themes/bphome/index.php:27 bp-themes/bphome/search.php:14
3122
+ #: bp-themes/bphome/search.php:30 bp-themes/bphome/single.php:12
3123
+ msgid "Next Entries &raquo;"
3124
+ msgstr ""
3125
+
3126
+ #: bp-themes/bphome/archive.php:38 bp-themes/bphome/index.php:11
3127
+ #: bp-themes/bphome/search.php:20
3128
+ msgid "Permanent Link to"
3129
+ msgstr ""
3130
+
3131
+ #: bp-themes/bphome/archive.php:45 bp-themes/bphome/search.php:23
3132
+ msgid "Posted in"
3133
+ msgstr ""
3134
+
3135
+ #: bp-themes/bphome/archive.php:45 bp-themes/bphome/index.php:18
3136
+ #: bp-themes/bphome/search.php:23
3137
+ msgid "No Comments &#187;"
3138
+ msgstr ""
3139
+
3140
+ #: bp-themes/bphome/archive.php:45 bp-themes/bphome/index.php:18
3141
+ #: bp-themes/bphome/search.php:23
3142
+ msgid "1 Comment &#187;"
3143
+ msgstr ""
3144
+
3145
+ #: bp-themes/bphome/archive.php:45 bp-themes/bphome/index.php:18
3146
+ #: bp-themes/bphome/search.php:23
3147
+ msgid "% Comments &#187;"
3148
+ msgstr ""
3149
+
3150
+ #: bp-themes/bphome/archive.php:58 bp-themes/bphome/index.php:32
3151
+ msgid "Not Found"
3152
+ msgstr ""
3153
+
3154
+ #: bp-themes/bphome/archives.php:13
3155
+ msgid "Archives by Month:"
3156
+ msgstr ""
3157
+
3158
+ #: bp-themes/bphome/archives.php:18
3159
+ msgid "Archives by Subject:"
3160
+ msgstr ""
3161
+
3162
+ #: bp-themes/bphome/attachment.php:16 bp-themes/bphome/single.php:19
3163
+ msgid "<p class=\"serif\">Read the rest of this entry &raquo;</p>"
3164
+ msgstr ""
3165
+
3166
+ #: bp-themes/bphome/attachment.php:18 bp-themes/bphome/page.php:12
3167
+ #: bp-themes/bphome/single.php:21
3168
+ msgid "<p><strong>Pages:</strong> "
3169
+ msgstr ""
3170
+
3171
+ #: bp-themes/bphome/attachment.php:27
3172
+ msgid "Sorry, no attachments matched your criteria."
3173
+ msgstr ""
3174
+
3175
+ #: bp-themes/bphome/comments-popup.php:9
3176
+ msgid "Comments on"
3177
+ msgstr ""
3178
+
3179
+ #: bp-themes/bphome/comments-popup.php:22
3180
+ msgid "Comments"
3181
+ msgstr ""
3182
+
3183
+ #: bp-themes/bphome/comments-popup.php:24
3184
+ msgid ""
3185
+ "<abbr title=\"Really Simple Syndication\">RSS</abbr> feed for comments on "
3186
+ "this post."
3187
+ msgstr ""
3188
+
3189
+ #: bp-themes/bphome/comments-popup.php:27
3190
+ msgid ""
3191
+ "The <abbr title=\"Universal Resource Locator\">URL</abbr> to TrackBack this "
3192
+ "entry is:"
3193
+ msgstr ""
3194
+
3195
+ #: bp-themes/bphome/comments-popup.php:45
3196
+ msgid "by"
3197
+ msgstr ""
3198
+
3199
+ #: bp-themes/bphome/comments-popup.php:51
3200
+ msgid "No comments yet."
3201
+ msgstr ""
3202
+
3203
+ #: bp-themes/bphome/comments-popup.php:55
3204
+ msgid "Leave a comment"
3205
+ msgstr ""
3206
+
3207
+ #: bp-themes/bphome/comments-popup.php:56
3208
+ msgid ""
3209
+ "Line and paragraph breaks automatic, e-mail address never displayed, "
3210
+ "<acronym title=\"Hypertext Markup Language\">HTML</acronym> allowed:"
3211
+ msgstr ""
3212
+
3213
+ #: bp-themes/bphome/comments-popup.php:60 bp-themes/bphome/comments.php:85
3214
+ msgid "Logged in as"
3215
+ msgstr ""
3216
+
3217
+ #: bp-themes/bphome/comments-popup.php:60
3218
+ msgid "Log out of this account"
3219
+ msgstr ""
3220
+
3221
+ #: bp-themes/bphome/comments-popup.php:60 bp-themes/bphome/comments.php:85
3222
+ msgid "Logout"
3223
+ msgstr ""
3224
+
3225
+ #: bp-themes/bphome/comments-popup.php:71
3226
+ msgid "E-mail"
3227
+ msgstr ""
3228
+
3229
+ #: bp-themes/bphome/comments-popup.php:76
3230
+ msgid "URL"
3231
+ msgstr ""
3232
+
3233
+ #: bp-themes/bphome/comments-popup.php:81
3234
+ msgid "Your Comment"
3235
+ msgstr ""
3236
+
3237
+ #: bp-themes/bphome/comments-popup.php:87
3238
+ msgid "Say It!"
3239
+ msgstr ""
3240
+
3241
+ #: bp-themes/bphome/comments-popup.php:92
3242
+ msgid "Sorry, the comment form is closed at this time."
3243
+ msgstr ""
3244
+
3245
+ #: bp-themes/bphome/comments-popup.php:97
3246
+ msgid "Close this window."
3247
+ msgstr ""
3248
+
3249
+ #: bp-themes/bphome/comments-popup.php:105
3250
+ msgid ""
3251
+ "Powered by <a href=\"http://wordpress.org/\" title=\"Powered by WordPress, "
3252
+ "state-of-the-art semantic personal publishing platform\"><strong>Wordpress</"
3253
+ "strong>"
3254
+ msgstr ""
3255
+
3256
+ #: bp-themes/bphome/comments.php:9
3257
+ msgid "This post is password protected. Enter the password to view comments."
3258
+ msgstr ""
3259
+
3260
+ #: bp-themes/bphome/comments.php:24
3261
+ msgid "No Responses"
3262
+ msgstr ""
3263
+
3264
+ #: bp-themes/bphome/comments.php:24
3265
+ msgid "One Response"
3266
+ msgstr ""
3267
+
3268
+ #: bp-themes/bphome/comments.php:24
3269
+ msgid "% Responses"
3270
+ msgstr ""
3271
+
3272
+ #: bp-themes/bphome/comments.php:24
3273
+ msgid "to"
3274
+ msgstr ""
3275
+
3276
+ #: bp-themes/bphome/comments.php:33 bp-wire/bp-wire-ajax.php:26
3277
+ msgid "said:"
3278
+ msgstr ""
3279
+
3280
+ #: bp-themes/bphome/comments.php:38
3281
+ msgid "Your comment is awaiting moderation."
3282
+ msgstr ""
3283
+
3284
+ #: bp-themes/bphome/comments.php:62
3285
+ msgid "Comments are closed."
3286
+ msgstr ""
3287
+
3288
+ #: bp-themes/bphome/comments.php:75
3289
+ msgid "Leave a Reply"
3290
+ msgstr ""
3291
+
3292
+ #: bp-themes/bphome/comments.php:78
3293
+ #, php-format
3294
+ msgid "You must be <a href=\"%s\">logged in</a> to post a comment."
3295
+ msgstr ""
3296
+
3297
+ #: bp-themes/bphome/comments.php:90 bp-themes/bphome/comments.php:93
3298
+ msgid "(required)"
3299
+ msgstr ""
3300
+
3301
+ #: bp-themes/bphome/comments.php:93
3302
+ msgid "Mail (will not be published)"
3303
+ msgstr ""
3304
+
3305
+ #: bp-themes/bphome/comments.php:102
3306
+ msgid "Submit Comment"
3307
+ msgstr ""
3308
+
3309
+ #: bp-themes/bphome/footer.php:5 bp-themes/bpmember/footer.php:4
3310
+ #: bp-themes/bpskeletonmember/footer.php:11
3311
+ #, php-format
3312
+ msgid ""
3313
+ "%s is proudly powered by <a href=\"http://mu.wordpress.org\">WordPress MU</"
3314
+ "a> and <a href=\"http://buddypress.org\">BuddyPress</a>"
3315
+ msgstr ""
3316
+
3317
+ #: bp-themes/bphome/header.php:17
3318
+ msgid "Blog Posts RSS Feed"
3319
+ msgstr ""
3320
+
3321
+ #: bp-themes/bphome/header.php:18
3322
+ msgid "Blog Posts Atom Feed"
3323
+ msgstr ""
3324
+
3325
+ #: bp-themes/bphome/index.php:12
3326
+ msgid "in"
3327
+ msgstr ""
3328
+
3329
+ #: bp-themes/bphome/index.php:12
3330
+ #, php-format
3331
+ msgid "by %s"
3332
+ msgstr ""
3333
+
3334
+ #: bp-themes/bphome/index.php:15 bp-themes/bpmember/blogs/recent-posts.php:16
3335
+ #: bp-themes/bpskeletonmember/blogs/recent-posts.php:32
3336
+ msgid "Read the rest of this entry &raquo;"
3337
+ msgstr ""
3338
+
3339
+ #: bp-themes/bphome/index.php:33
3340
+ msgid "Sorry, but you are looking for something that isn't here."
3341
+ msgstr ""
3342
+
3343
+ #: bp-themes/bphome/links.php:11
3344
+ msgid "Links:"
3345
+ msgstr ""
3346
+
3347
+ #: bp-themes/bphome/page.php:10
3348
+ msgid "<p class=\"serif\">Read the rest of this page &raquo;</p>"
3349
+ msgstr ""
3350
+
3351
+ #: bp-themes/bphome/page.php:18
3352
+ msgid "Edit this entry."
3353
+ msgstr ""
3354
+
3355
+ #: bp-themes/bphome/register.php:29
3356
+ msgid "Register for an Account"
3357
+ msgstr ""
3358
+
3359
+ #: bp-themes/bphome/search.php:10
3360
+ msgid "Search Results"
3361
+ msgstr ""
3362
+
3363
+ #: bp-themes/bphome/search.php:35
3364
+ msgid "No posts found. Try a different search?"
3365
+ msgstr ""
3366
+
3367
+ #: bp-themes/bphome/single.php:16
3368
+ msgid "Permanent link to"
3369
+ msgstr ""
3370
+
3371
+ #: bp-themes/bphome/single.php:31
3372
+ msgid "Sorry, no posts matched your criteria."
3373
+ msgstr ""
3374
+
3375
+ #: bp-themes/bpmember/404.php:4 bp-themes/bpskeletonmember/404.php:12
3376
+ msgid "Permission Denied"
3377
+ msgstr ""
3378
+
3379
+ #: bp-themes/bpmember/404.php:8 bp-themes/bpskeletonmember/404.php:16
3380
+ msgid "Not Found / No Access"
3381
+ msgstr ""
3382
+
3383
+ #: bp-themes/bpmember/404.php:9 bp-themes/bpskeletonmember/404.php:17
3384
+ msgid ""
3385
+ "The page you are looking for either does not exist, or you do not have the "
3386
+ "permissions to access it."
3387
+ msgstr ""
3388
+
3389
+ #: bp-themes/bpmember/activity/just-me.php:31
3390
+ #: bp-themes/bpmember/profile/index.php:38
3391
+ #: bp-themes/bpskeletonmember/activity/just-me.php:43
3392
+ #: bp-themes/bpskeletonmember/profile/index.php:51
3393
+ #, php-format
3394
+ msgid "%s's Activity"
3395
+ msgstr ""
3396
+
3397
+ #: bp-themes/bpmember/activity/just-me.php:50
3398
+ #: bp-themes/bpmember/profile/index.php:57
3399
+ #: bp-themes/bpskeletonmember/activity/just-me.php:44
3400
+ msgid "You haven't done anything yet."
3401
+ msgstr ""
3402
+
3403
+ #: bp-themes/bpmember/activity/just-me.php:50
3404
+ #: bp-themes/bpmember/profile/index.php:57
3405
+ #: bp-themes/bpskeletonmember/activity/just-me.php:44
3406
+ #, php-format
3407
+ msgid "%s hasn't done anything yet."
3408
+ msgstr ""
3409
+
3410
+ #: bp-themes/bpmember/activity/my-friends.php:23
3411
+ #: bp-themes/bpskeletonmember/activity/my-friends.php:37
3412
+ msgid "My Friends Activity"
3413
+ msgstr ""
3414
+
3415
+ #: bp-themes/bpmember/activity/my-friends.php:42
3416
+ #: bp-themes/bpskeletonmember/activity/my-friends.php:38
3417
+ msgid "Your friends haven't done anything yet."
3418
+ msgstr ""
3419
+
3420
+ #: bp-themes/bpmember/blogs/create.php:18
3421
+ #: bp-themes/bpskeletonmember/blogs/create.php:27
3422
+ msgid "Blog registration is currently disabled"
3423
+ msgstr ""
3424
+
3425
+ #: bp-themes/bpmember/blogs/my-blogs.php:23
3426
+ #: bp-themes/bpskeletonmember/blogs/my-blogs.php:40
3427
+ msgid "You haven't created any blogs yet."
3428
+ msgstr ""
3429
+
3430
+ #: bp-themes/bpmember/blogs/my-blogs.php:23
3431
+ #: bp-themes/bpskeletonmember/blogs/my-blogs.php:40
3432
+ #, php-format
3433
+ msgid "%s hasn't created any public blogs yet."
3434
+ msgstr ""
3435
+
3436
+ #: bp-themes/bpmember/blogs/recent-comments.php:15
3437
+ #: bp-themes/bpmember/wire/post-form.php:5
3438
+ #: bp-themes/bpmember/wire/post-list.php:23
3439
+ #: bp-themes/bpskeletonmember/blogs/recent-comments.php:29
3440
+ #: bp-themes/bpskeletonmember/wire/post-form.php:15
3441
+ #: bp-themes/bpskeletonmember/wire/post-list.php:37
3442
+ #, php-format
3443
+ msgid "On %1$s %2$s said:"
3444
+ msgstr ""
3445
+
3446
+ #: bp-themes/bpmember/blogs/recent-comments.php:15
3447
+ #: bp-themes/bpmember/blogs/recent-posts.php:15
3448
+ #: bp-themes/bpskeletonmember/blogs/recent-comments.php:29
3449
+ #: bp-themes/bpskeletonmember/blogs/recent-posts.php:30
3450
+ msgid "F jS, Y"
3451
+ msgstr ""
3452
+
3453
+ #: bp-themes/bpmember/blogs/recent-comments.php:17
3454
+ #: bp-themes/bpskeletonmember/blogs/recent-comments.php:35
3455
+ #, php-format
3456
+ msgid ""
3457
+ "Commented on the post <a href=\"%1$s\">%2$s</a> on the blog <a href=\"%3$s\">"
3458
+ "%4$s</a>."
3459
+ msgstr ""
3460
+
3461
+ #: bp-themes/bpmember/blogs/recent-comments.php:24
3462
+ #: bp-themes/bpskeletonmember/blogs/recent-comments.php:45
3463
+ msgid "You haven't posted any comments yet."
3464
+ msgstr ""
3465
+
3466
+ #: bp-themes/bpmember/blogs/recent-comments.php:24
3467
+ #: bp-themes/bpskeletonmember/blogs/recent-comments.php:45
3468
+ #, php-format
3469
+ msgid "%s hasn't posted any comments yet."
3470
+ msgstr ""
3471
+
3472
+ #: bp-themes/bpmember/blogs/recent-posts.php:14
3473
+ #: bp-themes/bpskeletonmember/blogs/recent-posts.php:29
3474
+ #, php-format
3475
+ msgid "Permanent Link to %s"
3476
+ msgstr ""
3477
+
3478
+ #: bp-themes/bpmember/blogs/recent-posts.php:15
3479
+ #: bp-themes/bpskeletonmember/blogs/recent-posts.php:30
3480
+ #, php-format
3481
+ msgid "%1$s <em>in %2$s by %3$s</em>"
3482
+ msgstr ""
3483
+
3484
+ #: bp-themes/bpmember/blogs/recent-posts.php:17
3485
+ #: bp-themes/bpskeletonmember/blogs/recent-posts.php:34
3486
+ msgid "No Comments"
3487
+ msgstr ""
3488
+
3489
+ #: bp-themes/bpmember/blogs/recent-posts.php:17
3490
+ #: bp-themes/bpskeletonmember/blogs/recent-posts.php:34
3491
+ msgid "1 Comment"
3492
+ msgstr ""
3493
+
3494
+ #: bp-themes/bpmember/blogs/recent-posts.php:17
3495
+ #: bp-themes/bpskeletonmember/blogs/recent-posts.php:34
3496
+ msgid "% Comments"
3497
+ msgstr ""
3498
+
3499
+ #: bp-themes/bpmember/blogs/recent-posts.php:24
3500
+ #: bp-themes/bpskeletonmember/blogs/recent-posts.php:44
3501
+ msgid "You haven't made any posts yet."
3502
+ msgstr ""
3503
+
3504
+ #: bp-themes/bpmember/blogs/recent-posts.php:24
3505
+ #: bp-themes/bpskeletonmember/blogs/recent-posts.php:44
3506
+ #, php-format
3507
+ msgid "%s hasn't made any posts yet."
3508
+ msgstr ""
3509
+
3510
+ #: bp-themes/bpmember/directories/blogs/blogs-loop.php:28
3511
+ #: bp-themes/bpskeletonmember/directories/blogs/blogs-loop.php:38
3512
+ msgid "Visit Blog"
3513
+ msgstr ""
3514
+
3515
+ #: bp-themes/bpmember/directories/blogs/blogs-loop.php:47
3516
+ #: bp-themes/bpskeletonmember/directories/blogs/blogs-loop.php:57
3517
+ msgid ""
3518
+ "No blogs found. Blogs must fill in at least one piece of profile data to "
3519
+ "show in blog lists."
3520
+ msgstr ""
3521
+
3522
+ #: bp-themes/bpmember/directories/blogs/index.php:6
3523
+ #: bp-themes/bpskeletonmember/directories/blogs/index.php:18
3524
+ msgid "Blog Directory"
3525
+ msgstr ""
3526
+
3527
+ #: bp-themes/bpmember/directories/blogs/index.php:40
3528
+ #: bp-themes/bpskeletonmember/directories/blogs/index.php:52
3529
+ msgid "Blog Listing"
3530
+ msgstr ""
3531
+
3532
+ #: bp-themes/bpmember/directories/blogs/index.php:58
3533
+ #: bp-themes/bpskeletonmember/directories/blogs/index.php:70
3534
+ msgid "Find Blogs"
3535
+ msgstr ""
3536
+
3537
+ #: bp-themes/bpmember/directories/blogs/index.php:65
3538
+ #: bp-themes/bpskeletonmember/directories/blogs/index.php:77
3539
+ msgid "Featured Blogs"
3540
+ msgstr ""
3541
+
3542
+ #: bp-themes/bpmember/directories/blogs/index.php:83
3543
+ #: bp-themes/bpskeletonmember/directories/blogs/index.php:95
3544
+ msgid "Description: "
3545
+ msgstr ""
3546
+
3547
+ #: bp-themes/bpmember/directories/blogs/index.php:99
3548
+ #: bp-themes/bpskeletonmember/directories/blogs/index.php:111
3549
+ msgid "There are not enough blogs to feature."
3550
+ msgstr ""
3551
+
3552
+ #: bp-themes/bpmember/directories/groups/groups-loop.php:47
3553
+ msgid "There were no groups found."
3554
+ msgstr ""
3555
+
3556
+ #: bp-themes/bpmember/directories/groups/index.php:6
3557
+ #: bp-themes/bpskeletonmember/directories/groups/index.php:18
3558
+ msgid "Groups Directory"
3559
+ msgstr ""
3560
+
3561
+ #: bp-themes/bpmember/directories/groups/index.php:40
3562
+ #: bp-themes/bpskeletonmember/directories/groups/index.php:52
3563
+ msgid "Groups Listing"
3564
+ msgstr ""
3565
+
3566
+ #: bp-themes/bpmember/directories/groups/index.php:58
3567
+ #: bp-themes/bpskeletonmember/directories/groups/index.php:70
3568
+ msgid "Find Groups"
3569
+ msgstr ""
3570
+
3571
+ #: bp-themes/bpmember/directories/groups/index.php:65
3572
+ #: bp-themes/bpskeletonmember/directories/groups/index.php:77
3573
+ msgid "Featured Groups"
3574
+ msgstr ""
3575
+
3576
+ #: bp-themes/bpmember/directories/groups/index.php:83
3577
+ #: bp-themes/bpskeletonmember/directories/groups/index.php:95
3578
+ msgid "Members:"
3579
+ msgstr ""
3580
+
3581
+ #: bp-themes/bpmember/directories/groups/index.php:88
3582
+ #: bp-themes/bpskeletonmember/directories/groups/index.php:100
3583
+ msgid "Description:"
3584
+ msgstr ""
3585
+
3586
+ #: bp-themes/bpmember/directories/members/index.php:6
3587
+ #: bp-themes/bpskeletonmember/directories/members/index.php:18
3588
+ msgid "Members Directory"
3589
+ msgstr ""
3590
+
3591
+ #: bp-themes/bpmember/directories/members/index.php:40
3592
+ #: bp-themes/bpskeletonmember/directories/members/index.php:52
3593
+ msgid "Member Listing"
3594
+ msgstr ""
3595
+
3596
+ #: bp-themes/bpmember/directories/members/index.php:57
3597
+ #: bp-themes/bpskeletonmember/directories/members/index.php:70
3598
+ msgid "Find Members"
3599
+ msgstr ""
3600
+
3601
+ #: bp-themes/bpmember/directories/members/index.php:64
3602
+ #: bp-themes/bpskeletonmember/directories/members/index.php:77
3603
+ msgid "Featured Members"
3604
+ msgstr ""
3605
+
3606
+ #: bp-themes/bpmember/directories/members/index.php:97
3607
+ #: bp-themes/bpskeletonmember/directories/members/index.php:110
3608
+ msgid "There are not enough members to feature."
3609
+ msgstr ""
3610
+
3611
+ #: bp-themes/bpmember/directories/members/members-loop.php:41
3612
+ #: bp-themes/bpskeletonmember/directories/members/members-loop.php:51
3613
+ msgid ""
3614
+ "No members found. Members must fill in at least one piece of profile data to "
3615
+ "show in member lists."
3616
+ msgstr ""
3617
+
3618
+ #: bp-themes/bpmember/friends/friends-loop.php:28
3619
+ msgid "No friends matched your search filter terms"
3620
+ msgstr ""
3621
+
3622
+ #: bp-themes/bpmember/friends/friends-loop.php:32
3623
+ #: bp-themes/bpskeletonmember/friends/friends-loop.php:37
3624
+ msgid "Your friends list is currently empty"
3625
+ msgstr ""
3626
+
3627
+ #: bp-themes/bpmember/friends/friends-loop.php:32
3628
+ #: bp-themes/bpskeletonmember/friends/friends-loop.php:37
3629
+ #, php-format
3630
+ msgid "%s's friends list is currently empty"
3631
+ msgstr ""
3632
+
3633
+ #: bp-themes/bpmember/friends/friends-loop.php:37
3634
+ #: bp-themes/bpskeletonmember/friends/friends-loop.php:42
3635
+ msgid "Why not make friends with some of these members?"
3636
+ msgstr ""
3637
+
3638
+ #: bp-themes/bpmember/friends/requests.php:11
3639
+ #: bp-themes/bpskeletonmember/friends/requests.php:18
3640
+ msgid "Friendship Requests"
3641
+ msgstr ""
3642
+
3643
+ #: bp-themes/bpmember/friends/requests.php:24
3644
+ #: bp-themes/bpmember/groups/admin/membership-requests.php:27
3645
+ #: bp-themes/bpmember/groups/list-invites.php:27
3646
+ #: bp-themes/bpskeletonmember/friends/requests.php:36
3647
+ #: bp-themes/bpskeletonmember/groups/admin/membership-requests.php:40
3648
+ #: bp-themes/bpskeletonmember/groups/list-invites.php:36
3649
+ msgid "Accept"
3650
+ msgstr ""
3651
+
3652
+ #: bp-themes/bpmember/friends/requests.php:30
3653
+ #: bp-themes/bpmember/groups/admin/membership-requests.php:33
3654
+ #: bp-themes/bpmember/groups/list-invites.php:33
3655
+ #: bp-themes/bpskeletonmember/friends/requests.php:40
3656
+ #: bp-themes/bpskeletonmember/groups/admin/membership-requests.php:44
3657
+ #: bp-themes/bpskeletonmember/groups/list-invites.php:40
3658
+ msgid "Reject"
3659
+ msgstr ""
3660
+
3661
+ #: bp-themes/bpmember/friends/requests.php:40
3662
+ #: bp-themes/bpskeletonmember/friends/requests.php:52
3663
+ msgid "You have no pending friendship requests."
3664
+ msgstr ""
3665
+
3666
+ #: bp-themes/bpmember/groups/admin/delete-group.php:20
3667
+ #: bp-themes/bpskeletonmember/groups/admin/delete-group.php:30
3668
+ msgid ""
3669
+ "WARNING: Deleting this group will completely remove ALL content associated "
3670
+ "with it. There is no way back, please be careful with this option."
3671
+ msgstr ""
3672
+
3673
+ #: bp-themes/bpmember/groups/admin/delete-group.php:23
3674
+ #: bp-themes/bpskeletonmember/groups/admin/delete-group.php:33
3675
+ msgid "I understand the consequences of deleting this group."
3676
+ msgstr ""
3677
+
3678
+ #: bp-themes/bpmember/groups/admin/edit-details.php:30
3679
+ #: bp-themes/bpskeletonmember/groups/admin/edit-details.php:40
3680
+ msgid "Notify group members of changes via email"
3681
+ msgstr ""
3682
+
3683
+ #: bp-themes/bpmember/groups/admin/manage-members.php:18
3684
+ #: bp-themes/bpmember/groups/list-members.php:23
3685
+ #: bp-themes/bpskeletonmember/groups/admin/manage-members.php:28
3686
+ #: bp-themes/bpskeletonmember/groups/list-members.php:31
3687
+ msgid "Administrators"
3688
+ msgstr ""
3689
+
3690
+ #: bp-themes/bpmember/groups/admin/manage-members.php:24
3691
+ #: bp-themes/bpmember/groups/list-members.php:29
3692
+ #: bp-themes/bpskeletonmember/groups/admin/manage-members.php:35
3693
+ #: bp-themes/bpskeletonmember/groups/list-members.php:40
3694
+ msgid "Moderators"
3695
+ msgstr ""
3696
+
3697
+ #: bp-themes/bpmember/groups/admin/membership-requests.php:43
3698
+ #: bp-themes/bpskeletonmember/groups/admin/membership-requests.php:55
3699
+ msgid "There are no pending membership requests."
3700
+ msgstr ""
3701
+
3702
+ #: bp-themes/bpmember/groups/forum/index.php:25
3703
+ #: bp-themes/bpskeletonmember/groups/forum/index.php:30
3704
+ msgid "Post New"
3705
+ msgstr ""
3706
+
3707
+ #: bp-themes/bpmember/groups/forum/index.php:25
3708
+ #: bp-themes/bpskeletonmember/groups/forum/index.php:30
3709
+ msgid "Post New &raquo;"
3710
+ msgstr ""
3711
+
3712
+ #: bp-themes/bpmember/groups/forum/index.php:59
3713
+ #: bp-themes/bpskeletonmember/groups/forum/index.php:70
3714
+ msgid "There are no topics for this group forum."
3715
+ msgstr ""
3716
+
3717
+ #: bp-themes/bpmember/groups/forum/index.php:71
3718
+ #: bp-themes/bpskeletonmember/groups/forum/index.php:82
3719
+ msgid "Post a New Topic:"
3720
+ msgstr ""
3721
+
3722
+ #: bp-themes/bpmember/groups/forum/index.php:76
3723
+ #: bp-themes/bpskeletonmember/groups/forum/index.php:87
3724
+ msgid "Content:"
3725
+ msgstr ""
3726
+
3727
+ #: bp-themes/bpmember/groups/forum/index.php:79
3728
+ #: bp-themes/bpskeletonmember/groups/forum/index.php:90
3729
+ msgid "Tags:"
3730
+ msgstr ""
3731
+
3732
+ #: bp-themes/bpmember/groups/forum/index.php:84
3733
+ #: bp-themes/bpskeletonmember/groups/forum/index.php:95
3734
+ msgid "Post Topic"
3735
+ msgstr ""
3736
+
3737
+ #: bp-themes/bpmember/groups/forum/topic.php:47
3738
+ #: bp-themes/bpskeletonmember/groups/forum/topic.php:54
3739
+ #, php-format
3740
+ msgid "%s said %s ago:"
3741
+ msgstr ""
3742
+
3743
+ #: bp-themes/bpmember/groups/forum/topic.php:63
3744
+ #: bp-themes/bpskeletonmember/groups/forum/topic.php:71
3745
+ msgid "Add a reply:"
3746
+ msgstr ""
3747
+
3748
+ #: bp-themes/bpmember/groups/forum/topic.php:66
3749
+ #: bp-themes/bpskeletonmember/groups/forum/topic.php:74
3750
+ msgid "Post Reply"
3751
+ msgstr ""
3752
+
3753
+ #: bp-themes/bpmember/groups/forum/topic.php:80
3754
+ #: bp-themes/bpskeletonmember/groups/forum/topic.php:89
3755
+ msgid "There are no posts for this topic."
3756
+ msgstr ""
3757
+
3758
+ #: bp-themes/bpmember/groups/group-home.php:37
3759
+ #: bp-themes/bpskeletonmember/groups/group-home.php:48
3760
+ msgid "News"
3761
+ msgstr ""
3762
+
3763
+ #: bp-themes/bpmember/groups/group-home.php:46
3764
+ #: bp-themes/bpskeletonmember/groups/group-home.php:59
3765
+ msgid "Active Forum Topics"
3766
+ msgstr ""
3767
+
3768
+ #: bp-themes/bpmember/groups/group-home.php:46
3769
+ #: bp-themes/bpmember/wire/post-list.php:2
3770
+ #: bp-themes/bpskeletonmember/groups/group-home.php:59
3771
+ #: bp-themes/bpskeletonmember/wire/post-list.php:13
3772
+ msgid "See All &raquo;"
3773
+ msgstr ""
3774
+
3775
+ #: bp-themes/bpmember/groups/group-home.php:53
3776
+ #: bp-themes/bpskeletonmember/groups/group-home.php:68
3777
+ #, php-format
3778
+ msgid "Members (%d) <a href=\"%s\">See All &raquo;</a>"
3779
+ msgstr ""
3780
+
3781
+ #: bp-themes/bpmember/groups/group-home.php:62
3782
+ #: bp-themes/bpmember/groups/wire.php:26
3783
+ #: bp-themes/bpskeletonmember/groups/group-home.php:78
3784
+ #: bp-themes/bpskeletonmember/groups/wire.php:35
3785
+ msgid "Group Wire"
3786
+ msgstr ""
3787
+
3788
+ #: bp-themes/bpmember/groups/group-home.php:62
3789
+ #: bp-themes/bpmember/groups/wire.php:26
3790
+ #, php-format
3791
+ msgid "There are no wire posts for %s"
3792
+ msgstr ""
3793
+
3794
+ #: bp-themes/bpmember/groups/group-home.php:70
3795
+ #: bp-themes/bpskeletonmember/groups/group-home.php:87
3796
+ msgid "Sorry, the group does not exist."
3797
+ msgstr ""
3798
+
3799
+ #: bp-themes/bpmember/groups/group-loop.php:11
3800
+ #: bp-themes/bpmember/groups/list-invites.php:20
3801
+ #: bp-themes/bpskeletonmember/groups/group-loop.php:23
3802
+ #: bp-themes/bpskeletonmember/groups/list-invites.php:29
3803
+ #, php-format
3804
+ msgid "%s members"
3805
+ msgstr ""
3806
+
3807
+ #: bp-themes/bpmember/groups/group-loop.php:14
3808
+ #: bp-themes/bpskeletonmember/groups/group-loop.php:26
3809
+ msgid "Membership Pending Approval"
3810
+ msgstr ""
3811
+
3812
+ #: bp-themes/bpmember/groups/group-loop.php:32
3813
+ #: bp-themes/bpskeletonmember/groups/group-loop.php:47
3814
+ msgid "Why not join a few of these groups?"
3815
+ msgstr ""
3816
+
3817
+ #: bp-themes/bpmember/groups/group-loop.php:39
3818
+ #: bp-themes/bpskeletonmember/groups/group-loop.php:55
3819
+ msgid "No matching groups found."
3820
+ msgstr ""
3821
+
3822
+ #: bp-themes/bpmember/groups/group-menu.php:10
3823
+ #: bp-themes/bpskeletonmember/groups/group-menu.php:26
3824
+ msgid "Admins"
3825
+ msgstr ""
3826
+
3827
+ #: bp-themes/bpmember/groups/group-menu.php:16
3828
+ #: bp-themes/bpskeletonmember/groups/group-menu.php:34
3829
+ msgid "Mods"
3830
+ msgstr ""
3831
+
3832
+ #: bp-themes/bpmember/groups/leave-group-confirm.php:23
3833
+ #: bp-themes/bpskeletonmember/groups/leave-group-confirm.php:30
3834
+ msgid "Confirm Leave Group"
3835
+ msgstr ""
3836
+
3837
+ #: bp-themes/bpmember/groups/leave-group-confirm.php:24
3838
+ #: bp-themes/bpskeletonmember/groups/leave-group-confirm.php:31
3839
+ msgid "Are you sure you want to leave this group?"
3840
+ msgstr ""
3841
+
3842
+ #: bp-themes/bpmember/groups/leave-group-confirm.php:27
3843
+ #: bp-themes/bpskeletonmember/groups/leave-group-confirm.php:34
3844
+ msgid "Yes, I'd like to leave this group."
3845
+ msgstr ""
3846
+
3847
+ #: bp-themes/bpmember/groups/leave-group-confirm.php:28
3848
+ #: bp-themes/bpskeletonmember/groups/leave-group-confirm.php:35
3849
+ msgid "No, I'll stay!"
3850
+ msgstr ""
3851
+
3852
+ #: bp-themes/bpmember/groups/list-invites.php:44
3853
+ #: bp-themes/bpskeletonmember/groups/list-invites.php:53
3854
+ msgid "You have no outstanding group invites."
3855
+ msgstr ""
3856
+
3857
+ #: bp-themes/bpmember/groups/list-members.php:35
3858
+ #: bp-themes/bpskeletonmember/groups/list-members.php:49
3859
+ msgid "Group Members"
3860
+ msgstr ""
3861
+
3862
+ #: bp-themes/bpmember/groups/request-membership.php:27
3863
+ #: bp-themes/bpskeletonmember/groups/request-membership.php:37
3864
+ #, php-format
3865
+ msgid "You are requesting to become a member of the group '%s'."
3866
+ msgstr ""
3867
+
3868
+ #: bp-themes/bpmember/groups/request-membership.php:30
3869
+ #: bp-themes/bpskeletonmember/groups/request-membership.php:40
3870
+ msgid "Comments (optional)"
3871
+ msgstr ""
3872
+
3873
+ #: bp-themes/bpmember/groups/request-membership.php:33
3874
+ #: bp-themes/bpskeletonmember/groups/request-membership.php:43
3875
+ msgid "Send Request"
3876
+ msgstr ""
3877
+
3878
+ #: bp-themes/bpmember/groups/send-invite.php:30
3879
+ #: bp-themes/bpskeletonmember/groups/send-invite.php:36
3880
+ msgid ""
3881
+ "You either need to build up your friends list, or your friends have already "
3882
+ "been invited or are current members."
3883
+ msgstr ""
3884
+
3885
+ #: bp-themes/bpmember/messages/compose.php:8
3886
+ #: bp-themes/bpskeletonmember/messages/compose.php:17
3887
+ msgid "Compose Message"
3888
+ msgstr ""
3889
+
3890
+ #: bp-themes/bpmember/messages/compose.php:16
3891
+ #: bp-themes/bpskeletonmember/messages/compose.php:25
3892
+ msgid "Send To"
3893
+ msgstr ""
3894
+
3895
+ #: bp-themes/bpmember/messages/compose.php:25
3896
+ #: bp-themes/bpskeletonmember/messages/compose.php:35
3897
+ msgid "This is a notice to all users."
3898
+ msgstr ""
3899
+
3900
+ #: bp-themes/bpmember/messages/compose.php:28
3901
+ #: bp-themes/bpskeletonmember/messages/compose.php:39
3902
+ msgid "Subject"
3903
+ msgstr ""
3904
+
3905
+ #: bp-themes/bpmember/messages/compose.php:31
3906
+ #: bp-themes/bpskeletonmember/messages/compose.php:42
3907
+ msgid "Message"
3908
+ msgstr ""
3909
+
3910
+ #: bp-themes/bpmember/messages/compose.php:39
3911
+ #: bp-themes/bpskeletonmember/messages/compose.php:50
3912
+ msgid "Send"
3913
+ msgstr ""
3914
+
3915
+ #: bp-themes/bpmember/messages/index.php:30
3916
+ #: bp-themes/bpskeletonmember/messages/index.php:47
3917
+ msgid "From:"
3918
+ msgstr ""
3919
+
3920
+ #: bp-themes/bpmember/messages/index.php:38
3921
+ #: bp-themes/bpmember/messages/notices.php:33
3922
+ #: bp-themes/bpmember/messages/sentbox.php:33
3923
+ #: bp-themes/bpskeletonmember/messages/index.php:57
3924
+ #: bp-themes/bpskeletonmember/messages/notices.php:44
3925
+ #: bp-themes/bpskeletonmember/messages/sentbox.php:51
3926
+ msgid "Delete Message"
3927
+ msgstr ""
3928
+
3929
+ #: bp-themes/bpmember/messages/index.php:48
3930
+ #: bp-themes/bpskeletonmember/messages/index.php:68
3931
+ msgid "You have no messages in your inbox."
3932
+ msgstr ""
3933
+
3934
+ #: bp-themes/bpmember/messages/notices.php:12
3935
+ #: bp-themes/bpskeletonmember/messages/notices.php:22
3936
+ msgid "Sent Notices"
3937
+ msgstr ""
3938
+
3939
+ #: bp-themes/bpmember/messages/notices.php:29
3940
+ #: bp-themes/bpskeletonmember/messages/notices.php:39
3941
+ msgid "Sent:"
3942
+ msgstr ""
3943
+
3944
+ #: bp-themes/bpmember/messages/notices.php:42
3945
+ #: bp-themes/bpskeletonmember/messages/notices.php:54
3946
+ msgid "You have not sent any notices."
3947
+ msgstr ""
3948
+
3949
+ #: bp-themes/bpmember/messages/sentbox.php:25
3950
+ #: bp-themes/bpskeletonmember/messages/sentbox.php:41
3951
+ msgid "To:"
3952
+ msgstr ""
3953
+
3954
+ #: bp-themes/bpmember/messages/sentbox.php:43
3955
+ #: bp-themes/bpskeletonmember/messages/sentbox.php:62
3956
+ msgid "You have no sent messages."
3957
+ msgstr ""
3958
+
3959
+ #: bp-themes/bpmember/profile/change-avatar.php:9
3960
+ #: bp-themes/bpskeletonmember/profile/change-avatar.php:15 bp-xprofile.php:209
3961
+ msgid "Change Avatar"
3962
+ msgstr ""
3963
+
3964
+ #: bp-themes/bpmember/profile/edit.php:13
3965
+ #: bp-themes/bpskeletonmember/profile/edit.php:30
3966
+ #, php-format
3967
+ msgid "Editing '%s'"
3968
+ msgstr ""
3969
+
3970
+ #: bp-themes/bpmember/profile/index.php:75
3971
+ #: bp-themes/bpskeletonmember/profile/index.php:77 bp-wire.php:55
3972
+ msgid "My Wire"
3973
+ msgstr ""
3974
+
3975
+ #: bp-themes/bpmember/profile/index.php:75
3976
+ #: bp-themes/bpmember/wire/latest.php:30
3977
+ #: bp-themes/bpskeletonmember/profile/index.php:77
3978
+ #: bp-themes/bpskeletonmember/wire/latest.php:25
3979
+ #, php-format
3980
+ msgid "%s's Wire"
3981
+ msgstr ""
3982
+
3983
+ #: bp-themes/bpmember/profile/index.php:75
3984
+ #: bp-themes/bpmember/wire/latest.php:30
3985
+ #: bp-themes/bpskeletonmember/profile/index.php:78
3986
+ #: bp-themes/bpskeletonmember/wire/latest.php:25
3987
+ msgid "No one has posted to your wire yet."
3988
+ msgstr ""
3989
+
3990
+ #: bp-themes/bpmember/profile/index.php:75
3991
+ #: bp-themes/bpmember/wire/latest.php:30
3992
+ #: bp-themes/bpskeletonmember/profile/index.php:78
3993
+ #: bp-themes/bpskeletonmember/wire/latest.php:25
3994
+ #, php-format
3995
+ msgid "No one has posted to %s's wire yet."
3996
+ msgstr ""
3997
+
3998
+ #: bp-themes/bpmember/profile/profile-loop.php:38
3999
+ #: bp-themes/bpskeletonmember/profile/profile-loop.php:58
4000
+ msgid "Sorry, this person does not have a public profile."
4001
+ msgstr ""
4002
+
4003
+ #: bp-themes/bpmember/userbar.php:2 bp-themes/bpskeletonmember/userbar.php:13
4004
+ msgid "Me"
4005
+ msgstr ""
4006
+
4007
+ #: bp-themes/bpmember/userbar.php:24 bp-themes/bpskeletonmember/userbar.php:33
4008
+ msgid "You must log in to access your account."
4009
+ msgstr ""
4010
+
4011
+ #: bp-themes/bpmember/userbar.php:32 bp-themes/bpskeletonmember/userbar.php:43
4012
+ msgid "Password"
4013
+ msgstr ""
4014
+
4015
+ #: bp-themes/bpmember/wire/latest.php:30
4016
+ #: bp-themes/bpskeletonmember/wire/latest.php:25
4017
+ msgid "Your Wire"
4018
+ msgstr ""
4019
+
4020
+ #: bp-themes/bpmember/wire/post-form.php:15
4021
+ #: bp-themes/bpskeletonmember/wire/post-form.php:26
4022
+ msgid "Notify members via email (will slow down posting)"
4023
+ msgstr ""
4024
+
4025
+ #: bp-themes/bpmember/wire/post-form.php:20
4026
+ #: bp-themes/bpskeletonmember/wire/post-form.php:32
4027
+ msgid "Post &raquo;"
4028
+ msgstr ""
4029
+
4030
+ #: bp-themes/bpskeletonmember/groups/group-home.php:78
4031
+ #: bp-themes/bpskeletonmember/groups/wire.php:35
4032
+ #, php-format
4033
+ msgid "The are no wire posts for %s"
4034
+ msgstr ""
4035
+
4036
+ #: bp-themes/bpskeletonmember/profile/index.php:52
4037
+ msgid "You haven't done anything recently."
4038
+ msgstr ""
4039
+
4040
+ #: bp-themes/bpskeletonmember/profile/index.php:52
4041
+ #, php-format
4042
+ msgid "%s has not done anything recently."
4043
+ msgstr ""
4044
+
4045
+ #: bp-wire.php:51
4046
+ msgid "All Posts"
4047
+ msgstr ""
4048
+
4049
+ #: bp-wire/bp-wire-ajax.php:25
4050
+ msgid "On"
4051
+ msgstr ""
4052
+
4053
+ #: bp-wire/bp-wire-templatetags.php:143
4054
+ msgid "There are currently no wire posts."
4055
+ msgstr ""
4056
+
4057
+ #: bp-xprofile.php:176 bp-xprofile/bp-xprofile-admin.php:36
4058
+ msgid "Profile Field Setup"
4059
+ msgstr ""
4060
+
4061
+ #: bp-xprofile.php:208 bp-xprofile/bp-xprofile-templatetags.php:379
4062
+ msgid "Edit Profile"
4063
+ msgstr ""
4064
+
4065
+ #: bp-xprofile.php:305
4066
+ msgid "A member posts on your wire"
4067
+ msgstr ""
4068
+
4069
+ #: bp-xprofile.php:373
4070
+ msgid "Wire message could not be posted. Please try again."
4071
+ msgstr ""
4072
+
4073
+ #: bp-xprofile.php:424
4074
+ msgid "Wire post could not be deleted, please try again."
4075
+ msgstr ""
4076
+
4077
+ #: bp-xprofile.php:513
4078
+ #, php-format
4079
+ msgid "%s wrote on their own wire"
4080
+ msgstr ""
4081
+
4082
+ #: bp-xprofile.php:521
4083
+ #, php-format
4084
+ msgid "%s wrote on %s wire"
4085
+ msgstr ""
4086
+
4087
+ #: bp-xprofile.php:549
4088
+ #, php-format
4089
+ msgid "%s updated the \"%s\" information on their profile"
4090
+ msgstr ""
4091
+
4092
+ #: bp-xprofile.php:577
4093
+ #, php-format
4094
+ msgid "You have %d new posts on your wire"
4095
+ msgstr ""
4096
+
4097
+ #: bp-xprofile.php:580
4098
+ #, php-format
4099
+ msgid "%s posted on your wire"
4100
+ msgstr ""
4101
+
4102
+ #: bp-xprofile.php:618
4103
+ msgid "Information"
4104
+ msgstr ""
4105
+
4106
+ #: bp-xprofile.php:657
4107
+ #, php-format
4108
+ msgid "%s cannot be left blank."
4109
+ msgstr ""
4110
+
4111
+ #: bp-xprofile.php:709
4112
+ msgid "There was a problem saving changes to this field, please try again."
4113
+ msgstr ""
4114
+
4115
+ #: bp-xprofile.php:726
4116
+ msgid "Save Changes &raquo;"
4117
+ msgstr ""
4118
+
4119
+ #: bp-xprofile.php:734
4120
+ msgid ""
4121
+ "There were problems saving your information. Please fix the following:<br />"
4122
+ msgstr ""
4123
+
4124
+ #: bp-xprofile.php:743
4125
+ msgid "Changes saved."
4126
+ msgstr ""
4127
+
4128
+ #: bp-xprofile.php:754
4129
+ msgid "That group does not exist."
4130
+ msgstr ""
4131
+
4132
+ #: bp-xprofile/bp-xprofile-admin.php:38
4133
+ msgid ""
4134
+ "Your users will distinguish themselves through their profile page. \n"
4135
+ "\t\t You must give them profile fields that allow them to describe "
4136
+ "themselves \n"
4137
+ "\t\t\tin a way that is relevant to the theme of your social network."
4138
+ msgstr ""
4139
+
4140
+ #: bp-xprofile/bp-xprofile-admin.php:42
4141
+ msgid "NOTE: Any fields in the first group will appear on the signup page."
4142
+ msgstr ""
4143
+
4144
+ #: bp-xprofile/bp-xprofile-admin.php:70
4145
+ msgid "Field Name"
4146
+ msgstr ""
4147
+
4148
+ #: bp-xprofile/bp-xprofile-admin.php:71
4149
+ #: bp-xprofile/bp-xprofile-classes.php:751
4150
+ #: bp-xprofile/bp-xprofile-classes.php:836
4151
+ msgid "Field Type"
4152
+ msgstr ""
4153
+
4154
+ #: bp-xprofile/bp-xprofile-admin.php:72
4155
+ msgid "Required?"
4156
+ msgstr ""
4157
+
4158
+ #: bp-xprofile/bp-xprofile-admin.php:73
4159
+ msgid "Action"
4160
+ msgstr ""
4161
+
4162
+ #: bp-xprofile/bp-xprofile-admin.php:93
4163
+ msgid "There are no fields in this group."
4164
+ msgstr ""
4165
+
4166
+ #: bp-xprofile/bp-xprofile-admin.php:97
4167
+ msgid "Add New Field"
4168
+ msgstr ""
4169
+
4170
+ #: bp-xprofile/bp-xprofile-admin.php:106 bp-xprofile/bp-xprofile-admin.php:111
4171
+ msgid "Add New Group"
4172
+ msgstr ""
4173
+
4174
+ #: bp-xprofile/bp-xprofile-admin.php:110
4175
+ msgid "You have no groups."
4176
+ msgstr ""
4177
+
4178
+ #: bp-xprofile/bp-xprofile-admin.php:136
4179
+ msgid "There was an error saving the group. Please try again"
4180
+ msgstr ""
4181
+
4182
+ #: bp-xprofile/bp-xprofile-admin.php:139
4183
+ msgid "The group was saved successfully."
4184
+ msgstr ""
4185
+
4186
+ #: bp-xprofile/bp-xprofile-admin.php:168
4187
+ msgid "There was an error deleting the group. Please try again"
4188
+ msgstr ""
4189
+
4190
+ #: bp-xprofile/bp-xprofile-admin.php:171
4191
+ msgid "The group was deleted successfully."
4192
+ msgstr ""
4193
+
4194
+ #: bp-xprofile/bp-xprofile-admin.php:204
4195
+ msgid "There was an error saving the field. Please try again"
4196
+ msgstr ""
4197
+
4198
+ #: bp-xprofile/bp-xprofile-admin.php:210
4199
+ msgid "The field was saved successfully."
4200
+ msgstr ""
4201
+
4202
+ #: bp-xprofile/bp-xprofile-admin.php:238
4203
+ msgid "field"
4204
+ msgstr ""
4205
+
4206
+ #: bp-xprofile/bp-xprofile-admin.php:240
4207
+ msgid "option"
4208
+ msgstr ""
4209
+
4210
+ #: bp-xprofile/bp-xprofile-admin.php:246
4211
+ #, php-format
4212
+ msgid "There was an error deleting the %s. Please try again"
4213
+ msgstr ""
4214
+
4215
+ #: bp-xprofile/bp-xprofile-admin.php:249
4216
+ #, php-format
4217
+ msgid "The %s was deleted successfully!"
4218
+ msgstr ""
4219
+
4220
+ #: bp-xprofile/bp-xprofile-classes.php:104
4221
+ msgid "Add Group"
4222
+ msgstr ""
4223
+
4224
+ #: bp-xprofile/bp-xprofile-classes.php:107
4225
+ msgid "Edit Group"
4226
+ msgstr ""
4227
+
4228
+ #: bp-xprofile/bp-xprofile-classes.php:128
4229
+ msgid "Profile Group Name"
4230
+ msgstr ""
4231
+
4232
+ #: bp-xprofile/bp-xprofile-classes.php:171
4233
+ msgid "Please make sure you give the group a name."
4234
+ msgstr ""
4235
+
4236
+ #: bp-xprofile/bp-xprofile-classes.php:492
4237
+ msgid "Clear"
4238
+ msgstr ""
4239
+
4240
+ #: bp-xprofile/bp-xprofile-classes.php:555
4241
+ msgid "January"
4242
+ msgstr ""
4243
+
4244
+ #: bp-xprofile/bp-xprofile-classes.php:555
4245
+ msgid "February"
4246
+ msgstr ""
4247
+
4248
+ #: bp-xprofile/bp-xprofile-classes.php:555
4249
+ msgid "March"
4250
+ msgstr ""
4251
+
4252
+ #: bp-xprofile/bp-xprofile-classes.php:556
4253
+ msgid "April"
4254
+ msgstr ""
4255
+
4256
+ #: bp-xprofile/bp-xprofile-classes.php:556
4257
+ msgid "May"
4258
+ msgstr ""
4259
+
4260
+ #: bp-xprofile/bp-xprofile-classes.php:556
4261
+ msgid "June"
4262
+ msgstr ""
4263
+
4264
+ #: bp-xprofile/bp-xprofile-classes.php:557
4265
+ msgid "July"
4266
+ msgstr ""
4267
+
4268
+ #: bp-xprofile/bp-xprofile-classes.php:557
4269
+ msgid "August"
4270
+ msgstr ""
4271
+
4272
+ #: bp-xprofile/bp-xprofile-classes.php:557
4273
+ msgid "September"
4274
+ msgstr ""
4275
+
4276
+ #: bp-xprofile/bp-xprofile-classes.php:558
4277
+ msgid "October"
4278
+ msgstr ""
4279
+
4280
+ #: bp-xprofile/bp-xprofile-classes.php:558
4281
+ msgid "November"
4282
+ msgstr ""
4283
+
4284
+ #: bp-xprofile/bp-xprofile-classes.php:558
4285
+ msgid "December"
4286
+ msgstr ""
4287
+
4288
+ #: bp-xprofile/bp-xprofile-classes.php:654
4289
+ msgid "Please enter options for this Field:"
4290
+ msgstr ""
4291
+
4292
+ #: bp-xprofile/bp-xprofile-classes.php:655
4293
+ msgid "Order By:"
4294
+ msgstr ""
4295
+
4296
+ #: bp-xprofile/bp-xprofile-classes.php:658
4297
+ msgid "Order Entered"
4298
+ msgstr ""
4299
+
4300
+ #: bp-xprofile/bp-xprofile-classes.php:659
4301
+ msgid "Name - Ascending"
4302
+ msgstr ""
4303
+
4304
+ #: bp-xprofile/bp-xprofile-classes.php:660
4305
+ msgid "Name - Descending"
4306
+ msgstr ""
4307
+
4308
+ #: bp-xprofile/bp-xprofile-classes.php:674
4309
+ #: bp-xprofile/bp-xprofile-classes.php:688
4310
+ msgid "Option"
4311
+ msgstr ""
4312
+
4313
+ #: bp-xprofile/bp-xprofile-classes.php:676
4314
+ #: bp-xprofile/bp-xprofile-classes.php:689
4315
+ msgid "Default Value"
4316
+ msgstr ""
4317
+
4318
+ #: bp-xprofile/bp-xprofile-classes.php:694
4319
+ msgid "Add Another Option"
4320
+ msgstr ""
4321
+
4322
+ #: bp-xprofile/bp-xprofile-classes.php:702
4323
+ msgid "Add Field"
4324
+ msgstr ""
4325
+
4326
+ #: bp-xprofile/bp-xprofile-classes.php:705
4327
+ msgid "Edit Field"
4328
+ msgstr ""
4329
+
4330
+ #: bp-xprofile/bp-xprofile-classes.php:729
4331
+ #: bp-xprofile/bp-xprofile-classes.php:818
4332
+ msgid "Field Title"
4333
+ msgstr ""
4334
+
4335
+ #: bp-xprofile/bp-xprofile-classes.php:736
4336
+ #: bp-xprofile/bp-xprofile-classes.php:823
4337
+ msgid "Field Description"
4338
+ msgstr ""
4339
+
4340
+ #: bp-xprofile/bp-xprofile-classes.php:743
4341
+ #: bp-xprofile/bp-xprofile-classes.php:828
4342
+ msgid "Is This Field Required?"
4343
+ msgstr ""
4344
+
4345
+ #: bp-xprofile/bp-xprofile-classes.php:745
4346
+ #: bp-xprofile/bp-xprofile-classes.php:831
4347
+ msgid "Not Required"
4348
+ msgstr ""
4349
+
4350
+ #: bp-xprofile/bp-xprofile-classes.php:746
4351
+ #: bp-xprofile/bp-xprofile-classes.php:832
4352
+ msgid "Required"
4353
+ msgstr ""
4354
+
4355
+ #: bp-xprofile/bp-xprofile-classes.php:753
4356
+ #: bp-xprofile/bp-xprofile-classes.php:840
4357
+ msgid "Text Box"
4358
+ msgstr ""
4359
+
4360
+ #: bp-xprofile/bp-xprofile-classes.php:754
4361
+ #: bp-xprofile/bp-xprofile-classes.php:842
4362
+ msgid "Multi-line Text Box"
4363
+ msgstr ""
4364
+
4365
+ #: bp-xprofile/bp-xprofile-classes.php:755
4366
+ #: bp-xprofile/bp-xprofile-classes.php:844
4367
+ msgid "Date Selector"
4368
+ msgstr ""
4369
+
4370
+ #: bp-xprofile/bp-xprofile-classes.php:756
4371
+ #: bp-xprofile/bp-xprofile-classes.php:846
4372
+ msgid "Radio Buttons"
4373
+ msgstr ""
4374
+
4375
+ #: bp-xprofile/bp-xprofile-classes.php:757
4376
+ #: bp-xprofile/bp-xprofile-classes.php:848
4377
+ msgid "Drop Down Select Box"
4378
+ msgstr ""
4379
+
4380
+ #: bp-xprofile/bp-xprofile-classes.php:758
4381
+ #: bp-xprofile/bp-xprofile-classes.php:850
4382
+ msgid "Multi Select Box"
4383
+ msgstr ""
4384
+
4385
+ #: bp-xprofile/bp-xprofile-classes.php:759
4386
+ msgid "Checkboxes"
4387
+ msgstr ""
4388
+
4389
+ #: bp-xprofile/bp-xprofile-classes.php:766
4390
+ msgid "Save"
4391
+ msgstr ""
4392
+
4393
+ #: bp-xprofile/bp-xprofile-classes.php:767
4394
+ msgid "or"
4395
+ msgstr ""
4396
+
4397
+ #: bp-xprofile/bp-xprofile-classes.php:767
4398
+ msgid "Cancel"
4399
+ msgstr ""
4400
+
4401
+ #: bp-xprofile/bp-xprofile-classes.php:780
4402
+ msgid "Add Prebuilt Field"
4403
+ msgstr ""
4404
+
4405
+ #: bp-xprofile/bp-xprofile-classes.php:856
4406
+ msgid "Add"
4407
+ msgstr ""
4408
+
4409
+ #: bp-xprofile/bp-xprofile-classes.php:868
4410
+ msgid "No prebuilt fields available at this time."
4411
+ msgstr ""
4412
+
4413
+ #: bp-xprofile/bp-xprofile-classes.php:910
4414
+ msgid "Visit author homepage"
4415
+ msgstr ""
4416
+
4417
+ #: bp-xprofile/bp-xprofile-classes.php:914
4418
+ msgid "Anonymous"
4419
+ msgstr ""
4420
+
4421
+ #: bp-xprofile/bp-xprofile-classes.php:940
4422
+ msgid "Please make sure you fill out all required fields."
4423
+ msgstr ""
4424
+
4425
+ #: bp-xprofile/bp-xprofile-classes.php:943
4426
+ msgid ""
4427
+ "Radio button field types require at least one option. Please add options "
4428
+ "below."
4429
+ msgstr ""
4430
+
4431
+ #: bp-xprofile/bp-xprofile-classes.php:946
4432
+ #: bp-xprofile/bp-xprofile-classes.php:949
4433
+ msgid ""
4434
+ "Select box field types require at least one option. Please add options below."
4435
+ msgstr ""
4436
+
4437
+ #: bp-xprofile/bp-xprofile-classes.php:952
4438
+ msgid ""
4439
+ "Checkbox field types require at least one option. Please add options below."
4440
+ msgstr ""
4441
+
4442
+ #: bp-xprofile/bp-xprofile-notifications.php:37
4443
+ #, php-format
4444
+ msgid "%s posted on your wire."
4445
+ msgstr ""
4446
+
4447
+ #: bp-xprofile/bp-xprofile-notifications.php:40
4448
+ #, php-format
4449
+ msgid ""
4450
+ "%s posted on your wire:\n"
4451
+ "\n"
4452
+ "\"%s\"\n"
4453
+ "\n"
4454
+ "To view your wire: %s\n"
4455
+ "\n"
4456
+ "---------------------\n"
4457
+ msgstr ""
4458
+
4459
+ #: bp-xprofile/bp-xprofile-signup.php:17
4460
+ msgid "Your Profile Details"
4461
+ msgstr ""
4462
+
4463
+ #: bp-xprofile/bp-xprofile-signup.php:18
4464
+ msgid ""
4465
+ "Please fill in the following fields to start up your member profile. Fields\n"
4466
+ "\t\t\tmarked with a star are required."
4467
+ msgstr ""
4468
+
4469
+ #: bp-xprofile/bp-xprofile-signup.php:46
4470
+ msgid "Profile Picture (Avatar)"
4471
+ msgstr ""
4472
+
4473
+ #: bp-xprofile/bp-xprofile-signup.php:47
4474
+ msgid ""
4475
+ "You can upload an image from your computer to use as an avatar. This avatar "
4476
+ "will appear on your profile page."
4477
+ msgstr ""
4478
+
4479
+ #: bp-xprofile/bp-xprofile-signup.php:59
4480
+ msgid "Select a file:"
4481
+ msgstr ""
4482
+
4483
+ #: bp-xprofile/bp-xprofile-signup.php:137
4484
+ #, php-format
4485
+ msgid "%s cannot be left blank"
4486
+ msgstr ""
4487
+
4488
+ #: bp-xprofile/bp-xprofile-templatetags.php:348
4489
+ msgid ""
4490
+ "Avatar uploads are currently disabled. Why not use a <a href=\"http://"
4491
+ "gravatar.com\" target=\"_blank\">gravatar</a> instead?"
4492
+ msgstr ""
4493
+
4494
+ #: bp-xprofile/bp-xprofile-templatetags.php:357
4495
+ msgid "Profile not recently updated"
4496
+ msgstr ""
4497
+
4498
+ #: bp-xprofile/bp-xprofile-templatetags.php:368
4499
+ #, php-format
4500
+ msgid "Profile updated %s ago"
4501
+ msgstr ""
bp-loader.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ 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.0
8
+ Author URI: http://buddypress.org/developers/
9
+ Site Wide Only: true
10
+ */
11
+
12
+ define( 'BP_VERSION', '1.0' );
13
+
14
+ /***
15
+ * This file will load in each BuddyPress component based on which
16
+ * of the components have been activated on the "BuddyPress" admin menu.
17
+ */
18
+
19
+ require_once( 'bp-core.php' );
20
+ $deactivated = apply_filters( 'bp_deactivated_components', get_site_option( 'bp-deactivated-components' ) );
21
+
22
+ /* Activity Streams */
23
+ if ( !isset( $deactivated['bp-activity.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-activity.php') )
24
+ include( 'bp-activity.php' );
25
+
26
+ /* Blog Tracking */
27
+ if ( !isset( $deactivated['bp-blogs.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-blogs.php') )
28
+ include( 'bp-blogs.php' );
29
+
30
+ /* bbPress Forum Integration */
31
+ if ( !isset( $deactivated['bp-forums.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-forums.php') )
32
+ include( 'bp-forums.php' );
33
+
34
+ /* Friend Connections */
35
+ if ( !isset( $deactivated['bp-friends.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-friends.php') )
36
+ include( 'bp-friends.php' );
37
+
38
+ /* Groups Support */
39
+ if ( !isset( $deactivated['bp-groups.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-groups.php') )
40
+ include( '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-messages.php' );
45
+
46
+ /* Wire Support */
47
+ if ( !isset( $deactivated['bp-wire.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-wire.php') )
48
+ include( '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-xprofile.php' );
53
+
54
+ ?>
bp-messages.php ADDED
@@ -0,0 +1,602 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ define ( 'BP_MESSAGES_VERSION', '1.0' );
4
+ define ( 'BP_MESSAGES_DB_VERSION', '1300' );
5
+
6
+ /* Define the slug for the component */
7
+ if ( !defined( 'BP_MESSAGES_SLUG' ) )
8
+ define ( 'BP_MESSAGES_SLUG', 'messages' );
9
+
10
+ require ( 'bp-messages/bp-messages-classes.php' );
11
+ require ( 'bp-messages/bp-messages-ajax.php' );
12
+ require ( 'bp-messages/bp-messages-cssjs.php' );
13
+ require ( 'bp-messages/bp-messages-templatetags.php' );
14
+ require ( 'bp-messages/bp-messages-filters.php' );
15
+
16
+ /**************************************************************************
17
+ messages_install()
18
+
19
+ Sets up the database tables ready for use on a site installation.
20
+ **************************************************************************/
21
+
22
+ function messages_install() {
23
+ global $wpdb, $bp;
24
+
25
+ if ( !empty($wpdb->charset) )
26
+ $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
27
+
28
+ $sql[] = "CREATE TABLE {$bp->messages->table_name_threads} (
29
+ id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
30
+ message_ids longtext NOT NULL,
31
+ sender_ids longtext NOT NULL,
32
+ first_post_date datetime NOT NULL,
33
+ last_post_date datetime NOT NULL,
34
+ last_message_id bigint(20) NOT NULL,
35
+ last_sender_id bigint(20) NOT NULL,
36
+ KEY last_message_id (last_message_id),
37
+ KEY last_sender_id (last_sender_id)
38
+ ) {$charset_collate};";
39
+
40
+ $sql[] = "CREATE TABLE {$bp->messages->table_name_recipients} (
41
+ id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
42
+ user_id bigint(20) NOT NULL,
43
+ thread_id bigint(20) NOT NULL,
44
+ sender_only tinyint(1) NOT NULL DEFAULT '0',
45
+ unread_count int(10) NOT NULL DEFAULT '0',
46
+ is_deleted tinyint(1) NOT NULL DEFAULT '0',
47
+ KEY user_id (user_id),
48
+ KEY thread_id (thread_id),
49
+ KEY is_deleted (is_deleted),
50
+ KEY sender_only (sender_only),
51
+ KEY unread_count (unread_count)
52
+ ) {$charset_collate};";
53
+
54
+ $sql[] = "CREATE TABLE {$bp->messages->table_name_messages} (
55
+ id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
56
+ sender_id bigint(20) NOT NULL,
57
+ subject varchar(200) NOT NULL,
58
+ message longtext NOT NULL,
59
+ date_sent datetime NOT NULL,
60
+ message_order int(10) NOT NULL,
61
+ sender_is_group tinyint(1) NOT NULL DEFAULT '0',
62
+ KEY sender_id (sender_id),
63
+ KEY message_order (message_order),
64
+ KEY sender_is_group (sender_is_group)
65
+ ) {$charset_collate};";
66
+
67
+ $sql[] = "CREATE TABLE {$bp->messages->table_name_notices} (
68
+ id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
69
+ subject varchar(200) NOT NULL,
70
+ message longtext NOT NULL,
71
+ date_sent datetime NOT NULL,
72
+ is_active tinyint(1) NOT NULL DEFAULT '0',
73
+ KEY is_active (is_active)
74
+ ) {$charset_collate};";
75
+
76
+ require_once( ABSPATH . 'wp-admin/upgrade-functions.php' );
77
+ dbDelta($sql);
78
+
79
+ add_site_option( 'bp-messages-db-version', BP_MESSAGES_DB_VERSION );
80
+ }
81
+
82
+
83
+ /**************************************************************************
84
+ messages_setup_globals()
85
+
86
+ Set up and add all global variables for this component, and add them to
87
+ the $bp global variable array.
88
+ **************************************************************************/
89
+
90
+ function messages_setup_globals() {
91
+ global $bp, $wpdb;
92
+
93
+ $bp->messages->table_name_threads = $wpdb->base_prefix . 'bp_messages_threads';
94
+ $bp->messages->table_name_messages = $wpdb->base_prefix . 'bp_messages_messages';
95
+ $bp->messages->table_name_recipients = $wpdb->base_prefix . 'bp_messages_recipients';
96
+ $bp->messages->table_name_notices = $wpdb->base_prefix . 'bp_messages_notices';
97
+ $bp->messages->format_activity_function = 'messages_format_activity';
98
+ $bp->messages->format_notification_function = 'messages_format_notifications';
99
+ $bp->messages->image_base = BP_PLUGIN_URL . '/bp-messages/images';
100
+ $bp->messages->slug = BP_MESSAGES_SLUG;
101
+
102
+ $bp->version_numbers->messages = BP_MESSAGES_VERSION;
103
+ }
104
+ add_action( 'plugins_loaded', 'messages_setup_globals', 5 );
105
+ add_action( 'admin_menu', 'messages_setup_globals', 1 );
106
+
107
+
108
+ /**************************************************************************
109
+ messages_add_admin_menu()
110
+
111
+ Creates the administration interface menus and checks to see if the DB
112
+ tables are set up.
113
+ **************************************************************************/
114
+
115
+ function messages_check_installed() {
116
+ global $wpdb, $bp;
117
+
118
+ if ( !is_site_admin() )
119
+ return false;
120
+
121
+ /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
122
+ if ( get_site_option('bp-messages-db-version') < BP_MESSAGES_DB_VERSION )
123
+ messages_install();
124
+ }
125
+ add_action( 'admin_menu', 'messages_check_installed', 1 );
126
+
127
+ /**************************************************************************
128
+ messages_setup_nav()
129
+
130
+ Set up front end navigation.
131
+ **************************************************************************/
132
+
133
+ function messages_setup_nav() {
134
+ global $bp;
135
+
136
+ if ( $bp->current_component == $bp->messages->slug ) {
137
+ $inbox_count = messages_get_unread_count();
138
+ $inbox_display = ( $inbox_count ) ? ' style="display:inline;"' : ' style="display:none;"';
139
+ $count_indicator = '&nbsp; <span' . $inbox_display . ' class="unread-count inbox-count">' . $inbox_count . '</span>';
140
+ }
141
+
142
+ /* Add 'Profile' to the main navigation */
143
+ bp_core_add_nav_item( __('Messages', 'buddypress'), $bp->messages->slug, false, false );
144
+ bp_core_add_nav_default( $bp->messages->slug, 'messages_screen_inbox', 'inbox', bp_is_home() );
145
+
146
+ $messages_link = $bp->loggedin_user->domain . $bp->messages->slug . '/';
147
+
148
+ /* Add the subnav items to the profile */
149
+ bp_core_add_subnav_item( $bp->messages->slug, 'inbox', __('Inbox', 'buddypress') . $count_indicator, $messages_link, 'messages_screen_inbox', false, bp_is_home() );
150
+ bp_core_add_subnav_item( $bp->messages->slug, 'sentbox', __('Sent Messages', 'buddypress'), $messages_link, 'messages_screen_sentbox', false, bp_is_home() );
151
+ bp_core_add_subnav_item( $bp->messages->slug, 'compose', __('Compose', 'buddypress'), $messages_link, 'messages_screen_compose', false, bp_is_home() );
152
+ bp_core_add_subnav_item( $bp->messages->slug, 'notices', __('Notices', 'buddypress'), $messages_link, 'messages_screen_notices', false, true, true );
153
+
154
+ if ( $bp->current_component == $bp->messages->slug ) {
155
+ if ( bp_is_home() ) {
156
+ $bp->bp_options_title = __( 'My Messages', 'buddypress' );
157
+ } else {
158
+ $bp_options_avatar = bp_core_get_avatar( $bp->displayed_user->id, 1 );
159
+ $bp->bp_options_title = $bp->displayed_user->fullname;
160
+ }
161
+ }
162
+ }
163
+ add_action( 'wp', 'messages_setup_nav', 2 );
164
+ add_action( 'admin_menu', 'messages_setup_nav', 2 );
165
+
166
+ /***** Screens **********/
167
+
168
+ function messages_screen_inbox() {
169
+ do_action( 'messages_screen_inbox' );
170
+ bp_core_load_template( apply_filters( 'messages_template_inbox', 'messages/index' ) );
171
+ }
172
+
173
+ function messages_screen_sentbox() {
174
+ do_action( 'messages_screen_sentbox' );
175
+ bp_core_load_template( apply_filters( 'messages_template_sentbox', 'messages/sentbox' ) );
176
+ }
177
+
178
+ function messages_screen_compose() {
179
+ // Remove any saved message data from a previous session.
180
+ messages_remove_callback_values();
181
+
182
+ //var_dump($_POST['send_to_usernames']);
183
+
184
+ $recipients = false;
185
+ if ( empty( $_POST['send_to_usernames'] ) ) {
186
+ if ( !empty( $_POST['send-to-input'] ) ) {
187
+ // Replace commas with places
188
+ $recipients = str_replace( ',', ' ', $_POST['send-to-input'] );
189
+ $recipients = str_replace( ' ', ' ', $recipients );
190
+ }
191
+ } else {
192
+ $recipients = $_POST['send_to_usernames'];
193
+ }
194
+
195
+ if ( $recipients || ( isset($_POST['send-notice']) && is_site_admin() ) ) {
196
+ messages_send_message( $recipients, $_POST['subject'], $_POST['content'], $_POST['thread_id'], false, true );
197
+ }
198
+
199
+ do_action( 'messages_screen_compose' );
200
+
201
+ bp_core_load_template( apply_filters( 'messages_template_compose', 'messages/compose' ) );
202
+ }
203
+
204
+ function messages_screen_notices() {
205
+ global $bp, $notice_id;
206
+
207
+ if ( !is_site_admin() )
208
+ return false;
209
+
210
+ $notice_id = $bp->action_variables[1];
211
+
212
+ if ( $notice_id && is_numeric($notice_id) ) {
213
+ $notice = new BP_Messages_Notice($notice_id);
214
+
215
+ if ( 'deactivate' == $bp->action_variables[0] ) {
216
+ if ( !$notice->deactivate() ) {
217
+ bp_core_add_message( __('There was a problem deactivating that notice.', 'buddypress'), 'error' );
218
+ } else {
219
+ bp_core_add_message( __('Notice deactivated.', 'buddypress') );
220
+ }
221
+ } else if ( 'activate' == $bp->action_variables[0] ) {
222
+ if ( !$notice->activate() ) {
223
+ bp_core_add_message( __('There was a problem activating that notice.', 'buddypress'), 'error' );
224
+ } else {
225
+ bp_core_add_message( __('Notice activated.', 'buddypress') );
226
+ }
227
+ } else if ( 'delete' == $bp->action_variables[0] ) {
228
+ if ( !$notice->delete() ) {
229
+ bp_core_add_message( __('There was a problem deleting that notice.', 'buddypress'), 'buddypress' );
230
+ } else {
231
+ bp_core_add_message( __('Notice deleted.', 'buddypress') );
232
+ }
233
+ }
234
+ bp_core_redirect( $bp->loggedin_user->domain . $bp->messages->slug . '/notices' );
235
+ }
236
+
237
+ do_action( 'messages_screen_notices' );
238
+
239
+ bp_core_load_template( apply_filters( 'messages_template_notices', 'messages/notices' ) );
240
+ }
241
+
242
+ function messages_screen_notification_settings() {
243
+ global $current_user; ?>
244
+ <table class="notification-settings" id="messages-notification-settings">
245
+ <tr>
246
+ <th class="icon"></th>
247
+ <th class="title"><?php _e( 'Messages', 'buddypress' ) ?></th>
248
+ <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th>
249
+ <th class="no"><?php _e( 'No', 'buddypress' )?></th>
250
+ </tr>
251
+ <tr>
252
+ <td></td>
253
+ <td><?php _e( 'A member sends you a new message', 'buddypress' ) ?></td>
254
+ <td class="yes"><input type="radio" name="notifications[notification_messages_new_message]" value="yes" <?php if ( !get_usermeta( $current_user->id, 'notification_messages_new_message' ) || 'yes' == get_usermeta( $current_user->id, 'notification_messages_new_message' ) ) { ?>checked="checked" <?php } ?>/></td>
255
+ <td class="no"><input type="radio" name="notifications[notification_messages_new_message]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id, 'notification_messages_new_message' ) ) { ?>checked="checked" <?php } ?>/></td>
256
+ </tr>
257
+ <tr>
258
+ <td></td>
259
+ <td><?php _e( 'A new site notice is posted', 'buddypress' ) ?></td>
260
+ <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>
261
+ <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>
262
+ </tr>
263
+
264
+ <?php do_action( 'messages_screen_notification_settings' ) ?>
265
+ </table>
266
+ <?php
267
+ }
268
+ add_action( 'bp_notification_settings', 'messages_screen_notification_settings', 2 );
269
+
270
+ /***** Actions **********/
271
+
272
+ function messages_action_view_message() {
273
+ global $bp, $thread_id;
274
+
275
+ if ( $bp->current_component != $bp->messages->slug || $bp->current_action != 'view' )
276
+ return false;
277
+
278
+ $thread_id = $bp->action_variables[0];
279
+
280
+ if ( !$thread_id || !is_numeric($thread_id) || !BP_Messages_Thread::check_access($thread_id) ) {
281
+ bp_core_redirect( $bp->displayed_user->domain . $bp->current_component );
282
+ } else {
283
+ $bp->bp_options_nav[$bp->messages->slug]['view'] = array(
284
+ 'name' => sprintf( __( 'From: %s', 'buddypress'), BP_Messages_Thread::get_last_sender($thread_id) ),
285
+ 'link' => $bp->loggedin_user->domain . $bp->messages->slug . '/'
286
+ );
287
+
288
+ bp_core_load_template( apply_filters( 'messages_template_view_message', 'messages/view' ) );
289
+ }
290
+ }
291
+ add_action( 'wp', 'messages_action_view_message', 3 );
292
+
293
+
294
+ function messages_action_delete_message() {
295
+ global $bp, $thread_id;
296
+
297
+ if ( $bp->current_component != $bp->messages->slug || $bp->action_variables[0] != 'delete' )
298
+ return false;
299
+
300
+ $thread_id = $bp->action_variables[1];
301
+
302
+ if ( !$thread_id || !is_numeric($thread_id) || !BP_Messages_Thread::check_access($thread_id) ) {
303
+ bp_core_redirect( $bp->displayed_user->domain . $bp->current_component . '/' . $bp->current_action );
304
+ } else {
305
+ //echo $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action; die;
306
+ // delete message
307
+ if ( !messages_delete_thread($thread_id) ) {
308
+ bp_core_add_message( __('There was an error deleting that message.', 'buddypress'), 'error' );
309
+ } else {
310
+ bp_core_add_message( __('Message deleted.', 'buddypress') );
311
+ }
312
+ bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action );
313
+ }
314
+ }
315
+ add_action( 'wp', 'messages_action_delete_message', 3 );
316
+
317
+
318
+ function messages_action_bulk_delete() {
319
+ global $bp, $thread_ids;
320
+
321
+ if ( $bp->current_component != $bp->messages->slug || $bp->action_variables[0] != 'bulk-delete' )
322
+ return false;
323
+
324
+ $thread_ids = $_POST['thread_ids'];
325
+
326
+ if ( !$thread_ids || !BP_Messages_Thread::check_access($thread_ids) ) {
327
+ bp_core_redirect( $bp->displayed_user->domain . $bp->current_component . '/' . $bp->current_action );
328
+ } else {
329
+ if ( !messages_delete_thread( $thread_ids ) ) {
330
+ bp_core_add_message( __('There was an error deleting messages.', 'buddypress'), 'error' );
331
+ } else {
332
+ bp_core_add_message( __('Messages deleted.', 'buddypress') );
333
+ }
334
+ bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action );
335
+ }
336
+ }
337
+ add_action( 'wp', 'messages_action_bulk_delete', 3 );
338
+
339
+
340
+ /**************************************************************************
341
+ messages_record_activity()
342
+
343
+ Records activity for the logged in user within the friends component so that
344
+ it will show in the users activity stream (if installed)
345
+ **************************************************************************/
346
+
347
+ function messages_record_activity( $args = true ) {
348
+ if ( function_exists('bp_activity_record') ) {
349
+ extract($args);
350
+ bp_activity_record( $item_id, $component_name, $component_action, $is_private );
351
+ }
352
+ }
353
+
354
+ function messages_delete_activity( $args = true ) {
355
+ if ( function_exists('bp_activity_delete') ) {
356
+ extract($args);
357
+ bp_activity_delete( $item_id, $component_name, $component_action, $user_id, $secondary_item_id );
358
+ }
359
+ }
360
+
361
+ function messages_format_notifications( $action, $item_id, $secondary_item_id, $total_items ) {
362
+ global $bp;
363
+
364
+ if ( 'new_message' == $action ) {
365
+ if ( (int)$total_items > 1 )
366
+ 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 );
367
+ else
368
+ 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 );
369
+ }
370
+
371
+ do_action( 'messages_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
372
+
373
+ return false;
374
+ }
375
+
376
+
377
+ /**************************************************************************
378
+ messages_send_message()
379
+
380
+ Send a message.
381
+ **************************************************************************/
382
+
383
+ function messages_send_message( $recipients, $subject, $content, $thread_id, $from_ajax = false, $from_template = false, $is_reply = false ) {
384
+ global $pmessage;
385
+ global $message, $type;
386
+ global $bp, $current_user;
387
+
388
+ if ( !check_admin_referer( 'messages_send_message' ) )
389
+ return false;
390
+
391
+ messages_add_callback_values( $recipients, $subject, $content );
392
+
393
+ if ( isset( $_POST['send-notice'] ) ) {
394
+ if ( messages_send_notice( $subject, $content, $from_template ) ) {
395
+ bp_core_add_message( __('Notice posted successfully.', 'buddypress') );
396
+ } else {
397
+ bp_core_add_message( __('There was an error posting that notice.', 'buddypress'), 'error' );
398
+ }
399
+ bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/notices' );
400
+ return true;
401
+ }
402
+
403
+ $recipients = explode( ' ', $recipients );
404
+
405
+ // If there are no recipients
406
+ if ( count( $recipients ) < 1 ) {
407
+ if ( !$from_ajax ) {
408
+ bp_core_add_message( __('Please enter at least one valid user to send this message to.', 'buddypress'), 'error' );
409
+ bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/compose' );
410
+ } else {
411
+ return array('status' => 0, 'message' => __('There was an error sending the reply, please try again.', 'buddypress'));
412
+ }
413
+
414
+ // If there is only 1 recipient and it is the logged in user.
415
+ } else if ( 1 == count( $recipients ) && $recipients[0] == $current_user->user_login ) {
416
+ bp_core_add_message( __('You must send your message to one or more users not including yourself.', 'buddypress'), 'error' );
417
+ bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/compose' );
418
+
419
+ // If the subject or content boxes are empty.
420
+ } else if ( empty( $subject ) || empty( $content ) ) {
421
+ if ( !$from_ajax ) {
422
+ bp_core_add_message( __('Please make sure you fill in all the fields.', 'buddypress'), 'error' );
423
+ bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/compose' );
424
+ } else {
425
+ return array('status' => 0, 'message' => __('Please make sure you have typed a message before sending a reply.', 'buddypress'));
426
+ }
427
+
428
+ // Passed validation continue.
429
+ } else {
430
+
431
+ // Strip the logged in user from the recipient list if they exist
432
+ if ( $key = array_search( $current_user->user_login, $recipients ) )
433
+ unset( $recipients[$key] );
434
+
435
+ $pmessage = new BP_Messages_Message;
436
+
437
+ $pmessage->sender_id = $bp->loggedin_user->id;
438
+ $pmessage->subject = $subject;
439
+ $pmessage->message = $content;
440
+ $pmessage->thread_id = $thread_id;
441
+ $pmessage->date_sent = time();
442
+ $pmessage->message_order = 0; // TODO
443
+ $pmessage->sender_is_group = 0;
444
+
445
+ if ( $is_reply ) {
446
+ $thread = new BP_Messages_Thread($thread_id);
447
+ $pmessage->recipients = $thread->get_recipients();
448
+ } else {
449
+ $pmessage->recipients = BP_Messages_Message::get_recipient_ids( $recipients );
450
+ }
451
+
452
+ if ( !is_null( $pmessage->recipients ) ) {
453
+ if ( !$pmessage->send() ) {
454
+ $message = __('Message could not be sent, please try again.', 'buddypress');
455
+ $type = 'error';
456
+
457
+ if ( $from_ajax ) {
458
+ return array('status' => 0, 'message' => $message);
459
+ } else {
460
+ bp_core_add_message( $message, $type );
461
+ bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/compose' );
462
+ }
463
+ } else {
464
+ $message = __('Message sent successfully!', 'buddypress') . ' <a href="' . $bp->loggedin_user->domain . $bp->messages->slug . '/view/' . $pmessage->thread_id . '">' . __('View Message', 'buddypress') . '</a> &raquo;';
465
+ $type = 'success';
466
+
467
+ // Send screen notifications to the recipients
468
+ for ( $i = 0; $i < count($pmessage->recipients); $i++ ) {
469
+ if ( $pmessage->recipients[$i] != $bp->loggedin_user->id ) {
470
+ bp_core_add_notification( $pmessage->id, $pmessage->recipients[$i], 'messages', 'new_message' );
471
+ }
472
+ }
473
+
474
+ // Send email notifications to the recipients
475
+ require_once( BP_PLUGIN_DIR . '/bp-messages/bp-messages-notifications.php' );
476
+ messages_notification_new_message( array( 'item_id' => $pmessage->id, 'recipient_ids' => $pmessage->recipients, 'thread_id' => $pmessage->thread_id, 'component_name' => 'messages', 'component_action' => 'message_sent', 'is_private' => 1 ) );
477
+
478
+ do_action( 'messages_send_message', array( 'item_id' => $pmessage->id, 'recipient_ids' => $pmessage->recipients, 'thread_id' => $pmessage->thread_id, 'component_name' => 'messages', 'component_action' => 'message_sent', 'is_private' => 1 ) );
479
+
480
+ if ( $from_ajax ) {
481
+ return array('status' => 1, 'message' => $message, 'reply' => $pmessage);
482
+ } else {
483
+ bp_core_add_message( $message );
484
+ bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/inbox' );
485
+ }
486
+ }
487
+ } else {
488
+ $message = __('Message could not be sent, please try again.', 'buddypress');
489
+ $type = 'error';
490
+
491
+ if ( $from_ajax ) {
492
+ return array('status' => 0, 'message' => $message);
493
+ } else {
494
+ bp_core_add_message( $message, $type );
495
+ bp_core_redirect( $bp->loggedin_user->domain . $bp->messages->slug . '/compose' );
496
+ }
497
+ }
498
+ }
499
+
500
+ }
501
+
502
+ function messages_add_callback_values( $recipients, $subject, $content ) {
503
+ $_SESSION['send_to'] = $recipients;
504
+ $_SESSION['subject'] = $subject;
505
+ $_SESSION['content'] = $content;
506
+ }
507
+
508
+ function messages_remove_callback_values() {
509
+ unset($_SESSION['send_to']);
510
+ unset($_SESSION['subject']);
511
+ unset($_SESSION['content']);
512
+ }
513
+
514
+ /**************************************************************************
515
+ messages_send_notice()
516
+
517
+ Handles the sending of notices by an administrator
518
+ **************************************************************************/
519
+
520
+ function messages_send_notice( $subject, $message, $from_template ) {
521
+
522
+
523
+ if ( !is_site_admin() || empty( $subject ) || empty( $message ) ) {
524
+ return false;
525
+ } else {
526
+ // Has access to send notices, lets do it.
527
+ $notice = new BP_Messages_Notice;
528
+ $notice->subject = $subject;
529
+ $notice->message = $message;
530
+ $notice->date_sent = time();
531
+ $notice->is_active = 1;
532
+ $notice->save(); // send it.
533
+
534
+ do_action( 'messages_send_notice', $subject, $message );
535
+
536
+ return true;
537
+ }
538
+ }
539
+
540
+ /**************************************************************************
541
+ messages_delete_thread()
542
+
543
+ Handles the deletion of a single or multiple threads.
544
+ **************************************************************************/
545
+
546
+ function messages_delete_thread( $thread_ids ) {
547
+ if ( !check_admin_referer( 'messages_delete_thread' ) )
548
+ return false;
549
+
550
+ if ( is_array($thread_ids) ) {
551
+ $error = 0;
552
+ for ( $i = 0; $i < count($thread_ids); $i++ ) {
553
+ if ( !$status = BP_Messages_Thread::delete($thread_ids[$i]) )
554
+ $error = 1;
555
+ }
556
+
557
+ if ( $error )
558
+ return false;
559
+
560
+ do_action( 'messages_delete_thread', $thread_ids );
561
+
562
+ return true;
563
+ } else {
564
+ if ( !BP_Messages_Thread::delete($thread_ids) )
565
+ return false;
566
+
567
+ do_action( 'messages_delete_thread', $thread_ids );
568
+
569
+ return true;
570
+ }
571
+ }
572
+
573
+ function messages_get_unread_count( $user_id = false ) {
574
+ global $bp;
575
+
576
+ if ( !$user_id )
577
+ $user_id = $bp->loggedin_user->id;
578
+
579
+ return BP_Messages_Thread::get_inbox_count( $user_id );
580
+ }
581
+
582
+ function messages_is_user_sender( $user_id, $message_id ) {
583
+ return BP_Messages_Message::is_user_sender( $user_id, $message_id );
584
+ }
585
+
586
+ function messages_get_message_sender( $message_id ) {
587
+ return BP_Messages_Message::get_message_sender( $message_id );
588
+ }
589
+
590
+
591
+
592
+ // List actions to clear super cached pages on, if super cache is installed
593
+ add_action( 'messages_delete_thread', 'bp_core_clear_cache' );
594
+ add_action( 'messages_send_notice', 'bp_core_clear_cache' );
595
+ add_action( 'messages_message_sent', 'bp_core_clear_cache' );
596
+
597
+ // Don't cache message inbox/sentbox/compose as it's too problematic
598
+ add_action( 'messages_screen_compose', 'bp_core_clear_cache' );
599
+ add_action( 'messages_screen_sentbox', 'bp_core_clear_cache' );
600
+ add_action( 'messages_screen_inbox', 'bp_core_clear_cache' );
601
+
602
+ ?>
bp-messages/autocomplete/bp-messages-autocomplete.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* Load the WP environment */
3
+ require_once( preg_replace('%(.*)[/\\\\]wp-content[/\\\\].*%', '\1', dirname( __FILE__ ) ) . '/wp-load.php' );
4
+ require_once( BP_PLUGIN_DIR . '/bp-core.php' );
5
+ require_once( BP_PLUGIN_DIR . '/bp-friends.php' );
6
+
7
+ // Setup the $bp global array as it's not auto set outside of the normal WP enviro.
8
+ bp_core_setup_globals();
9
+ friends_setup_globals();
10
+
11
+ // Get the friend ids based on the search terms
12
+ $friends = friends_search_friends( $_GET['q'], $bp->loggedin_user->id, $_GET['limit'], 1 );
13
+
14
+ if ( $friends['friends'] ) {
15
+ foreach ( $friends['friends'] as $user_id ) {
16
+ $ud = get_userdata($user_id);
17
+ $username = $ud->user_login;
18
+ echo bp_core_get_avatar( $user_id, 1, 15, 15 ) . ' ' . bp_fetch_user_fullname( $user_id, false ) . ' (' . $username . ')
19
+ ';
20
+ }
21
+ }
22
+ ?>
bp-messages/bp-messages-ajax.php ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function messages_ajax_send_reply() {
4
+ global $bp;
5
+
6
+ check_ajax_referer( 'messages_send_message' );
7
+
8
+ $result = messages_send_message($_REQUEST['send_to'], $_REQUEST['subject'], $_REQUEST['content'], $_REQUEST['thread_id'], true, false, true);
9
+
10
+ if ( $result['status'] ) { ?>
11
+ <div class="avatar-box">
12
+ <?php if ( function_exists('bp_core_get_avatar') )
13
+ echo bp_core_get_avatar($result['reply']->sender_id, 1);
14
+ ?>
15
+
16
+ <h3><?php echo bp_core_get_userlink($result['reply']->sender_id) ?></h3>
17
+ <small><?php echo bp_format_time($result['reply']->date_sent) ?></small>
18
+ </div>
19
+ <?php echo stripslashes( apply_filters( 'bp_get_message_content', $result['reply']->message ) ) ?>
20
+ <div class="clear"></div>
21
+ <?php
22
+ } else {
23
+ $result['message'] = '<img src="' . $bp->messages->image_base . '/warning.gif" alt="Warning" /> &nbsp;' . $result['message'];
24
+ echo "-1[[split]]" . $result['message'];
25
+ }
26
+ }
27
+ add_action( 'wp_ajax_messages_send_reply', 'messages_ajax_send_reply' );
28
+
29
+ function messages_ajax_markunread() {
30
+ global $bp;
31
+
32
+ if ( !isset($_POST['thread_ids']) ) {
33
+ echo "-1[[split]]" . __('There was a problem marking messages as unread.', 'buddypress');
34
+ } else {
35
+ $thread_ids = explode( ',', $_POST['thread_ids'] );
36
+
37
+ for ( $i = 0; $i < count($thread_ids); $i++ ) {
38
+ BP_Messages_Thread::mark_as_unread($thread_ids[$i]);
39
+ }
40
+ }
41
+ }
42
+ add_action( 'wp_ajax_messages_markunread', 'messages_ajax_markunread' );
43
+
44
+ function messages_ajax_markread() {
45
+ global $bp;
46
+
47
+ if ( !isset($_POST['thread_ids']) ) {
48
+ echo "-1[[split]]" . __('There was a problem marking messages as read.', 'buddypress');
49
+ } else {
50
+ $thread_ids = explode( ',', $_POST['thread_ids'] );
51
+
52
+ for ( $i = 0; $i < count($thread_ids); $i++ ) {
53
+ BP_Messages_Thread::mark_as_read($thread_ids[$i]);
54
+ }
55
+ }
56
+ }
57
+ add_action( 'wp_ajax_messages_markread', 'messages_ajax_markread' );
58
+
59
+ function messages_ajax_delete() {
60
+ global $bp;
61
+
62
+ if ( !isset($_POST['thread_ids']) ) {
63
+ echo "-1[[split]]" . __( 'There was a problem deleting messages.', 'buddypress' );
64
+ } else {
65
+ $thread_ids = explode( ',', $_POST['thread_ids'] );
66
+
67
+ for ( $i = 0; $i < count($thread_ids); $i++ ) {
68
+ BP_Messages_Thread::delete($thread_ids[$i]);
69
+ }
70
+
71
+ _e('Messages deleted.', 'buddypress');
72
+ }
73
+ }
74
+ add_action( 'wp_ajax_messages_delete', 'messages_ajax_delete' );
75
+
76
+ function messages_ajax_close_notice() {
77
+ global $userdata;
78
+
79
+ if ( !isset($_POST['notice_id']) ) {
80
+ echo "-1[[split]]" . __('There was a problem closing the notice.', 'buddypress');
81
+ } else {
82
+ $notice_ids = get_usermeta( $userdata->ID, 'closed_notices' );
83
+
84
+ $notice_ids[] = (int) $_POST['notice_id'];
85
+
86
+ update_usermeta( $userdata->ID, 'closed_notices', $notice_ids );
87
+ }
88
+ }
89
+ add_action( 'wp_ajax_messages_close_notice', 'messages_ajax_close_notice' );
90
+
91
+ ?>
bp-messages/bp-messages-classes.php ADDED
@@ -0,0 +1,563 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.
47
+ if ( $this->get_all_messages )
48
+ $this->has_access = $this->check_access($id);
49
+ else
50
+ $this->has_access = true;
51
+
52
+ if ( $this->has_access ) {
53
+ $this->thread_id = $thread->id;
54
+ $this->message_ids = maybe_unserialize($thread->message_ids);
55
+
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
+
79
+ // Flip the array back to start from the oldest message
80
+ $this->message_ids = array_reverse( $this->message_ids );
81
+ }
82
+
83
+ $this->last_message_id = $this->message_ids[(count($this->message_ids) - 1)];
84
+ $this->last_sender_id = messages_get_message_sender( $this->last_message_id );
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
115
+ return false;
116
+ }
117
+
118
+ function get_unread() {
119
+ global $wpdb, $bp;
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
+
138
+ $recipients = $wpdb->get_col( $wpdb->prepare( "SELECT user_id FROM {$bp->messages->table_name_recipients} WHERE thread_id = %d", $this->thread_id ) );
139
+
140
+ for ( $i = 0; $i < count($recipients); $i++ ) {
141
+ $recipient = $recipients[$i];
142
+
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 ) );
160
+
161
+ if ( !$recipients ) {
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 ) {
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
+ $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 ORDER BY t.last_post_date DESC$pag_sql", $bp->loggedin_user->id );
189
+
190
+ if ( !$thread_ids = $wpdb->get_results($sql) )
191
+ return false;
192
+
193
+ $threads = false;
194
+
195
+ for ( $i = 0; $i < count($thread_ids); $i++ ) {
196
+ $threads[$i] = new BP_Messages_Thread( $thread_ids[$i]->thread_id, false, $box );
197
+
198
+ if ( !$threads[$i]->message_ids )
199
+ unset($threads[$i]);
200
+ }
201
+
202
+ // reset keys
203
+ return array_reverse( array_reverse( $threads ) );
204
+ }
205
+
206
+ function mark_as_read( $thread_id ) {
207
+ global $wpdb, $bp;
208
+
209
+ $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 );
210
+ $wpdb->query($sql);
211
+ }
212
+
213
+ function mark_as_unread( $thread_id ) {
214
+ global $wpdb, $bp;
215
+
216
+ $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 );
217
+ $wpdb->query($sql);
218
+ }
219
+
220
+ function get_total_threads_for_user( $user_id, $box = 'inbox' ) {
221
+ global $wpdb, $bp;
222
+
223
+ $exclude_sender = '';
224
+ if ( $box != 'sentbox' )
225
+ $exclude_sender = ' AND sender_only != 1';
226
+
227
+ 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", $user_id ) );
228
+ }
229
+
230
+ function user_is_sender($thread_id) {
231
+ global $wpdb, $bp;
232
+
233
+ $sender_ids = $wpdb->get_var( $wpdb->prepare( "SELECT sender_ids FROM {$bp->messages->table_name_threads} WHERE id = %d", $thread_id ) );
234
+
235
+ if ( !$sender_ids )
236
+ return false;
237
+
238
+ $sender_ids = unserialize($sender_ids);
239
+
240
+ return in_array( $bp->loggedin_user->id, $sender_ids );
241
+ }
242
+
243
+ function get_last_sender($thread_id) {
244
+ global $wpdb, $bp;
245
+
246
+ $sql = $wpdb->prepare("SELECT last_sender_id FROM {$bp->messages->table_name_threads} WHERE id = %d", $thread_id);
247
+
248
+ if ( !$sender_id = $wpdb->get_var($sql) )
249
+ return false;
250
+
251
+ return bp_core_get_userlink( $sender_id, true );
252
+ }
253
+
254
+ function get_inbox_count() {
255
+ global $wpdb, $bp;
256
+
257
+ $sql = $wpdb->prepare( "SELECT unread_count FROM {$bp->messages->table_name_recipients} WHERE user_id = %d AND is_deleted = 0", $bp->loggedin_user->id );
258
+
259
+ if ( !$unread_counts = $wpdb->get_results($sql) )
260
+ return false;
261
+
262
+ $count = 0;
263
+ for ( $i = 0; $i < count($unread_counts); $i++ ) {
264
+ $count += $unread_counts[$i]->unread_count;
265
+ }
266
+
267
+ return $count;
268
+ }
269
+
270
+ function check_access($id) {
271
+ global $wpdb, $bp;
272
+
273
+ $sql = $wpdb->prepare("SELECT id FROM {$bp->messages->table_name_recipients} WHERE thread_id = %d AND user_id = %d", $id, $bp->loggedin_user->id );
274
+ $has_access = $wpdb->get_var($sql);
275
+
276
+ if ( $has_access )
277
+ return true;
278
+
279
+ return false;
280
+ }
281
+
282
+ function get_recipient_links($recipients) {
283
+ if ( count($recipients) >= 5 )
284
+ return count($recipients) . __(' Recipients', 'buddypress');
285
+
286
+ for ( $i = 0; $i < count($recipients); $i++ ) {
287
+ $recipient_links[] = bp_core_get_userlink( $recipients[$i] );
288
+ }
289
+
290
+ return implode( ', ', $recipient_links);
291
+ }
292
+ }
293
+
294
+ Class BP_Messages_Message {
295
+ var $id = null;
296
+ var $sender_id;
297
+ var $subject;
298
+ var $message;
299
+ var $date_sent;
300
+ var $message_order;
301
+ var $sender_is_group;
302
+
303
+ var $thread_id;
304
+ var $recipients = false;
305
+
306
+ function bp_messages_message( $id = null ) {
307
+ global $bp;
308
+
309
+ $this->date_sent = time();
310
+ $this->sender_id = $bp->loggedin_user->id;
311
+
312
+ if ( $id ) {
313
+ $this->populate($id);
314
+ }
315
+ }
316
+
317
+ function populate( $id ) {
318
+ global $wpdb, $bp;
319
+
320
+ $sql = $wpdb->prepare("SELECT * FROM {$bp->messages->table_name_messages} WHERE id = %d", $id);
321
+
322
+ if ( $message = $wpdb->get_row($sql) ) {
323
+ $this->id = $message->id;
324
+ $this->sender_id = $message->sender_id;
325
+ $this->subject = $message->subject;
326
+ $this->message = $message->message;
327
+ $this->date_sent = $message->date_sent;
328
+ $this->message_order = $message->message_order;
329
+ $this->sender_is_group = $message->sender_is_group;
330
+ }
331
+
332
+ }
333
+
334
+ function send() {
335
+ global $wpdb, $bp;
336
+
337
+ $this->sender_id = apply_filters( 'messages_message_sender_id_before_save', $this->sender_id, $this->id );
338
+ $this->subject = apply_filters( 'messages_message_subject_before_save', $this->subject, $this->id );
339
+ $this->message = apply_filters( 'messages_message_content_before_save', $this->message, $this->id );
340
+ $this->date_sent = apply_filters( 'messages_message_date_sent_before_save', $this->date_sent, $this->id );
341
+ $this->message_order = apply_filters( 'messages_message_order_before_save', $this->message_order, $this->id );
342
+ $this->sender_is_group = apply_filters( 'messages_message_sender_is_group_before_save', $this->sender_is_group, $this->id );
343
+
344
+ do_action( 'messages_message_before_save', $this );
345
+
346
+ // First insert the message into the messages table
347
+ if ( !$wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->messages->table_name_messages} ( sender_id, subject, message, date_sent, message_order, sender_is_group ) VALUES ( %d, %s, %s, FROM_UNIXTIME(%d), %d, %d )", $this->sender_id, $this->subject, $this->message, $this->date_sent, $this->message_order, $this->sender_is_group ) ) )
348
+ return false;
349
+
350
+ // Next, if thread_id is set, we are adding to an existing thread, if not, start a new one.
351
+ if ( $this->thread_id ) {
352
+ // Select and update the current message ids for the thread.
353
+ $the_ids = $wpdb->get_row( $wpdb->prepare( "SELECT message_ids, sender_ids FROM {$bp->messages->table_name_threads} WHERE id = %d", $this->thread_id ) );
354
+ $message_ids = unserialize($the_ids->message_ids);
355
+ $message_ids[] = $wpdb->insert_id;
356
+ $message_ids = serialize($message_ids);
357
+
358
+ // We need this so we can return the new message ID.
359
+ $message_id = $wpdb->insert_id;
360
+
361
+ // Update the sender ids for the thread
362
+ $sender_ids = unserialize($the_ids->sender_ids);
363
+
364
+ if ( !in_array( $this->sender_id, $sender_ids ) || !$sender_ids )
365
+ $sender_ids[] = $this->sender_id;
366
+
367
+ $sender_ids = serialize($sender_ids);
368
+
369
+ // Update the thread the message belongs to.
370
+ $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 WHERE id = %d", $message_ids, $sender_ids, $wpdb->insert_id, $this->sender_id, $this->thread_id ) );
371
+
372
+ // Find the recipients and update the unread counts for each
373
+ if ( !$this->recipients )
374
+ $this->recipients = $this->get_recipients();
375
+
376
+ for ( $i = 0; $i < count($this->recipients); $i++ ) {
377
+ if ( $this->recipients[$i]->user_id != $bp->loggedin_user->id )
378
+ $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET unread_count = unread_count + 1, sender_only = 0 WHERE thread_id = %d AND user_id = %d", $this->thread_id, $this->recipients[$i] ) );
379
+ }
380
+ } else {
381
+ // Create a new thread.
382
+ $message_id = $wpdb->insert_id;
383
+ $serialized_message_id = serialize( array( (int)$message_id ) );
384
+ $serialized_sender_id = serialize( array( (int)$bp->loggedin_user->id ) );
385
+
386
+ $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 );
387
+
388
+ if ( false === $wpdb->query($sql) )
389
+ return false;
390
+
391
+
392
+ $this->thread_id = $wpdb->insert_id;
393
+
394
+ // Add a new entry for each recipient;
395
+ for ( $i = 0; $i < count($this->recipients); $i++ ) {
396
+ $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 ) );
397
+ }
398
+
399
+ if ( !in_array( $this->sender_id, $this->recipients ) ) {
400
+ // Finally, add a recipient entry for the sender, as replies need to go to this person too.
401
+ $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 ) );
402
+ }
403
+ }
404
+
405
+ $this->id = $message_id;
406
+ messages_remove_callback_values();
407
+
408
+ do_action( 'messages_message_after_save', $this );
409
+
410
+ return true;
411
+ }
412
+
413
+ function get_recipients() {
414
+ global $bp, $wpdb;
415
+
416
+ return $wpdb->get_results( $wpdb->prepare( "SELECT user_id FROM {$bp->messages->table_name_recipients} WHERE thread_id = %d", $this->thread_id ) );
417
+ }
418
+
419
+ // Static Functions
420
+
421
+ function get_recipient_ids( $recipient_usernames ) {
422
+ if ( !$recipient_usernames )
423
+ return false;
424
+
425
+ if ( is_array($recipient_usernames) ) {
426
+ for ( $i = 0; $i < count($recipient_usernames); $i++ ) {
427
+ if ( $rid = bp_core_get_userid( trim($recipient_usernames[$i]) ) )
428
+ $recipient_ids[] = $rid;
429
+ }
430
+ }
431
+
432
+ return $recipient_ids;
433
+ }
434
+
435
+ function get_last_sent_for_user( $thread_id ) {
436
+ global $wpdb, $bp;
437
+
438
+ $message_ids = $wpdb->get_var( $wpdb->prepare( "SELECT message_ids FROM {$bp->messages->table_name_threads} WHERE id = %d", $thread_id ) );
439
+ $message_ids = implode( ',', unserialize($message_ids));
440
+
441
+ $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 );
442
+ return $wpdb->get_var($sql);
443
+ }
444
+
445
+ function is_user_sender( $user_id, $message_id ) {
446
+ global $wpdb, $bp;
447
+ 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 ) );
448
+ }
449
+
450
+ function get_message_sender( $message_id ) {
451
+ global $wpdb, $bp;
452
+ return $wpdb->get_var( $wpdb->prepare( "SELECT sender_id FROM {$bp->messages->table_name_messages} WHERE id = %d", $message_id ) );
453
+ }
454
+ }
455
+
456
+ Class BP_Messages_Notice {
457
+ var $id = null;
458
+ var $subject;
459
+ var $message;
460
+ var $date_sent;
461
+ var $is_active;
462
+
463
+ function bp_messages_notice($id = null) {
464
+ if ( $id ) {
465
+ $this->id = $id;
466
+ $this->populate($id);
467
+ }
468
+ }
469
+
470
+ function populate() {
471
+ global $wpdb, $bp;
472
+
473
+ $notice = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->messages->table_name_notices} WHERE id = %d", $this->id ) );
474
+
475
+ if ( $notice ) {
476
+ $this->subject = $notice->subject;
477
+ $this->message = $notice->message;
478
+ $this->date_sent = $notice->date_sent;
479
+ $this->is_active = $notice->is_active;
480
+ }
481
+ }
482
+
483
+ function save() {
484
+ global $wpdb, $bp;
485
+
486
+ $this->subject = apply_filters( 'messages_notice_subject_before_save', $this->subject, $this->id );
487
+ $this->message = apply_filters( 'messages_notice_message_before_save', $this->message, $this->id );
488
+
489
+ do_action( 'messages_notice_before_save', $this );
490
+
491
+ if ( !$this->id ) {
492
+ $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 );
493
+ } else {
494
+ $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 );
495
+ }
496
+
497
+ if ( !$wpdb->query($sql) )
498
+ return false;
499
+
500
+ if ( !$id = $this->id )
501
+ $id = $wpdb->insert_id;
502
+
503
+ // Now deactivate all notices apart from the new one.
504
+ $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_notices} SET is_active = 0 WHERE id != %d", $id ) );
505
+
506
+ update_usermeta( $bp->loggedin_user->id, 'last_activity', date( 'Y-m-d H:i:s' ) );
507
+
508
+ do_action( 'messages_notice_after_save', $this );
509
+
510
+ return true;
511
+ }
512
+
513
+ function activate() {
514
+ $this->is_active = 1;
515
+ if ( !$this->save() )
516
+ return false;
517
+
518
+ return true;
519
+ }
520
+
521
+ function deactivate() {
522
+ $this->is_active = 0;
523
+ if ( !$this->save() )
524
+ return false;
525
+
526
+ return true;
527
+ }
528
+
529
+ function delete() {
530
+ global $wpdb, $bp;
531
+
532
+ $sql = $wpdb->prepare( "DELETE FROM {$bp->messages->table_name_notices} WHERE id = %d", $this->id );
533
+
534
+ if ( !$wpdb->query($sql) )
535
+ return false;
536
+
537
+ return true;
538
+ }
539
+
540
+ // Static Functions
541
+
542
+ function get_notices() {
543
+ global $wpdb, $bp;
544
+
545
+ $notices = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->messages->table_name_notices} ORDER BY date_sent DESC" ) );
546
+ return $notices;
547
+ }
548
+
549
+ function get_total_notice_count() {
550
+ global $wpdb, $bp;
551
+
552
+ $notice_count = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM " . $bp->messages->table_name_notices ) );
553
+ return $notice_count;
554
+ }
555
+
556
+ function get_active() {
557
+ global $wpdb, $bp;
558
+
559
+ $notice_id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_notices} WHERE is_active = 1") );
560
+ return new BP_Messages_Notice($notice_id);
561
+ }
562
+ }
563
+ ?>
bp-messages/bp-messages-cssjs.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function messages_add_js() {
4
+ global $bp;
5
+
6
+ if ( $bp->current_component == $bp->messages->slug )
7
+ wp_enqueue_script( 'bp-messages-js', BP_PLUGIN_URL . '/bp-messages/js/general.js' );
8
+
9
+ // Include the autocomplete JS for composing a message.
10
+ if ( $bp->current_component == $bp->messages->slug && $bp->current_action == 'compose') {
11
+ wp_enqueue_script( 'bp-jquery-autocomplete', BP_PLUGIN_URL . '/bp-messages/js/autocomplete/jquery.autocomplete.js', 'jquery' );
12
+ wp_enqueue_script( 'bp-jquery-autocomplete-fb', BP_PLUGIN_URL . '/bp-messages/js/autocomplete/jquery.autocompletefb.js', 'jquery' );
13
+ wp_enqueue_script( 'bp-jquery-bgiframe', BP_PLUGIN_URL . '/bp-messages/js/autocomplete/jquery.bgiframe.min.js', 'jquery' );
14
+ wp_enqueue_script( 'bp-jquery-dimensions', BP_PLUGIN_URL . '/bp-messages/js/autocomplete/jquery.dimensions.js', 'jquery' );
15
+ wp_enqueue_script( 'bp-autocomplete-init', BP_PLUGIN_URL . '/bp-messages/js/autocomplete/init.php', 'jquery' );
16
+ }
17
+
18
+ }
19
+ add_action( 'template_redirect', 'messages_add_js', 1 );
20
+
21
+ function messages_add_css() {
22
+ global $bp;
23
+
24
+ if ( $bp->current_component == $bp->messages->slug && $bp->current_action == 'compose') {
25
+ wp_enqueue_style( 'bp-messages-autocomplete', BP_PLUGIN_URL . '/bp-messages/css/autocomplete/jquery.autocompletefb.css' );
26
+ wp_print_styles();
27
+ }
28
+ }
29
+ add_action( 'wp_head', 'messages_add_css' );
30
+
31
+
32
+ function messages_add_structure_css() {
33
+ /* Enqueue the structure CSS file to give basic positional formatting for components */
34
+ wp_enqueue_style( 'bp-messages-structure', BP_PLUGIN_URL . '/bp-messages/css/structure.css' );
35
+ }
36
+ add_action( 'bp_styles', 'messages_add_structure_css' );
37
+
38
+
39
+ ?>
bp-messages/bp-messages-filters.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /* Apply WordPress defined filters */
4
+ add_filter( 'bp_get_message_notice_subject', 'wp_filter_kses', 1 );
5
+ add_filter( 'bp_get_message_notice_text', 'wp_filter_kses', 1 );
6
+ add_filter( 'bp_get_message_thread_subject', 'wp_filter_kses', 1 );
7
+ add_filter( 'bp_get_message_thread_excerpt', 'wp_filter_kses', 1 );
8
+ add_filter( 'bp_get_messages_subject_value', 'wp_filter_kses', 1 );
9
+ add_filter( 'bp_get_messages_content_value', 'wp_filter_kses', 1 );
10
+ add_filter( 'bp_get_message_content', 'wp_filter_kses', 1 );
11
+ add_filter( 'messages_message_content_before_save', 'wp_filter_kses', 1 );
12
+ add_filter( 'messages_message_subject_before_save', 'wp_filter_kses', 1 );
13
+ add_filter( 'messages_notice_message_before_save', 'wp_filter_kses', 1 );
14
+ add_filter( 'messages_notice_subject_before_save', 'wp_filter_kses', 1 );
15
+
16
+ add_filter( 'bp_get_message_notice_subject', 'wptexturize' );
17
+ add_filter( 'bp_get_message_notice_text', 'wptexturize' );
18
+ add_filter( 'bp_get_message_thread_subject', 'wptexturize' );
19
+ add_filter( 'bp_get_message_thread_excerpt', 'wptexturize' );
20
+ add_filter( 'bp_get_message_content', 'wptexturize' );
21
+
22
+ add_filter( 'bp_get_message_notice_subject', 'convert_smilies', 2 );
23
+ add_filter( 'bp_get_message_notice_text', 'convert_smilies', 2 );
24
+ add_filter( 'bp_get_message_thread_subject', 'convert_smilies', 2 );
25
+ add_filter( 'bp_get_message_thread_excerpt', 'convert_smilies', 2 );
26
+ add_filter( 'bp_get_message_content', 'convert_smilies', 2 );
27
+
28
+ add_filter( 'bp_get_message_notice_subject', 'convert_chars' );
29
+ add_filter( 'bp_get_message_notice_text', 'convert_chars' );
30
+ add_filter( 'bp_get_message_thread_subject', 'convert_chars' );
31
+ add_filter( 'bp_get_message_thread_excerpt', 'convert_chars' );
32
+ add_filter( 'bp_get_message_content', 'convert_chars' );
33
+
34
+ add_filter( 'bp_get_message_notice_subject', 'wpautop' );
35
+ add_filter( 'bp_get_message_notice_text', 'wpautop' );
36
+ add_filter( 'bp_get_message_thread_subject', 'wpautop' );
37
+ add_filter( 'bp_get_message_thread_excerpt', 'wpautop' );
38
+ add_filter( 'bp_get_message_content', 'wpautop' );
39
+
40
+ add_filter( 'bp_get_message_notice_subject', 'stripslashes_deep' );
41
+ add_filter( 'bp_get_message_notice_text', 'stripslashes_deep' );
42
+ add_filter( 'bp_get_message_thread_subject', 'stripslashes_deep' );
43
+ add_filter( 'bp_get_message_thread_excerpt', 'stripslashes_deep' );
44
+ add_filter( 'bp_get_messages_subject_value', 'stripslashes_deep' );
45
+ add_filter( 'bp_get_messages_content_value', 'stripslashes_deep' );
46
+ add_filter( 'bp_get_message_content', 'stripslashes_deep' );
47
+
48
+ ?>
bp-messages/bp-messages-notifications.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
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_fetch_user_fullname( $message->sender_id, false );
10
+
11
+ for ( $i = 0; $i < count($recipient_ids); $i++ ) {
12
+ if ( $message->sender_id == $recipient_ids[$i] || 'no' == get_userdata( $recipient_ids[$i], 'notification-messages-new-message' ) ) continue;
13
+
14
+ $ud = get_userdata($recipient_ids[$i]);
15
+ $message_link = site_url() . '/' . BP_MEMBERS_SLUG . '/' . $ud->user_login . '/messages/view/' . $message->id;
16
+ $settings_link = site_url() . '/' . BP_MEMBERS_SLUG . '/' . $ud->user_login . '/settings/notifications';
17
+
18
+ // Set up and send the message
19
+ $to = $ud->user_email;
20
+ $subject = '[' . get_blog_option( 1, 'blogname' ) . '] ' . sprintf( __( 'New message from %s', 'buddypress' ), stripslashes($sender_name) );
21
+
22
+ $message = sprintf( __(
23
+ '%s sent you a new message:
24
+
25
+ Subject: %s
26
+
27
+ "%s"
28
+
29
+ To view the message: %s
30
+
31
+ ---------------------
32
+ ', 'buddypress' ), $sender_name, stripslashes( wp_filter_kses( $message->subject ) ), stripslashes( wp_filter_kses( $message->message ) ), $message_link );
33
+
34
+ $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
35
+
36
+ // Send it
37
+ wp_mail( $to, $subject, $message );
38
+ }
39
+ }
40
+
41
+
42
+ /* This is too expensive to send on normal servers uncomment at your own risk. */
43
+
44
+ // function messages_notification_new_notice( $message_subject, $message ) {
45
+ // global $bp, $wpdb;
46
+ //
47
+ // $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" ) );
48
+ //
49
+ // for ( $i = 0; $i < count($users); $i++ ) {
50
+ // if ( get_userdata( $users[$i]->user_id, 'notification-messages-new-notice' ) == 'no' ) continue;
51
+ //
52
+ // $message_link = site_url() . '/' . BP_MEMBERS_SLUG . '/' . $users[$i]->user_login . '/messages';
53
+ // $settings_link = site_url() . '/' . BP_MEMBERS_SLUG . '/' . $users[$i]->user_login . '/settings/notifications';
54
+ //
55
+ // // Set up and send the message
56
+ // $to = $users[$i]->user_email;
57
+ // $subject = __( 'New Site Notice', 'buddypress' );
58
+ //
59
+ // $message = sprintf( __(
60
+ // 'A new site notice has been posted on %s:
61
+ //
62
+ // "%s: %s"
63
+ //
64
+ // To view the notice: %s
65
+ //
66
+ // ---------------------
67
+ // ', 'buddypress' ), get_blog_option( 1, 'blogname' ), stripslashes( strip_tags( $message_subject ) ), stripslashes( strip_tags( $message ) ), $message_link );
68
+ //
69
+ // $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
70
+ //
71
+ // // Send it
72
+ // wp_mail( $to, $subject, $message );
73
+ //
74
+ // unset($message);
75
+ // unset($subject);
76
+ // unset($to);
77
+ // }
78
+ // }
79
+ // add_action( 'bp_messages_notice_sent', 'messages_notification_new_notice', 10, 2 );
80
+
81
+ ?>
bp-messages/bp-messages-templatetags.php ADDED
@@ -0,0 +1,562 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ Class BP_Messages_Template {
4
+ var $current_thread = -1;
5
+ var $current_thread_count;
6
+ var $total_thread_count;
7
+ var $threads;
8
+ var $thread;
9
+
10
+ var $in_the_loop;
11
+ var $user_id;
12
+ var $box;
13
+
14
+ var $pag_page;
15
+ var $pag_num;
16
+ var $pag_links;
17
+
18
+ function bp_messages_template( $user_id, $box, $per_page, $max ) {
19
+ $this->pag_page = isset( $_GET['mpage'] ) ? intval( $_GET['mpage'] ) : 1;
20
+ $this->pag_num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : $per_page;
21
+ $this->user_id = $user_id;
22
+ $this->box = $box;
23
+
24
+ if ( 'notices' == $this->box )
25
+ $this->threads = BP_Messages_Notice::get_notices();
26
+ else
27
+ $this->threads = BP_Messages_Thread::get_current_threads_for_user( $this->user_id, $this->box, $this->pag_num, $this->pag_page );
28
+
29
+ if ( !$this->threads ) {
30
+ $this->thread_count = 0;
31
+ $this->total_thread_count = 0;
32
+ } else {
33
+ if ( !$max ) {
34
+ if ( 'notices' == $this->box )
35
+ $this->total_thread_count = BP_Messages_Notice::get_total_notice_count();
36
+ else
37
+ $this->total_thread_count = BP_Messages_Thread::get_total_threads_for_user( $this->user_id, $this->box );
38
+ } else {
39
+ $this->total_thread_count = (int)$max;
40
+ }
41
+
42
+ if ( $max ) {
43
+ if ( $max >= count($this->threads) )
44
+ $this->thread_count = count($this->threads);
45
+ else
46
+ $this->thread_count = (int)$max;
47
+ } else {
48
+ $this->thread_count = count($this->threads);
49
+ }
50
+ }
51
+
52
+ $this->pag_links = paginate_links( array(
53
+ 'base' => add_query_arg( 'mpage', '%#%' ),
54
+ 'format' => '',
55
+ 'total' => ceil($this->total_thread_count / $this->pag_num),
56
+ 'current' => $this->pag_page,
57
+ 'prev_text' => '&laquo;',
58
+ 'next_text' => '&raquo;',
59
+ 'mid_size' => 1
60
+ ));
61
+ }
62
+
63
+ function has_threads() {
64
+ if ( $this->thread_count )
65
+ return true;
66
+
67
+ return false;
68
+ }
69
+
70
+ function next_thread() {
71
+ $this->current_thread++;
72
+ $this->thread = $this->threads[$this->current_thread];
73
+
74
+ return $this->thread;
75
+ }
76
+
77
+ function rewind_threads() {
78
+ $this->current_thread = -1;
79
+ if ( $this->thread_count > 0 ) {
80
+ $this->thread = $this->threads[0];
81
+ }
82
+ }
83
+
84
+ function message_threads() {
85
+ if ( $this->current_thread + 1 < $this->thread_count ) {
86
+ return true;
87
+ } elseif ( $this->current_thread + 1 == $this->thread_count ) {
88
+ do_action('loop_end');
89
+ // Do some cleaning up after the loop
90
+ $this->rewind_threads();
91
+ }
92
+
93
+ $this->in_the_loop = false;
94
+ return false;
95
+ }
96
+
97
+ function the_message_thread() {
98
+ global $thread;
99
+
100
+ $this->in_the_loop = true;
101
+ $thread = $this->next_thread();
102
+
103
+ if ( 0 == $this->current_thread ) // loop has just started
104
+ do_action('loop_start');
105
+ }
106
+ }
107
+
108
+ function bp_has_message_threads( $args = '' ) {
109
+ global $bp, $messages_template;
110
+
111
+ $defaults = array(
112
+ 'user_id' => $bp->loggedin_user->id,
113
+ 'box' => 'inbox',
114
+ 'per_page' => 10,
115
+ 'max' => false
116
+ );
117
+
118
+ $r = wp_parse_args( $args, $defaults );
119
+ extract( $r, EXTR_SKIP );
120
+
121
+ if ( 'notices' == $bp->current_action && !is_site_admin() ) {
122
+ wp_redirect( $bp->displayed_user->id );
123
+ } else {
124
+ if ( 'inbox' == $bp->current_action )
125
+ bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, 'messages', 'new_message' );
126
+
127
+ if ( 'sentbox' == $bp->current_action )
128
+ $box = 'sentbox';
129
+
130
+ if ( 'notices' == $bp->current_action )
131
+ $box = 'notices';
132
+
133
+ $messages_template = new BP_Messages_Template( $user_id, $box, $per_page, $max );
134
+ }
135
+
136
+ return $messages_template->has_threads();
137
+ }
138
+
139
+ function bp_message_threads() {
140
+ global $messages_template;
141
+ return $messages_template->message_threads();
142
+ }
143
+
144
+ function bp_message_thread() {
145
+ global $messages_template;
146
+ return $messages_template->the_message_thread();
147
+ }
148
+
149
+ function bp_message_thread_id() {
150
+ echo bp_get_message_thread_id();
151
+ }
152
+ function bp_get_message_thread_id() {
153
+ global $messages_template;
154
+ return apply_filters( 'bp_get_message_thread_id', $messages_template->thread->thread_id );
155
+ }
156
+
157
+ function bp_message_thread_subject() {
158
+ echo bp_get_message_thread_subject();
159
+ }
160
+ function bp_get_message_thread_subject() {
161
+ global $messages_template;
162
+ return apply_filters( 'bp_message_thread_subject', stripslashes_deep( $messages_template->thread->last_message_subject ) );
163
+ }
164
+
165
+ function bp_message_thread_excerpt() {
166
+ echo bp_get_message_thread_excerpt();
167
+ }
168
+ function bp_get_message_thread_excerpt() {
169
+ global $messages_template;
170
+ return apply_filters( 'bp_get_message_thread_excerpt', bp_create_excerpt($messages_template->thread->last_message_message, 20) );
171
+ }
172
+
173
+ function bp_message_thread_from() {
174
+ echo bp_get_message_thread_from();
175
+ }
176
+ function bp_get_message_thread_from() {
177
+ global $messages_template;
178
+ return apply_filters( 'bp_get_message_thread_from', bp_core_get_userlink($messages_template->thread->last_sender_id) );
179
+ }
180
+
181
+ function bp_message_thread_to() {
182
+ echo bp_get_message_thread_to();
183
+ }
184
+ function bp_get_message_thread_to() {
185
+ global $messages_template;
186
+ return apply_filters( 'bp_message_thread_to', BP_Messages_Thread::get_recipient_links($messages_template->thread->recipients) );
187
+ }
188
+
189
+ function bp_message_thread_view_link() {
190
+ echo bp_get_message_thread_view_link();
191
+ }
192
+ function bp_get_message_thread_view_link() {
193
+ global $messages_template, $bp;
194
+ return apply_filters( 'bp_get_message_thread_view_link', $bp->loggedin_user->domain . $bp->messages->slug . '/view/' . $messages_template->thread->thread_id );
195
+ }
196
+
197
+ function bp_message_thread_delete_link() {
198
+ echo bp_get_message_thread_delete_link();
199
+ }
200
+ function bp_get_message_thread_delete_link() {
201
+ global $messages_template, $bp;
202
+ 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' ) );
203
+ }
204
+
205
+ function bp_message_thread_has_unread() {
206
+ global $messages_template;
207
+
208
+ if ( $messages_template->thread->unread_count )
209
+ return true;
210
+
211
+ return false;
212
+ }
213
+
214
+ function bp_message_thread_unread_count() {
215
+ echo bp_get_message_thread_unread_count();
216
+ }
217
+ function bp_get_message_thread_unread_count() {
218
+ global $messages_template;
219
+
220
+ if ( (int)$messages_template->thread->unread_count )
221
+ return apply_filters( 'bp_get_message_thread_unread_count', $messages_template->thread->unread_count );
222
+
223
+ return false;
224
+ }
225
+
226
+ function bp_message_thread_last_post_date() {
227
+ echo bp_get_message_thread_last_post_date();
228
+ }
229
+ function bp_get_message_thread_last_post_date() {
230
+ global $messages_template;
231
+ echo apply_filters( 'bp_get_message_thread_last_post_date', bp_format_time( strtotime($messages_template->thread->last_post_date) ) );
232
+ }
233
+
234
+ function bp_message_thread_avatar() {
235
+ echo bp_get_message_thread_avatar();
236
+ }
237
+ function bp_get_message_thread_avatar() {
238
+ global $messages_template;
239
+ echo apply_filters( 'bp_get_message_thread_avatar', bp_core_get_avatar($messages_template->thread->last_sender_id, 1) );
240
+ }
241
+
242
+ function bp_message_thread_view() {
243
+ global $thread_id;
244
+
245
+ messages_view_thread($thread_id);
246
+ }
247
+
248
+ function bp_total_unread_messages_count() {
249
+ echo bp_get_total_unread_messages_count();
250
+ }
251
+ function bp_get_total_unread_messages_count() {
252
+ return apply_filters( 'bp_get_total_unread_messages_count', BP_Messages_Thread::get_inbox_count() );
253
+ }
254
+
255
+ function bp_messages_pagination() {
256
+ echo bp_get_messages_pagination();
257
+ }
258
+ function bp_get_messages_pagination() {
259
+ global $messages_template;
260
+ return apply_filters( 'bp_get_messages_pagination', $messages_template->pag_links );
261
+ }
262
+
263
+ function bp_messages_pagination_count() {
264
+ global $messages_template;
265
+
266
+ $from_num = intval( ( $messages_template->pag_page - 1 ) * $messages_template->pag_num ) + 1;
267
+ $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) ;
268
+
269
+ echo sprintf( __( 'Viewing message %d to %d (of %d messages)', 'buddypress' ), $from_num, $to_num, $messages_template->total_thread_count ); ?> &nbsp;
270
+ <img id="ajax-loader-messages" src="<?php echo $bp->core->image_base ?>/ajax-loader.gif" height="7" alt="<?php _e( "Loading", "buddypress" ) ?>" style="display: none;" /><?php
271
+ }
272
+
273
+ function bp_messages_form_action() {
274
+ echo bp_get_messages_form_action();
275
+ }
276
+ function bp_get_messages_form_action() {
277
+ global $bp;
278
+
279
+ return apply_filters( 'bp_get_messages_form_action', $bp->loggedin_user->domain . $bp->messages->slug . '/' . $bp->current_action );
280
+ }
281
+
282
+ function bp_messages_username_value() {
283
+ echo bp_get_messages_username_value();
284
+ }
285
+ function bp_get_messages_username_value() {
286
+ if ( isset( $_SESSION['send_to'] ) ) {
287
+ return apply_filters( 'bp_get_messages_username_value', $_SESSION['send_to'] );
288
+ } else if ( isset( $_GET['r'] ) && !isset( $_SESSION['send_to'] ) ) {
289
+ return apply_filters( 'bp_get_messages_username_value', $_GET['r'] );
290
+ }
291
+ }
292
+
293
+ function bp_messages_subject_value() {
294
+ echo bp_get_messages_subject_value();
295
+ }
296
+ function bp_get_messages_subject_value() {
297
+ return apply_filters( 'bp_get_messages_subject_value', $_SESSION['subject'] );
298
+ }
299
+
300
+ function bp_messages_content_value() {
301
+ echo bp_get_messages_content_value();
302
+ }
303
+ function bp_get_messages_content_value() {
304
+ return apply_filters( 'bp_get_messages_content_value', $_SESSION['content'] );
305
+ }
306
+
307
+ function bp_messages_options() {
308
+ global $bp;
309
+
310
+ if ( $bp->current_action != 'sentbox' ) {
311
+ ?>
312
+ <?php _e( 'Select:', 'buddypress' ) ?>
313
+ <select name="message-type-select" id="message-type-select">
314
+ <option value=""></option>
315
+ <option value="read"><?php _e('Read', 'buddypress') ?></option>
316
+ <option value="unread"><?php _e('Unread', 'buddypress') ?></option>
317
+ <option value="all"><?php _e('All', 'buddypress') ?></option>
318
+ </select> &nbsp;
319
+ <a href="#" id="mark_as_read"><?php _e('Mark as Read', 'buddypress') ?></a> &nbsp;
320
+ <a href="#" id="mark_as_unread"><?php _e('Mark as Unread', 'buddypress') ?></a> &nbsp;
321
+ <?php } ?>
322
+ <a href="#" id="delete_<?php echo $bp->current_action ?>_messages"><?php _e('Delete Selected', 'buddypress') ?></a> &nbsp;
323
+ <?php
324
+ }
325
+
326
+ function bp_message_is_active_notice() {
327
+ global $messages_template;
328
+
329
+ if ( $messages_template->thread->is_active ) {
330
+ echo "<strong>";
331
+ _e( 'Currently Active', 'buddypress' );
332
+ echo "</strong>";
333
+ }
334
+ }
335
+ function bp_get_message_is_active_notice() {
336
+ global $messages_template;
337
+
338
+ if ( $messages_template->thread->is_active )
339
+ return true;
340
+
341
+ return false;
342
+ }
343
+
344
+ function bp_message_notice_post_date() {
345
+ echo bp_get_message_notice_post_date();
346
+ }
347
+ function bp_get_message_notice_post_date() {
348
+ global $messages_template;
349
+ return apply_filters( 'bp_get_message_notice_post_date', bp_format_time( strtotime($messages_template->thread->date_sent) ) );
350
+ }
351
+
352
+ function bp_message_notice_subject() {
353
+ echo bp_get_message_notice_subject();
354
+ }
355
+ function bp_get_message_notice_subject() {
356
+ global $messages_template;
357
+ return apply_filters( 'bp_get_message_notice_subject', $messages_template->thread->subject );
358
+ }
359
+
360
+ function bp_message_notice_text() {
361
+ echo bp_get_message_notice_text();
362
+ }
363
+ function bp_get_message_notice_text() {
364
+ global $messages_template;
365
+ return apply_filters( 'bp_get_message_notice_text', $messages_template->thread->message );
366
+ }
367
+
368
+ function bp_message_notice_delete_link() {
369
+ echo bp_get_message_notice_delete_link();
370
+ }
371
+ function bp_get_message_notice_delete_link() {
372
+ global $messages_template, $bp;
373
+
374
+ return apply_filters( 'bp_get_message_notice_delete_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->messages->slug . '/notices/delete/' . $messages_template->thread->id, 'messages_delete_thread' ) );
375
+ }
376
+
377
+ function bp_message_activate_deactivate_link() {
378
+ echo bp_get_message_activate_deactivate_link();
379
+ }
380
+ function bp_get_message_activate_deactivate_link() {
381
+ global $messages_template, $bp;
382
+
383
+ if ( 1 == (int)$messages_template->thread->is_active ) {
384
+ $link = wp_nonce_url( $bp->loggedin_user->domain . $bp->messages->slug . '/notices/deactivate/' . $messages_template->thread->id, 'messages_deactivate_notice' );
385
+ } else {
386
+ $link = wp_nonce_url( $bp->loggedin_user->domain . $bp->messages->slug . '/notices/activate/' . $messages_template->thread->id, 'messages_activate_notice' );
387
+ }
388
+ return apply_filters( 'bp_get_message_activate_deactivate_link', $link );
389
+ }
390
+
391
+ function bp_message_activate_deactivate_text() {
392
+ echo bp_get_message_activate_deactivate_text();
393
+ }
394
+ function bp_get_message_activate_deactivate_text() {
395
+ global $messages_template;
396
+
397
+ if ( 1 == (int)$messages_template->thread->is_active ) {
398
+ $text = __('Deactivate', 'buddypress');
399
+ } else {
400
+ $text = __('Activate', 'buddypress');
401
+ }
402
+ return apply_filters( 'bp_message_activate_deactivate_text', $text );
403
+ }
404
+
405
+ function bp_message_get_notices() {
406
+ global $userdata;
407
+
408
+ $notice = BP_Messages_Notice::get_active();
409
+ $closed_notices = get_usermeta( $userdata->ID, 'closed_notices');
410
+
411
+ if ( !$closed_notices )
412
+ $closed_notices = array();
413
+
414
+ if ( is_array($closed_notices) ) {
415
+ if ( !in_array( $notice->id, $closed_notices ) && $notice->id ) {
416
+ ?>
417
+ <div class="notice" id="<?php echo $notice->id ?>">
418
+ <h5><?php echo stripslashes($notice->subject) ?></h5>
419
+ <?php echo stripslashes($notice->message) ?>
420
+ <a href="#" id="close-notice"><?php _e( 'Close', 'buddypress' ) ?></a>
421
+ </div>
422
+ <?php
423
+ }
424
+ }
425
+ }
426
+
427
+ function bp_send_message_button() {
428
+ global $bp;
429
+
430
+ if ( bp_is_home() || !is_user_logged_in() )
431
+ return false;
432
+
433
+ $ud = get_userdata( $bp->displayed_user->id );
434
+ ?>
435
+ <div class="generic-button">
436
+ <a class="send-message" title="<?php _e( 'Send Message', 'buddypress' ) ?>" href="<?php echo $bp->loggedin_user->domain . $bp->messages->slug ?>/compose/?r=<?php echo $ud->user_login ?>"><?php _e( 'Send Message', 'buddypress' ) ?></a>
437
+ </div>
438
+ <?php
439
+ }
440
+
441
+ function bp_message_loading_image_src() {
442
+ echo bp_get_message_loading_image_src();
443
+ }
444
+ function bp_get_message_loading_image_src() {
445
+ global $bp;
446
+ return apply_filters( 'bp_get_message_loading_image_src', $bp->messages->image_base . '/ajax-loader.gif' );
447
+ }
448
+
449
+ function bp_message_get_recipient_tabs() {
450
+ global $bp;
451
+
452
+ if ( isset( $_GET['r'] ) ) {
453
+ $user_id = bp_core_get_userid_from_user_login( $_GET['r'] );
454
+
455
+ if ( $user_id ) {
456
+ ?>
457
+ <li id="un-<?php echo $_GET['r'] ?>" class="friend-tab">
458
+ <span>
459
+ <?php echo bp_core_get_avatar( $user_id, 1, 15, 15 ) ?>
460
+ <?php echo bp_core_get_userlink( $user_id ) ?>
461
+ </span>
462
+ <span class="p">X</span>
463
+ </li>
464
+ <?php
465
+ }
466
+ }
467
+ }
468
+
469
+ function bp_message_get_recipient_usernames() {
470
+ echo bp_get_message_get_recipient_usernames();
471
+ }
472
+ function bp_get_message_get_recipient_usernames() {
473
+ return apply_filters( 'bp_get_message_get_recipient_usernames', $_GET['r'] );
474
+ }
475
+
476
+ function messages_view_thread( $thread_id ) {
477
+ global $bp;
478
+
479
+ $thread = new BP_Messages_Thread( $thread_id, true );
480
+
481
+ if ( !$thread->has_access ) {
482
+ unset($_GET['mode']); ?>
483
+ <div id="message" class="error">
484
+ <p><?php _e( 'There was an error when viewing that message', 'buddypress' ) ?></p>
485
+ </div>
486
+ <?php
487
+ } else {
488
+ if ( $thread->messages ) { ?>
489
+ <?php $thread->mark_read() ?>
490
+
491
+ <div class="wrap">
492
+ <h2 id="message-subject"><?php echo $thread->subject; ?></h2>
493
+ <table class="form-table">
494
+ <tbody>
495
+ <tr>
496
+ <td>
497
+ <img src="<?php echo $bp->messages->image_base ?>/email_open.gif" alt="Message" style="vertical-align: top;" /> &nbsp;
498
+ <?php _e('Sent between ', 'buddypress') ?> <?php echo BP_Messages_Thread::get_recipient_links($thread->recipients) ?>
499
+ <?php _e('and', 'buddypress') ?> <?php echo bp_core_get_userlink($bp->loggedin_user->id) ?>.
500
+ </td>
501
+ </tr>
502
+ </tbody>
503
+ </table>
504
+
505
+ <?php
506
+ $counter = 0;
507
+
508
+ foreach ( $thread->messages as $message ) {
509
+ $alt = ( $counter % 2 == 1 ) ? ' alt' : '';
510
+ ?>
511
+ <a name="<?php echo 'm-' . $message->id ?>"></a>
512
+ <div class="message-box<?php echo $alt ?>">
513
+ <div class="avatar-box">
514
+ <?php echo apply_filters( 'bp_get_message_sender_avatar', bp_core_get_avatar( $message->sender_id, 1 ) ) ?>
515
+ <h3><?php echo apply_filters( 'bp_get_message_sender_id', bp_core_get_userlink( $message->sender_id ) ) ?></h3>
516
+ <small><?php echo apply_filters( 'bp_get_message_date_sent', bp_format_time( strtotime($message->date_sent ) ) ) ?></small>
517
+ </div>
518
+
519
+ <?php do_action( 'messages_custom_fields_output_before' ) ?>
520
+
521
+ <?php echo apply_filters( 'bp_get_message_content', stripslashes($message->message) ); ?>
522
+
523
+ <?php do_action( 'messages_custom_fields_output_after' ) ?>
524
+
525
+ <div class="clear"></div>
526
+ </div>
527
+ <?php
528
+ $counter++;
529
+ }
530
+
531
+ ?>
532
+ <form id="send-reply" action="<?php bp_messages_form_action() ?>" method="post">
533
+ <div class="message-box">
534
+ <div id="messagediv">
535
+ <div class="avatar-box">
536
+ <?php if ( function_exists('bp_core_get_avatar') )
537
+ echo bp_core_get_avatar($bp->loggedin_user->id, 1);
538
+ ?>
539
+
540
+ <h3><?php _e("Reply: ", 'buddypress') ?></h3>
541
+ </div>
542
+ <label for="reply"></label>
543
+ <div>
544
+ <textarea name="content" id="message_content" rows="15" cols="40"><?php echo attribute_escape( wp_filter_kses( $content ) ); ?></textarea>
545
+ </div>
546
+ </div>
547
+ <p class="submit">
548
+ <input type="submit" name="send" value="<?php _e( 'Send Reply', 'buddypress' ) ?> &rarr;" id="send_reply_button"/>
549
+ </p>
550
+ <input type="hidden" id="thread_id" name="thread_id" value="<?php echo $thread->thread_id ?>" />
551
+ <input type="hidden" name="subject" id="subject" value="<?php _e('Re: ', 'buddypress'); echo str_replace( 'Re: ', '', $thread->last_message_subject); ?>" />
552
+ </div>
553
+
554
+ <?php wp_nonce_field( 'messages_send_message', '_wpnonce_send_message' ) ?>
555
+ </form>
556
+ </div>
557
+ <?php
558
+ }
559
+ }
560
+ }
561
+
562
+ ?>
bp-messages/css/autocomplete/jquery.autocompletefb.css ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .ac_results {
2
+ padding: 0px;
3
+ overflow: hidden;
4
+ z-index: 99999;
5
+ background: #fff;
6
+ border: 1px solid #ccc;
7
+ -moz-border-radius-bottomleft: 3px;
8
+ -khtml-border-bottom-left-radius: 3px;
9
+ -webkit-border-bottom-left-radius: 3px;
10
+ border-bottom-left-radius: 3px;
11
+ -moz-border-radius-bottomright: 3px;
12
+ -khtml-border-bottom-right-radius: 3px;
13
+ -webkit-border-bottom-right-radius: 3px;
14
+ border-bottom-right-radius: 3px;
15
+ }
16
+ .ac_results ul {
17
+ width: 100%;
18
+ list-style-position: outside;
19
+ list-style: none;
20
+ padding: 0;
21
+ margin: 0;
22
+ }
23
+
24
+ .ac_results li {
25
+ margin: 0px;
26
+ padding: 5px 10px;
27
+ cursor: pointer;
28
+ display: block;
29
+ font-size: 1em;
30
+ line-height: 16px;
31
+ overflow: hidden;
32
+ }
33
+ .ac_results li img {
34
+ padding-right: 5px;
35
+ }
36
+
37
+ .ac_loading {
38
+ background : url('../../images/ajax-loader.gif') right center no-repeat;
39
+ }
40
+
41
+ .ac_odd {
42
+ background-color: #f0f0f0;
43
+ }
44
+
45
+ .ac_over {
46
+ background-color: #888;
47
+ color: #fff;
48
+ }
49
+
50
+ ul.acfb-holder {
51
+ margin : 0;
52
+ height : auto !important;
53
+ height : 1%;
54
+ overflow: hidden;
55
+ }
56
+ ul.acfb-holder li {
57
+ float : left;
58
+ margin : 0 5px 4px 0;
59
+ list-style-type: none;
60
+ }
61
+
62
+ ul.acfb-holder li.friend-tab {
63
+ border-radius : 3px;
64
+ -moz-border-radius : 3px;
65
+ -webkit-border-radius : 3px;
66
+ border : 1px solid #ffe7c7;
67
+ padding : 2px 7px 2px;
68
+ background : #FFF9DF;
69
+ font-size: 1em;
70
+ }
71
+ li.friend-tab img.avatar {
72
+ border-width: 2px !important;
73
+ vertical-align: middle;
74
+ }
75
+
76
+ li.friend-tab span.p {
77
+ padding-left: 5px;
78
+ font-size: 0.8em;
79
+ cursor: pointer;
80
+ }
81
+
82
+ input#send-to-input { width: 275px !important; }
83
+
bp-messages/css/structure.css ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ table#message-threads {
2
+ width: 100%;
3
+ }
4
+ table#message-threads tr td, .message-box {
5
+ padding: 1em;
6
+ }
7
+ table#message-threads tr td p {
8
+ margin: 0;
9
+ }
10
+
11
+ .avatar-box {
12
+ float: left;
13
+ border: none !important;
14
+ }
15
+
16
+ .message-box {
17
+ padding: 15px 10px;
18
+ padding-left: 135px;
19
+ min-height: 140px;
20
+ }
21
+ .message-box .avatar-box {
22
+ float: left;
23
+ width: 110px;
24
+ margin: 0 0 0 -125px;
25
+ }
26
+ #main #content .avatar-box h3 {
27
+ margin: 1em 0 0 0;
28
+ }
29
+
30
+ .avatar-box small {
31
+ line-height: 1.5;
32
+ }
33
+
34
+ #message_content_tbl { border: 1px solid #ddd; }
35
+ .mceToolbar, .mceStatusbar { background: #eee; }
36
+
37
+ #send_reply_button { margin: 1.5em 0 0 0;}
38
+
39
+ div.ajax_reply, div.error-box {
40
+ text-align: center;
41
+ padding: 15px;
42
+ }
43
+ div.div.ajax_reply img, div.error-box img { vertical-align: middle; }
44
+
45
+ #send_message_form {
46
+ margin-top: -1em;
47
+ }
48
+
49
+ #main #content #send_message_form h3 {
50
+ margin: 0;
51
+ }
52
+
53
+ #send_message_form input {
54
+ width: 45%;
55
+ padding: 0.2em;
56
+ margin: 0 0 0.5em 0;
57
+ }
58
+
59
+ #send_message_form textarea {
60
+ width: 100%;
61
+ padding: 0.2em;
62
+ }
63
+
64
+ #send_message_form input#send {
65
+ width: auto;
66
+ font: normal 1em inherit;
67
+ margin-top: 1.5em;
68
+ }
69
+
70
+ span.unread-count {
71
+ padding: 0 0.5em;
72
+ }
73
+ .read .unread-count { display: none; }
74
+
75
+ .messages-options {
76
+ float: right;
77
+ padding: 0 3em 0 0;
78
+ margin-top: -2px;
79
+ }
80
+ .messages-options select { width: auto; }
81
+
82
+ .notices td { vertical-align: top; }
83
+ .notice {
84
+ position: relative;
85
+ padding: 1.2em;
86
+ }
87
+
88
+ .notice a#close-notice {
89
+ position: absolute;
90
+ top: 1em;
91
+ right: 1.2em;
92
+ }
93
+
94
+ .notice h5 {
95
+ margin: 0 0 0.8em 0;
96
+ }
bp-messages/images/ajax-loader.gif ADDED
Binary file
bp-messages/images/email.gif ADDED
Binary file
bp-messages/images/email_draft.gif ADDED
Binary file
bp-messages/images/email_open.gif ADDED
Binary file
bp-messages/images/email_sent.gif ADDED
Binary file
bp-messages/images/loading.gif ADDED
Binary file
bp-messages/images/nav_bullet.gif ADDED
Binary file
bp-messages/images/warning.gif ADDED
Binary file
bp-messages/js/autocomplete/init.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* Load the WP environment */
3
+ require_once( preg_replace('%(.*)[/\\\\]wp-content[/\\\\].*%', '\1', dirname( __FILE__ ) ) . '/wp-load.php' );
4
+ header( 'Content: text/javascript' );
5
+ ?>
6
+
7
+ jQuery(document).ready(function() {
8
+ var acfb =
9
+ jQuery("ul.first").autoCompletefb({urlLookup:'<?php echo BP_PLUGIN_URL . '/bp-messages/autocomplete/bp-messages-autocomplete.php' ?>'});
10
+
11
+ jQuery('#send_message_form').submit( function() {
12
+ var users = document.getElementById('send-to-usernames').className;
13
+ document.getElementById('send-to-usernames').value = String(users);
14
+ });
15
+
16
+ });
bp-messages/js/autocomplete/jquery.autocomplete.js ADDED
@@ -0,0 +1,728 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Autocomplete - jQuery plugin 1.0 Beta
3
+ *
4
+ * Copyright (c) 2007 Dylan Verheul, Dan G. Switzer, Anjesh Tuladhar, Jörn Zaefferer
5
+ *
6
+ * Dual licensed under the MIT and GPL licenses:
7
+ * http://www.opensource.org/licenses/mit-license.php
8
+ * http://www.gnu.org/licenses/gpl.html
9
+ *
10
+ * Revision: $Id: jquery.autocomplete.js 4485 2008-01-20 13:52:47Z joern.zaefferer $
11
+ *
12
+ */
13
+
14
+ ;(function($) {
15
+
16
+ $.fn.extend({
17
+ autocomplete: function(urlOrData, options) {
18
+ var isUrl = typeof urlOrData == "string";
19
+ options = $.extend({}, $.Autocompleter.defaults, {
20
+ url: isUrl ? urlOrData : null,
21
+ data: isUrl ? null : urlOrData,
22
+ delay: isUrl ? $.Autocompleter.defaults.delay : 10,
23
+ max: options && !options.scroll ? 10 : 150
24
+ }, options);
25
+
26
+ // if highlight is set to false, replace it with a do-nothing function
27
+ options.highlight = options.highlight || function(value) { return value; };
28
+
29
+ return this.each(function() {
30
+ new $.Autocompleter(this, options);
31
+ });
32
+ },
33
+ result: function(handler) {
34
+ return this.bind("result", handler);
35
+ },
36
+ search: function(handler) {
37
+ return this.trigger("search", [handler]);
38
+ },
39
+ flushCache: function() {
40
+ return this.trigger("flushCache");
41
+ },
42
+ setOptions: function(options){
43
+ return this.trigger("setOptions", [options]);
44
+ },
45
+ unautocomplete: function() {
46
+ return this.trigger("unautocomplete");
47
+ }
48
+ });
49
+
50
+ $.Autocompleter = function(input, options) {
51
+
52
+ var KEY = {
53
+ UP: 38,
54
+ DOWN: 40,
55
+ DEL: 46,
56
+ TAB: 9,
57
+ RETURN: 13,
58
+ ESC: 27,
59
+ COMMA: 188,
60
+ PAGEUP: 33,
61
+ PAGEDOWN: 34
62
+ };
63
+
64
+ // Create $ object for input element
65
+ var $input = $(input).attr("autocomplete", "off").addClass(options.inputClass);
66
+
67
+ var timeout;
68
+ var previousValue = "";
69
+ var cache = $.Autocompleter.Cache(options);
70
+ var hasFocus = 0;
71
+ var lastKeyPressCode;
72
+ var config = {
73
+ mouseDownOnSelect: false
74
+ };
75
+ var select = $.Autocompleter.Select(options, input, selectCurrent, config);
76
+
77
+ $input.keydown(function(event) {
78
+ // track last key pressed
79
+ lastKeyPressCode = event.keyCode;
80
+ switch(event.keyCode) {
81
+
82
+ case KEY.UP:
83
+ event.preventDefault();
84
+ if ( select.visible() ) {
85
+ select.prev();
86
+ } else {
87
+ onChange(0, true);
88
+ }
89
+ break;
90
+
91
+ case KEY.DOWN:
92
+ event.preventDefault();
93
+ if ( select.visible() ) {
94
+ select.next();
95
+ } else {
96
+ onChange(0, true);
97
+ }
98
+ break;
99
+
100
+ case KEY.PAGEUP:
101
+ event.preventDefault();
102
+ if ( select.visible() ) {
103
+ select.pageUp();
104
+ } else {
105
+ onChange(0, true);
106
+ }
107
+ break;
108
+
109
+ case KEY.PAGEDOWN:
110
+ event.preventDefault();
111
+ if ( select.visible() ) {
112
+ select.pageDown();
113
+ } else {
114
+ onChange(0, true);
115
+ }
116
+ break;
117
+
118
+ // matches also semicolon
119
+ case options.multiple && $.trim(options.multipleSeparator) == "," && KEY.COMMA:
120
+ case KEY.TAB:
121
+ case KEY.RETURN:
122
+ if( selectCurrent() ){
123
+ // make sure to blur off the current field
124
+ if( !options.multiple )
125
+ $input.blur();
126
+ event.preventDefault();
127
+ $input.focus();
128
+ }
129
+ break;
130
+
131
+ case KEY.ESC:
132
+ select.hide();
133
+ break;
134
+
135
+ default:
136
+ clearTimeout(timeout);
137
+ timeout = setTimeout(onChange, options.delay);
138
+ break;
139
+ }
140
+ }).keypress(function() {
141
+ // having fun with opera - remove this binding and Opera submits the form when we select an entry via return
142
+ }).focus(function(){
143
+ // track whether the field has focus, we shouldn't process any
144
+ // results if the field no longer has focus
145
+ hasFocus++;
146
+ }).blur(function() {
147
+ hasFocus = 0;
148
+ if (!config.mouseDownOnSelect) {
149
+ hideResults();
150
+ }
151
+ }).click(function() {
152
+ // show select when clicking in a focused field
153
+ if ( hasFocus++ > 1 && !select.visible() ) {
154
+ onChange(0, true);
155
+ }
156
+ }).bind("search", function() {
157
+ // TODO why not just specifying both arguments?
158
+ var fn = (arguments.length > 1) ? arguments[1] : null;
159
+ function findValueCallback(q, data) {
160
+ var result;
161
+ if( data && data.length ) {
162
+ for (var i=0; i < data.length; i++) {
163
+ if( data[i].result.toLowerCase() == q.toLowerCase() ) {
164
+ result = data[i];
165
+ break;
166
+ }
167
+ }
168
+ }
169
+ if( typeof fn == "function" ) fn(result);
170
+ else $input.trigger("result", result && [result.data, result.value]);
171
+ }
172
+ $.each(trimWords($input.val()), function(i, value) {
173
+ request(value, findValueCallback, findValueCallback);
174
+ });
175
+ }).bind("flushCache", function() {
176
+ cache.flush();
177
+ }).bind("setOptions", function() {
178
+ $.extend(options, arguments[1]);
179
+ // if we've updated the data, repopulate
180
+ if ( "data" in arguments[1] )
181
+ cache.populate();
182
+ }).bind("unautocomplete", function() {
183
+ select.unbind();
184
+ $input.unbind();
185
+ });
186
+
187
+
188
+ function selectCurrent() {
189
+ var selected = select.selected();
190
+ if( !selected )
191
+ return false;
192
+
193
+ var v = selected.result;
194
+ previousValue = v;
195
+
196
+ if ( options.multiple ) {
197
+ var words = trimWords($input.val());
198
+ if ( words.length > 1 ) {
199
+ v = words.slice(0, words.length - 1).join( options.multipleSeparator ) + options.multipleSeparator + v;
200
+ }
201
+ v += options.multipleSeparator;
202
+ }
203
+
204
+ $input.val(v);
205
+ hideResultsNow();
206
+ $input.trigger("result", [selected.data, selected.value]);
207
+ return true;
208
+ }
209
+
210
+ function onChange(crap, skipPrevCheck) {
211
+ if( lastKeyPressCode == KEY.DEL ) {
212
+ select.hide();
213
+ return;
214
+ }
215
+
216
+ var currentValue = $input.val();
217
+
218
+ if ( !skipPrevCheck && currentValue == previousValue )
219
+ return;
220
+
221
+ previousValue = currentValue;
222
+
223
+ currentValue = lastWord(currentValue);
224
+ if ( currentValue.length >= options.minChars) {
225
+ $input.addClass(options.loadingClass);
226
+ jQuery('#send-to-loading').show();
227
+ if (!options.matchCase)
228
+ currentValue = currentValue.toLowerCase();
229
+ request(currentValue, receiveData, hideResultsNow);
230
+ } else {
231
+ stopLoading();
232
+ select.hide();
233
+ }
234
+ };
235
+
236
+ function trimWords(value) {
237
+ if ( !value ) {
238
+ return [""];
239
+ }
240
+ var words = value.split( $.trim( options.multipleSeparator ) );
241
+ var result = [];
242
+ $.each(words, function(i, value) {
243
+ if ( $.trim(value) )
244
+ result[i] = $.trim(value);
245
+ });
246
+ return result;
247
+ }
248
+
249
+ function lastWord(value) {
250
+ if ( !options.multiple )
251
+ return value;
252
+ var words = trimWords(value);
253
+ return words[words.length - 1];
254
+ }
255
+
256
+ // fills in the input box w/the first match (assumed to be the best match)
257
+ function autoFill(q, sValue){
258
+ // autofill in the complete box w/the first match as long as the user hasn't entered in more data
259
+ // if the last user key pressed was backspace, don't autofill
260
+ if( options.autoFill && (lastWord($input.val()).toLowerCase() == q.toLowerCase()) && lastKeyPressCode != 8 ) {
261
+ // fill in the value (keep the case the user has typed)
262
+ $input.val($input.val() + sValue.substring(lastWord(previousValue).length));
263
+ // select the portion of the value not typed by the user (so the next character will erase)
264
+ $.Autocompleter.Selection(input, previousValue.length, previousValue.length + sValue.length);
265
+ }
266
+ };
267
+
268
+ function hideResults() {
269
+ clearTimeout(timeout);
270
+ timeout = setTimeout(hideResultsNow, 200);
271
+ };
272
+
273
+ function hideResultsNow() {
274
+ select.hide();
275
+ clearTimeout(timeout);
276
+ stopLoading();
277
+ if (options.mustMatch) {
278
+ // call search and run callback
279
+ $input.search(
280
+ function (result){
281
+ // if no value found, clear the input box
282
+ if( !result ) $input.val("");
283
+ }
284
+ );
285
+ }
286
+ };
287
+
288
+ function receiveData(q, data) {
289
+ if ( data && data.length && hasFocus ) {
290
+ stopLoading();
291
+ select.display(data, q);
292
+
293
+ var newData = data[0].value.split(';');
294
+ data.value = newData[0];
295
+
296
+ autoFill(q, data.value);
297
+ select.show();
298
+ } else {
299
+ hideResultsNow();
300
+ }
301
+ };
302
+
303
+ function request(term, success, failure) {
304
+ if (!options.matchCase)
305
+ term = term.toLowerCase();
306
+ var data = cache.load(term);
307
+ // recieve the cached data
308
+ if (data && data.length) {
309
+ success(term, data);
310
+ // if an AJAX url has been supplied, try loading the data now
311
+ } else if( (typeof options.url == "string") && (options.url.length > 0) ){
312
+
313
+ var extraParams = {};
314
+ $.each(options.extraParams, function(key, param) {
315
+ extraParams[key] = typeof param == "function" ? param() : param;
316
+ });
317
+
318
+ $.ajax({
319
+ // try to leverage ajaxQueue plugin to abort previous requests
320
+ mode: "abort",
321
+ // limit abortion to this input
322
+ port: "autocomplete" + input.name,
323
+ dataType: options.dataType,
324
+ url: options.url,
325
+ data: $.extend({
326
+ q: lastWord(term),
327
+ limit: options.max
328
+ }, extraParams),
329
+ success: function(data) {
330
+ var parsed = options.parse && options.parse(data) || parse(data);
331
+ cache.add(term, parsed);
332
+ success(term, parsed);
333
+ }
334
+ });
335
+ } else {
336
+ failure(term);
337
+ }
338
+ };
339
+
340
+ function parse(data) {
341
+ var parsed = [];
342
+ var rows = data.split("\n");
343
+ for (var i=0; i < rows.length; i++) {
344
+ var row = $.trim(rows[i]);
345
+ if (row) {
346
+ row = row.split("|");
347
+ parsed[parsed.length] = {
348
+ data: row,
349
+ value: row[0],
350
+ result: options.formatResult && options.formatResult(row, row[0]) || row[0]
351
+ };
352
+ }
353
+ }
354
+ return parsed;
355
+ };
356
+
357
+ function stopLoading() {
358
+ $input.removeClass(options.loadingClass);
359
+ jQuery('#send-to-loading').hide();
360
+ };
361
+
362
+ };
363
+
364
+ $.Autocompleter.defaults = {
365
+ inputClass: "ac_input",
366
+ resultsClass: "ac_results",
367
+ loadingClass: "ac_loading",
368
+ minChars: 1,
369
+ delay: 400,
370
+ matchCase: false,
371
+ matchSubset: true,
372
+ matchContains: false,
373
+ cacheLength: 10,
374
+ max: 100,
375
+ mustMatch: false,
376
+ extraParams: {},
377
+ selectFirst: true,
378
+ formatItem: function(row) { return row[0]; },
379
+ autoFill: false,
380
+ width: 0,
381
+ multiple: false,
382
+ multipleSeparator: ", ",
383
+ highlight: function(value, term) {
384
+ return value.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi, "\\$1") + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong>$1</strong>");
385
+ },
386
+ scroll: true,
387
+ scrollHeight: 250,
388
+ attachTo: 'body'
389
+ };
390
+
391
+ $.Autocompleter.Cache = function(options) {
392
+
393
+ var data = {};
394
+ var length = 0;
395
+
396
+ function matchSubset(s, sub) {
397
+ if (!options.matchCase)
398
+ s = s.toLowerCase();
399
+ var i = s.indexOf(sub);
400
+ if (i == -1) return false;
401
+ return i == 0 || options.matchContains;
402
+ };
403
+
404
+ function add(q, value) {
405
+ if (length > options.cacheLength){
406
+ flush();
407
+ }
408
+ if (!data[q]){
409
+ length++;
410
+ }
411
+ data[q] = value;
412
+ }
413
+
414
+ function populate(){
415
+ if( !options.data ) return false;
416
+ // track the matches
417
+ var stMatchSets = {},
418
+ nullData = 0;
419
+
420
+ // no url was specified, we need to adjust the cache length to make sure it fits the local data store
421
+ if( !options.url ) options.cacheLength = 1;
422
+
423
+ // track all options for minChars = 0
424
+ stMatchSets[""] = [];
425
+
426
+ // loop through the array and create a lookup structure
427
+ for ( var i = 0, ol = options.data.length; i < ol; i++ ) {
428
+ var rawValue = options.data[i];
429
+ // if rawValue is a string, make an array otherwise just reference the array
430
+ rawValue = (typeof rawValue == "string") ? [rawValue] : rawValue;
431
+
432
+ var value = options.formatItem(rawValue, i+1, options.data.length);
433
+ if ( value === false )
434
+ continue;
435
+
436
+ var firstChar = value.charAt(0).toLowerCase();
437
+ // if no lookup array for this character exists, look it up now
438
+ if( !stMatchSets[firstChar] )
439
+ stMatchSets[firstChar] = [];
440
+
441
+ // if the match is a string
442
+ var row = {
443
+ value: value,
444
+ data: rawValue,
445
+ result: options.formatResult && options.formatResult(rawValue) || value
446
+ };
447
+
448
+ // push the current match into the set list
449
+ stMatchSets[firstChar].push(row);
450
+
451
+ // keep track of minChars zero items
452
+ if ( nullData++ < options.max ) {
453
+ stMatchSets[""].push(row);
454
+ }
455
+ };
456
+
457
+ // add the data items to the cache
458
+ $.each(stMatchSets, function(i, value) {
459
+ // increase the cache size
460
+ options.cacheLength++;
461
+ // add to the cache
462
+ add(i, value);
463
+ });
464
+ }
465
+
466
+ // populate any existing data
467
+ setTimeout(populate, 25);
468
+
469
+ function flush(){
470
+ data = {};
471
+ length = 0;
472
+ }
473
+
474
+ return {
475
+ flush: flush,
476
+ add: add,
477
+ populate: populate,
478
+ load: function(q) {
479
+ if (!options.cacheLength || !length)
480
+ return null;
481
+ /*
482
+ * if dealing w/local data and matchContains than we must make sure
483
+ * to loop through all the data collections looking for matches
484
+ */
485
+ if( !options.url && options.matchContains ){
486
+ // track all matches
487
+ var csub = [];
488
+ // loop through all the data grids for matches
489
+ for( var k in data ){
490
+ // don't search through the stMatchSets[""] (minChars: 0) cache
491
+ // this prevents duplicates
492
+ if( k.length > 0 ){
493
+ var c = data[k];
494
+ $.each(c, function(i, x) {
495
+ // if we've got a match, add it to the array
496
+ if (matchSubset(x.value, q)) {
497
+ csub.push(x);
498
+ }
499
+ });
500
+ }
501
+ }
502
+ return csub;
503
+ } else
504
+ // if the exact item exists, use it
505
+ if (data[q]){
506
+ return data[q];
507
+ } else
508
+ if (options.matchSubset) {
509
+ for (var i = q.length - 1; i >= options.minChars; i--) {
510
+ var c = data[q.substr(0, i)];
511
+ if (c) {
512
+ var csub = [];
513
+ $.each(c, function(i, x) {
514
+ if (matchSubset(x.value, q)) {
515
+ csub[csub.length] = x;
516
+ }
517
+ });
518
+ return csub;
519
+ }
520
+ }
521
+ }
522
+ return null;
523
+ }
524
+ };
525
+ };
526
+
527
+ $.Autocompleter.Select = function (options, input, select, config) {
528
+ var CLASSES = {
529
+ ACTIVE: "ac_over"
530
+ };
531
+
532
+ var listItems,
533
+ active = -1,
534
+ data,
535
+ term = "",
536
+ needsInit = true,
537
+ element,
538
+ list;
539
+
540
+ // Create results
541
+ function init() {
542
+ if (!needsInit)
543
+ return;
544
+ element = $("<div/>")
545
+ .hide()
546
+ .addClass(options.resultsClass)
547
+ .css("position", "absolute")
548
+ .appendTo(options.attachTo);
549
+
550
+ list = $("<ul>").appendTo(element).mouseover( function(event) {
551
+ if(target(event).nodeName && target(event).nodeName.toUpperCase() == 'LI') {
552
+ active = $("li", list).removeClass(CLASSES.ACTIVE).index(target(event));
553
+ $(target(event)).addClass(CLASSES.ACTIVE);
554
+ }
555
+ }).click(function(event) {
556
+ $(target(event)).addClass(CLASSES.ACTIVE);
557
+ select();
558
+ input.focus();
559
+ return false;
560
+ }).mousedown(function() {
561
+ config.mouseDownOnSelect = true;
562
+ }).mouseup(function() {
563
+ config.mouseDownOnSelect = false;
564
+ });
565
+
566
+ if( options.width > 0 )
567
+ element.css("width", options.width);
568
+
569
+ needsInit = false;
570
+ }
571
+
572
+ function target(event) {
573
+ var element = event.target;
574
+ while(element && element.tagName != "LI")
575
+ element = element.parentNode;
576
+ // more fun with IE, sometimes event.target is empty, just ignore it then
577
+ if(!element)
578
+ return [];
579
+ return element;
580
+ }
581
+
582
+ function moveSelect(step) {
583
+ listItems.slice(active, active + 1).removeClass();
584
+ movePosition(step);
585
+ var activeItem = listItems.slice(active, active + 1).addClass(CLASSES.ACTIVE);
586
+ if(options.scroll) {
587
+ var offset = 0;
588
+ listItems.slice(0, active).each(function() {
589
+ offset += this.offsetHeight;
590
+ });
591
+ if((offset + activeItem[0].offsetHeight - list.scrollTop()) > list[0].clientHeight) {
592
+ list.scrollTop(offset + activeItem[0].offsetHeight - list.innerHeight());
593
+ } else if(offset < list.scrollTop()) {
594
+ list.scrollTop(offset);
595
+ }
596
+ }
597
+ };
598
+
599
+ function movePosition(step) {
600
+ active += step;
601
+ if (active < 0) {
602
+ active = listItems.size() - 1;
603
+ } else if (active >= listItems.size()) {
604
+ active = 0;
605
+ }
606
+ }
607
+
608
+ function limitNumberOfItems(available) {
609
+ return options.max && options.max < available
610
+ ? options.max
611
+ : available;
612
+ }
613
+
614
+ function fillList() {
615
+ list.empty();
616
+ var max = limitNumberOfItems(data.length);
617
+ for (var i=0; i < max; i++) {
618
+ if (!data[i])
619
+ continue;
620
+ var formatted = options.formatItem(data[i].data, i+1, max, data[i].value, term);
621
+ if ( formatted === false )
622
+ continue;
623
+ var li = $("<li>").html( options.highlight(formatted, term) ).addClass(i%2 == 0 ? "ac_event" : "ac_odd").appendTo(list)[0];
624
+ $.data(li, "ac_data", data[i]);
625
+ }
626
+ listItems = list.find("li");
627
+ if ( options.selectFirst ) {
628
+ listItems.slice(0, 1).addClass(CLASSES.ACTIVE);
629
+ active = 0;
630
+ }
631
+ list.bgiframe();
632
+ }
633
+
634
+ return {
635
+ display: function(d, q) {
636
+ init();
637
+ data = d;
638
+ term = q;
639
+ fillList();
640
+ },
641
+ next: function() {
642
+ moveSelect(1);
643
+ },
644
+ prev: function() {
645
+ moveSelect(-1);
646
+ },
647
+ pageUp: function() {
648
+ if (active != 0 && active - 8 < 0) {
649
+ moveSelect( -active );
650
+ } else {
651
+ moveSelect(-8);
652
+ }
653
+ },
654
+ pageDown: function() {
655
+ if (active != listItems.size() - 1 && active + 8 > listItems.size()) {
656
+ moveSelect( listItems.size() - 1 - active );
657
+ } else {
658
+ moveSelect(8);
659
+ }
660
+ },
661
+ hide: function() {
662
+ element && element.hide();
663
+ active = -1;
664
+ },
665
+ visible : function() {
666
+ return element && element.is(":visible");
667
+ },
668
+ current: function() {
669
+ return this.visible() && (listItems.filter("." + CLASSES.ACTIVE)[0] || options.selectFirst && listItems[0]);
670
+ },
671
+ show: function() {
672
+ var offset = $(input).offset();
673
+ element.css({
674
+ width: typeof options.width == "string" || options.width > 0 ? options.width : $(input).width(),
675
+ top: offset.top + input.offsetHeight,
676
+ left: offset.left
677
+ }).show();
678
+ if(options.scroll) {
679
+ list.scrollTop(0);
680
+ list.css({
681
+ maxHeight: options.scrollHeight,
682
+ overflow: 'auto'
683
+ });
684
+
685
+ if($.browser.msie && typeof document.body.style.maxHeight === "undefined") {
686
+ var listHeight = 0;
687
+ listItems.each(function() {
688
+ listHeight += this.offsetHeight;
689
+ });
690
+ var scrollbarsVisible = listHeight > options.scrollHeight;
691
+ list.css('height', scrollbarsVisible ? options.scrollHeight : listHeight );
692
+ if (!scrollbarsVisible) {
693
+ // IE doesn't recalculate width when scrollbar disappears
694
+ listItems.width( list.width() - parseInt(listItems.css("padding-left")) - parseInt(listItems.css("padding-right")) );
695
+ }
696
+ }
697
+
698
+ }
699
+ },
700
+ selected: function() {
701
+ var selected = listItems && listItems.filter("." + CLASSES.ACTIVE).removeClass(CLASSES.ACTIVE);
702
+ return selected && selected.length && $.data(selected[0], "ac_data");
703
+ },
704
+ unbind: function() {
705
+ element && element.remove();
706
+ }
707
+ };
708
+ };
709
+
710
+ $.Autocompleter.Selection = function(field, start, end) {
711
+ if( field.createTextRange ){
712
+ var selRange = field.createTextRange();
713
+ selRange.collapse(true);
714
+ selRange.moveStart("character", start);
715
+ selRange.moveEnd("character", end);
716
+ selRange.select();
717
+ } else if( field.setSelectionRange ){
718
+ field.setSelectionRange(start, end);
719
+ } else {
720
+ if( field.selectionStart ){
721
+ field.selectionStart = start;
722
+ field.selectionEnd = end;
723
+ }
724
+ }
725
+ field.focus();
726
+ };
727
+
728
+ })(jQuery);
bp-messages/js/autocomplete/jquery.autocompletefb.js ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * jQuery plugin: autoCompletefb(AutoComplete Facebook)
3
+ * @requires jQuery v1.2.2 or later
4
+ * using plugin:jquery.autocomplete.js
5
+ *
6
+ * Credits:
7
+ * - Idea: Facebook
8
+ * - Guillermo Rauch: Original MooTools script
9
+ * - InteRiders <http://interiders.com/>
10
+ *
11
+ * Copyright (c) 2008 Widi Harsojo <wharsojo@gmail.com>, http://wharsojo.wordpress.com/
12
+ * Dual licensed under the MIT and GPL licenses:
13
+ * http://www.opensource.org/licenses/mit-license.php
14
+ * http://www.gnu.org/licenses/gpl.html
15
+ */
16
+
17
+ jQuery.fn.autoCompletefb = function(options)
18
+ {
19
+ var tmp = this;
20
+ var settings =
21
+ {
22
+ ul : tmp,
23
+ urlLookup : [""],
24
+ acOptions : {},
25
+ foundClass : ".friend-tab",
26
+ inputClass : ".send-to-input"
27
+ }
28
+
29
+ if(options) jQuery.extend(settings, options);
30
+
31
+ var acfb =
32
+ {
33
+ params : settings,
34
+ removeFind : function(o){
35
+ acfb.removeUsername(o);
36
+ jQuery(o).unbind('click').parent().remove();
37
+ jQuery(settings.inputClass,tmp).focus();
38
+ return tmp.acfb;
39
+ },
40
+ removeUsername: function(o){
41
+ var newID = o.parentNode.id.split('-');
42
+ jQuery('#send-to-usernames').removeClass(newID[1]);
43
+ }
44
+ }
45
+
46
+ jQuery(settings.foundClass+" img.p").click(function(){
47
+ acfb.removeFind(this);
48
+ });
49
+
50
+ jQuery(settings.inputClass,tmp).autocomplete(settings.urlLookup,settings.acOptions);
51
+ jQuery(settings.inputClass,tmp).result(function(e,d,f){
52
+ var f = settings.foundClass.replace(/\./,'');
53
+ var d = String(d).split(' (');
54
+ var un = d[1].substr(0, d[1].length-1);
55
+ var v = '<li class="'+f+'" id="un-'+un+'"><span>'+d[0]+'</span> <span class="p">X</span></li>';
56
+ var x = jQuery(settings.inputClass,tmp).before(v);
57
+
58
+ jQuery('#send-to-usernames').addClass(un);
59
+
60
+ jQuery('.p',x[0].previousSibling).click(function(){
61
+ acfb.removeFind(this);
62
+ });
63
+ jQuery(settings.inputClass,tmp).val('');
64
+ });
65
+
66
+ jQuery(settings.inputClass,tmp).focus();
67
+ return acfb;
68
+ }
bp-messages/js/autocomplete/jquery.bgiframe.min.js ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ /* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net)
2
+ * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
3
+ * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
4
+ *
5
+ * $LastChangedDate: 2007-07-22 01:45:56 +0200 (Son, 22 Jul 2007) $
6
+ * $Rev: 2447 $
7
+ *
8
+ * Version 2.1.1
9
+ */
10
+ (function($){$.fn.bgIframe=$.fn.bgiframe=function(s){if($.browser.msie&&/6.0/.test(navigator.userAgent)){s=$.extend({top:'auto',left:'auto',width:'auto',height:'auto',opacity:true,src:'javascript:false;'},s||{});var prop=function(n){return n&&n.constructor==Number?n+'px':n;},html='<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+'style="display:block;position:absolute;z-index:-1;'+(s.opacity!==false?'filter:Alpha(Opacity=\'0\');':'')+'top:'+(s.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(s.top))+';'+'left:'+(s.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(s.left))+';'+'width:'+(s.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(s.width))+';'+'height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+'"/>';return this.each(function(){if($('> iframe.bgiframe',this).length==0)this.insertBefore(document.createElement(html),this.firstChild);});}return this;};})(jQuery);
bp-messages/js/autocomplete/jquery.dimensions.js ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Copyright (c) 2007 Paul Bakaus (paul.bakaus@googlemail.com) and Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
2
+ * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
3
+ * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
4
+ *
5
+ * $LastChangedDate: 2007-09-11 05:38:31 +0300 (Вт, 11 сен 2007) $
6
+ * $Rev: 3238 $
7
+ *
8
+ * Version: @VERSION
9
+ *
10
+ * Requires: jQuery 1.2+
11
+ */
12
+
13
+ (function($){
14
+
15
+ $.dimensions = {
16
+ version: '@VERSION'
17
+ };
18
+
19
+ // Create innerHeight, innerWidth, outerHeight and outerWidth methods
20
+ $.each( [ 'Height', 'Width' ], function(i, name){
21
+
22
+ // innerHeight and innerWidth
23
+ $.fn[ 'inner' + name ] = function() {
24
+ if (!this[0]) return;
25
+
26
+ var torl = name == 'Height' ? 'Top' : 'Left', // top or left
27
+ borr = name == 'Height' ? 'Bottom' : 'Right'; // bottom or right
28
+
29
+ return this[ name.toLowerCase() ]() + num(this, 'padding' + torl) + num(this, 'padding' + borr);
30
+ };
31
+
32
+ // outerHeight and outerWidth
33
+ $.fn[ 'outer' + name ] = function(options) {
34
+ if (!this[0]) return;
35
+
36
+ var torl = name == 'Height' ? 'Top' : 'Left', // top or left
37
+ borr = name == 'Height' ? 'Bottom' : 'Right'; // bottom or right
38
+
39
+ options = $.extend({ margin: false }, options || {});
40
+
41
+ return this[ name.toLowerCase() ]()
42
+ + num(this, 'border' + torl + 'Width') + num(this, 'border' + borr + 'Width')
43
+ + num(this, 'padding' + torl) + num(this, 'padding' + borr)
44
+ + (options.margin ? (num(this, 'margin' + torl) + num(this, 'margin' + borr)) : 0);
45
+ };
46
+ });
47
+
48
+ // Create scrollLeft and scrollTop methods
49
+ $.each( ['Left', 'Top'], function(i, name) {
50
+ $.fn[ 'scroll' + name ] = function(val) {
51
+ if (!this[0]) return;
52
+
53
+ return val != undefined ?
54
+
55
+ // Set the scroll offset
56
+ this.each(function() {
57
+ this == window || this == document ?
58
+ window.scrollTo(
59
+ name == 'Left' ? val : $(window)[ 'scrollLeft' ](),
60
+ name == 'Top' ? val : $(window)[ 'scrollTop' ]()
61
+ ) :
62
+ this[ 'scroll' + name ] = val;
63
+ }) :
64
+
65
+ // Return the scroll offset
66
+ this[0] == window || this[0] == document ?
67
+ self[ (name == 'Left' ? 'pageXOffset' : 'pageYOffset') ] ||
68
+ $.boxModel && document.documentElement[ 'scroll' + name ] ||
69
+ document.body[ 'scroll' + name ] :
70
+ this[0][ 'scroll' + name ];
71
+ };
72
+ });
73
+
74
+ $.fn.extend({
75
+ position: function() {
76
+ var left = 0, top = 0, elem = this[0], offset, parentOffset, offsetParent, results;
77
+
78
+ if (elem) {
79
+ // Get *real* offsetParent
80
+ offsetParent = this.offsetParent();
81
+
82
+ // Get correct offsets
83
+ offset = this.offset();
84
+ parentOffset = offsetParent.offset();
85
+
86
+ // Subtract element margins
87
+ offset.top -= num(elem, 'marginTop');
88
+ offset.left -= num(elem, 'marginLeft');
89
+
90
+ // Add offsetParent borders
91
+ parentOffset.top += num(offsetParent, 'borderTopWidth');
92
+ parentOffset.left += num(offsetParent, 'borderLeftWidth');
93
+
94
+ // Subtract the two offsets
95
+ results = {
96
+ top: offset.top - parentOffset.top,
97
+ left: offset.left - parentOffset.left
98
+ };
99
+ }
100
+
101
+ return results;
102
+ },
103
+
104
+ offsetParent: function() {
105
+ var offsetParent = this[0].offsetParent;
106
+ while ( offsetParent && (!/^body|html$/i.test(offsetParent.tagName) && $.css(offsetParent, 'position') == 'static') )
107
+ offsetParent = offsetParent.offsetParent;
108
+ return $(offsetParent);
109
+ }
110
+ });
111
+
112
+ var num = function(el, prop) {
113
+ return parseInt($.css(el.jquery?el[0]:el,prop))||0;
114
+ };
115
+
116
+ })(jQuery);
bp-messages/js/general.js ADDED
@@ -0,0 +1,297 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function checkAll() {
2
+ var checkboxes = document.getElementsByTagName("input");
3
+ for(var i=0; i<checkboxes.length; i++) {
4
+ if(checkboxes[i].type == "checkbox") {
5
+ if($("check_all").checked == "") {
6
+ checkboxes[i].checked = "";
7
+ }
8
+ else {
9
+ checkboxes[i].checked = "checked";
10
+ }
11
+ }
12
+ }
13
+ }
14
+
15
+ jQuery(document).ready( function() {
16
+ jQuery("input#send-notice").click(
17
+ function() {
18
+ if ( jQuery("#send_to") ) {
19
+ jQuery("#send_to").val('');
20
+ }
21
+ }
22
+ );
23
+
24
+ jQuery("input#send_reply_button").click(
25
+ function() {
26
+ //tinyMCE.triggerSave(true, true);
27
+
28
+ var rand = Math.floor(Math.random()*100001);
29
+ jQuery("form#send-reply").before('<div style="display:none;" class="ajax_reply" id="' + rand + '">Sending Message...</div>');
30
+ jQuery("div#" + rand).fadeIn();
31
+
32
+ jQuery.post( ajaxurl, {
33
+ action: 'messages_send_reply',
34
+ 'cookie': encodeURIComponent(document.cookie),
35
+ '_wpnonce': jQuery("input#_wpnonce_send_message").val(),
36
+
37
+ 'content': jQuery("#message_content").val(),
38
+ 'send_to': jQuery("input#send_to").val(),
39
+ 'subject': jQuery("input#subject").val(),
40
+ 'thread_id': jQuery("input#thread_id").val()
41
+ },
42
+ function(response)
43
+ {
44
+ response = response.substr(0, response.length-1);
45
+ var css_class = 'message-box';
46
+
47
+ setTimeout( function() {
48
+ jQuery("div#" + rand).slideUp();
49
+ }, 500);
50
+
51
+ setTimeout( function() {
52
+ var err_num = response.split('[[split]]');
53
+ if ( err_num[0] == "-1" ) {
54
+ response = err_num[1];
55
+ css_class = 'error-box';
56
+ }
57
+
58
+ //tinyMCE.activeEditor.setContent('')
59
+ jQuery("#message_content").val('');
60
+
61
+ jQuery("div#" + rand).html(response).attr('class', css_class).slideDown();
62
+ }, 1250);
63
+ });
64
+
65
+ return false;
66
+ }
67
+ );
68
+
69
+ jQuery("a#mark_as_read").click(
70
+ function() {
71
+ checkboxes_tosend = '';
72
+ checkboxes = jQuery("#message-threads tr td input[type='checkbox']");
73
+ for(var i=0; i<checkboxes.length; i++) {
74
+ if(checkboxes[i].checked) {
75
+ if ( jQuery('tr#m-' + checkboxes[i].value).hasClass('unread') ) {
76
+ checkboxes_tosend += checkboxes[i].value;
77
+ jQuery('tr#m-' + checkboxes[i].value).removeClass('unread');
78
+ jQuery('tr#m-' + checkboxes[i].value).addClass('read');
79
+ jQuery('tr#m-' + checkboxes[i].value + ' td span.unread-count').html('0');
80
+ var inboxcount = jQuery('.inbox-count').html();
81
+ if ( parseInt(inboxcount) == 1 ) {
82
+ jQuery('.inbox-count').css('display', 'none');
83
+ jQuery('.inbox-count').html('0');
84
+ } else {
85
+ jQuery('.inbox-count').html(parseInt(inboxcount) - 1);
86
+ }
87
+
88
+ if ( i != checkboxes.length - 1 ) {
89
+ checkboxes_tosend += ','
90
+ }
91
+ }
92
+ }
93
+ }
94
+
95
+ jQuery.post( ajaxurl, {
96
+ action: 'messages_markread',
97
+ 'thread_ids': checkboxes_tosend
98
+ },
99
+ function(response) {
100
+ response = response.substr(0, response.length-1);
101
+ var err_num = response.split('[[split]]');
102
+ if ( err_num[0] == "-1" ) {
103
+ // error
104
+ jQuery('table#message-threads').before('<div id="message" class="error fade"><p>' + err_num[1] + '</p></div>')
105
+ }
106
+ });
107
+ return false;
108
+ }
109
+ );
110
+
111
+ jQuery("a#mark_as_unread").click(
112
+ function() {
113
+ checkboxes_tosend = '';
114
+ checkboxes = jQuery("#message-threads tr td input[type='checkbox']");
115
+ for(var i=0; i<checkboxes.length; i++) {
116
+ if(checkboxes[i].checked) {
117
+ if ( jQuery('tr#m-' + checkboxes[i].value).hasClass('read') ) {
118
+ checkboxes_tosend += checkboxes[i].value;
119
+ jQuery('tr#m-' + checkboxes[i].value).removeClass('read');
120
+ jQuery('tr#m-' + checkboxes[i].value).addClass('unread');
121
+ jQuery('tr#m-' + checkboxes[i].value + ' td span.unread-count').html('1');
122
+ var inboxcount = jQuery('.inbox-count').html();
123
+
124
+ if ( parseInt(inboxcount) == 0 ) {
125
+ jQuery('.inbox-count').css('display', 'inline');
126
+ jQuery('.inbox-count').html('1');
127
+ } else {
128
+ jQuery('.inbox-count').html(parseInt(inboxcount) + 1);
129
+ }
130
+
131
+ if ( i != checkboxes.length - 1 ) {
132
+ checkboxes_tosend += ','
133
+ }
134
+ }
135
+ }
136
+ }
137
+
138
+ jQuery.post( ajaxurl, {
139
+ action: 'messages_markunread',
140
+ 'thread_ids': checkboxes_tosend
141
+ },
142
+ function(response) {
143
+ response = response.substr(0, response.length-1);
144
+ var err_num = response.split('[[split]]');
145
+ if ( err_num[0] == "-1" ) {
146
+ // error
147
+ jQuery('table#message-threads').before('<div id="message" class="error fade"><p>' + err_num[1] + '</p></div>')
148
+ }
149
+ });
150
+ return false;
151
+ }
152
+ );
153
+
154
+ jQuery("a#delete_inbox_messages").click(
155
+ function() {
156
+ checkboxes_tosend = '';
157
+ checkboxes = jQuery("#message-threads tr td input[type='checkbox']");
158
+
159
+ for(var i=0; i<checkboxes.length; i++) {
160
+ if(checkboxes[i].checked) {
161
+ checkboxes_tosend += checkboxes[i].value;
162
+
163
+ if ( jQuery('tr#m-' + checkboxes[i].value).hasClass('unread') ) {
164
+ var inboxcount = jQuery('.inbox-count').html();
165
+
166
+ if ( parseInt(inboxcount) == 1 ) {
167
+ jQuery('.inbox-count').css('display', 'none');
168
+ jQuery('.inbox-count').html('0');
169
+ } else {
170
+ jQuery('.inbox-count').html(parseInt(inboxcount) - 1);
171
+ }
172
+ }
173
+
174
+ if ( i != checkboxes.length - 1 ) {
175
+ checkboxes_tosend += ','
176
+ }
177
+
178
+ jQuery('tr#m-' + checkboxes[i].value).remove();
179
+ }
180
+ }
181
+
182
+ if ( !checkboxes_tosend ) return false;
183
+
184
+ jQuery.post( ajaxurl, {
185
+ action: 'messages_delete',
186
+ 'thread_ids': checkboxes_tosend
187
+ },
188
+ function(response) {
189
+ response = response.substr(0, response.length-1);
190
+ var err_num = response.split('[[split]]');
191
+
192
+ jQuery('#message').remove();
193
+
194
+ if ( err_num[0] == "-1" ) {
195
+ // error
196
+ jQuery('table#message-threads').before('<div id="message" class="error fade"><p>' + err_num[1] + '</p></div>')
197
+ } else {
198
+ jQuery('table#message-threads').before('<div id="message" class="updated"><p>' + response + '</p></div>')
199
+ }
200
+ });
201
+ return false;
202
+ }
203
+ );
204
+
205
+ jQuery("a#delete_sentbox_messages").click(
206
+ function() {
207
+ checkboxes_tosend = '';
208
+ checkboxes = jQuery("#message-threads tr td input[type='checkbox']");
209
+
210
+ if ( !checkboxes.length ) return false;
211
+
212
+ for(var i=0; i<checkboxes.length; i++) {
213
+ if(checkboxes[i].checked) {
214
+ checkboxes_tosend += checkboxes[i].value;
215
+
216
+ if ( i != checkboxes.length - 1 ) {
217
+ checkboxes_tosend += ','
218
+ }
219
+ jQuery('tr#m-' + checkboxes[i].value).remove();
220
+ }
221
+ }
222
+
223
+ if ( !checkboxes_tosend ) return false;
224
+
225
+ jQuery.post( ajaxurl, {
226
+ action: 'messages_delete',
227
+ 'thread_ids': checkboxes_tosend
228
+ },
229
+ function(response) {
230
+ response = response.substr(0, response.length-1);
231
+ var err_num = response.split('[[split]]');
232
+
233
+ jQuery('#message').remove();
234
+
235
+ if ( err_num[0] == "-1" ) {
236
+ // error
237
+ jQuery('table#message-threads').before('<div id="message" class="error fade"><p>' + err_num[1] + '</p></div>')
238
+ } else {
239
+ jQuery('table#message-threads').before('<div id="message" class="updated"><p>' + response + '</p></div>')
240
+ }
241
+ });
242
+ return false;
243
+ }
244
+ );
245
+
246
+
247
+ jQuery("a#close-notice").click(
248
+ function() {
249
+ jQuery.post( ajaxurl, {
250
+ action: 'messages_close_notice',
251
+ 'notice_id': jQuery('.notice').attr('id')
252
+ },
253
+ function(response) {
254
+ response = response.substr(0, response.length-1);
255
+ var err_num = response.split('[[split]]');
256
+
257
+ if ( err_num[0] == "-1" ) {
258
+ // error
259
+ jQuery('.notice').before('<div id="message" class="error fade"><p>' + err_num[1] + '</p></div>')
260
+ } else {
261
+ jQuery('.notice').remove();
262
+ }
263
+ });
264
+ return false;
265
+ }
266
+ );
267
+
268
+ jQuery("select#message-type-select").change(
269
+ function() {
270
+ var selection = jQuery("select#message-type-select").val();
271
+ var checkboxes = jQuery("td input[type='checkbox']");
272
+ for(var i=0; i<checkboxes.length; i++) {
273
+ checkboxes[i].checked = "";
274
+ }
275
+
276
+ switch(selection) {
277
+ case 'unread':
278
+ var checkboxes = jQuery("tr.unread td input[type='checkbox']");
279
+ for(var i=0; i<checkboxes.length; i++) {
280
+ checkboxes[i].checked = "checked";
281
+ }
282
+ break;
283
+ case 'read':
284
+ var checkboxes = jQuery("tr.read td input[type='checkbox']");
285
+ for(var i=0; i<checkboxes.length; i++) {
286
+ checkboxes[i].checked = "checked";
287
+ }
288
+ break;
289
+ case 'all':
290
+ for(var i=0; i<checkboxes.length; i++) {
291
+ checkboxes[i].checked = "checked";
292
+ }
293
+ break;
294
+ }
295
+ }
296
+ );
297
+ });
bp-themes/bphome/404.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php get_header(); ?>
2
+
3
+ <div id="content" class="widecolumn">
4
+
5
+ <div id="right-column">
6
+ <?php if ( !function_exists('dynamic_sidebar')
7
+ || !dynamic_sidebar('right-column') ) : ?>
8
+
9
+ <div class="widget-error">
10
+ <?php _e( 'Please log in and add widgets to this column.', 'buddypress' ) ?> <a href="<?php echo get_option('siteurl') ?>/wp-admin/widgets.php?s=&amp;show=&amp;sidebar=sidebar-3"><?php _e( 'Add Widgets', 'buddypress' ) ?></a>
11
+ </div>
12
+
13
+ <?php endif; ?>
14
+ </div>
15
+
16
+ <div id="center-column">
17
+ <?php if ( !function_exists('dynamic_sidebar')
18
+ || !dynamic_sidebar('center-column') ) : ?>
19
+
20
+ <div class="widget-error">
21
+ <?php _e( 'Please log in and add widgets to this column.', 'buddypress' ) ?> <a href="<?php echo get_option('siteurl') ?>/wp-admin/widgets.php?s=&amp;show=&amp;sidebar=sidebar-2"><?php _e( 'Add Widgets', 'buddypress' ) ?></a>
22
+ </div>
23
+
24
+ <?php endif; ?>
25
+ </div>
26
+
27
+ <div id="left-column">
28
+ <div class="404 bp_core_widget_welcome">
29
+ <h2 class="widgettitle"><?php _e( 'Sorry, that page was not found', 'buddypress' ) ?></h2>
30
+
31
+ <div id="message" class="info">
32
+ <p><?php _e( 'The page you were looking for was not found.', 'buddypress' ) ?>
33
+ </div>
34
+ </div>
35
+ </div>
36
+
37
+
38
+ </div>
39
+
40
+ <?php get_footer(); ?>
bp-themes/bphome/activate.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php get_header(); ?>
2
+
3
+ <div id="content" class="widecolumn">
4
+
5
+ <div id="right-column">
6
+ <?php if ( !function_exists('dynamic_sidebar')
7
+ || !dynamic_sidebar('right-column') ) : ?>
8
+
9
+ <div class="widget-error">
10
+ <?php _e( 'Please log in and add widgets to this column.', 'buddypress' ) ?> <a href="<?php echo get_option('siteurl') ?>/wp-admin/widgets.php?s=&amp;show=&amp;sidebar=sidebar-3"><?php _e( 'Add Widgets', 'buddypress' ) ?></a>
11
+ </div>
12
+
13
+ <?php endif; ?>
14
+ </div>
15
+
16
+ <div id="left-column" class="span-two">
17
+ <div class="register bp_core_widget_welcome">
18
+ <h2 class="widgettitle"><?php _e( 'Activate your Account', 'buddypress' ) ?></h2>
19
+ <?php bp_core_activation_do_activation() ?>
20
+ </div>
21
+ </div>
22
+
23
+ </div>
24
+
25
+ <?php get_footer(); ?>
bp-themes/bphome/archive.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php get_header(); ?>
2
+
3
+ <div id="content" class="narrowcolumn">
4
+ <div class="widget" id="latest-news">
5
+ <h2 class="widgettitle"><?php _e( 'Blog', 'buddypress' ) ?></h2>
6
+
7
+ <?php if (have_posts()) : ?>
8
+
9
+ <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
10
+ <?php /* If this is a category archive */ if (is_category()) { ?>
11
+ <h3 class="pageTitle"><?php _e( 'Archive for the', 'buddypress' ) ?> &#8216;<?php single_cat_title(); ?>&#8217; <?php _e( 'Category', 'buddypress' ) ?></h3>
12
+
13
+ <?php /* If this is a daily archive */ } elseif (is_day()) { ?>
14
+ <h3 class="pageTitle"><?php _e( 'Archive for', 'buddypress' ) ?> <?php the_time('F j, Y'); ?></h3>
15
+
16
+ <?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
17
+ <h3 class="pageTitle"><?php _e( 'Archive for', 'buddypress' ) ?> <?php the_time('F, Y'); ?></h3>
18
+
19
+ <?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
20
+ <h3 class="pageTitle"><?php _e( 'Archive for', 'buddypress' ) ?> <?php the_time('Y'); ?></h3>
21
+
22
+ <?php /* If this is an author archive */ } elseif (is_author()) { ?>
23
+ <h3 class="pageTitle"><?php _e( 'Author Archive', 'buddypress' ) ?></h3>
24
+
25
+ <?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
26
+ <h3 class="pageTitle"><?php _e( 'Blog Archives', 'buddypress' ) ?></h3>
27
+
28
+ <?php } ?>
29
+
30
+
31
+ <div class="navigation">
32
+ <div class="alignleft"><?php next_posts_link( __( '&laquo; Previous Entries', 'buddypress' ) ) ?></div>
33
+ <div class="alignright"><?php previous_posts_link( __( 'Next Entries &raquo;', 'buddypress' ) ) ?></div>
34
+ </div>
35
+
36
+ <?php while (have_posts()) : the_post(); ?>
37
+ <div class="post">
38
+ <h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php _e( 'Permanent Link to', 'buddypress' ) ?> <?php the_title(); ?>"><?php the_title(); ?></a></h3>
39
+ <small><?php the_time('F j, Y') ?></small>
40
+
41
+ <div class="entry">
42
+ <?php the_content() ?>
43
+ </div>
44
+
45
+ <p class="postmetadata"><?php _e( 'Posted in', 'buddypress' ) ?> <?php the_category(', ') ?> | <?php edit_post_link( __( 'Edit', 'buddypress' ), '', ' | '); ?> <?php comments_popup_link( __( 'No Comments &#187;', 'buddypress' ), __( '1 Comment &#187;', 'buddypress' ), __( '% Comments &#187;', 'buddypress' ) ); ?></p>
46
+
47
+ </div>
48
+
49
+ <?php endwhile; ?>
50
+
51
+ <div class="navigation">
52
+ <div class="alignleft"><?php next_posts_link( __( '&laquo; Previous Entries', 'buddypress' ) ) ?></div>
53
+ <div class="alignright"><?php previous_posts_link( __( 'Next Entries &raquo;', 'buddypress' ) ) ?></div>
54
+ </div>
55
+
56
+ <?php else : ?>
57
+
58
+ <h2 class="center"><?php _e( 'Not Found', 'buddypress' ) ?></h2>
59
+ <?php include (TEMPLATEPATH . '/searchform.php'); ?>
60
+
61
+ <?php endif; ?>
62
+
63
+ </div>
64
+
65
+ </div>
66
+
67
+ <?php get_sidebar(); ?>
68
+
69
+ <?php get_footer(); ?>
bp-themes/bphome/archives.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Template Name: Archives
4
+ */
5
+ ?>
6
+
7
+ <?php get_header(); ?>
8
+
9
+ <div id="content" class="widecolumn">
10
+
11
+ <?php include (TEMPLATEPATH . '/searchform.php'); ?>
12
+
13
+ <h2><?php _e( 'Archives by Month:', 'buddypress' ) ?></h2>
14
+ <ul>
15
+ <?php wp_get_archives('type=monthly'); ?>
16
+ </ul>
17
+
18
+ <h2><?php _e( 'Archives by Subject:', 'buddypress' ) ?></h2>
19
+ <ul>
20
+ <?php wp_list_categories(); ?>
21
+ </ul>
22
+
23
+ </div>
24
+
25
+ <?php get_footer(); ?>
bp-themes/bphome/attachment.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php get_header(); ?>
2
+
3
+ <div id="content" class="widecolumn">
4
+
5
+ <div class="widget" id="latest-news">
6
+ <h2 class="widgettitle"><?php _e( 'Blog', 'buddypress' ) ?></h2>
7
+ <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
8
+
9
+ <?php $attachment_link = get_the_attachment_link($post->ID, true, array(450, 800)); // This also populates the iconsize for the next line ?>
10
+ <?php $_post = &get_post($post->ID); $classname = ($_post->iconsize[0] <= 128 ? 'small' : '') . 'attachment'; // This lets us style narrow icons specially ?>
11
+ <div class="post" id="post-<?php the_ID(); ?>">
12
+ <h2><a href="<?php echo get_permalink($post->post_parent); ?>" rev="attachment"><?php echo get_the_title($post->post_parent); ?></a> &raquo; <a href="<?php echo get_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a></h2>
13
+ <div class="entry">
14
+ <p class="<?php echo $classname; ?>"><?php echo $attachment_link; ?><br /><?php echo basename($post->guid); ?></p>
15
+
16
+ <?php the_content( __('<p class="serif">Read the rest of this entry &raquo;</p>', 'buddypress' ) ); ?>
17
+
18
+ <?php wp_link_pages( array( 'before' => __( '<p><strong>Pages:</strong> ', 'buddypress' ), 'after' => '</p>', 'next_or_number' => 'number')); ?>
19
+
20
+ </div>
21
+ </div>
22
+
23
+ <?php comments_template(); ?>
24
+
25
+ <?php endwhile; else: ?>
26
+
27
+ <p><?php _e( 'Sorry, no attachments matched your criteria.', 'buddypress' ) ?></p>
28
+
29
+ <?php endif; ?>
30
+ </div>
31
+ </div>
32
+
33
+ <?php get_footer(); ?>
bp-themes/bphome/comments-popup.php ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* Don't remove these lines. */
3
+ add_filter('comment_text', 'popuplinks');
4
+ while ( have_posts()) : the_post();
5
+ ?>
6
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
7
+ <html xmlns="http://www.w3.org/1999/xhtml">
8
+ <head>
9
+ <title><?php echo get_option('blogname'); ?> - <?php _e( 'Comments on', 'buddypress' ) ?> <?php the_title(); ?></title>
10
+
11
+ <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
12
+ <style type="text/css" media="screen">
13
+ @import url( <?php bloginfo('stylesheet_url'); ?> );
14
+ body { margin: 3px; }
15
+ </style>
16
+
17
+ </head>
18
+ <body id="commentspopup">
19
+
20
+ <h1 id="header"><a href="" title="<?php echo get_option('blogname'); ?>"><?php echo get_option('blogname'); ?></a></h1>
21
+
22
+ <h2 id="comments"><?php _e( 'Comments', 'buddypress' ) ?></h2>
23
+
24
+ <p><a href="<?php echo get_post_comments_feed_link($post->ID); ?>"><?php _e( '<abbr title="Really Simple Syndication">RSS</abbr> feed for comments on this post.', 'buddypress' ) ?></a></p>
25
+
26
+ <?php if ('open' == $post->ping_status) { ?>
27
+ <p><?php _e( 'The <abbr title="Universal Resource Locator">URL</abbr> to TrackBack this entry is:', 'buddypress' ) ?> <em><?php trackback_url() ?></em></p>
28
+ <?php } ?>
29
+
30
+ <?php
31
+ // this line is WordPress' motor, do not delete it.
32
+ $commenter = wp_get_current_commenter();
33
+ extract($commenter);
34
+ $comments = get_approved_comments($id);
35
+ $post = get_post($id);
36
+ if (!empty($post->post_password) && $_COOKIE['wp-postpass_'. COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie
37
+ echo(get_the_password_form());
38
+ } else { ?>
39
+
40
+ <?php if ($comments) { ?>
41
+ <ol id="commentlist">
42
+ <?php foreach ($comments as $comment) { ?>
43
+ <li id="comment-<?php comment_ID() ?>">
44
+ <?php comment_text() ?>
45
+ <p><cite><?php comment_type('Comment', 'Trackback', 'Pingback'); ?> <?php _e( 'by', 'buddypress' ) ?> <?php comment_author_link() ?> &#8212; <?php comment_date() ?> @ <a href="#comment-<?php comment_ID() ?>"><?php comment_time() ?></a></cite></p>
46
+ </li>
47
+
48
+ <?php } // end for each comment ?>
49
+ </ol>
50
+ <?php } else { // this is displayed if there are no comments so far ?>
51
+ <p><?php _e( 'No comments yet.', 'buddypress' ) ?></p>
52
+ <?php } ?>
53
+
54
+ <?php if ('open' == $post->comment_status) { ?>
55
+ <h2><?php _e( 'Leave a comment', 'buddypress' ) ?></h2>
56
+ <p><?php _e( 'Line and paragraph breaks automatic, e-mail address never displayed, <acronym title="Hypertext Markup Language">HTML</acronym> allowed:', 'buddypress' ) ?> <code><?php echo allowed_tags(); ?></code></p>
57
+
58
+ <form action="<?php echo site_url(); ?>/wp-comments-post.php" method="post" id="commentform">
59
+ <?php if ( $user_ID ) : ?>
60
+ <p><?php _e( 'Logged in as', 'buddypress' ) ?> <a href="<?php echo site_url(); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo site_url(); ?>/wp-login.php?action=logout" title="<?php _e( 'Log out of this account', 'buddypress' ) ?>"><?php _e( 'Logout', 'buddypress' ) ?> &raquo;</a></p>
61
+ <?php else : ?>
62
+ <p>
63
+ <input type="text" name="author" id="author" class="textarea" value="<?php echo $comment_author; ?>" size="28" tabindex="1" />
64
+ <label for="author"><?php _e( 'Name', 'buddypress' ) ?></label>
65
+ <input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
66
+ <input type="hidden" name="redirect_to" value="<?php echo attribute_escape($_SERVER["REQUEST_URI"]); ?>" />
67
+ </p>
68
+
69
+ <p>
70
+ <input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="28" tabindex="2" />
71
+ <label for="email"><?php _e( 'E-mail', 'buddypress' ) ?></label>
72
+ </p>
73
+
74
+ <p>
75
+ <input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="28" tabindex="3" />
76
+ <label for="url"><abbr title="Universal Resource Locator"><?php _e( 'URL', 'buddypress' ) ?></abbr></label>
77
+ </p>
78
+ <?php endif; ?>
79
+
80
+ <p>
81
+ <label for="comment"><?php _e( 'Your Comment', 'buddypress' ) ?></label>
82
+ <br />
83
+ <textarea name="comment" id="comment" cols="70" rows="4" tabindex="4"></textarea>
84
+ </p>
85
+
86
+ <p>
87
+ <input name="submit" type="submit" tabindex="5" value="<?php _e( 'Say It!', 'buddypress