Jump to content

  • Chat
  •  
  •  

Welcome to Formiculture.com!

This is a website for anyone interested in Myrmecology and all aspects of finding, keeping, and studying ants. The site and forum are free to use. Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation points to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. If you already have an account, login here - otherwise create an account for free today!

Photo

Request for some help with a simple PHP modification


  • Please log in to reply
27 replies to this topic

#21 Offline dspdrew - Posted April 9 2017 - 4:34 AM

dspdrew
  • LocationSanta Ana, CA

Barristan is the winner!

 

Thanks, man.


  • MikeMc likes this

#22 Offline dspdrew - Posted April 9 2017 - 8:11 AM

dspdrew
  • LocationSanta Ana, CA

While I have this thread here, and apparently the attention of some who know PHP, I'm going to work on a couple other mods I have had planned. If I run into trouble I'll be posting it here.



#23 Offline dspdrew - Posted April 9 2017 - 9:25 AM

dspdrew
  • LocationSanta Ana, CA

Does this "hook" work by sort of intercepting the arrays, modifying them, and then sending them to the template?

/**
 * Remove Forums from Board Index
 * @file        tbRfbiBoardIndex.php     Skin overloader (skin_boards)
 *
 * @copyright    (c) 2006 - 2013 Invision Byte
 * @link        http://www.invisionbyte.net/
 * @author        Terabyte
 * @since        17/12/2010
 * @updated        07/08/2011
 * @version        2.0.0 (20000)
 */
class tbRfbiBoardIndex extends skin_boards(~id~)
{
    public function boardIndexTemplate( $lastvisit="", $stats=array(), $cat_data=array(), $show_side_blocks=true, $side_blocks=array() )
    {
        /* Prepare.. */
        $this->settings['tb_rfbi_forums'] = IPSText::cleanPermString( $this->settings['tb_rfbi_forums'] );
        
        if ( $this->settings['tb_rfbi_forums'] && is_array($cat_data) && count($cat_data) )
        {
            /* ..and explode! */
            $idsToHide = array_flip( explode(',', $this->settings['tb_rfbi_forums']) ); // Flip it!
            
            foreach( $cat_data as $catIndex => $catData )
            {
                /* Take care of the categories */
                if ( isset($idsToHide[ $catData['cat_data']['id'] ]) )
                {
                    unset( $cat_data[ $catIndex ], $idsToHide[ $catData['cat_data']['id'] ] );
                    
                    /* Count check */
                    if ( !count($idsToHide) )
                    {
                        break;
                    }
                }
                /* Take care of forums */
                elseif ( is_array($catData['forum_data']) && count($catData['forum_data']) )
                {
                    foreach( $catData['forum_data'] as $fIndex => $fData )
                    {
                        if ( isset($idsToHide[ $fIndex ]) )
                        {
                            unset( $cat_data[ $catIndex ]['forum_data'][ $fIndex ], $idsToHide[ $fIndex ] );
                                    
                            /* Count check */
                            if ( !count($idsToHide) )
                            {
                                break 2;
                            }
                        }
                        /* Take care of subforums */
                        elseif ( is_array($fData['subforums']) && count($fData['subforums']) )
                        {
                            foreach( $fData['subforums'] as $subIndex => $subData )
                            {
                                if ( isset($idsToHide[ $subData[0] ]) )
                                {
                                    unset( $cat_data[ $catIndex ]['forum_data'][ $fIndex ]['subforums'][ $subIndex ], $idsToHide[ $subData[0] ] );
                                    
                                    /* Count check */
                                    if ( !count($idsToHide) )
                                    {
                                        break 3;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        
        return parent::boardIndexTemplate( $lastvisit, $stats, $cat_data, $show_side_blocks, $side_blocks );
    }
}


#24 Offline dspdrew - Posted April 9 2017 - 11:10 AM

dspdrew
  • LocationSanta Ana, CA

Okay I can't figure it out without spending days and days studying PHP. Does anyone know how I can modify the above code to hide an entire forum category (ID: 45) from the index page, excluding (allowing it to show) for all members in a particular group (ID: 17)?

 

The settings for this hook only allow me to hide categories, forums , and subforums from the index page for all groups. I want to add a conditional to hide it from all but one, or a list of groups.



#25 Offline teek - Posted April 10 2017 - 6:42 PM

teek

    Member

  • Members
  • PipPip
  • 11 posts
  • LocationArizona
Nested if, excuse the pseudo code:
if(forumIndex != 45){
/* Usual code to display */
} else {
if(groupID = 17) {
/* Usual code to display */
} else {
break
}
}

#26 Offline teek - Posted April 10 2017 - 6:43 PM

teek

    Member

  • Members
  • PipPip
  • 11 posts
  • LocationArizona
Or compound:
if(forumIndex != 45 && groupID = 17){
/* Usual code to display */
} else {
break
}

#27 Offline dspdrew - Posted April 11 2017 - 3:34 AM

dspdrew
  • LocationSanta Ana, CA

Yeah I get the general idea, but I need to know the actual variables/arrays and how to get them.



#28 Offline Barristan - Posted April 17 2017 - 12:23 AM

Barristan

    Advanced Member

  • Members
  • PipPipPip
  • 884 posts
  • LocationBindlach, Bavaria, Germany

Yeah I get the general idea, but I need to know the actual variables/arrays and how to get them.

 

I think you'll have to find out how to obtain the current user and his group because nobody seems to know how to do that ;)






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users