/bp-core/deprecated/1.9.php

  1. <?php 
  2. /** 
  3. * BuddyPress Member Notifications 
  4. * 
  5. * Backwards compatibility functions and filters used for member notifications. 
  6. * Use bp-notifications instead. 
  7. * 
  8. * @package BuddyPress 
  9. * @subpackage MembersNotifications 
  10. */ 
  11.  
  12. // Exit if accessed directly 
  13. defined( 'ABSPATH' ) || exit; 
  14.  
  15. /** 
  16. * Add a notification for a specific user, from a specific component. 
  17. * 
  18. * @deprecated Deprecated since BuddyPress 1.9.0. Use 
  19. * bp_notifications_add_notification() instead. 
  20. * 
  21. * @since 1.0.0 
  22. * @param string $item_id 
  23. * @param int $user_id 
  24. * @param string $component_name 
  25. * @param string $component_action 
  26. * @param string $secondary_item_id 
  27. * @param string $date_notified 
  28. * @param int $is_new 
  29. * @return boolean True on success, false on failure. 
  30. */ 
  31. function bp_core_add_notification( $item_id, $user_id, $component_name, $component_action, $secondary_item_id = 0, $date_notified = false, $is_new = 1 ) { 
  32.  
  33. // Bail if notifications is not active 
  34. if ( ! bp_is_active( 'notifications' ) ) { 
  35. return false; 
  36.  
  37. // Trigger the deprecated function notice 
  38. _deprecated_function( __FUNCTION__, '1.9', 'bp_notifications_add_notification()' ); 
  39.  
  40. // Notifications must always have a time 
  41. if ( false === $date_notified ) { 
  42. $date_notified = bp_core_current_time(); 
  43.  
  44. // Add the notification 
  45. return bp_notifications_add_notification( array( 
  46. 'item_id' => $item_id,  
  47. 'user_id' => $user_id,  
  48. 'component_name' => $component_name,  
  49. 'component_action' => $component_action,  
  50. 'secondary_item_id' => $secondary_item_id,  
  51. 'date_notified' => $date_notified,  
  52. 'is_new' => $is_new 
  53. ) ); 
  54.  
  55. /** 
  56. * Delete a specific notification by its ID. 
  57. * 
  58. * @deprecated Deprecated since BuddyPress 1.9.0. Use 
  59. * bp_notifications_delete_notification() instead. 
  60. * 
  61. * @since 1.0.0 
  62. * @param int $id ID of notification. 
  63. * @return boolean True on success, false on failure. 
  64. */ 
  65. function bp_core_delete_notification( $id ) { 
  66.  
  67. // Bail if notifications is not active 
  68. if ( ! bp_is_active( 'notifications' ) ) { 
  69. return false; 
  70.  
  71. // Trigger the deprecated function notice 
  72. _deprecated_function( __FUNCTION__, '1.9', 'bp_notifications_delete_notification()' ); 
  73.  
  74. return BP_Notifications_Notification::delete_by_id( $id ); 
  75.  
  76. /** 
  77. * Get a specific notification by its ID. 
  78. * 
  79. * @deprecated Deprecated since BuddyPress 1.9.0. Use 
  80. * bp_notifications_get_notification() instead. 
  81. * 
  82. * @since 1.0.0 
  83. * @param int $id ID of notification. 
  84. * @return BP_Core_Notification 
  85. */ 
  86. function bp_core_get_notification( $id ) { 
  87.  
  88. // Bail if notifications is not active 
  89. if ( ! bp_is_active( 'notifications' ) ) { 
  90. return false; 
  91.  
  92. // Trigger the deprecated function notice 
  93. _deprecated_function( __FUNCTION__, '1.9', 'bp_notifications_get_notification()' ); 
  94.  
  95. return bp_notifications_get_notification( $id ); 
  96.  
  97. /** 
  98. * Get notifications for a specific user. 
  99. * 
  100. * @deprecated Deprecated since BuddyPress 1.9.0. Use 
  101. * bp_notifications_get_notifications_for_user() instead. 
  102. * 
  103. * @since 1.0.0 
  104. * @param int $user_id ID of user. 
  105. * @param string $format 
  106. * @return boolean Object or array on success, false on failure. 
  107. */ 
  108. function bp_core_get_notifications_for_user( $user_id, $format = 'string' ) { 
  109.  
  110. // Bail if notifications is not active 
  111. if ( ! bp_is_active( 'notifications' ) ) { 
  112. return false; 
  113.  
  114. // Trigger the deprecated function notice 
  115. _deprecated_function( __FUNCTION__, '1.9', 'bp_notifications_get_notifications_for_user()' ); 
  116.  
  117. return bp_notifications_get_notifications_for_user( $user_id, $format ); 
  118.  
  119. /** Delete ********************************************************************/ 
  120.  
  121. /** 
  122. * Delete notifications for a user by type. 
  123. * 
  124. * Used when clearing out notifications for a specific component when the user 
  125. * has visited that component. 
  126. * 
  127. * @deprecated Deprecated since BuddyPress 1.9.0. Use 
  128. * bp_notifications_delete_notifications_by_type() instead. 
  129. * 
  130. * @since 1.0.0 
  131. * @param int $user_id 
  132. * @param string $component_name 
  133. * @param string $component_action 
  134. * @return boolean True on success, false on failure. 
  135. */ 
  136. function bp_core_delete_notifications_by_type( $user_id, $component_name, $component_action ) { 
  137.  
  138. // Bail if notifications is not active 
  139. if ( ! bp_is_active( 'notifications' ) ) { 
  140. return false; 
  141.  
  142. // Trigger the deprecated function notice 
  143. _deprecated_function( __FUNCTION__, '1.9', 'bp_notifications_delete_notifications_by_type()' ); 
  144.  
  145. return bp_notifications_delete_notifications_by_type( $user_id, $component_name, $component_action ); 
  146.  
  147. /** 
  148. * Delete notifications for an item ID. 
  149. * 
  150. * Used when clearing out notifications for a specific component when the user 
  151. * has visited that component. 
  152. * 
  153. * @deprecated Deprecated since BuddyPress 1.9.0. Use 
  154. * bp_notifications_delete_notifications_by_item_id() instead. 
  155. * 
  156. * @since 1.0.0 
  157. * @param int $user_id 
  158. * @param string $component_name 
  159. * @param string $component_action 
  160. * @return boolean True on success, false on failure. 
  161. */ 
  162. function bp_core_delete_notifications_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id = false ) { 
  163.  
  164. // Bail if notifications is not active 
  165. if ( ! bp_is_active( 'notifications' ) ) { 
  166. return false; 
  167.  
  168. // Trigger the deprecated function notice 
  169. _deprecated_function( __FUNCTION__, '1.9', 'bp_notifications_delete_notifications_by_item_id()' ); 
  170.  
  171. return bp_notifications_delete_notifications_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id ); 
  172.  
  173. /** 
  174. * Delete all notifications for by type. 
  175. * 
  176. * @deprecated Deprecated since BuddyPress 1.9.0. Use 
  177. * bp_notifications_delete_all_notifications_by_type() instead. 
  178. * 
  179. * @since 1.0.0 
  180. * @param int $user_id 
  181. * @param string $component_name 
  182. * @param string $component_action 
  183. * @return boolean True on success, false on failure. 
  184. */ 
  185. function bp_core_delete_all_notifications_by_type( $item_id, $component_name, $component_action = false, $secondary_item_id = false ) { 
  186.  
  187. // Bail if notifications is not active 
  188. if ( ! bp_is_active( 'notifications' ) ) { 
  189. return false; 
  190.  
  191. // Trigger the deprecated function notice 
  192. _deprecated_function( __FUNCTION__, '1.9', 'bp_notifications_delete_all_notifications_by_type()' ); 
  193.  
  194. bp_notifications_delete_all_notifications_by_type( $item_id, $component_name, $component_action, $secondary_item_id ); 
  195.  
  196. /** 
  197. * Delete all notifications for a user. 
  198. * 
  199. * Used when clearing out all notifications for a user, when deleted or spammed 
  200. * 
  201. * @deprecated Deprecated since BuddyPress 1.9.0. Use 
  202. * bp_notifications_delete_notifications_from_user() instead. 
  203. * 
  204. * @since 1.0.0 
  205. * @param int $user_id 
  206. * @param string $component_name 
  207. * @param string $component_action 
  208. * @return boolean True on success, false on failure. 
  209. */ 
  210. function bp_core_delete_notifications_from_user( $user_id, $component_name, $component_action ) { 
  211.  
  212. // Bail if notifications is not active 
  213. if ( ! bp_is_active( 'notifications' ) ) { 
  214. return false; 
  215.  
  216. // Trigger the deprecated function notice 
  217. _deprecated_function( __FUNCTION__, '1.9', 'bp_notifications_delete_notifications_from_user()' ); 
  218.  
  219. return bp_notifications_delete_notifications_from_user( $user_id, $component_name, $component_action ); 
  220.  
  221. /** Helpers *******************************************************************/ 
  222.  
  223. /** 
  224. * Check if a user has access to a specific notification. 
  225. * 
  226. * Used before deleting a notification for a user. 
  227. * 
  228. * @deprecated Deprecated since BuddyPress 1.9.0. Use 
  229. * bp_notifications_check_notification_access() instead. 
  230. * 
  231. * @since 1.0.0 
  232. * @param int $user_id 
  233. * @param int $notification_id 
  234. * @return boolean True on success, false on failure. 
  235. */ 
  236. function bp_core_check_notification_access( $user_id, $notification_id ) { 
  237.  
  238. // Bail if notifications is not active 
  239. if ( ! bp_is_active( 'notifications' ) ) { 
  240. return false; 
  241.  
  242. // Trigger the deprecated function notice 
  243. _deprecated_function( __FUNCTION__, '1.9', 'bp_notifications_check_notification_access()' ); 
  244.  
  245. return bp_notifications_check_notification_access( $user_id, $notification_id ); 
.