[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-core/deprecated/ -> 1.9.php (source)

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


Generated: Thu Nov 21 01:00:57 2024 Cross-referenced by PHPXref 0.7.1