BuddyPress - Version 1.2

Version Description

Download this release

Release Info

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

Code changes from version 1.1.3 to 1.2

Files changed (400) hide show
  1. bp-activity.php +884 -111
  2. bp-activity/bp-activity-classes.php +356 -142
  3. bp-activity/bp-activity-filters.php +98 -1
  4. bp-activity/bp-activity-notifications.php +139 -0
  5. bp-activity/bp-activity-templatetags.php +584 -100
  6. bp-activity/bp-activity-widgets.php +0 -87
  7. bp-activity/deprecated/bp-activity-deprecated.php +0 -95
  8. bp-activity/deprecated/css/structure.css +0 -15
  9. bp-activity/deprecated/images/rss.png +0 -0
  10. bp-activity/feeds/bp-activity-favorites-feed.php +63 -0
  11. bp-activity/feeds/bp-activity-friends-feed.php +22 -8
  12. bp-activity/feeds/bp-activity-group-feed.php +53 -0
  13. bp-activity/feeds/bp-activity-mentions-feed.php +58 -0
  14. bp-activity/feeds/bp-activity-mygroups-feed.php +58 -0
  15. bp-activity/feeds/bp-activity-personal-feed.php +21 -8
  16. bp-activity/feeds/bp-activity-sitewide-feed.php +14 -6
  17. bp-blogs.php +215 -166
  18. bp-blogs/admin-tabs/admin.css +0 -56
  19. bp-blogs/admin-tabs/bp-blogs-comments-tab.php +0 -3
  20. bp-blogs/admin-tabs/bp-blogs-posts-tab.php +0 -3
  21. bp-blogs/admin-tabs/bp-blogs-tab.php +0 -3
  22. bp-blogs/bp-blogs-classes.php +255 -219
  23. bp-blogs/bp-blogs-templatetags.php +323 -1153
  24. bp-blogs/bp-blogs-widgets.php +39 -31
  25. bp-blogs/deprecated/bp-blogs-deprecated.php +0 -105
  26. bp-blogs/deprecated/css/structure.css +0 -84
  27. bp-blogs/deprecated/js/directory-blogs.js +0 -104
  28. bp-core.php +549 -185
  29. bp-core/bp-core-activation.php +38 -32
  30. bp-core/bp-core-admin.php +17 -69
  31. bp-core/bp-core-adminbar.php +137 -166
  32. bp-core/bp-core-avatars.php +83 -55
  33. bp-core/bp-core-catchuri.php +7 -5
  34. bp-core/bp-core-classes.php +246 -103
  35. bp-core/bp-core-cssjs.php +18 -29
  36. bp-core/bp-core-notifications.php +2 -2
  37. bp-core/bp-core-settings.php +24 -15
  38. bp-core/bp-core-signup.php +121 -42
  39. bp-core/bp-core-templatetags.php +788 -610
  40. bp-core/bp-core-widgets.php +42 -118
  41. bp-core/bp-core-wpabstraction.php +157 -0
  42. bp-core/css/widget-members.css +0 -0
  43. bp-core/deprecated/bp-core-deprecated.php +0 -965
  44. bp-core/deprecated/css/admin-bar.css +0 -239
  45. bp-core/deprecated/css/structure.css +0 -322
  46. bp-core/deprecated/images/accept_button_side.gif +0 -0
  47. bp-core/deprecated/images/add_button_side.gif +0 -0
  48. bp-core/deprecated/images/add_friend_button.gif +0 -0
  49. bp-core/deprecated/images/admin-menu-arrow.gif +0 -0
  50. bp-core/deprecated/images/admin_bar_back.gif +0 -0
  51. bp-core/deprecated/images/admin_bar_logo.gif +0 -0
  52. bp-core/deprecated/images/ajax-loader.gif +0 -0
  53. bp-core/deprecated/images/blog.png +0 -0
  54. bp-core/deprecated/images/button_back.gif +0 -0
  55. bp-core/deprecated/images/check_button_side.gif +0 -0
  56. bp-core/deprecated/images/loading_button_side.gif +0 -0
  57. bp-core/deprecated/images/logout_bullet.gif +0 -0
  58. bp-core/deprecated/images/member.png +0 -0
  59. bp-core/deprecated/images/nav_bullet.gif +0 -0
  60. bp-core/deprecated/images/reject_button_side.gif +0 -0
  61. bp-core/deprecated/images/remove_button_side.gif +0 -0
  62. bp-core/deprecated/images/remove_friend_button.gif +0 -0
  63. bp-core/deprecated/images/requested_friend_button.gif +0 -0
  64. bp-core/deprecated/images/view_button_side.gif +0 -0
  65. bp-core/deprecated/js/directory-members.js +0 -111
  66. bp-core/deprecated/js/general.js +0 -100
  67. bp-core/deprecated/js/jquery/jquery.livequery.pack.js +0 -9
  68. bp-core/deprecated/js/jquery/jquery.tablednd.js +0 -314
  69. bp-core/images/Jcrop.gif +0 -0
  70. bp-core/images/admin_menu_icon.png +0 -0
  71. bp-core/images/mystery-man.jpg +0 -0
  72. bp-core/js/admin-bar.js +0 -9
  73. bp-core/js/widget-members.js +12 -12
  74. bp-forums.php +176 -34
  75. bp-forums/bb-config.php +1 -1
  76. bp-forums/bp-forums-admin.php +19 -10
  77. bp-forums/bp-forums-bbpress.php +2 -1
  78. bp-forums/bp-forums-filters.php +30 -10
  79. bp-forums/bp-forums-templatetags.php +141 -87
  80. bp-forums/deprecated/images/closed.png +0 -0
  81. bp-friends.php +158 -238
  82. bp-friends/bp-friends-classes.php +12 -20
  83. bp-friends/bp-friends-notifications.php +13 -7
  84. bp-friends/bp-friends-templatetags.php +138 -381
  85. bp-friends/deprecated/bp-friends-deprecated.php +0 -102
  86. bp-friends/deprecated/css/structure.css +0 -28
  87. bp-friends/deprecated/images/ajax-loader.gif +0 -0
  88. bp-friends/deprecated/js/general.js +0 -73
  89. bp-groups.php +635 -783
  90. bp-groups/bp-groups-admin.php +0 -129
  91. bp-groups/bp-groups-classes.php +313 -240
  92. bp-groups/bp-groups-filters.php +25 -24
  93. bp-groups/bp-groups-notifications.php +116 -84
  94. bp-groups/bp-groups-templatetags.php +432 -814
  95. bp-groups/bp-groups-widgets.php +14 -14
  96. bp-groups/deprecated/bp-groups-deprecated.php +0 -842
  97. bp-groups/deprecated/css/structure.css +0 -38
  98. bp-groups/deprecated/images/ajax-loader.gif +0 -0
  99. bp-groups/deprecated/images/none-thumbnail.gif +0 -0
  100. bp-groups/deprecated/images/none.gif +0 -0
  101. bp-groups/deprecated/js/directory-groups.js +0 -138
  102. bp-groups/deprecated/js/general.js +0 -196
  103. bp-groups/js/widget-groups.js +12 -12
  104. bp-languages/buddypress.pot +2010 -2554
  105. bp-loader.php +50 -18
  106. bp-messages.php +65 -51
  107. bp-messages/bp-messages-classes.php +115 -223
  108. bp-messages/bp-messages-cssjs.php +0 -0
  109. bp-messages/bp-messages-filters.php +4 -1
  110. bp-messages/bp-messages-notifications.php +19 -52
  111. bp-messages/bp-messages-templatetags.php +103 -132
  112. bp-messages/css/autocomplete/jquery.autocompletefb.css +21 -21
  113. bp-messages/deprecated/bp-messages-deprecated.php +0 -305
  114. bp-messages/deprecated/css/structure.css +0 -96
  115. bp-messages/deprecated/images/ajax-loader.gif +0 -0
  116. bp-messages/deprecated/images/email.gif +0 -0
  117. bp-messages/deprecated/images/email_draft.gif +0 -0
  118. bp-messages/deprecated/images/email_open.gif +0 -0
  119. bp-messages/deprecated/images/email_sent.gif +0 -0
  120. bp-messages/deprecated/images/loading.gif +0 -0
  121. bp-messages/deprecated/images/nav_bullet.gif +0 -0
  122. bp-messages/deprecated/images/warning.gif +0 -0
  123. bp-messages/deprecated/js/general.js +0 -297
  124. bp-messages/js/autocomplete/jquery.autocomplete.js +59 -59
  125. bp-messages/js/autocomplete/jquery.autocompletefb.js +0 -0
  126. bp-messages/js/autocomplete/jquery.bgiframe.min.js +0 -0
  127. bp-messages/js/autocomplete/jquery.dimensions.js +0 -0
  128. bp-status.php +0 -169
  129. bp-status/bp-status-filters.php +0 -20
  130. bp-status/bp-status-templatetags.php +0 -112
  131. bp-status/bp-status-widgets.php +0 -0
  132. bp-themes/{bp-sn-parent → bp-default}/404.php +4 -2
  133. bp-themes/bp-default/_inc/ajax.php +562 -0
  134. bp-themes/bp-default/_inc/css/adminbar.css +169 -99
  135. bp-themes/bp-default/_inc/css/default.css +1750 -0
  136. bp-themes/bp-default/_inc/css/reset.css +64 -0
  137. bp-themes/bp-default/_inc/css/screen.css +0 -2284
  138. bp-themes/bp-default/_inc/global.js +1245 -0
  139. bp-themes/bp-default/_inc/images/45pc_black.png +0 -0
  140. bp-themes/bp-default/_inc/images/60pc_black.png +0 -0
  141. bp-themes/bp-default/_inc/images/accept_button.gif +0 -0
  142. bp-themes/bp-default/_inc/images/accept_button_side.gif +0 -0
  143. bp-themes/bp-default/_inc/images/activity_arrow.gif +0 -0
  144. bp-themes/bp-default/_inc/images/activity_bullet.gif +0 -0
  145. bp-themes/bp-default/_inc/images/add_button_side.gif +0 -0
  146. bp-themes/bp-default/_inc/images/add_friend_button.gif +0 -0
  147. bp-themes/bp-default/_inc/images/add_friend_icon.gif +0 -0
  148. bp-themes/bp-default/_inc/images/admin-menu-arrow.gif +0 -0
  149. bp-themes/bp-default/_inc/images/admin_bar_back.gif +0 -0
  150. bp-themes/bp-default/_inc/images/admin_bar_logo.gif +0 -0
  151. bp-themes/bp-default/_inc/images/admin_menu_icon.png +0 -0
  152. bp-themes/bp-default/_inc/images/ajax-loader.gif +0 -0
  153. bp-themes/bp-default/_inc/images/arrowback_icon.gif +0 -0
  154. bp-themes/bp-default/_inc/images/background.gif +0 -0
  155. bp-themes/bp-default/_inc/images/background_blog.gif +0 -0
  156. bp-themes/bp-default/_inc/images/blog.png +0 -0
  157. bp-themes/bp-default/_inc/images/blog_bullet.gif +0 -0
  158. bp-themes/bp-default/_inc/images/blogadmin_icon.gif +0 -0
  159. bp-themes/bp-default/_inc/images/bp_logo.gif +0 -0
  160. bp-themes/bp-default/_inc/images/button_back.gif +0 -0
  161. bp-themes/bp-default/_inc/images/centercol_header_back.gif +0 -0
  162. bp-themes/bp-default/_inc/images/check_button_side.gif +0 -0
  163. bp-themes/bp-default/_inc/images/closed.png +0 -0
  164. bp-themes/bp-default/_inc/images/comments_icon.gif +0 -0
  165. bp-themes/bp-default/_inc/images/content_back.gif +0 -0
  166. bp-themes/bp-default/_inc/images/content_header.gif +0 -0
  167. bp-themes/bp-default/_inc/images/create_account_button.gif +0 -0
  168. bp-themes/bp-default/_inc/images/cross_bullet.gif +0 -0
  169. bp-themes/bp-default/_inc/images/default_header.jpg +0 -0
  170. bp-themes/bp-default/_inc/images/error_back.gif +0 -0
  171. bp-themes/bp-default/_inc/images/error_icon.gif +0 -0
  172. bp-themes/bp-default/_inc/images/forum_bullet.gif +0 -0
  173. bp-themes/bp-default/_inc/images/friends_bullet.gif +0 -0
  174. bp-themes/bp-default/_inc/images/group_header.gif +0 -0
  175. bp-themes/bp-default/_inc/images/groups_bullet.gif +0 -0
  176. bp-themes/bp-default/_inc/images/info_icon.gif +0 -0
  177. bp-themes/bp-default/_inc/images/invite_bullet.gif +0 -0
  178. bp-themes/bp-default/_inc/images/{item_list_back.gif → item_back.gif} +0 -0
  179. bp-themes/bp-default/_inc/images/leftcol_header_back.gif +0 -0
  180. bp-themes/bp-default/_inc/images/leftmenu_group_header.gif +0 -0
  181. bp-themes/bp-default/_inc/images/loading_button_side.gif +0 -0
  182. bp-themes/bp-default/_inc/images/logo.gif +0 -0
  183. bp-themes/bp-default/_inc/images/logout_bullet.gif +0 -0
  184. bp-themes/bp-default/_inc/images/member.png +0 -0
  185. bp-themes/bp-default/_inc/images/message_thread_back.gif +0 -0
  186. bp-themes/bp-default/_inc/images/message_thread_unread_back.gif +0 -0
  187. bp-themes/bp-default/_inc/images/messages_bullet.gif +0 -0
  188. bp-themes/bp-default/_inc/images/mystery-man.jpg +0 -0
  189. bp-themes/bp-default/_inc/images/nav_bullet.gif +0 -0
  190. bp-themes/bp-default/_inc/images/navitem_selected_back.gif +0 -0
  191. bp-themes/bp-default/_inc/images/notice_back.gif +0 -0
  192. bp-themes/bp-default/_inc/images/optionnavitem_selected_back.gif +0 -0
  193. bp-themes/bp-default/_inc/images/optionsbar_header_arrow.gif +0 -0
  194. bp-themes/bp-default/_inc/images/optionsbar_header_noarrow.gif +0 -0
  195. bp-themes/bp-default/_inc/images/profile_bullet.gif +0 -0
  196. bp-themes/bp-default/_inc/images/quotes_background.gif +0 -0
  197. bp-themes/bp-default/_inc/images/reject_button.gif +0 -0
  198. bp-themes/bp-default/_inc/images/reject_button_side.gif +0 -0
  199. bp-themes/bp-default/_inc/images/remove_button_side.gif +0 -0
  200. bp-themes/bp-default/_inc/images/remove_friend_button.gif +0 -0
  201. bp-themes/bp-default/_inc/images/replyto_arrow.gif +0 -0
  202. bp-themes/bp-default/_inc/images/request_bullet.gif +0 -0
  203. bp-themes/bp-default/_inc/images/requested_friend_button.gif +0 -0
  204. bp-themes/bp-default/_inc/images/rightcol_header_back.gif +0 -0
  205. bp-themes/bp-default/_inc/images/rss.png +0 -0
  206. bp-themes/bp-default/_inc/images/settings_bullet.gif +0 -0
  207. bp-themes/bp-default/_inc/images/sidebar_back.gif +0 -0
  208. bp-themes/bp-default/_inc/images/sidebar_header.gif +0 -0
  209. bp-themes/bp-default/_inc/images/status_bullet.gif +0 -0
  210. bp-themes/bp-default/_inc/images/tag_icon.gif +0 -0
  211. bp-themes/bp-default/_inc/images/topoption_selected_back.gif +0 -0
  212. bp-themes/bp-default/_inc/images/updated_back.gif +0 -0
  213. bp-themes/bp-default/_inc/images/updated_icon.gif +0 -0
  214. bp-themes/bp-default/_inc/images/userbar_header.gif +0 -0
  215. bp-themes/bp-default/_inc/images/userbar_selected_arrow.gif +0 -0
  216. bp-themes/bp-default/_inc/images/view_button_side.gif +0 -0
  217. bp-themes/bp-default/_inc/images/welcome_header_back.gif +0 -0
  218. bp-themes/bp-default/_inc/images/white-grad.png +0 -0
  219. bp-themes/bp-default/_inc/images/wire_bullet.gif +0 -0
  220. bp-themes/bp-default/_inc/options.php +55 -0
  221. bp-themes/bp-default/activity/activity-loop.php +45 -0
  222. bp-themes/bp-default/activity/entry.php +76 -0
  223. bp-themes/bp-default/activity/index.php +104 -0
  224. bp-themes/bp-default/activity/post-form.php +62 -0
  225. bp-themes/bp-default/archive.php +73 -0
  226. bp-themes/{bp-sn-parent → bp-default}/attachment.php +2 -2
  227. bp-themes/bp-default/blogs/blogs-loop.php +64 -0
  228. bp-themes/bp-default/blogs/create.php +36 -0
  229. bp-themes/bp-default/blogs/index.php +55 -0
  230. bp-themes/{bp-sn-parent → bp-default}/comments.php +71 -32
  231. bp-themes/{bp-sn-parent → bp-default}/footer.php +2 -5
  232. bp-themes/{bp-sn-parent/directories → bp-default}/forums/forums-loop.php +21 -11
  233. bp-themes/bp-default/forums/index.php +111 -0
  234. bp-themes/bp-default/functions.php +239 -0
  235. bp-themes/bp-default/groups/create.php +262 -0
  236. bp-themes/bp-default/groups/groups-loop.php +60 -0
  237. bp-themes/bp-default/groups/index.php +57 -0
  238. bp-themes/bp-default/groups/single/activity.php +38 -0
  239. bp-themes/bp-default/groups/single/admin.php +312 -0
  240. bp-themes/bp-default/groups/single/forum.php +53 -0
  241. bp-themes/bp-default/groups/single/forum/edit.php +68 -0
  242. bp-themes/bp-default/groups/single/forum/topic.php +111 -0
  243. bp-themes/bp-default/groups/single/group-header.php +46 -0
  244. bp-themes/bp-default/groups/single/home.php +67 -0
  245. bp-themes/bp-default/groups/single/members.php +54 -0
  246. bp-themes/bp-default/groups/single/plugins.php +38 -0
  247. bp-themes/bp-default/groups/single/request-membership.php +18 -0
  248. bp-themes/bp-default/groups/single/send-invites.php +77 -0
  249. bp-themes/bp-default/header.php +107 -0
  250. bp-themes/bp-default/index.php +65 -0
  251. bp-themes/{bp-sn-parent → bp-default}/links.php +3 -1
  252. bp-themes/bp-default/members/index.php +60 -0
  253. bp-themes/bp-default/members/members-loop.php +75 -0
  254. bp-themes/bp-default/members/single/activity.php +48 -0
  255. bp-themes/bp-default/members/single/activity/permalink.php +17 -0
  256. bp-themes/bp-default/members/single/blogs.php +24 -0
  257. bp-themes/bp-default/members/single/friends.php +34 -0
  258. bp-themes/bp-default/members/single/friends/requests.php +41 -0
  259. bp-themes/bp-default/members/single/groups.php +37 -0
  260. bp-themes/bp-default/members/single/groups/invites.php +39 -0
  261. bp-themes/bp-default/members/single/home.php +56 -0
  262. bp-themes/bp-default/members/single/member-header.php +56 -0
  263. bp-themes/bp-default/members/single/messages.php +29 -0
  264. bp-themes/bp-default/members/single/messages/compose.php +38 -0
  265. bp-themes/bp-default/members/single/messages/messages-loop.php +73 -0
  266. bp-themes/bp-default/members/single/messages/notices-loop.php +54 -0
  267. bp-themes/bp-default/members/single/messages/single.php +98 -0
  268. bp-themes/bp-default/members/single/plugins.php +45 -0
  269. bp-themes/bp-default/members/single/profile.php +24 -0
  270. bp-themes/bp-default/members/single/profile/change-avatar.php +60 -0
  271. bp-themes/bp-default/members/single/profile/edit.php +117 -0
  272. bp-themes/{bp-sn-parent → bp-default/members/single}/profile/profile-loop.php +13 -18
  273. bp-themes/{bp-sn-parent → bp-default}/page.php +8 -6
  274. bp-themes/bp-default/registration/activate.php +58 -0
  275. bp-themes/{bp-sn-parent → bp-default}/registration/register.php +43 -26
  276. bp-themes/bp-default/rtl.css +743 -0
  277. bp-themes/bp-default/screenshot.png +0 -0
  278. bp-themes/bp-default/search.php +71 -0
  279. bp-themes/{bp-sn-parent → bp-default}/searchform.php +0 -0
  280. bp-themes/bp-default/sidebar.php +76 -0
  281. bp-themes/bp-default/single.php +59 -0
  282. bp-themes/bp-default/style.css +16 -17
  283. bp-themes/bp-sn-parent/_inc/ajax.php +0 -448
  284. bp-themes/bp-sn-parent/_inc/css/adminbar.css +0 -138
  285. bp-themes/bp-sn-parent/_inc/css/components.css +0 -550
  286. bp-themes/bp-sn-parent/_inc/css/fonts/12px.css +0 -293
  287. bp-themes/bp-sn-parent/_inc/css/fonts/14px.css +0 -292
  288. bp-themes/bp-sn-parent/_inc/css/fonts/18px.css +0 -292
  289. bp-themes/bp-sn-parent/_inc/css/fonts/20px.css +0 -292
  290. bp-themes/bp-sn-parent/_inc/css/fonts/22px.css +0 -292
  291. bp-themes/bp-sn-parent/_inc/css/layout/blog-dir-pages/2c-center.css +0 -10
  292. bp-themes/bp-sn-parent/_inc/css/layout/blog-dir-pages/2c-left.css +0 -18
  293. bp-themes/bp-sn-parent/_inc/css/layout/blog-dir-pages/2c-right.css +0 -18
  294. bp-themes/bp-sn-parent/_inc/css/layout/home-page/1c.css +0 -3
  295. bp-themes/bp-sn-parent/_inc/css/layout/home-page/2c-center.css +0 -11
  296. bp-themes/bp-sn-parent/_inc/css/layout/home-page/2c-left.css +0 -11
  297. bp-themes/bp-sn-parent/_inc/css/layout/home-page/2c-right.css +0 -11
  298. bp-themes/bp-sn-parent/_inc/css/layout/home-page/3c-center.css +0 -16
  299. bp-themes/bp-sn-parent/_inc/css/layout/home-page/3c-left.css +0 -15
  300. bp-themes/bp-sn-parent/_inc/css/layout/home-page/3c-right.css +0 -15
  301. bp-themes/bp-sn-parent/_inc/css/layout/internal-pages/1c.css +0 -27
  302. bp-themes/bp-sn-parent/_inc/css/layout/internal-pages/2c-left.css +0 -36
  303. bp-themes/bp-sn-parent/_inc/css/layout/internal-pages/2c-right.css +0 -36
  304. bp-themes/bp-sn-parent/_inc/css/layout/internal-pages/3c-left.css +0 -19
  305. bp-themes/bp-sn-parent/_inc/css/layout/internal-pages/3c-right.css +0 -19
  306. bp-themes/bp-sn-parent/_inc/css/screen.css +0 -155
  307. bp-themes/bp-sn-parent/_inc/images/admin_bar_logo.gif +0 -0
  308. bp-themes/bp-sn-parent/_inc/images/ajax-loader.gif +0 -0
  309. bp-themes/bp-sn-parent/_inc/images/closed_topic.png +0 -0
  310. bp-themes/bp-sn-parent/_inc/images/mystery-man.jpg +0 -0
  311. bp-themes/bp-sn-parent/_inc/js/ajax.js +0 -1141
  312. bp-themes/bp-sn-parent/_inc/js/jquery-livequery.js +0 -9
  313. bp-themes/bp-sn-parent/activity/just-me.php +0 -73
  314. bp-themes/bp-sn-parent/activity/my-friends.php +0 -74
  315. bp-themes/bp-sn-parent/archive.php +0 -65
  316. bp-themes/bp-sn-parent/blogs/create.php +0 -32
  317. bp-themes/bp-sn-parent/blogs/my-blogs.php +0 -44
  318. bp-themes/bp-sn-parent/blogs/recent-comments.php +0 -45
  319. bp-themes/bp-sn-parent/blogs/recent-posts.php +0 -49
  320. bp-themes/bp-sn-parent/directories/blogs/blogs-loop.php +0 -60
  321. bp-themes/bp-sn-parent/directories/blogs/index.php +0 -130
  322. bp-themes/bp-sn-parent/directories/forums/index.php +0 -121
  323. bp-themes/bp-sn-parent/directories/groups/groups-loop.php +0 -60
  324. bp-themes/bp-sn-parent/directories/groups/index.php +0 -138
  325. bp-themes/bp-sn-parent/directories/members/index.php +0 -125
  326. bp-themes/bp-sn-parent/directories/members/members-loop.php +0 -54
  327. bp-themes/bp-sn-parent/friends/friends-loop.php +0 -74
  328. bp-themes/bp-sn-parent/friends/index.php +0 -31
  329. bp-themes/bp-sn-parent/friends/requests.php +0 -65
  330. bp-themes/bp-sn-parent/functions.php +0 -70
  331. bp-themes/bp-sn-parent/groups/create.php +0 -241
  332. bp-themes/bp-sn-parent/groups/group-loop.php +0 -75
  333. bp-themes/bp-sn-parent/groups/index.php +0 -29
  334. bp-themes/bp-sn-parent/groups/invites.php +0 -62
  335. bp-themes/bp-sn-parent/groups/single/admin.php +0 -340
  336. bp-themes/bp-sn-parent/groups/single/forum/edit.php +0 -100
  337. bp-themes/bp-sn-parent/groups/single/forum/index.php +0 -105
  338. bp-themes/bp-sn-parent/groups/single/forum/topic.php +0 -123
  339. bp-themes/bp-sn-parent/groups/single/home.php +0 -201
  340. bp-themes/bp-sn-parent/groups/single/leave-confirm.php +0 -50
  341. bp-themes/bp-sn-parent/groups/single/members.php +0 -121
  342. bp-themes/bp-sn-parent/groups/single/menu.php +0 -33
  343. bp-themes/bp-sn-parent/groups/single/request-membership.php +0 -56
  344. bp-themes/bp-sn-parent/groups/single/send-invite.php +0 -102
  345. bp-themes/bp-sn-parent/groups/single/wire.php +0 -41
  346. bp-themes/bp-sn-parent/header.php +0 -119
  347. bp-themes/bp-sn-parent/home.php +0 -44
  348. bp-themes/bp-sn-parent/index.php +0 -58
  349. bp-themes/bp-sn-parent/messages/compose.php +0 -51
  350. bp-themes/bp-sn-parent/messages/index.php +0 -76
  351. bp-themes/bp-sn-parent/messages/notices.php +0 -67
  352. bp-themes/bp-sn-parent/messages/sentbox.php +0 -69
  353. bp-themes/bp-sn-parent/messages/view.php +0 -110
  354. bp-themes/bp-sn-parent/optionsbar.php +0 -25
  355. bp-themes/bp-sn-parent/plugin-template.php +0 -13
  356. bp-themes/bp-sn-parent/profile/change-avatar.php +0 -76
  357. bp-themes/bp-sn-parent/profile/edit.php +0 -127
  358. bp-themes/bp-sn-parent/profile/index.php +0 -150
  359. bp-themes/bp-sn-parent/profile/profile-header.php +0 -17
  360. bp-themes/bp-sn-parent/profile/profile-menu.php +0 -23
  361. bp-themes/bp-sn-parent/registration/activate.php +0 -55
  362. bp-themes/bp-sn-parent/screenshot.png +0 -0
  363. bp-themes/bp-sn-parent/search.php +0 -59
  364. bp-themes/bp-sn-parent/sidebar.php +0 -18
  365. bp-themes/bp-sn-parent/single.php +0 -54
  366. bp-themes/bp-sn-parent/status/post-form.php +0 -20
  367. bp-themes/bp-sn-parent/style.css +0 -22
  368. bp-themes/bp-sn-parent/userbar.php +0 -49
  369. bp-themes/bp-sn-parent/wire/latest.php +0 -30
  370. bp-themes/bp-sn-parent/wire/post-form.php +0 -48
  371. bp-themes/bp-sn-parent/wire/post-list.php +0 -77
  372. bp-wire.php +0 -141
  373. bp-wire/bp-wire-classes.php +0 -119
  374. bp-wire/bp-wire-filters.php +0 -31
  375. bp-wire/bp-wire-templatetags.php +0 -394
  376. bp-wire/deprecated/bp-wire-deprecated.php +0 -101
  377. bp-wire/deprecated/css/structure.css +0 -34
  378. bp-wire/deprecated/images/ajax-loader.gif +0 -0
  379. bp-xprofile.php +90 -279
  380. bp-xprofile/admin/css/admin.css +0 -0
  381. bp-xprofile/admin/images/move.gif +0 -0
  382. bp-xprofile/admin/images/tick.gif +0 -0
  383. bp-xprofile/admin/js/admin.js +0 -0
  384. bp-xprofile/bp-xprofile-admin.php +6 -7
  385. bp-xprofile/bp-xprofile-classes.php +118 -49
  386. bp-xprofile/bp-xprofile-cssjs.php +0 -0
  387. bp-xprofile/bp-xprofile-filters.php +39 -2
  388. bp-xprofile/bp-xprofile-notifications.php +0 -59
  389. bp-xprofile/bp-xprofile-templatetags.php +36 -51
  390. bp-xprofile/deprecated/bp-xprofile-deprecated.php +0 -833
  391. bp-xprofile/deprecated/css/signup.css +0 -0
  392. bp-xprofile/deprecated/css/structure.css +0 -82
  393. bp-xprofile/deprecated/images/cross.gif +0 -0
  394. bp-xprofile/deprecated/images/nav_bullet.gif +0 -0
  395. bp-xprofile/deprecated/images/none-thumbnail.gif +0 -0
  396. bp-xprofile/deprecated/images/none.gif +0 -0
  397. bp-xprofile/deprecated/js/general.js +0 -0
  398. favicon.ico +0 -0
  399. license.txt +0 -0
  400. readme.txt +34 -37
