Skip to:
Content

bbPress.org


Ignore:
Timestamp:
04/17/2012 05:37:00 PM (14 years ago)
Author:
johnjamesjacoby
Message:

More aggressively check private and hidden forums when changing forum status. (plugin branch)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-includes/bbp-forum-functions.php

    r3840 r3852  
    803803    if ( in_array( $forum_id, $private ) ) {
    804804
    805         $offset = array_search( $forum_id, (array) $private );
     805        $offset = array_search( $forum_id, $private );
    806806
    807807        // Splice around it
     
    809809
    810810        // Update private forums minus this one
    811         update_option( '_bbp_private_forums', array_unique( array_values( $private ) ) );
     811        update_option( '_bbp_private_forums', array_unique( array_filter( array_values( $private ) ) ) );
    812812    }
    813813
     
    818818    if ( in_array( $forum_id, $hidden ) ) {
    819819
    820         $offset = array_search( $forum_id, (array) $hidden );
     820        $offset = array_search( $forum_id, $hidden );
    821821
    822822        // Splice around it
     
    824824
    825825        // Update hidden forums minus this one
    826         update_option( '_bbp_hidden_forums', array_unique( array_values( $hidden ) ) );
     826        update_option( '_bbp_hidden_forums', array_unique( array_filter( array_values( $hidden ) ) ) );
    827827    }
    828828
     
    859859    if ( bbp_get_private_status_id() != $current_visibility ) {
    860860
    861         // Remove from _bbp_hidden_forums site option
    862         if ( bbp_get_hidden_status_id() == $current_visibility ) {
    863 
    864             // Get hidden forums
    865             $hidden = bbp_get_hidden_forum_ids();
    866 
    867             // Find this forum in the array
    868             if ( in_array( $forum_id, $hidden ) ) {
    869 
    870                 $offset = array_search( $forum_id, (array) $hidden );
    871 
    872                 // Splice around it
    873                 array_splice( $hidden, $offset, 1 );
    874 
    875                 // Update hidden forums minus this one
    876                 update_option( '_bbp_hidden_forums', array_unique( array_values( $hidden ) ) );
    877             }
     861        // Get hidden forums
     862        $hidden = bbp_get_hidden_forum_ids();
     863
     864        // Find this forum in the array
     865        if ( in_array( $forum_id, $hidden ) ) {
     866
     867            $offset = array_search( $forum_id, $hidden );
     868
     869            // Splice around it
     870            array_splice( $hidden, $offset, 1 );
     871
     872            // Update hidden forums minus this one
     873            update_option( '_bbp_hidden_forums', array_unique( array_filter( array_values( $hidden ) ) ) );
    878874        }
    879875
     
    881877        $private   = bbp_get_private_forum_ids();
    882878        $private[] = $forum_id;
    883         update_option( '_bbp_private_forums', array_unique( array_values( $private ) ) );
     879        update_option( '_bbp_private_forums', array_unique( array_filter( array_values( $private ) ) ) );
    884880
    885881        // Update forums visibility setting
     
    912908    if ( bbp_get_hidden_status_id() != $current_visibility ) {
    913909
    914         // Remove from _bbp_private_forums site option
    915         if ( bbp_get_private_status_id() == $current_visibility ) {
    916 
    917             // Get private forums
    918             $private = bbp_get_private_forum_ids();
    919 
    920             // Find this forum in the array
    921             if ( in_array( $forum_id, $private ) ) {
    922 
    923                 $offset = array_search( $forum_id, (array) $private );
    924 
    925                 // Splice around it
    926                 array_splice( $private, $offset, 1 );
    927 
    928                 // Update private forums minus this one
    929                 update_option( '_bbp_private_forums', array_unique( array_values( $private ) ) );
    930             }
     910        // Get private forums
     911        $private = bbp_get_private_forum_ids();
     912
     913        // Find this forum in the array
     914        if ( in_array( $forum_id, $private ) ) {
     915
     916            $offset = array_search( $forum_id, $private );
     917
     918            // Splice around it
     919            array_splice( $private, $offset, 1 );
     920
     921            // Update private forums minus this one
     922            update_option( '_bbp_private_forums', array_unique( array_filter( array_values( $private ) ) ) );
    931923        }
    932924
     
    934926        $hidden   = bbp_get_hidden_forum_ids();
    935927        $hidden[] = $forum_id;
    936         update_option( '_bbp_hidden_forums', array_unique( array_values( $hidden ) ) );
     928        update_option( '_bbp_hidden_forums', array_unique( array_filter( array_values( $hidden ) ) ) );
    937929
    938930        // Update forums visibility setting
Note: See TracChangeset for help on using the changeset viewer.