Collapsable YaBB Front End 1.3.a Allows board members to collapse the board index to show only those categorys that they are interested in. Settings for each member are stored in a .cat file in your /Members directory. Hence this mod does not modify any existing YaBB variable or member files. Might not play well with other mods that effect the BoardIndex.pl file, especially those that fiddle with the display of categories and boards. No probs with advanced instant messanger. History: -------- 1.3.a adds instructions to make it work with Yabb SP1.3.2 1.3 - .cat files are now deleted (oops!) 1.2 - added icon showing if there are new posts in a category - only displays when cat is collapsed 1.2 - categories defualt to expanded when .cat file is modified 1.1 - Removed code that upgrades old .cat files Author's Email: morpj97@hn.ozemail.com.au snYpir http://boardmod.yabbforum.com/yabb/YaBB.pl?action=viewprofile&username=snYpir Sources\BoardIndex.pl $txt{'20'} ~; ### snYpir's collapsable YaBB part 1 # expand/collapse all buttons if ( $username ne 'Guest' ){ $yymain .= qq~
$txt{'20'} · $exptxt{'1'} · $exptxt{'2'} ·
~; } else{ $yymain .= qq~$txt{'20'}~; } ### end snYpir's collapsable YaBB part 1 $yymain .= qq~
foreach $curcat (@categories) { unless( $openmemgr{$curcat} ) { next; } ### snYpir's collapsable YaBB part 2 # init catstatus counter my $catcount=0; if ( $username ne 'Guest' ){ # load the .cat file for this user, put into array fopen(FILE, "$memberdir/$username.cat"); @catstatus = ; fclose(FILE); # remove trailing newline chars for( $_ = 0; $_ < @catstatus; $_++ ) { chomp $catstatus[$_]; } # .cat file for this user not found, or number of categories changed? if ( @catstatus ne @categories ){ # write new .cat file for user fopen( FILE, ">$memberdir/$username.cat", 1); for( $_ = 0; $_ < @categories; $_++ ) { print FILE "1\n"; } fclose(FILE); fopen(FILE, "$memberdir/$username.cat"); @catstatus = ; fclose(FILE); for( $_ = 0; $_ < @catstatus; $_++ ) { chomp $catstatus[$_]; } } } ### end snYpir's collapsable YaBB part 2 $catname{$curcat} ~; ### snYpir's collapsable YaBB part 3 if ( $username ne 'Guest' ) { my $newmsg = 0; my $new = ""; # determine if there are new posts somewhere in this category, but only if cat is collapsed if ( !$catstatus[$catcount] ) { foreach $curboard (@{$catboards{$curcat}}) { chomp $curboard; my $dlp = &getlog($curboard); if( $max_log_days_old && $lastposttime{$curboard} ne $txt{'470'} && $dlp < stringtotime( $lastpostrealtime{$curboard} ) ) { $newmsg = 1; last; } } if ( $newmsg ) { $new = qq~$txt{'333'}~; } else { $new = qq~$txt{'334'}~; } } $yymain .= qq~« $new $catname{$curcat} »~; } else { $yymain .= qq~« $catname{$curcat} »~; } ### end snYpir's collapsable YaBB part 3 $yymain .= qq~ foreach $curboard (@{$catboards{$curcat}}) { chomp $curboard; fopen(FILE, "$boardsdir/$curboard.dat"); ### snYpir's collapsable YaBB part 4 # if category is open, display boards (or if this user is a guest) if( $catstatus[$catcount] || $username eq 'Guest' ){ ### end snYpir's collapsable YaBB part 4 } my $checkadded = 0; ### snYpir's collapsable YaBB part 5 #endif } ++$catcount; ### end snYpir's collapsable YaBB part 5 sub MarkAllRead { ### snYpir's collapsable YaBB - subs sub Collapse_Cat { my ($catindex,@catstatus); if ( $username eq 'Guest' ){ &fatal_error($exptxt{'4'}); exit; } # Grab the index of the category to collapse/expand $catindex = $INFO{'cat'}; # read the current users category file fopen(FILE, "$memberdir/$username.cat"); @catstatus = ; fclose(FILE); chomp @catstatus; # does the file exist? if ( $catstatus[0] != 1 && $catstatus[0] != 0 ){ &fatal_error($exptxt{'3'}); exit; } # toggle the status of the selected category if ( $catstatus[$catindex] eq 1 ){ $catstatus[$catindex] = 0; } else{ $catstatus[$catindex] = 1; } # rewrite category file for this user fopen( FILE, ">$memberdir/$username.cat", 1); for( $_ = 0; $_ < @catstatus; $_++ ) { print FILE "$catstatus[$_]\n"; } fclose(FILE); &redirectinternal; exit; } sub Collapse_All { my ($state,@catstatus); $state = $INFO{'status'}; if ( $username eq 'Guest' ){ &fatal_error($exptxt{'4'}); exit; } # read the current users category file fopen(FILE, "$memberdir/$username.cat"); my @catstatus = ; fclose(FILE); chomp @catstatus; # does the file exist? if ( $catstatus[0] != 1 && $catstatus[0] != 0 ){ &fatal_error($exptxt{'3'}); exit; } # rewrite category file for this user fopen( FILE, ">$memberdir/$username.cat", 1); for( $_ = 0; $_ < @catstatus; $_++ ) { print FILE "$state\n"; } fclose(FILE); &redirectinternal; exit; } ### end snYpir's collapsable YaBB - subs english.lng 1; $exptxt{'1'} = "Expand"; $exptxt{'2'} = "Collapse"; $exptxt{'3'} = " User category file not found - please try refreshing the board index (back then F5).\n If you receive this message again, please inform an administrator."; $exptxt{'4'} = " You must be a member to use the collapsable/collapsable categories!"; ### If you are running YaBB 1.3.2 skip edit file YaBB.pl section YaBB.pl elsif ($action eq 'clean_log') { require "$sourcedir/Admin.pl"; &clean_log; } elsif ($action eq 'collapse_cat') { require "$sourcedir/BoardIndex.pl"; &Collapse_Cat; } elsif ($action eq 'collapse_all') { require "$sourcedir/BoardIndex.pl"; &Collapse_All; } ### If you are running YaBB SP1.3.2 only Sublist.pl 'clean_log',"Admin.pl&clean_log", 'collapse_cat',"BoardIndex.pl&Collapse_Cat", 'collapse_all',"BoardIndex.pl&Collapse_All", ### End YaBB SP 1.3.2 only section Sources\Profile.pl unlink("$memberdir/$member{'username'}.log"); unlink("$memberdir/$member{'username'}.cat"); unlink("$memberdir/$username.log"); unlink("$memberdir/$username.cat"); Sources\Admin.pl unlink("$memberdir/$currentmem.log"); unlink("$memberdir/$currentmem.cat");