[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-forums/bbpress/ -> favorites.php (source)

   1  <?php
   2  require_once ('./bb-load.php');
   3  
   4  if ( isset( $_GET['fav'] ) && isset( $_GET['topic_id'] ) ) {
   5      bb_auth( 'logged_in' );
   6  
   7      if ( !bb_current_user_can( 'edit_favorites_of', $user_id ) ) {
   8          bb_die( __( 'You cannot edit those favorites. How did you get here?' ) );
   9      }
  10  
  11      $fav = (int) $_GET['fav'];
  12      $topic_id = (int) $_GET['topic_id'];
  13  
  14      bb_check_admin_referer( 'toggle-favorite_' . $topic_id );
  15  
  16      $topic = get_topic( $topic_id );
  17      if ( !$topic || 0 != $topic->topic_status ) {
  18          exit;
  19      }
  20  
  21      if ( $fav ) {
  22          bb_add_user_favorite( $user_id, $topic_id );
  23      } else {
  24          bb_remove_user_favorite( $user_id, $topic_id );
  25      }
  26  
  27      $ref = wp_get_referer();
  28      if ( false !== strpos( $ref, bb_get_uri( null, null, BB_URI_CONTEXT_TEXT ) ) ) {
  29          bb_safe_redirect( $ref );
  30      } else {
  31          wp_redirect( get_topic_link( $topic_id ) );
  32      }
  33      exit;
  34  }
  35  
  36  if ( !bb_is_profile() ) {
  37      $sendto = get_profile_tab_link( $user->ID, 'favorites' );
  38      wp_redirect( $sendto );
  39      exit;
  40  }
  41  
  42  if ( $topics = get_user_favorites( $user->ID, true ) ) {
  43      bb_cache_last_posts( $topics );
  44  }
  45  
  46  $favorites_total = isset( $user->favorites ) ? count( explode( ',', $user->favorites ) ) : 0;
  47  
  48  bb_load_template( 'favorites.php', array( 'favorites_total', 'self' ) );


Generated: Thu Dec 7 01:01:35 2017 Cross-referenced by PHPXref 0.7.1