bp-activity.php CHANGED
@@ -1,6 +1,6 @@
1
<?php
2
3
- define ( 'BP_ACTIVITY_DB_VERSION', '1800' );
4
5
/* Define the slug for the component */
6
if ( !defined( 'BP_ACTIVITY_SLUG' ) )
@@ -8,46 +8,67 @@ if ( !defined( 'BP_ACTIVITY_SLUG' ) )
8
9
require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-classes.php' );
10
require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-templatetags.php' );
11
- require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-widgets.php' );
12
require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-filters.php' );
13
14
- /* Include deprecated functions if settings allow */
15
- if ( !defined( 'BP_IGNORE_DEPRECATED' ) )
16
- require ( BP_PLUGIN_DIR . '/bp-activity/deprecated/bp-activity-deprecated.php' );
17
-
18
function bp_activity_install() {
19
global $wpdb, $bp;
20
21
if ( !empty($wpdb->charset) )
22
$charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
23
24
$sql[] = "CREATE TABLE {$bp->activity->table_name} (
25
id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
26
user_id bigint(20) NOT NULL,
27
- component_name varchar(75) NOT NULL,
28
- component_action varchar(75) NOT NULL,
29
content longtext NOT NULL,
30
primary_link varchar(150) NOT NULL,
31
item_id varchar(75) NOT NULL,
32
- secondary_item_id varchar(75) NOT NULL,
33
date_recorded datetime NOT NULL,
34
hide_sitewide bool DEFAULT 0,
35
KEY date_recorded (date_recorded),
36
KEY user_id (user_id),
37
KEY item_id (item_id),
38
- KEY component_name (component_name)
39
) {$charset_collate};";
40
41
require_once( ABSPATH . 'wp-admin/upgrade-functions.php' );
42
dbDelta($sql);
43
44
- /* Drop the old sitewide and user activity tables */
45
- $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->base_prefix}bp_activity_user_activity" );
46
- $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->base_prefix}bp_activity_sitewide" );
47
-
48
- /* TODO: Rename the old user activity cached table */
49
- //$wpdb->query( "RENAME TABLE {$wpdb->base_prefix}bp_activity_user_activity_cached TO {$bp->activity->table_name}" );
50
-
51
update_site_option( 'bp-activity-db-version', BP_ACTIVITY_DB_VERSION );
52
}
53
@@ -57,21 +78,22 @@ function bp_activity_setup_globals() {
57
/* Internal identifier */
58
$bp->activity->id = 'activity';
59
60
- $bp->activity->table_name = $wpdb->base_prefix . 'bp_activity_user_activity_cached';
61
$bp->activity->slug = BP_ACTIVITY_SLUG;
62
63
/* Register this in the active components array */
64
$bp->active_components[$bp->activity->slug] = $bp->activity->id;
65
66
do_action( 'bp_activity_setup_globals' );
67
}
68
- add_action( 'plugins_loaded', 'bp_activity_setup_globals', 5 );
69
- add_action( 'admin_menu', 'bp_activity_setup_globals', 2 );
70
71
function bp_activity_check_installed() {
72
global $wpdb, $bp;
73
74
- if ( get_site_option('bp-activity-db-version') < BP_ACTIVITY_DB_VERSION )
75
bp_activity_install();
76
}
77
add_action( 'admin_menu', 'bp_activity_check_installed' );
@@ -80,7 +102,7 @@ function bp_activity_setup_root_component() {
80
/* Register 'activity' as a root component (for RSS feed use) */
81
bp_core_add_root_component( BP_ACTIVITY_SLUG );
82
}
83
- add_action( 'plugins_loaded', 'bp_activity_setup_root_component' );
84
85
function bp_activity_setup_nav() {
86
global $bp;
@@ -88,14 +110,24 @@ function bp_activity_setup_nav() {
88
/* Add 'Activity' to the main navigation */
89
bp_core_new_nav_item( array( 'name' => __( 'Activity', 'buddypress' ), 'slug' => $bp->activity->slug, 'position' => 10, 'screen_function' => 'bp_activity_screen_my_activity', 'default_subnav_slug' => 'just-me', 'item_css_id' => $bp->activity->id ) );
90
91
- $activity_link = $bp->loggedin_user->domain . $bp->activity->slug . '/';
92
93
- /* Add the subnav items to the activity nav item */
94
- bp_core_new_subnav_item( array( 'name' => __( 'Just Me', 'buddypress' ), 'slug' => 'just-me', 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->slug, 'screen_function' => 'bp_activity_screen_my_activity', 'position' => 10 ) );
95
- bp_core_new_subnav_item( array( 'name' => __( 'My Friends', 'buddypress' ), 'slug' => 'my-friends', 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->slug, 'screen_function' => 'bp_activity_screen_friends_activity', 'position' => 20, 'item_css_id' => 'activity-my-friends' ) );
96
97
if ( $bp->current_component == $bp->activity->slug ) {
98
- if ( bp_is_home() ) {
99
$bp->bp_options_title = __( 'My Activity', 'buddypress' );
100
} else {
101
$bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) );
@@ -105,9 +137,21 @@ function bp_activity_setup_nav() {
105
106
do_action( 'bp_activity_setup_nav' );
107
}
108
- add_action( 'plugins_loaded', 'bp_activity_setup_nav' );
109
add_action( 'admin_menu', 'bp_activity_setup_nav' );
110
111
112
/********************************************************************************
113
* Screen Functions
@@ -119,20 +163,127 @@ add_action( 'admin_menu', 'bp_activity_setup_nav' );
119
120
function bp_activity_screen_my_activity() {
121
do_action( 'bp_activity_screen_my_activity' );
122
- bp_core_load_template( apply_filters( 'bp_activity_template_my_activity', 'activity/just-me' ) );
123
}
124
125
- function bp_activity_screen_friends_activity() {
126
global $bp;
127
128
- /* Make sure delete links do not show for friends activity items */
129
if ( !is_site_admin() )
130
$bp->is_item_admin = false;
131
132
- do_action( 'bp_activity_screen_friends_activity' );
133
- bp_core_load_template( apply_filters( 'bp_activity_template_friends_activity', 'activity/my-friends' ) );
134
}
135
136
137
/********************************************************************************
138
* Action Functions
@@ -142,6 +293,41 @@ function bp_activity_screen_friends_activity() {
142
* back to the default screen after execution.
143
*/
144
145
function bp_activity_action_delete_activity() {
146
global $bp;
147
@@ -155,32 +341,134 @@ function bp_activity_action_delete_activity() {
155
check_admin_referer( 'bp_activity_delete_link' );
156
157
$activity_id = $bp->action_variables[0];
158
159
/* Check access */
160
- if ( !is_site_admin() ) {
161
- $activity = new BP_Activity_Activity( $activity_id );
162
163
- if ( $activity->user_id != $bp->loggedin_user->id )
164
- return false;
165
- }
166
167
/* Now delete the activity item */
168
- if ( bp_activity_delete_by_activity_id( $activity_id ) )
169
bp_core_add_message( __( 'Activity deleted', 'buddypress' ) );
170
else
171
bp_core_add_message( __( 'There was an error when deleting that activity', 'buddypress' ), 'error' );
172
173
- do_action( 'bp_activity_action_delete_activity', $activity_id );
174
-
175
- bp_core_redirect( $_SERVER['HTTP_REFERER'] );
176
}
177
add_action( 'wp', 'bp_activity_action_delete_activity', 3 );
178
179
180
function bp_activity_action_sitewide_feed() {
181
global $bp, $wp_query;
182
183
- if ( $bp->current_component != $bp->activity->slug || $bp->current_action != 'feed' || $bp->displayed_user->id )
184
return false;
185
186
$wp_query->is_404 = false;
@@ -208,7 +496,7 @@ add_action( 'wp', 'bp_activity_action_personal_feed', 3 );
208
function bp_activity_action_friends_feed() {
209
global $bp, $wp_query;
210
211
- if ( $bp->current_component != $bp->activity->slug || !$bp->displayed_user->id || $bp->current_action != 'my-friends' || $bp->action_variables[0] != 'feed' )
212
return false;
213
214
$wp_query->is_404 = false;
@@ -219,6 +507,47 @@ function bp_activity_action_friends_feed() {
219
}
220
add_action( 'wp', 'bp_activity_action_friends_feed', 3 );
221
222
223
/********************************************************************************
224
* Business Functions
@@ -229,35 +558,99 @@ add_action( 'wp', 'bp_activity_action_friends_feed', 3 );
229
* true or false on success or failure.
230
*/
231
232
function bp_activity_add( $args = '' ) {
233
global $bp, $wpdb;
234
235
$defaults = array(
236
- 'content' => false, // The content of the activity item
237
- 'primary_link' => false, // The primary URL for this item in RSS feeds
238
- 'component_name' => false, // The name/ID of the component e.g. groups, profile, mycomponent
239
- 'component_action' => false, // The component action e.g. new_wire_post, profile_updated
240
241
'user_id' => $bp->loggedin_user->id, // Optional: The user to record the activity for, can be false if this activity is not for a user.
242
- 'item_id' => false, // Optional: The ID of the specific item being recorded, e.g. a blog_id, or wire_post_id
243
'secondary_item_id' => false, // Optional: A second ID used to further filter e.g. a comment_id
244
- 'recorded_time' => time(), // The time that this activity was recorded
245
'hide_sitewide' => false // Should this be hidden on the sitewide activity stream?
246
);
247
248
- $r = wp_parse_args( $args, $defaults );
249
- extract( $r, EXTR_SKIP );
250
251
- /* Insert the "time-since" placeholder */
252
- if ( $content )
253
- $content = bp_activity_add_timesince_placeholder( $content );
254
255
- $activity = new BP_Activity_Activity;
256
$activity->user_id = $user_id;
257
$activity->content = $content;
258
$activity->primary_link = $primary_link;
259
- $activity->component_name = $component_name;
260
- $activity->component_action = $component_action;
261
$activity->item_id = $item_id;
262
$activity->secondary_item_id = $secondary_item_id;
263
$activity->date_recorded = $recorded_time;
@@ -266,85 +659,302 @@ function bp_activity_add( $args = '' ) {
266
if ( !$activity->save() )
267
return false;
268
269
- do_action( 'bp_activity_add', $args );
270
271
- return true;
272
- }
273
274
- /* There are multiple ways to delete activity items, depending on the information you have at the time. */
275
276
- function bp_activity_delete_by_item_id( $args = '' ) {
277
global $bp;
278
279
$defaults = array(
280
- 'item_id' => false,
281
- 'component_name' => false,
282
- 'component_action' => false, // optional
283
- 'user_id' => false, // optional
284
- 'secondary_item_id' => false // optional
285
);
286
287
$r = wp_parse_args( $args, $defaults );
288
extract( $r, EXTR_SKIP );
289
290
- if ( !BP_Activity_Activity::delete_by_item_id( $item_id, $component_name, $component_action, $user_id, $secondary_item_id ) )
291
return false;
292
293
- do_action( 'bp_activity_delete_by_item_id', $item_id, $component_name, $component_action, $user_id, $secondary_item_id );
294
295
- return true;
296
}
297
298
- function bp_activity_delete_by_activity_id( $activity_id ) {
299
- if ( !BP_Activity_Activity::delete_by_activity_id( $activity_id ) )
300
return false;
301
302
- do_action( 'bp_activity_delete_by_activity_id', $activity_id );
303
304
- return true;
305
}
306
307
- function bp_activity_delete_by_content( $user_id, $content, $component_name, $component_action ) {
308
- /* Insert the "time-since" placeholder to match the existing content in the DB */
309
- $content = bp_activity_add_timesince_placeholder( $content );
310
311
- if ( !BP_Activity_Activity::delete_by_content( $user_id, $content, $component_name, $component_action ) )
312
return false;
313
314
- do_action( 'bp_activity_delete_by_content', $user_id, $content, $component_name, $component_action );
315
316
return true;
317
}
318
319
- function bp_activity_delete_for_user_by_component( $user_id, $component_name ) {
320
- if ( !BP_Activity_Activity::delete_for_user_by_component( $user_id, $component_name ) )
321
return false;
322
323
- do_action( 'bp_activity_delete_for_user_by_component', $user_id, $component_name );
324
325
return true;
326
}
327
-
328
- function bp_activity_add_timesince_placeholder( $content ) {
329
- /* Check a time-since span doesn't already exist */
330
- if ( false === strpos( $content, '<span class="time-since">' ) ) {
331
- if ( !$pos = strpos( $content, '<blockquote' ) ) {
332
- if ( !$pos = strpos( $content, '<div' ) ) {
333
- if ( !$pos = strpos( $content, '<ul' ) ) {
334
- $content .= ' <span class="time-since">%s</span>';
335
- }
336
- }
337
}
338
}
339
340
- if ( (int) $pos ) {
341
- $before = substr( $content, 0, (int) $pos );
342
- $after = substr( $content, (int) $pos, strlen( $content ) );
343
344
- $content = $before . ' <span class="time-since">%s</span>' . $after;
345
}
346
347
- return apply_filters( 'bp_activity_add_timesince_placeholder', $content );
348
}
349
350
function bp_activity_set_action( $component_id, $key, $value ) {
@@ -368,10 +978,69 @@ function bp_activity_get_action( $component_id, $key ) {
368
return apply_filters( 'bp_activity_get_action', $bp->activity->actions->{$component_id}->{$key}, $component_id, $key );
369
}
370
371
- function bp_activity_check_exists_by_content( $content ) {
372
- /* Insert the "time-since" placeholder to match the existing content in the DB */
373
- $content = bp_activity_add_timesince_placeholder( $content );
374
375
return apply_filters( 'bp_activity_check_exists_by_content', BP_Activity_Activity::check_exists_by_content( $content ) );
376
}
377
@@ -379,21 +1048,115 @@ function bp_activity_get_last_updated() {
379
return apply_filters( 'bp_activity_get_last_updated', BP_Activity_Activity::get_last_updated() );
380
}
381
382
- function bp_activity_get_sitewide_activity( $max_items = 30, $pag_num = false, $pag_page = false, $filter = false ) {
383
- return apply_filters( 'bp_activity_get_sitewide_activity', BP_Activity_Activity::get_sitewide_activity( $max_items, $pag_num, $pag_page, $filter ), $max_items, $pag_num, $pag_page, $filter );
384
}
385
386
- function bp_activity_get_user_activity( $user_id, $max_items = 30, $pag_num = false, $pag_page = false, $filter = false ) {
387
- return apply_filters( 'bp_activity_get_user_activity', BP_Activity_Activity::get_activity_for_user( $user_id, $max_items, $pag_num, $pag_page, $filter ), $user_id, $max_items, $pag_num, $pag_page, $filter );
388
}
389
390
- function bp_activity_get_friends_activity( $user_id, $max_items = 30, $max_items_per_friend = false, $pag_num = false, $pag_page = false, $filter = false ) {
391
- return apply_filters( 'bp_activity_get_friends_activity', BP_Activity_Activity::get_activity_for_friends( $user_id, $max_items, $max_items_per_friend, $pag_num, $pag_page, $filter ), $user_id, $max_items, $max_items_per_friend, $pag_num, $pag_page, $filter );
392
}
393
394
function bp_activity_remove_data( $user_id ) {
395
// Clear the user's activity from the sitewide stream and clear their activity tables
396
- BP_Activity_Activity::delete_for_user( $user_id );
397
398
do_action( 'bp_activity_remove_data', $user_id );
399
}
@@ -401,9 +1164,19 @@ add_action( 'wpmu_delete_user', 'bp_activity_remove_data' );
401
add_action( 'delete_user', 'bp_activity_remove_data' );
402
add_action( 'make_spam_user', 'bp_activity_remove_data' );
403
404
- /* Ordering function - don't call this directly */
405
- function bp_activity_order_by_date( $a, $b ) {
406
- return apply_filters( 'bp_activity_order_by_date', strcasecmp( $b['date_recorded'], $a['date_recorded'] ) );
407
}
408
409
?>
1
<?php
2
3
+ define ( 'BP_ACTIVITY_DB_VERSION', '2060' );
4
5
/* Define the slug for the component */
6
if ( !defined( 'BP_ACTIVITY_SLUG' ) )
8
9
require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-classes.php' );
10
require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-templatetags.php' );
11
require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-filters.php' );
12
13
function bp_activity_install() {
14
global $wpdb, $bp;
15
16
if ( !empty($wpdb->charset) )
17
$charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
18
19
+ /* Rename the old user activity cached table if needed. */
20
+ if ( $wpdb->get_var( "SHOW TABLES LIKE '%{$wpdb->base_prefix}bp_activity_user_activity_cached%'" ) )
21
+ $wpdb->query( "RENAME TABLE {$wpdb->base_prefix}bp_activity_user_activity_cached TO {$bp->activity->table_name}" );
22
+
23
+ /* Rename fields from pre BP 1.2 */
24
+ if ( $wpdb->get_var( "SHOW TABLES LIKE '%{$bp->activity->table_name}%'" ) ) {
25
+ if ( $wpdb->get_var( "SHOW COLUMNS FROM {$bp->activity->table_name} LIKE 'component_action'" ) )
26
+ $wpdb->query( "ALTER TABLE {$bp->activity->table_name} CHANGE component_action type varchar(75) NOT NULL" );
27
+
28
+ if ( $wpdb->get_var( "SHOW COLUMNS FROM {$bp->activity->table_name} LIKE 'component_name'" ) )
29
+ $wpdb->query( "ALTER TABLE {$bp->activity->table_name} CHANGE component_name component varchar(75) NOT NULL" );
30
+ }
31
+
32
+ /**
33
+ * Build the tables
34
+ */
35
$sql[] = "CREATE TABLE {$bp->activity->table_name} (
36
id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
37
user_id bigint(20) NOT NULL,
38
+ component varchar(75) NOT NULL,
39
+ type varchar(75) NOT NULL,
40
+ action text NOT NULL,
41
content longtext NOT NULL,
42
primary_link varchar(150) NOT NULL,
43
item_id varchar(75) NOT NULL,
44
+ secondary_item_id varchar(75) DEFAULT NULL,
45
date_recorded datetime NOT NULL,
46
hide_sitewide bool DEFAULT 0,
47
+ mptt_left int(11) NOT NULL,
48
+ mptt_right int(11) NOT NULL,
49
KEY date_recorded (date_recorded),
50
KEY user_id (user_id),
51
KEY item_id (item_id),
52
+ KEY secondary_item_id (secondary_item_id),
53
+ KEY component (component),
54
+ KEY type (type),
55
+ KEY mptt_left (mptt_left),
56
+ KEY mptt_right (mptt_right),
57
+ KEY hide_sitewide (hide_sitewide)
58
) {$charset_collate};";
59
60
+ $sql[] = "CREATE TABLE {$bp->activity->table_name_meta} (
61
+ id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
62
+ activity_id bigint(20) NOT NULL,
63
+ meta_key varchar(255) DEFAULT NULL,
64
+ meta_value longtext DEFAULT NULL,
65
+ KEY activity_id (activity_id),
66
+ KEY meta_key (meta_key)
67
+ ) {$charset_collate};";
68
+
69
require_once( ABSPATH . 'wp-admin/upgrade-functions.php' );
70
dbDelta($sql);
71
72
update_site_option( 'bp-activity-db-version', BP_ACTIVITY_DB_VERSION );
73
}
74
78
/* Internal identifier */
79
$bp->activity->id = 'activity';
80
81
+ $bp->activity->table_name = $wpdb->base_prefix . 'bp_activity';
82
+ $bp->activity->table_name_meta = $wpdb->base_prefix . 'bp_activity_meta';
83
$bp->activity->slug = BP_ACTIVITY_SLUG;
84
+ $bp->activity->format_notification_function = 'bp_activity_format_notifications';
85
86
/* Register this in the active components array */
87
$bp->active_components[$bp->activity->slug] = $bp->activity->id;
88
89
do_action( 'bp_activity_setup_globals' );
90
}
91
+ add_action( 'bp_setup_globals', 'bp_activity_setup_globals' );
92
93
function bp_activity_check_installed() {
94
global $wpdb, $bp;
95
96
+ if ( $bp->site_options['bp-activity-db-version'] < BP_ACTIVITY_DB_VERSION )
97
bp_activity_install();
98
}
99
add_action( 'admin_menu', 'bp_activity_check_installed' );
102
/* Register 'activity' as a root component (for RSS feed use) */
103
bp_core_add_root_component( BP_ACTIVITY_SLUG );
104
}
105
+ add_action( 'bp_setup_root_components', 'bp_activity_setup_root_component' );
106
107
function bp_activity_setup_nav() {
108
global $bp;
110
/* Add 'Activity' to the main navigation */
111
bp_core_new_nav_item( array( 'name' => __( 'Activity', 'buddypress' ), 'slug' => $bp->activity->slug, 'position' => 10, 'screen_function' => 'bp_activity_screen_my_activity', 'default_subnav_slug' => 'just-me', 'item_css_id' => $bp->activity->id ) );
112
113
+ $user_domain = ( !empty( $bp->displayed_user->domain ) ) ? $bp->displayed_user->domain : $bp->loggedin_user->domain;
114
+ $user_login = ( !empty( $bp->displayed_user->userdata->user_login ) ) ? $bp->displayed_user->userdata->user_login : $bp->loggedin_user->userdata->user_login;
115
+ $activity_link = $user_domain . $bp->activity->slug . '/';
116
+
117
+ /* Add the subnav items to the activity nav item if we are using a theme that supports this */
118
+ bp_core_new_subnav_item( array( 'name' => __( 'Personal', 'buddypress' ), 'slug' => 'just-me', 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->slug, 'screen_function' => 'bp_activity_screen_my_activity', 'position' => 10 ) );
119
+
120
+ if ( bp_is_active( 'friends' ) )
121
+ bp_core_new_subnav_item( array( 'name' => __( 'Friends', 'buddypress' ), 'slug' => BP_FRIENDS_SLUG, 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->slug, 'screen_function' => 'bp_activity_screen_friends', 'position' => 20, 'item_css_id' => 'activity-friends' ) );
122
+
123
+ if ( bp_is_active( 'groups' ) )
124
+ bp_core_new_subnav_item( array( 'name' => __( 'Groups', 'buddypress' ), 'slug' => BP_GROUPS_SLUG, 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->slug, 'screen_function' => 'bp_activity_screen_groups', 'position' => 30, 'item_css_id' => 'activity-groups' ) );
125
126
+ bp_core_new_subnav_item( array( 'name' => __( 'Favorites', 'buddypress' ), 'slug' => 'favorites', 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->slug, 'screen_function' => 'bp_activity_screen_favorites', 'position' => 40, 'item_css_id' => 'activity-favs' ) );
127
+ bp_core_new_subnav_item( array( 'name' => sprintf( __( '@%s Mentions', 'buddypress' ), $user_login ), 'slug' => 'mentions', 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->slug, 'screen_function' => 'bp_activity_screen_mentions', 'position' => 50, 'item_css_id' => 'activity-mentions' ) );
128
129
if ( $bp->current_component == $bp->activity->slug ) {
130
+ if ( bp_is_my_profile() ) {
131
$bp->bp_options_title = __( 'My Activity', 'buddypress' );
132
} else {
133
$bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) );
137
138
do_action( 'bp_activity_setup_nav' );
139
}
140
+ add_action( 'bp_setup_nav', 'bp_activity_setup_nav' );
141
add_action( 'admin_menu', 'bp_activity_setup_nav' );
142
143
+ function bp_activity_directory_activity_setup() {
144
+ global $bp;
145
+
146
+ if ( $bp->current_component == $bp->activity->slug && empty( $bp->current_action ) ) {
147
+ $bp->is_directory = true;
148
+
149
+ do_action( 'bp_activity_directory_activity_setup' );
150
+ bp_core_load_template( apply_filters( 'bp_activity_directory_activity_setup', 'activity/index' ) );
151
+ }
152
+ }
153
+ add_action( 'wp', 'bp_activity_directory_activity_setup', 2 );
154
+
155
156
/********************************************************************************
157
* Screen Functions
163
164
function bp_activity_screen_my_activity() {
165
do_action( 'bp_activity_screen_my_activity' );
166
+ bp_core_load_template( apply_filters( 'bp_activity_template_my_activity', 'members/single/home' ) );
167
}
168
169
+ function bp_activity_screen_friends() {
170
global $bp;
171
172
+ if ( !bp_is_active( 'friends' ) )
173
+ return false;
174
+
175
if ( !is_site_admin() )
176
$bp->is_item_admin = false;
177
178
+ do_action( 'bp_activity_screen_friends' );
179
+ bp_core_load_template( apply_filters( 'bp_activity_template_friends_activity', 'members/single/home' ) );
180
}
181
182
+ function bp_activity_screen_groups() {
183
+ global $bp;
184
+
185
+ if ( !bp_is_active( 'groups' ) )
186
+ return false;
187
+
188
+ if ( !is_site_admin() )
189
+ $bp->is_item_admin = false;
190
+
191
+ do_action( 'bp_activity_screen_groups' );
192
+ bp_core_load_template( apply_filters( 'bp_activity_template_groups_activity', 'members/single/home' ) );
193
+ }
194
+
195
+ function bp_activity_screen_favorites() {
196
+ global $bp;
197
+
198
+ if ( !is_site_admin() )
199
+ $bp->is_item_admin = false;
200
+
201
+ do_action( 'bp_activity_screen_favorites' );
202
+ bp_core_load_template( apply_filters( 'bp_activity_template_favorite_activity', 'members/single/home' ) );
203
+ }
204
+
205
+ function bp_activity_screen_mentions() {
206
+ global $bp;
207
+
208
+ if ( !is_site_admin() )
209
+ $bp->is_item_admin = false;
210
+
211
+ do_action( 'bp_activity_screen_mentions' );
212
+ bp_core_load_template( apply_filters( 'bp_activity_template_mention_activity', 'members/single/home' ) );
213
+ }
214
+
215
+ function bp_activity_screen_single_activity_permalink() {
216
+ global $bp;
217
+
218
+ if ( !$bp->displayed_user->id || $bp->current_component != $bp->activity->slug )
219
+ return false;
220
+
221
+ if ( empty( $bp->current_action ) || !is_numeric( $bp->current_action ) )
222
+ return false;
223
+
224
+ /* Get the activity details */
225
+ $activity = bp_activity_get_specific( array( 'activity_ids' => $bp->current_action ) );
226
+
227
+ if ( !$activity = $activity['activities'][0] )
228
+ bp_core_redirect( $bp->root_domain );
229
+
230
+ $has_access = true;
231
+ /* Redirect based on the type of activity */
232
+ if ( $activity->component == $bp->groups->id ) {
233
+ if ( !function_exists( 'groups_get_group' ) )
234
+ bp_core_redirect( $bp->root_domain );
235
+
236
+ if ( $group = groups_get_group( array( 'group_id' => $activity->item_id ) ) ) {
237
+ /* Check to see if the group is not public, if so, check the user has access to see this activity */
238
+ if ( 'public' != $group->status ) {
239
+ if ( !groups_is_user_member( $bp->loggedin_user->id, $group->id ) )
240
+ $has_access = false;
241
+ }
242
+ }
243
+ }
244
+
245
+ $has_access = apply_filters( 'bp_activity_permalink_access', $has_access, &$activity );
246
+
247
+ do_action( 'bp_activity_screen_single_activity_permalink', $activity, $has_access );
248
+
249
+ if ( !$has_access ) {
250
+ bp_core_add_message( __( 'You do not have access to this activity.', 'buddypress' ), 'error' );
251
+ bp_core_redirect( $bp->loggedin_user->domain );
252
+ }
253
+
254
+ bp_core_load_template( apply_filters( 'bp_activity_template_profile_activity_permalink', 'members/single/activity/permalink' ) );
255
+ }
256
+ /* This screen is not attached to a nav item, so we need to add an action for it. */
257
+ add_action( 'wp', 'bp_activity_screen_single_activity_permalink', 3 );
258
+
259
+ function bp_activity_screen_notification_settings() {
260
+ global $bp; ?>
261
+ <table class="notification-settings" id="activity-notification-settings">
262
+ <tr>
263
+ <th class="icon"></th>
264
+ <th class="title"><?php _e( 'Activity', 'buddypress' ) ?></th>
265
+ <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th>
266
+ <th class="no"><?php _e( 'No', 'buddypress' )?></th>
267
+ </tr>
268
+
269
+ <tr>
270
+ <td></td>
271
+ <td><?php printf( __( 'A member mentions you in an update using "@%s"', 'buddypress' ), bp_core_get_username( $bp->loggedin_user->id, $bp->loggedin_user->userdata->user_nicename, $bp->loggedin_user->userdata->user_login ) ) ?></td>
272
+ <td class="yes"><input type="radio" name="notifications[notification_activity_new_mention]" value="yes" <?php if ( !get_usermeta( $bp->loggedin_user->id, 'notification_activity_new_mention' ) || 'yes' == get_usermeta( $bp->loggedin_user->id, 'notification_activity_new_mention' ) ) { ?>checked="checked" <?php } ?>/></td>
273
+ <td class="no"><input type="radio" name="notifications[notification_activity_new_mention]" value="no" <?php if ( 'no' == get_usermeta( $bp->loggedin_user->id, 'notification_activity_new_mention' ) ) { ?>checked="checked" <?php } ?>/></td>
274
+ </tr>
275
+ <tr>
276
+ <td></td>
277
+ <td><?php printf( __( "A member replies to an update or comment you've posted", 'buddypress' ), $current_user->user_login ) ?></td>
278
+ <td class="yes"><input type="radio" name="notifications[notification_activity_new_reply]" value="yes" <?php if ( !get_usermeta( $bp->loggedin_user->id, 'notification_activity_new_reply' ) || 'yes' == get_usermeta( $bp->loggedin_user->id, 'notification_activity_new_reply' ) ) { ?>checked="checked" <?php } ?>/></td>
279
+ <td class="no"><input type="radio" name="notifications[notification_activity_new_reply]" value="no" <?php if ( 'no' == get_usermeta( $bp->loggedin_user->id, 'notification_activity_new_reply' ) ) { ?>checked="checked" <?php } ?>/></td>
280
+ </tr>
281
+
282
+ <?php do_action( 'bp_activity_screen_notification_settings' ) ?>
283
+ </table>
284
+ <?php
285
+ }
286
+ add_action( 'bp_notification_settings', 'bp_activity_screen_notification_settings', 1 );
287
288
/********************************************************************************
289
* Action Functions
293
* back to the default screen after execution.
294
*/
295
296
+ function bp_activity_action_permalink_router() {
297
+ global $bp;
298
+
299
+ if ( $bp->current_component != $bp->activity->slug || $bp->current_action != 'p' )
300
+ return false;
301
+
302
+ if ( empty( $bp->action_variables[0] ) || !is_numeric( $bp->action_variables[0] ) )
303
+ return false;
304
+
305
+ /* Get the activity details */
306
+ $activity = bp_activity_get_specific( array( 'activity_ids' => $bp->action_variables[0] ) );
307
+
308
+ if ( !$activity = $activity['activities'][0] )
309
+ bp_core_redirect( $bp->root_domain );
310
+
311
+ $redirect = false;
312
+ /* Redirect based on the type of activity */
313
+ if ( $activity->component == $bp->groups->id ) {
314
+ if ( $activity->user_id )
315
+ $redirect = bp_core_get_user_domain( $activity->user_id, $activity->user_nicename, $activity->user_login ) . $bp->activity->slug . '/' . $activity->id;
316
+ else {
317
+ if ( $group = groups_get_group( array( 'group_id' => $activity->item_id ) ) )
318
+ $redirect = bp_get_group_permalink( $group ) . $bp->activity->slug . '/' . $activity->id;
319
+ }
320
+ } else
321
+ $redirect = bp_core_get_user_domain( $activity->user_id, $activity->user_nicename, $activity->user_login ) . $bp->activity->slug . '/' . $activity->id;
322
+
323
+ if ( !$redirect )
324
+ bp_core_redirect( $bp->root_domain );
325
+
326
+ /* Redirect to the actual activity permalink page */
327
+ bp_core_redirect( apply_filters( 'bp_activity_action_permalink_url', $redirect . '/', &$activity ) );
328
+ }
329
+ add_action( 'wp', 'bp_activity_action_permalink_router', 3 );
330
+
331
function bp_activity_action_delete_activity() {
332
global $bp;
333
341
check_admin_referer( 'bp_activity_delete_link' );
342
343
$activity_id = $bp->action_variables[0];
344
+ $activity = new BP_Activity_Activity( $activity_id );
345
346
/* Check access */
347
+ if ( !is_site_admin() && $activity->user_id != $bp->loggedin_user->id )
348
+ return false;
349
350
+ /* Call the action before the delete so plugins can still fetch information about it */
351
+ do_action( 'bp_activity_action_delete_activity', $activity_id, $activity->user_id );
352
353
/* Now delete the activity item */
354
+ if ( bp_activity_delete( array( 'id' => $activity_id, 'user_id' => $activity->user_id ) ) )
355
bp_core_add_message( __( 'Activity deleted', 'buddypress' ) );
356
else
357
bp_core_add_message( __( 'There was an error when deleting that activity', 'buddypress' ), 'error' );
358
359
+ bp_core_redirect( wp_get_referer() );
360
}
361
add_action( 'wp', 'bp_activity_action_delete_activity', 3 );
362
363
+ function bp_activity_action_post_update() {
364
+ global $bp;
365
+
366
+ if ( !is_user_logged_in() || $bp->current_component != $bp->activity->slug || $bp->current_action != 'post' )
367
+ return false;
368
+
369
+ /* Check the nonce */
370
+ check_admin_referer( 'post_update', '_wpnonce_post_update' );
371
+
372
+ $content = apply_filters( 'bp_activity_post_update_content', $_POST['whats-new'] );
373
+ $object = apply_filters( 'bp_activity_post_update_object', $_POST['whats-new-post-object'] );
374
+ $item_id = apply_filters( 'bp_activity_post_update_item_id', $_POST['whats-new-post-in'] );
375
+
376
+ if ( empty( $content ) ) {
377
+ bp_core_add_message( __( 'Please enter some content to post.', 'buddypress' ), 'error' );
378
+ bp_core_redirect( wp_get_referer() );
379
+ }
380
+
381
+ if ( !(int)$item_id ) {
382
+ $activity_id = bp_activity_post_update( array( 'content' => $content ) );
383
+
384
+ } else if ( 'groups' == $object && function_exists( 'groups_post_update' ) ) {
385
+ if ( (int)$item_id ) {
386
+ $activity_id = groups_post_update( array( 'content' => $content, 'group_id' => $item_id ) );
387
+ }
388
+ } else
389
+ $activity_id = apply_filters( 'bp_activity_custom_update', $object, $item_id, $content );
390
+
391
+ if ( !empty( $activity_id ) )
392
+ bp_core_add_message( __( 'Update Posted!', 'buddypress' ) );
393
+ else
394
+ bp_core_add_message( __( 'There was an error when posting your update, please try again.', 'buddypress' ), 'error' );
395
+
396
+ bp_core_redirect( wp_get_referer() );
397
+ }
398
+ add_action( 'wp', 'bp_activity_action_post_update', 3 );
399
+
400
+ function bp_activity_action_post_comment() {
401
+ global $bp;
402
+
403
+ if ( !is_user_logged_in() || $bp->current_component != $bp->activity->slug || $bp->current_action != 'reply' )
404
+ return false;
405
+
406
+ /* Check the nonce */
407
+ check_admin_referer( 'new_activity_comment', '_wpnonce_new_activity_comment' );
408
+
409
+ $activity_id = apply_filters( 'bp_activity_post_comment_activity_id', $_POST['comment_form_id'] );
410
+ $content = apply_filters( 'bp_activity_post_comment_content', $_POST['ac_input_' . $activity_id] );
411
+
412
+ if ( empty( $content ) ) {
413
+ bp_core_add_message( __( 'Please do not leave the comment area blank.', 'buddypress' ), 'error' );
414
+ bp_core_redirect( wp_get_referer() . '#ac-form-' . $activity_id );
415
+ }
416
+
417
+ $comment_id = bp_activity_new_comment( array(
418
+ 'content' => $content,
419
+ 'activity_id' => $activity_id,
420
+ 'parent_id' => $parent_id
421
+ ));
422
+
423
+ if ( !empty( $comment_id ) )
424
+ bp_core_add_message( __( 'Reply Posted!', 'buddypress' ) );
425
+ else
426
+ bp_core_add_message( __( 'There was an error posting that reply, please try again.', 'buddypress' ), 'error' );
427
+
428
+ bp_core_redirect( wp_get_referer() . '#ac-form-' . $activity_id );
429
+ }
430
+ add_action( 'wp', 'bp_activity_action_post_comment', 3 );
431
+
432
+ function bp_activity_action_mark_favorite() {
433
+ global $bp;
434
+
435
+ if ( !is_user_logged_in() || $bp->current_component != $bp->activity->slug || $bp->current_action != 'favorite' )
436
+ return false;
437
+
438
+ /* Check the nonce */
439
+ check_admin_referer( 'mark_favorite' );
440
+
441
+ if ( bp_activity_add_user_favorite( $bp->action_variables[0] ) )
442
+ bp_core_add_message( __( 'Activity marked as favorite.', 'buddypress' ) );
443
+ else
444
+ bp_core_add_message( __( 'There was an error marking that activity as a favorite, please try again.', 'buddypress' ), 'error' );
445
+
446
+ bp_core_redirect( wp_get_referer() . '#activity-' . $bp->action_variables[0] );
447
+ }
448
+ add_action( 'wp', 'bp_activity_action_mark_favorite', 3 );
449
+
450
+ function bp_activity_action_remove_favorite() {
451
+ global $bp;
452
+
453
+ if ( !is_user_logged_in() || $bp->current_component != $bp->activity->slug || $bp->current_action != 'unfavorite' )
454
+ return false;
455
+
456
+ /* Check the nonce */
457
+ check_admin_referer( 'unmark_favorite' );
458
+
459
+ if ( bp_activity_remove_user_favorite( $bp->action_variables[0] ) )
460
+ bp_core_add_message( __( 'Activity removed as favorite.', 'buddypress' ) );
461
+ else
462
+ bp_core_add_message( __( 'There was an error removing that activity as a favorite, please try again.', 'buddypress' ), 'error' );
463
+
464
+ bp_core_redirect( wp_get_referer() . '#activity-' . $bp->action_variables[0] );
465
+ }
466
+ add_action( 'wp', 'bp_activity_action_remove_favorite', 3 );
467
468
function bp_activity_action_sitewide_feed() {
469
global $bp, $wp_query;
470
471
+ if ( $bp->current_component != $bp->activity->slug || $bp->current_action != 'feed' || $bp->displayed_user->id || $bp->groups->current_group )
472
return false;
473
474
$wp_query->is_404 = false;
496
function bp_activity_action_friends_feed() {
497
global $bp, $wp_query;
498
499
+ if ( $bp->current_component != $bp->activity->slug || !$bp->displayed_user->id || $bp->current_action != 'friends' || $bp->action_variables[0] != 'feed' )
500
return false;
501
502
$wp_query->is_404 = false;
507
}
508
add_action( 'wp', 'bp_activity_action_friends_feed', 3 );
509
510
+ function bp_activity_action_my_groups_feed() {
511
+ global $bp, $wp_query;
512
+
513
+ if ( $bp->current_component != $bp->activity->slug || !$bp->displayed_user->id || $bp->current_action != 'groups' || $bp->action_variables[0] != 'feed' )
514
+ return false;
515
+
516
+ $wp_query->is_404 = false;
517
+ status_header( 200 );
518
+
519
+ include_once( 'bp-activity/feeds/bp-activity-mygroups-feed.php' );
520
+ die;
521
+ }
522
+ add_action( 'wp', 'bp_activity_action_my_groups_feed', 3 );
523
+
524
+ function bp_activity_action_mentions_feed() {
525
+ global $bp, $wp_query;
526
+
527
+ if ( $bp->current_component != $bp->activity->slug || !$bp->displayed_user->id || $bp->current_action != 'mentions' || $bp->action_variables[0] != 'feed' )
528
+ return false;
529
+
530
+ $wp_query->is_404 = false;
531
+ status_header( 200 );
532
+
533
+ include_once( 'bp-activity/feeds/bp-activity-mentions-feed.php' );
534
+ die;
535
+ }
536
+ add_action( 'wp', 'bp_activity_action_mentions_feed', 3 );
537
+
538
+ function bp_activity_action_favorites_feed() {
539
+ global $bp, $wp_query;
540
+
541
+ if ( $bp->current_component != $bp->activity->slug || !$bp->displayed_user->id || $bp->current_action != 'favorites' || $bp->action_variables[0] != 'feed' )
542
+ return false;
543
+
544
+ $wp_query->is_404 = false;
545
+ status_header( 200 );
546
+
547
+ include_once( 'bp-activity/feeds/bp-activity-favorites-feed.php' );
548
+ die;
549
+ }
550
+ add_action( 'wp', 'bp_activity_action_favorites_feed', 3 );
551
552
/********************************************************************************
553
* Business Functions
558
* true or false on success or failure.
559
*/
560
561
+ function bp_activity_get( $args = '' ) {
562
+ $defaults = array(
563
+ 'max' => false, // Maximum number of results to return
564
+ 'page' => 1, // page 1 without a per_page will result in no pagination.
565
+ 'per_page' => false, // results per page
566
+ 'sort' => 'DESC', // sort ASC or DESC
567
+ 'display_comments' => false, // false for no comments. 'stream' for within stream display, 'threaded' for below each activity item
568
+
569
+ 'search_terms' => false, // Pass search terms as a string
570
+ 'show_hidden' => false, // Show activity items that are hidden site-wide?
571
+
572
+ /**
573
+ * Pass filters as an array -- all filter items can be multiple values comma separated:
574
+ * array(
575
+ * 'user_id' => false, // user_id to filter on
576
+ * 'object' => false, // object to filter on e.g. groups, profile, status, friends
577
+ * 'action' => false, // action to filter on e.g. activity_update, profile_updated
578
+ * 'primary_id' => false, // object ID to filter on e.g. a group_id or forum_id or blog_id etc.
579
+ * 'secondary_id' => false, // secondary object ID to filter on e.g. a post_id
580
+ * );
581
+ */
582
+ 'filter' => array()
583
+ );
584
+
585
+ $r = wp_parse_args( $args, $defaults );
586
+ extract( $r, EXTR_SKIP );
587
+
588
+ /* Attempt to return a cached copy of the first page of sitewide activity. */
589
+ if ( 1 == (int)$page && empty( $max ) && empty( $search_terms ) && empty( $filter ) && 'DESC' == $sort ) {
590
+ if ( !$activity = wp_cache_get( 'bp_activity_sitewide_front', 'bp' ) ) {
591
+ $activity = BP_Activity_Activity::get( $max, $page, $per_page, $sort, $search_terms, $filter, $display_comments, $show_hidden );
592
+ wp_cache_set( 'bp_activity_sitewide_front', BP_Activity_Activity::get( $max, $page, $per_page, $sort, $search_terms, $filter, $display_comments, $show_hidden ), 'bp' );
593
+ }
594
+ } else
595
+ $activity = BP_Activity_Activity::get( $max, $page, $per_page, $sort, $search_terms, $filter, $display_comments, $show_hidden );
596
+
597
+ return apply_filters( 'bp_activity_get', $activity, &$r );
598
+ }
599
+
600
+ function bp_activity_get_specific( $args = '' ) {
601
+ $defaults = array(
602
+ 'activity_ids' => false, // A single activity_id or array of IDs.
603
+ 'page' => 1, // page 1 without a per_page will result in no pagination.
604
+ 'per_page' => false, // results per page
605
+ 'max' => false, // Maximum number of results to return
606
+ 'sort' => 'DESC', // sort ASC or DESC
607
+ 'display_comments' => false // true or false to display threaded comments for these specific activity items
608
+ );
609
+
610
+ $r = wp_parse_args( $args, $defaults );
611
+ extract( $r, EXTR_SKIP );
612
+
613
+ return apply_filters( 'bp_activity_get_specific', BP_Activity_Activity::get_specific( $activity_ids, $max, $page, $per_page, $sort, $display_comments ) );
614
+ }
615
+
616
function bp_activity_add( $args = '' ) {
617
global $bp, $wpdb;
618
619
$defaults = array(
620
+ 'id' => false, // Pass an existing activity ID to update an existing entry.
621
+
622
+ 'action' => '', // The activity action - e.g. "Jon Doe posted an update"
623
+ 'content' => '', // Optional: The content of the activity item e.g. "BuddyPress is awesome guys!"
624
+
625
+ 'component' => false, // The name/ID of the component e.g. groups, profile, mycomponent
626
+ 'type' => false, // The activity type e.g. activity_update, profile_updated
627
+ 'primary_link' => '', // Optional: The primary URL for this item in RSS feeds (defaults to activity permalink)
628
629
'user_id' => $bp->loggedin_user->id, // Optional: The user to record the activity for, can be false if this activity is not for a user.
630
+ 'item_id' => false, // Optional: The ID of the specific item being recorded, e.g. a blog_id
631
'secondary_item_id' => false, // Optional: A second ID used to further filter e.g. a comment_id
632
+ 'recorded_time' => gmdate( "Y-m-d H:i:s" ), // The GMT time that this activity was recorded
633
'hide_sitewide' => false // Should this be hidden on the sitewide activity stream?
634
);
635
636
+ $params = wp_parse_args( $args, $defaults );
637
+ extract( $params, EXTR_SKIP );
638
+
639
+ /* Make sure we are backwards compatible */
640
+ if ( empty( $component ) && !empty( $component_name ) )
641
+ $component = $component_name;
642
643
+ if ( empty( $type ) && !empty( $component_action ) )
644
+ $type = $component_action;
645
+
646
+ $activity = new BP_Activity_Activity( $id );
647
648
$activity->user_id = $user_id;
649
+ $activity->component = $component;
650
+ $activity->type = $type;
651
+ $activity->action = $action;
652
$activity->content = $content;
653
$activity->primary_link = $primary_link;
654
$activity->item_id = $item_id;
655
$activity->secondary_item_id = $secondary_item_id;
656
$activity->date_recorded = $recorded_time;
659
if ( !$activity->save() )
660
return false;
661
662
+ /* If this is an activity comment, rebuild the tree */
663
+ if ( 'activity_comment' == $activity->type )
664
+ BP_Activity_Activity::rebuild_activity_comment_tree( $activity->item_id );
665
666
+ wp_cache_delete( 'bp_activity_sitewide_front', 'bp' );
667
+ do_action( 'bp_activity_add', $params );
668
669
+ return $activity->id;
670
+ }
671
672
+ function bp_activity_post_update( $args = '' ) {
673
global $bp;
674
675
$defaults = array(
676
+ 'content' => false,
677
+ 'user_id' => $bp->loggedin_user->id
678
);
679
680
$r = wp_parse_args( $args, $defaults );
681
extract( $r, EXTR_SKIP );
682
683
+ if ( empty( $content ) || !strlen( trim( $content ) ) )
684
return false;
685
686
+ /* Record this on the user's profile */
687
+ $from_user_link = bp_core_get_userlink( $user_id );
688
+ $activity_action = sprintf( __( '%s posted an update:', 'buddypress' ), $from_user_link );
689
+ $activity_content = $content;
690
691
+ $primary_link = bp_core_get_userlink( $user_id, false, true );
692
+
693
+ /* Now write the values */
694
+ $activity_id = bp_activity_add( array(
695
+ 'user_id' => $user_id,
696
+ 'action' => apply_filters( 'bp_activity_new_update_action', $activity_action ),
697
+ 'content' => apply_filters( 'bp_activity_new_update_content', $activity_content ),
698
+ 'primary_link' => apply_filters( 'bp_activity_new_update_primary_link', $primary_link ),
699
+ 'component' => $bp->activity->id,
700
+ 'type' => 'activity_update'
701
+ ) );
702
+
703
+ /* Add this update to the "latest update" usermeta so it can be fetched anywhere. */
704
+ update_usermeta( $bp->loggedin_user->id, 'bp_latest_update', array( 'id' => $activity_id, 'content' => wp_filter_kses( $content ) ) );
705
+
706
+ /* Require the notifications code so email notifications can be set on the 'bp_activity_posted_update' action. */
707
+ require_once( BP_PLUGIN_DIR . '/bp-activity/bp-activity-notifications.php' );
708
+
709
+ do_action( 'bp_activity_posted_update', $content, $user_id, $activity_id );
710
+
711
+ return $activity_id;
712
}
713
714
+ function bp_activity_new_comment( $args = '' ) {
715
+ global $bp;
716
+
717
+ $defaults = array(
718
+ 'content' => false,
719
+ 'user_id' => $bp->loggedin_user->id,
720
+ 'activity_id' => false, // ID of the root activity item
721
+ 'parent_id' => false // ID of a parent comment (optional)
722
+ );
723
+
724
+ $params = wp_parse_args( $args, $defaults );
725
+ extract( $params, EXTR_SKIP );
726
+
727
+ if ( empty($content) || empty($user_id) || empty($activity_id) )
728
return false;
729
730
+ if ( empty($parent_id) )
731
+ $parent_id = $activity_id;
732
733
+ /* Check to see if the parent activity is hidden, and if so, hide this comment publically. */
734
+ $activity = new BP_Activity_Activity( $activity_id );
735
+ $is_hidden = ( (int)$activity->hide_sitewide ) ? 1 : 0;
736
+
737
+ /* Insert the activity comment */
738
+ $comment_id = bp_activity_add( array(
739
+ 'action' => apply_filters( 'bp_activity_comment_action', sprintf( __( '%s posted a new activity comment:', 'buddypress' ), bp_core_get_userlink( $user_id ) ) ),
740
+ 'content' => apply_filters( 'bp_activity_comment_content', $content ),
741
+ 'component' => $bp->activity->id,
742
+ 'type' => 'activity_comment',
743
+ 'user_id' => $user_id,
744
+ 'item_id' => $activity_id,
745
+ 'secondary_item_id' => $parent_id,
746
+ 'hide_sitewide' => $is_hidden
747
+ ) );
748
+
749
+ /* Send an email notification if settings allow */
750
+ require_once( BP_PLUGIN_DIR . '/bp-activity/bp-activity-notifications.php' );
751
+ bp_activity_new_comment_notification( $comment_id, $user_id, $params );
752
+
753
+ /* Clear the comment cache for this activity */
754
+ wp_cache_delete( 'bp_activity_comments_' . $parent_id );
755
+
756
+ do_action( 'bp_activity_comment_posted', $comment_id, $params );
757
+
758
+ return $comment_id;
759
+ }
760
+
761
+ /**
762
+ * bp_activity_get_activity_id()
763
+ *
764
+ * Fetch the activity_id for an existing activity entry in the DB.
765
+ *
766
+ * @package BuddyPress Activity
767
+ */
768
+ function bp_activity_get_activity_id( $args = '' ) {
769
+ $defaults = array(
770
+ 'user_id' => false,
771
+ 'component' => false,
772
+ 'type' => false,
773
+ 'item_id' => false,
774
+ 'secondary_item_id' => false,
775
+ 'action' => false,
776
+ 'content' => false
777
+ );
778
+
779
+ $r = wp_parse_args( $args, $defaults );
780
+ extract( $r, EXTR_SKIP );
781
+
782
+ return apply_filters( 'bp_activity_get_activity_id', BP_Activity_Activity::get_id( $user_id, $component, $type, $item_id, $secondary_item_id, $action, $content ) );
783
}
784
785
+ /***
786
+ * Deleting Activity
787
+ *
788
+ * If you're looking to hook into one action that provides the ID(s) of
789
+ * the activity/activities deleted, then use:
790
+ *
791
+ * add_action( 'bp_activity_deleted_activities', 'my_function' );
792
+ *
793
+ * The action passes one parameter that is a single activity ID or an
794
+ * array of activity IDs depending on the number deleted.
795
+ *
796
+ * If you are deleting an activity comment please use bp_activity_delete_comment();
797
+ */
798
+
799
+ function bp_activity_delete( $args = '' ) {
800
+ global $bp;
801
+
802
+ /* Pass one or more the of following variables to delete by those variables */
803
+ $defaults = array(
804
+ 'id' => false,
805
+ 'action' => false,
806
+ 'content' => false,
807
+ 'component' => false,
808
+ 'type' => false,
809
+ 'primary_link' => false,
810
+ 'user_id' => false,
811
+ 'item_id' => false,
812
+ 'secondary_item_id' => false,
813
+ 'date_recorded' => false,
814
+ 'hide_sitewide' => false
815
+ );
816
+
817
+ $args = wp_parse_args( $args, $defaults );
818
819
+ if ( !$activity_ids_deleted = BP_Activity_Activity::delete( $args ) )
820
return false;
821
822
+ /* Check if the user's latest update has been deleted */
823
+ if ( empty( $args['user_id'] ) )
824
+ $user_id = $bp->loggedin_user->id;
825
+ else
826
+ $user_id = $args['user_id'];
827
+
828
+ $latest_update = get_usermeta( $user_id, 'bp_latest_update' );
829
+ if ( !empty( $latest_update ) ) {
830
+ if ( in_array( (int)$latest_update['id'], (array)$activity_ids_deleted ) )
831
+ delete_usermeta( $user_id, 'bp_latest_update' );
832
+ }
833
+
834
+ do_action( 'bp_activity_delete', $args );
835
+ do_action( 'bp_activity_deleted_activities', $activity_ids_deleted );
836
+
837
+ wp_cache_delete( 'bp_activity_sitewide_front', 'bp' );
838
839
return true;
840
}
841
+ /* The following functions have been deprecated in place of bp_activity_delete() */
842
+ function bp_activity_delete_by_item_id( $args = '' ) {
843
+ global $bp;
844
+
845
+ $defaults = array( 'item_id' => false, 'component' => false, 'type' => false, 'user_id' => false, 'secondary_item_id' => false );
846
+ $r = wp_parse_args( $args, $defaults );
847
+ extract( $r, EXTR_SKIP );
848
+
849
+ return bp_activity_delete( array( 'item_id' => $item_id, 'component' => $component, 'type' => $type, 'user_id' => $user_id, 'secondary_item_id' => $secondary_item_id ) );
850
+ }
851
+
852
+ function bp_activity_delete_by_activity_id( $activity_id ) {
853
+ return bp_activity_delete( array( 'id' => $activity_id ) );
854
+ }
855
856
+ function bp_activity_delete_by_content( $user_id, $content, $component, $type ) {
857
+ return bp_activity_delete( array( 'user_id' => $user_id, 'content' => $content, 'component' => $component, 'type' => $type ) );
858
+ }
859
+
860
+ function bp_activity_delete_for_user_by_component( $user_id, $component ) {
861
+ return bp_activity_delete( array( 'user_id' => $user_id, 'component' => $component ) );
862
+ }
863
+ /* End deprecation */
864
+
865
+ function bp_activity_delete_comment( $activity_id, $comment_id ) {
866
+ /***
867
+ * You may want to hook into this filter if you want to override this function and
868
+ * handle the deletion of child comments differently. Make sure you return false.
869
+ */
870
+ if ( !apply_filters( 'bp_activity_delete_comment_pre', true, $activity_id, $comment_id ) )
871
+ return false;
872
+
873
+ /* Delete any children of this comment. */
874
+ bp_activity_delete_children( $activity_id, $comment_id );
875
+
876
+ /* Delete the actual comment */
877
+ if ( !bp_activity_delete( array( 'id' => $comment_id, 'type' => 'activity_comment' ) ) )
878
return false;
879
880
+ /* Recalculate the comment tree */
881
+ BP_Activity_Activity::rebuild_activity_comment_tree( $activity_id );
882
+
883
+ do_action( 'bp_activity_delete_comment', $activity_id, $comment_id );
884
885
return true;
886
}
887
+ function bp_activity_delete_children( $activity_id, $comment_id) {
888
+ /* Recursively delete all children of this comment. */
889
+ if ( $children = BP_Activity_Activity::get_child_comments( $comment_id ) ) {
890
+ foreach( (array)$children as $child )
891
+ bp_activity_delete_children( $activity_id, $child->id );
892
}
893
+ bp_activity_delete( array( 'secondary_item_id' => $comment_id, 'type' => 'activity_comment', 'item_id' => $activity_id ) );
894
}
895
896
+ function bp_activity_get_permalink( $activity_id, $activity_obj = false ) {
897
+ global $bp;
898
+
899
+ if ( !$activity_obj )
900
+ $activity_obj = new BP_Activity_Activity( $activity_id );
901
902
+ if ( 'new_blog_post' == $activity_obj->type || 'new_blog_comment' == $activity_obj->type || 'new_forum_topic' == $activity_obj->type || 'new_forum_post' == $activity_obj->type )
903
+ $link = $activity_obj->primary_link;
904
+ else {
905
+ if ( 'activity_comment' == $activity_obj->type )
906
+ $link = $bp->root_domain . '/' . BP_ACTIVITY_SLUG . '/p/' . $activity_obj->item_id . '/';
907
+ else
908
+ $link = $bp->root_domain . '/' . BP_ACTIVITY_SLUG . '/p/' . $activity_obj->id . '/';
909
}
910
911
+ return apply_filters( 'bp_activity_get_permalink', $link );
912
+ }
913
+
914
+ function bp_activity_hide_user_activity( $user_id ) {
915
+ return BP_Activity_Activity::hide_all_for_user( $user_id );
916
+ }
917
+
918
+ /**
919
+ * bp_activity_thumbnail_content_images()
920
+ *
921
+ * Take content, remove all images and replace them with one thumbnail image.
922
+ *
923
+ * @package BuddyPress Activity
924
+ * @param $content str - The content to work with
925
+ * @return $content str - The content with images stripped and replaced with a single thumb.
926
+ */
927
+ function bp_activity_thumbnail_content_images( $content ) {
928
+ preg_match_all( '/<img[^>]*>/Ui', $content, $matches );
929
+ $content = preg_replace('/<img[^>]*>/Ui', '', $content );
930
+
931
+ if ( !empty( $matches ) ) {
932
+ /* Get the SRC value */
933
+ preg_match( '/<img.*?(src\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $src );
934
+
935
+ /* Get the width and height */
936
+ preg_match( '/<img.*?(height\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $height );
937
+ preg_match( '/<img.*?(width\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $width );
938
+
939
+ if ( !empty( $src ) ) {
940
+ $src = substr( substr( str_replace( 'src=', '', $src[1] ), 0, -1 ), 1 );
941
+ $height = substr( substr( str_replace( 'height=', '', $height[1] ), 0, -1 ), 1 );
942
+ $width = substr( substr( str_replace( 'width=', '', $width[1] ), 0, -1 ), 1 );
943
+
944
+ if ( empty( $width ) || empty( $height ) ) {
945
+ $width = 100;
946
+ $height = 100;
947
+ }
948
+
949
+ $ratio = (int)$width / (int)$height;
950
+ $new_height = 100;
951
+ $new_width = $new_height * $ratio;
952
+
953
+ $content = '<img src="' . esc_attr( $src) . '" width="' . $new_width . '" height="' . $new_height . '" alt="' . __( 'Thumbnail', 'buddypress' ) . '" class="align-left thumbnail" />' . $content;
954
+ }
955
+ }
956
+
957
+ return apply_filters( 'bp_activity_thumbnail_content_images', $content, $matches );
958
}
959
960
function bp_activity_set_action( $component_id, $key, $value ) {
978
return apply_filters( 'bp_activity_get_action', $bp->activity->actions->{$component_id}->{$key}, $component_id, $key );
979
}
980
981
+ function bp_activity_get_user_favorites( $user_id ) {
982
+ $my_favs = maybe_unserialize( get_usermeta( $user_id, 'bp_favorite_activities' ) );
983
+ $existing_favs = bp_activity_get_specific( array( 'activity_ids' => $my_favs ) );
984
+
985
+ foreach( (array)$existing_favs['activities'] as $fav )
986
+ $new_favs[] = $fav->id;
987
+
988
+ $new_favs = array_unique( (array)$new_favs );
989
+ update_usermeta( $user_id, 'bp_favorite_activities', $new_favs );
990
+
991
+ return apply_filters( 'bp_activity_get_user_favorites', $new_favs );
992
+ }
993
+
994
+ function bp_activity_add_user_favorite( $activity_id, $user_id = false ) {
995
+ global $bp;
996
+
997
+ if ( !$user_id )
998
+ $user_id = $bp->loggedin_user->id;
999
+
1000
+ /* Update the user's personal favorites */
1001
+ $my_favs = maybe_unserialize( get_usermeta( $bp->loggedin_user->id, 'bp_favorite_activities' ) );
1002
+ $my_favs[] = $activity_id;
1003
+
1004
+ /* Update the total number of users who have favorited this activity */
1005
+ $fav_count = bp_activity_get_meta( $activity_id, 'favorite_count' );
1006
+
1007
+ if ( !empty( $fav_count ) )
1008
+ $fav_count = (int)$fav_count + 1;
1009
+ else
1010
+ $fav_count = 1;
1011
+
1012
+ update_usermeta( $bp->loggedin_user->id, 'bp_favorite_activities', $my_favs );
1013
+ bp_activity_update_meta( $activity_id, 'favorite_count', $fav_count );
1014
+
1015
+ return true;
1016
+ }
1017
+
1018
+ function bp_activity_remove_user_favorite( $activity_id, $user_id = false ) {
1019
+ global $bp;
1020
+
1021
+ if ( !$user_id )
1022
+ $user_id = $bp->loggedin_user->id;
1023
1024
+ /* Remove the fav from the user's favs */
1025
+ $my_favs = maybe_unserialize( get_usermeta( $user_id, 'bp_favorite_activities' ) );
1026
+ $my_favs = array_flip( (array) $my_favs );
1027
+ unset( $my_favs[$activity_id] );
1028
+ $my_favs = array_unique( array_flip( $my_favs ) );
1029
+
1030
+ /* Update the total number of users who have favorited this activity */
1031
+ $fav_count = bp_activity_get_meta( $activity_id, 'favorite_count' );
1032
+
1033
+ if ( !empty( $fav_count ) ) {
1034
+ $fav_count = (int)$fav_count - 1;
1035
+ bp_activity_update_meta( $activity_id, 'favorite_count', $fav_count );
1036
+ }
1037
+
1038
+ update_usermeta( $user_id, 'bp_favorite_activities', $my_favs );
1039
+
1040
+ return true;
1041
+ }
1042
+
1043
+ function bp_activity_check_exists_by_content( $content ) {
1044
return apply_filters( 'bp_activity_check_exists_by_content', BP_Activity_Activity::check_exists_by_content( $content ) );
1045
}
1046
1048
return apply_filters( 'bp_activity_get_last_updated', BP_Activity_Activity::get_last_updated() );
1049
}
1050
1051
+ function bp_activity_total_favorites_for_user( $user_id = false ) {
1052
+ global $bp;
1053
+
1054
+ if ( !$user_id )
1055
+ $user_id = ( $bp->displayed_user->id ) ? $bp->displayed_user->id : $bp->loggedin_user->id;
1056
+
1057
+ return BP_Activity_Activity::total_favorite_count( $user_id );
1058
}
1059
1060
+ /********************************************************************************
1061
+ * Activity Meta Functions
1062
+ *
1063
+ * Meta functions allow you to store extra data for a particular item.
1064
+ */
1065
+
1066
+ function bp_activity_delete_meta( $activity_id, $meta_key = false, $meta_value = false ) {
1067
+ global $wpdb, $bp;
1068
+
1069
+ if ( !is_numeric( $activity_id ) )
1070
+ return false;
1071
+
1072
+ $meta_key = preg_replace( '|[^a-z0-9_]|i', '', $meta_key );
1073
+
1074
+ if ( is_array( $meta_value ) || is_object( $meta_value ) )
1075
+ $meta_value = serialize( $meta_value );
1076
+
1077
+ $meta_value = trim( $meta_value );
1078
+
1079
+ if ( !$meta_key ) {
1080
+ $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name_meta} WHERE activity_id = %d", $activity_id ) );
1081
+ } else if ( $meta_value ) {
1082
+ $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name_meta} WHERE activity_id = %d AND meta_key = %s AND meta_value = %s", $activity_id, $meta_key, $meta_value ) );
1083
+ } else {
1084
+ $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name_meta} WHERE activity_id = %d AND meta_key = %s", $activity_id, $meta_key ) );
1085
+ }
1086
+
1087
+ wp_cache_delete( 'bp_activity_meta_' . $meta_key . '_' . $activity_id, 'bp' );
1088
+
1089
+ return true;
1090
}
1091
1092
+ function bp_activity_get_meta( $activity_id, $meta_key = '' ) {
1093
+ global $wpdb, $bp;
1094
+
1095
+ $activity_id = (int)$activity_id;
1096
+
1097
+ if ( !$activity_id )
1098
+ return false;
1099
+
1100
+ if ( !empty($meta_key) ) {
1101
+ $meta_key = preg_replace( '|[^a-z0-9_]|i', '', $meta_key );
1102
+
1103
+ if ( !$metas = wp_cache_get( 'bp_activity_meta_' . $meta_key . '_' . $activity_id, 'bp' ) ) {
1104
+ $metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM {$bp->activity->table_name_meta} WHERE activity_id = %d AND meta_key = %s", $activity_id, $meta_key ) );
1105
+ wp_cache_set( 'bp_activity_meta_' . $meta_key . '_' . $activity_id, $metas, 'bp' );
1106
+ }
1107
+ } else
1108
+ $metas = $wpdb->get_col( $wpdb->prepare( "SELECT meta_value FROM {$bp->activity->table_name_meta} WHERE activity_id = %d", $activity_id ) );
1109
+
1110
+ if ( empty($metas) )
1111
+ return false;
1112
+
1113
+ $metas = array_map( 'maybe_unserialize', $metas );
1114
+
1115
+ if ( 1 == count($metas) )
1116
+ return $metas[0];
1117
+ else
1118
+ return $metas;
1119
+ }
1120
+
1121
+ function bp_activity_update_meta( $activity_id, $meta_key, $meta_value ) {
1122
+ global $wpdb, $bp;
1123
+
1124
+ if ( !is_numeric( $activity_id ) )
1125
+ return false;
1126
+
1127
+ $meta_key = preg_replace( '|[^a-z0-9_]|i', '', $meta_key );
1128
+
1129
+ if ( is_string( $meta_value ) )
1130
+ $meta_value = stripslashes( $wpdb->escape( $meta_value ) );
1131
+
1132
+ $meta_value = maybe_serialize( $meta_value );
1133
+
1134
+ if ( empty( $meta_value ) ) {
1135
+ return bp_activity_delete_meta( $activity_id, $meta_key );
1136
+ }
1137
+
1138
+ $cur = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name_meta} WHERE activity_id = %d AND meta_key = %s", $activity_id, $meta_key ) );
1139
+
1140
+ if ( !$cur ) {
1141
+ $wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->activity->table_name_meta} ( activity_id, meta_key, meta_value ) VALUES ( %d, %s, %s )", $activity_id, $meta_key, $meta_value ) );
1142
+ } else if ( $cur->meta_value != $meta_value ) {
1143
+ $wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name_meta} SET meta_value = %s WHERE activity_id = %d AND meta_key = %s", $meta_value, $activity_id, $meta_key ) );
1144
+ } else {
1145
+ return false;
1146
+ }
1147
+
1148
+ wp_cache_set( 'bp_activity_meta_' . $meta_key . '_' . $activity_id, $meta_value, 'bp' );
1149
+
1150
+ return true;
1151
}
1152
1153
function bp_activity_remove_data( $user_id ) {
1154
// Clear the user's activity from the sitewide stream and clear their activity tables
1155
+ bp_activity_delete( array( 'user_id' => $user_id ) );
1156
+
1157
+ // Remove any usermeta
1158
+ delete_usermeta( $user_id, 'bp_latest_update' );
1159
+ delete_usermeta( $user_id, 'bp_favorite_activities' );
1160
1161
do_action( 'bp_activity_remove_data', $user_id );
1162
}
1164
add_action( 'delete_user', 'bp_activity_remove_data' );
1165
add_action( 'make_spam_user', 'bp_activity_remove_data' );
1166
1167
+
1168
+ /********************************************************************************
1169
+ * Custom Actions
1170
+ *
1171
+ * Functions to set up custom BuddyPress actions that all other components can
1172
+ * hook in to.
1173
+ */
1174
+
1175
+ /* Allow core components and dependent plugins to register activity actions */
1176
+ function bp_register_activity_actions() {
1177
+ do_action( 'bp_register_activity_actions' );
1178
}
1179
+ add_action( 'plugins_loaded', 'bp_register_activity_actions' );
1180
+
1181
1182
?>
bp-activity/bp-activity-classes.php CHANGED
@@ -6,8 +6,10 @@ Class BP_Activity_Activity {
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 $hide_sitewide = false;
13
@@ -23,217 +25,401 @@ Class BP_Activity_Activity {
23
function populate() {
24
global $wpdb, $bp;
25
26
- $activity = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE id = %d", $this->id ) );
27
-
28
- $this->id = $activity->id;
29
- $this->item_id = $activity->item_id;
30
- $this->secondary_item_id = $activity->secondary_item_id;
31
- $this->user_id = $activity->user_id;
32
- $this->content = $activity->content;
33
- $this->primary_link = $activity->primary_link;
34
- $this->component_name = $activity->component_name;
35
- $this->component_action = $activity->component_action;
36
- $this->date_recorded = $activity->date_recorded;
37
- $this->hide_sitewide = $activity->hide_sitewide;
38
}
39
40
function save() {
41
global $wpdb, $bp, $current_user;
42
43
- do_action( 'bp_activity_before_save', $this );
44
45
- if ( !$this->component_name || !$this->component_action )
46
return false;
47
48
- /***
49
- * Before v1.1 of BuddyPress, activity content was calculated at a later point. This is no longer the
50
- * case, to to be backwards compatible we need to fetch content here to continue.
51
- */
52
- if ( empty( $this->content ) || !$this->content ) {
53
- if ( function_exists( $bp->{$this->component_name}->format_activity_function ) ) {
54
- if ( !$fetched_content = call_user_func( $bp->{$this->component_name}->format_activity_function, $this->item_id, $this->user_id, $this->component_action, $this->secondary_item_id, $this->for_secondary_user ) )
55
- return false;
56
-
57
- $this->content = $fetched_content['content'];
58
- $this->primary_link = $fetched_content['primary_link'];
59
- }
60
}
61
62
- if ( !$this->primary_link )
63
- $this->primary_link = $bp->loggedin_user->domain;
64
65
- if ( $existing_activity_id = $this->exists() )
66
- BP_Activity_Activity::delete_by_activity_id( $existing_activity_id );
67
68
- /* If we have an existing ID, update the activity item, otherwise insert it. */
69
- if ( $this->id ) {
70
- if ( $wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET user_id = %d, component_name = %s, component_action = %s, content = %s, primary_link = %s, date_recorded = FROM_UNIXTIME(%d), item_id = %s, secondary_item_id = %s, hide_sitewide = %d WHERE id = %d", $this->user_id, $this->component_name, $this->component_action, $this->content, $this->primary_link, $this->date_recorded, $this->item_id, $this->secondary_item_id, $this->hide_sitewide, $this->id ) ) ) {
71
- do_action( 'bp_activity_after_save', $this );
72
- return true;
73
}
74
- } else {
75
- if ( $wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->activity->table_name} ( user_id, component_name, component_action, content, primary_link, date_recorded, item_id, secondary_item_id, hide_sitewide ) VALUES ( %d, %s, %s, %s, %s, FROM_UNIXTIME(%d), %s, %s, %d )", $this->user_id, $this->component_name, $this->component_action, $this->content, $this->primary_link, $this->date_recorded, $this->item_id, $this->secondary_item_id, $this->hide_sitewide ) ) ) {
76
- do_action( 'bp_activity_after_save', $this );
77
- return true;
78
}
79
}
80
81
- return false;
82
}
83
84
- function exists() {
85
global $wpdb, $bp;
86
87
- /* This doesn't seem to be working correctly at the moment, so it is disabled [TODO] */
88
- return false;
89
-
90
- /* If we have an item id, try and match on that, if not do a content match */
91
- if ( $this->item_id ) {
92
- if ( $this->secondary_item_id )
93
- $secondary_sql = $wpdb->prepare( " AND secondary_item_id = %s", $secondary_item_id );
94
95
- return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE user_id = %d AND item_id = %s{$secondary_sql} AND component_name = %s AND component_action = %s", $this->user_id, $this->item_id, $this->component_name, $this->component_action ) );
96
- } else {
97
- return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE user_id = %d AND content = %s AND component_name = %s AND component_action = %s", $this->user_id, $this->content, $this->component_name, $this->component_action ) );
98
- }
99
- }
100
101
- /* Static Functions */
102
103
- function delete( $item_id, $component_name, $component_action, $user_id = false, $secondary_item_id = false ) {
104
- global $wpdb, $bp;
105
106
- if ( $secondary_item_id )
107
- $secondary_sql = $wpdb->prepare( "AND secondary_item_id = %s", $secondary_item_id );
108
109
- if ( $component_action )
110
- $component_action_sql = $wpdb->prepare( "AND component_action = %s", $component_action );
111
112
- if ( $user_id )
113
- $user_sql = $wpdb->prepare( "AND user_id = %d", $user_id );
114
115
- return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE item_id = %s {$secondary_sql} AND component_name = %s {$component_action_sql} {$user_sql}", $item_id, $component_name ) );
116
- }
117
118
- function delete_by_item_id( $item_id, $component_name, $component_action, $user_id = false, $secondary_item_id = false ) {
119
- return BP_Activity_Activity::delete( $item_id, $component_name, $component_action, $user_id, $secondary_item_id );
120
}
121
122
- function delete_by_activity_id( $activity_id ) {
123
global $bp, $wpdb;
124
125
- return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE id = %d", $activity_id ) );
126
- }
127
128
- function delete_by_content( $user_id, $content, $component_name, $component_action ) {
129
- global $bp, $wpdb;
130
131
- return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE user_id = %d AND content = %s AND component_name = %s AND component_action = %s", $user_id, $content, $component_name, $component_action ) );
132
- }
133
134
- function delete_for_user_by_component( $user_id, $component_name ) {
135
- global $bp, $wpdb;
136
137
- return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE user_id = %d AND component_name = %s", $user_id, $component_name ) );
138
- }
139
140
- function delete_for_user( $user_id ) {
141
- global $wpdb, $bp;
142
143
- return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE user_id = %d", $user_id ) );
144
}
145
146
- function get_activity_for_user( $user_id, $max_items, $limit, $page, $filter ) {
147
global $wpdb, $bp;
148
149
- if ( $limit && $page )
150
- $pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
151
152
- if ( $max_items )
153
- $max_sql = $wpdb->prepare( "LIMIT %d", $max_items );
154
155
- /* Sort out filtering */
156
- if ( $filter )
157
- $filter_sql = BP_Activity_Activity::get_filter_sql( $filter );
158
159
- if ( $limit && $page && $max_items )
160
- $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE user_id = %d $filter_sql ORDER BY date_recorded DESC $pag_sql", $user_id ) );
161
else
162
- $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE user_id = %d $filter_sql ORDER BY date_recorded DESC $pag_sql $max_sql", $user_id ) );
163
164
- $total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->activity->table_name} WHERE user_id = %d $filter_sql ORDER BY date_recorded DESC $max_sql", $user_id ) );
165
166
- return array( 'activities' => $activities, 'total' => (int)$total_activities );
167
}
168
169
- function get_activity_for_friends( $user_id, $max_items, $max_items_per_friend, $limit, $page, $filter ) {
170
- global $wpdb, $bp;
171
172
- // TODO: Max items per friend not yet implemented.
173
174
- if ( !function_exists('friends_get_friend_user_ids') )
175
- return false;
176
177
- if ( $limit && $page )
178
- $pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
179
180
- if ( $max_items )
181
- $max_sql = $wpdb->prepare( "LIMIT %d", $max_items );
182
183
- /* Sort out filtering */
184
- if ( $filter )
185
- $filter_sql = BP_Activity_Activity::get_filter_sql( $filter );
186
187
- $friend_ids = friends_get_friend_user_ids( $user_id );
188
189
- if ( !$friend_ids )
190
- return false;
191
192
- $friend_ids = implode( ',', $friend_ids );
193
194
- if ( $limit && $page && $max_items )
195
- $activities = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT id, user_id, content, primary_link, date_recorded, component_name, component_action FROM {$bp->activity->table_name} WHERE user_id IN ({$friend_ids}) $filter_sql ORDER BY date_recorded DESC $pag_sql" ) );
196
- else
197
- $activities = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT id, user_id, content, primary_link, date_recorded, component_name, component_action FROM {$bp->activity->table_name} WHERE user_id IN ({$friend_ids}) $filter_sql ORDER BY date_recorded DESC $pag_sql $max_sql" ) );
198
199
- $total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT user_id) FROM {$bp->activity->table_name} WHERE user_id IN ({$friend_ids}) $filter_sql ORDER BY date_recorded DESC $max_sql" ) );
200
201
- return array( 'activities' => $activities, 'total' => (int)$total_activities );
202
}
203
204
- function get_sitewide_activity( $max, $limit, $page, $filter ) {
205
global $wpdb, $bp;
206
207
- if ( $limit && $page )
208
- $pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
209
210
- if ( $max )
211
- $max_sql = $wpdb->prepare( "LIMIT %d", $max );
212
213
- /* Sort out filtering */
214
- if ( $filter )
215
- $filter_sql = BP_Activity_Activity::get_filter_sql( $filter );
216
217
- if ( $limit && $page && $max )
218
- $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE hide_sitewide = 0 $filter_sql ORDER BY date_recorded DESC $pag_sql" ) );
219
else
220
- $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE hide_sitewide = 0 $filter_sql ORDER BY date_recorded DESC $pag_sql $max_sql" ) );
221
222
- $total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->activity->table_name} WHERE hide_sitewide = 0 $filter_sql ORDER BY date_recorded DESC $max_sql" ) );
223
224
- return array( 'activities' => $activities, 'total' => (int)$total_activities );
225
}
226
227
- function get_recorded_component_names() {
228
global $wpdb, $bp;
229
230
- return $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT component_name FROM {$bp->activity->table_name} ORDER BY component_name ASC" ) );
231
}
232
233
function get_sitewide_items_for_feed( $limit = 35 ) {
234
global $wpdb, $bp;
235
236
- $activities = bp_activity_get_sitewide_activity( $limit );
237
for ( $i = 0; $i < count($activities); $i++ ) {
238
$title = explode( '<span', $activities[$i]['content'] );
239
@@ -249,13 +435,19 @@ Class BP_Activity_Activity {
249
function get_filter_sql( $filter_array ) {
250
global $wpdb;
251