Skip to:
Content

bbPress.org


Ignore:
Timestamp:
11/20/2013 07:50:55 PM (8 years ago)
Author:
johnjamesjacoby
Message:

Forum Subscriptions - Allow users to subscribe to new topics in specific forums.

  • Code largely lifted from existing Topics Subscriptions, and is based largely on forum-subscriptions.2.diff from mordauk, with edits for code consistency across bbPress components.
  • Refactor existing ambiguous function names into base functions for both forum and topic subscriptions.
  • Include new functions for getting and outputting subscriptions.
  • Modify user-subscriptions.php to show subscribed forums. This includes a modification to content-single-forum.php to include the "Unsubscribe" link if looking at a user profile page.
  • Modify templates/default/bbpress-functions.php to enqueue new JS file to handle forum subscription ajax.
  • Rename HTML element classes from bbp-topic-action to bbp-row-actions to better accommodate forum subscriptions (and any future actions.)
  • BuddyPress tested, JJJ approved.
  • See #2299. Props mordauk, netweb for the considerable effort.
  • More to do here, largely from forum-subscriptions.3.diff
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/forums/functions.php

    r5114 r5156  
    962962}
    963963
     964/** Subscriptions *************************************************************/
     965
     966/**
     967 * Remove a deleted forum from all users' subscriptions
     968 *
     969 * @since bbPress (rxxxx)
     970 *
     971 * @param int $forum_id Get the forum ID to remove
     972 * @uses bbp_is_subscriptions_active() To check if the subscriptions are active
     973 * @uses bbp_get_forum_id To get the forum id
     974 * @uses bbp_get_forum_subscribers() To get the forum subscribers
     975 * @uses bbp_remove_user_subscription() To remove the user subscription
     976 */
     977function bbp_remove_forum_from_all_subscriptions( $forum_id = 0 ) {
     978
     979    // Subscriptions are not active
     980    if ( ! bbp_is_subscriptions_active() ) {
     981        return;
     982    }
     983
     984    $forum_id = bbp_get_forum_id( $forum_id );
     985
     986    // Bail if no forum
     987    if ( empty( $forum_id ) ) {
     988        return;
     989    }
     990
     991    // Get users
     992    $users = (array) bbp_get_forum_subscribers( $forum_id );
     993
     994    // Users exist
     995    if ( !empty( $users ) ) {
     996
     997        // Loop through users
     998        foreach ( $users as $user ) {
     999
     1000            // Remove each user
     1001            bbp_remove_user_subscription( $user, $forum_id );
     1002        }
     1003    }
     1004}
     1005
    9641006/** Count Bumpers *************************************************************/
    9651007
Note: See TracChangeset for help on using the changeset viewer.