| ############################################################################### |
| ############################################################################### |
| # Notify.pl # |
| # Notify.pm # |
| |
| # $Date: 01.05.16 $ # |
| ############################################################################### |
| ############################################################################### |
| # YaBB: Yet another Bulletin Board # |
| # YaBB: Yet another Bulletin Board # |
| # Open-Source Community Software for Webmasters # |
| # Open-Source Community Software for Webmasters # |
| # Version: YaBB 2.5.2 # |
| # Version: YaBB 2.6.12 # |
| # Packaged: October 21, 2012 # |
| # Packaged: January 5, 2016 # |
| # Distributed by: http://www.yabbforum.com # |
| # Distributed by: http://www.yabbforum.com # |
| # =========================================================================== # |
| # =========================================================================== # |
| # Copyright (c) 2000-2012 YaBB (www.yabbforum.com) - All Rights Reserved. # |
| # Copyright (c) 2000-2016 YaBB (www.yabbforum.com) - All Rights Reserved. # |
| # Software by: The YaBB Development Team # |
| # Software by: The YaBB Development Team # |
| # with assistance from the YaBB community. # |
| # with assistance from the YaBB community. # |
| ############################################################################### |
| ############################################################################### |
| |
| use CGI::Carp qw(fatalsToBrowser); |
| |
| our $VERSION = '2.6.12'; |
| |
| |
| $notifyplver = 'YaBB 2.5.2 $Revision: 1.0 $'; |
| $notifypmver = 'YaBB 2.6.12 $Revision: 1651 $'; |
| if ($action eq 'detailedversion') { return 1; } |
| if ( $action eq 'detailedversion' ) { return 1; } |
| |
| |
| &LoadLanguage('Notify'); |
| LoadLanguage('Notify'); |
| |
| |
| sub ManageBoardNotify { |
| sub ManageBoardNotify { |
| my $todo = $_[0]; |
| my ( $todo, $theboard, $user, $userlang, $notetype, $noteview ) = @_; |
| my $theboard = $_[1]; |
| if ( $todo eq 'load' |
| my $user = $_[2]; |
| || $todo eq 'update' |
| my $userlang = $_[3]; |
| || $todo eq 'delete' |
| my $notetype = $_[4]; |
| || $todo eq 'add' ) |
| my $noteview = $_[5]; |
| { |
| if ($todo eq "load" || $todo eq "update" || $todo eq "delete" || $todo eq "add") { |
| undef %theboard; |
| undef %theboard; |
| ## open board mail file and build hash name / detail |
| ## open board mail file and build hash name / detail |
| if ( -e "$boardsdir/$theboard.mail" ) { |
| if (-e "$boardsdir/$theboard.mail") { |
| fopen( BOARDNOTE, "$boardsdir/$theboard.mail" ); |
| fopen(BOARDNOTE, "$boardsdir/$theboard.mail"); |
| %theboard = map { /(.*)\t(.*)/xsm } <BOARDNOTE>; |
| %theboard = map /(.*)\t(.*)/, <BOARDNOTE>; |
| fclose(BOARDNOTE); |
| fclose(BOARDNOTE); |
| } |
| } |
| } |
| } |
| if ( $todo eq 'add' ) { |
| if ($todo eq "add") { |
| if ( !$maxtnote ) { $maxtnote = 10; } |
| $theboard{$user} = "$userlang|$notetype|$noteview"; |
| $theboard{$user} = "$userlang|$notetype|$noteview"; |
| &LoadUser($user); |
| LoadUser($user); |
| my %b; |
| my %bb; |
| foreach (split(/,/, ${$uid.$user}{'board_notifications'})) { |
| my @oldnote = split /,/xsm, |
| $b{$_} = 1; |
| ${ $uid . $username }{'board_notifications'}; |
| } |
| if ( @oldnote < ( $maxtnote || 10 ) ) { |
| $b{$theboard} = 1; |
| foreach ( split /,/xsm, ${ $uid . $user }{'board_notifications'} ) { |
| ${$uid.$user}{'board_notifications'} = join(',', keys %b); |
| $bb{$_} = 1; |
| &UserAccount($user); |
| } |
| } elsif ($todo eq "update") { |
| $bb{$theboard} = 1; |
| if (exists $theboard{$user}) { |
| ${ $uid . $user }{'board_notifications'} = join q{,}, keys %bb; |
| my ($memlang, $memtype, $memview) = split(/\|/, $theboard{$user}); |
| UserAccount($user); |
| if ($userlang) { $memlang = $userlang; } |
| } |
| if ($notetype) { $memtype = $notetype; } |
| } |
| if ($noteview) { $memview = $noteview; } |
| elsif ( $todo eq 'update' ) { |
| $theboard{$user} = "$memlang|$memtype|$memview"; |
| if ( exists $theboard{$user} ) { |
| } |
| my ( $memlang, $memtype, $memview ) = |
| } elsif ($todo eq "delete") { |
| split /\|/xsm, $theboard{$user}; |
| my %b; |
| if ($userlang) { $memlang = $userlang; } |
| foreach my $u (split(',', $user)) { |
| if ($notetype) { $memtype = $notetype; } |
| delete $theboard{$u}; |
| if ($noteview) { $memview = $noteview; } |
| &LoadUser($u); |
| $theboard{$user} = "$memlang|$memtype|$memview"; |
| foreach (split(/,/, ${$uid.$u}{'board_notifications'})) { $b{$_} = 1; } |
| } |
| if (delete $b{$theboard}) { |
| } |
| ${$uid.$u}{'board_notifications'} = join(',', keys %b); |
| elsif ( $todo eq 'delete' ) { |
| &UserAccount($u); |
| my %bb; |
| } |
| foreach my $u ( split /,/xsm, $user ) { |
| undef %b; |
| delete $theboard{$u}; |
| } |
| LoadUser($u); |
| } |
| foreach ( split /,/xsm, ${ $uid . $u }{'board_notifications'} ) { |
| if ($todo eq "save" || $todo eq "update" || $todo eq "delete" || $todo eq "add") { |
| $bb{$_} = 1; |
| if (%theboard) { |
| } |
| fopen(BOARDNOTE, ">$boardsdir/$theboard.mail"); |
| if ( delete $bb{$theboard} ) { |
| print BOARDNOTE map "$_\t$theboard{$_}\n", sort { $theboard{$a} cmp $theboard{$b} } keys %theboard; |
| ${ $uid . $u }{'board_notifications'} = join q{,}, keys %bb; |
| fclose(BOARDNOTE); |
| UserAccount($u); |
| undef %theboard; |
| } |
| } else { |
| undef %bb; |
| unlink("$boardsdir/$theboard.mail"); |
| } |
| } |
| } |
| } |
| if ( $todo eq 'save' |
| |
| || $todo eq 'update' |
| |
| || $todo eq 'delete' |
| |
| || $todo eq 'add' ) |
| |
| { |
| |
| if (%theboard) { |
| |
| fopen( BOARDNOTE, ">$boardsdir/$theboard.mail" ); |
| |
| print {BOARDNOTE} map { "$_\t$theboard{$_}\n" } |
| |
| sort { $theboard{$a} cmp $theboard{$b} } keys %theboard |
| |
| or croak "$croak{'print'} BOARDNOTE"; |
| |
| fclose(BOARDNOTE); |
| |
| undef %theboard; |
| |
| } |
| |
| else { |
| |
| unlink "$boardsdir/$theboard.mail"; |
| |
| } |
| |
| } |
| |
| return; |
| } |
| } |
| |
| |
| sub BoardNotify { |
| sub BoardNotify { |
| if (!$currentboard) { &fatal_error("no_access"); } |
| if ( !$currentboard ) { fatal_error('no_access'); } |
| if ($iamguest) { &fatal_error("members_only"); } |
| if ($iamguest) { fatal_error('members_only'); } |
| my ($curuser, $curlang, $notifytype); |
| $selected1 = q{}; |
| $selected1 = ""; |
| $selected2 = q{}; |
| $selected2 = ""; |
| $deloption = q{}; |
| $deloption = ""; |
| my ( $boardname, undef ) = split /\|/xsm, $board{$currentboard}, 2; |
| my ($boardname, undef) = split(/\|/, $board{$currentboard}, 2); |
| ToChars($boardname); |
| &ToChars($boardname); |
| ManageBoardNotify( 'load', $currentboard ); |
| &ManageBoardNotify("load", $currentboard); |
| |
| $yymain .= qq~ |
| ## popup from MessageIndex |
| <form action="$scripturl?action=boardnotify3;board=$currentboard" method="post"> |
| |
| <table border="0" width="600" cellspacing="1" cellpadding="4" align="center" class="bordercolor"> |
| LoadLanguage('Notify'); |
| <tr> |
| get_template('MessageIndex'); |
| <td colspan="2" align="left" class="titlebg"> |
| |
| <img src="$imagesdir/notify.gif" alt="$notify_txt{'136'} - $boardname" title="$notify_txt{'136'} - $boardname" /> <span class="text1"><b>$notify_txt{'136'} - $boardname</b></span> |
| if ( exists $theboard{$username} ) { |
| </td> |
| ( $memlang, $memtype, $memview ) = split /\|/xsm, $theboard{$username}; |
| </tr><tr> |
| ${ 'selected' . $memtype } = q~ selected="selected"~; |
| <td class="windowbg" width="70%" align="left" valign="middle"><br /> |
| $deloption = qq~<option value="3">$notify_txt{'134'}</option>~; |
| ~; |
| $my_delopt = qq~$notify_txt{'137'} ~; |
| |
| } |
| if (exists $theboard{$username}) { |
| else { |
| ($memlang, $memtype, $memview) = split(/\|/, $theboard{$username}); |
| $my_delopt = qq~$notify_txt{'126'} ~; |
| ${ selected . $memtype } = qq~ selected="selected"~; |
| } |
| $deloption = qq~<option value="3">$notify_txt{'134'}</option>~; |
| |
| $yymain .= qq~$notify_txt{'137'} ~; |
| $yymain .= $brd_notify; |
| } else { |
| $yymain =~ s/{yabb boardname}/$boardname/gsm; |
| $yymain .= qq~$notify_txt{'126'} ~; |
| $yymain =~ s/{yabb currentboard}/$currentboard/gsm; |
| } |
| $yymain =~ s/{yabb currentboard}/$currentboard/gsm; |
| $yymain .= qq~ |
| $yymain =~ s/{yabb selected1}/$selected1/gsm; |
| <br /><br /> |
| $yymain =~ s/{yabb selected2}/$selected2/gsm; |
| </td><td class="windowbg" width="30%" align="center" valign="middle"> |
| $yymain =~ s/{yabb deloption}/$deloption/gsm; |
| <select name="$currentboard"> |
| $yymain =~ s/{yabb my_delopt}/$my_delopt/gsm; |
| <option value="1"$selected1>$notify_txt{'132'}</option> |
| |
| <option value="2"$selected2>$notify_txt{'133'}</option> |
| undef %theboard; |
| $deloption |
| $yytitle = "$notify_txt{'125'}"; |
| </select> |
| template(); |
| </td></tr> |
| return; |
| <tr> |
| |
| <td colspan="2" class="catbg" align="center"> |
| |
| <input type="submit" value="$notify_txt{'124'}" class="button" /> |
| |
| </td> |
| |
| </tr> |
| |
| </table> |
| |
| </form> |
| |
| ~; |
| |
| undef %theboard; |
| |
| $yytitle = "$notify_txt{'125'}"; |
| |
| &template; |
| |
| } |
| } |
| |
| |
| sub BoardNotify2 { |
| sub BoardNotify2 { |
| if ($iamguest) { &fatal_error("members_only"); } |
| if ($iamguest) { fatal_error('members_only'); } |
| foreach $variable (keys %FORM) { |
| foreach my $variable ( keys %FORM ) { |
| if ($variable eq 'formsession') { next; } |
| if ( $variable eq 'formsession' ) { next; } |
| $notify_type = $FORM{$variable}; |
| $notify_type = $FORM{$variable}; |
| if ($notify_type == 1 || $notify_type == 2) { |
| if ( $notify_type == 1 || $notify_type == 2 ) { |
| &ManageBoardNotify("add", $variable, $username, ${$uid.$username}{'language'}, $notify_type, "1"); |
| ManageBoardNotify( 'add', $variable, $username, |
| } elsif ($notify_type == 3) { |
| ${ $uid . $username }{'language'}, |
| &ManageBoardNotify("delete", $variable, $username); |
| $notify_type, '1' ); |
| } |
| } |
| } |
| elsif ( $notify_type == 3 ) { |
| if ($action eq "boardnotify3") { |
| ManageBoardNotify( 'delete', $variable, $username ); |
| $yySetLocation = qq~$scripturl?board=$INFO{'board'}~; |
| } |
| } else { |
| } |
| $yySetLocation = qq~$scripturl?action=shownotify~; |
| if ( $action eq 'boardnotify3' ) { |
| } |
| $yySetLocation = qq~$scripturl?board=$INFO{'board'}~; |
| &redirectexit; |
| } |
| |
| else { |
| |
| $yySetLocation = qq~$scripturl?action=shownotify~; |
| |
| } |
| |
| redirectexit(); |
| |
| return; |
| } |
| } |
| |
| |
| sub ManageThreadNotify { |
| sub ManageThreadNotify { |
| my $todo = $_[0]; |
| my ( $todo, $thethread, $user, $userlang, $notetype, $noteview ) = @_; |
| my $thethread = $_[1]; |
| if ( $todo eq 'load' |
| my $user = $_[2]; |
| || $todo eq 'update' |
| my $userlang = $_[3]; |
| || $todo eq 'delete' |
| my $notetype = $_[4]; |
| || $todo eq 'add' ) |
| my $noteview = $_[5]; |
| { |
| |
| undef %thethread; |
| if ($todo eq "load" || $todo eq "update" || $todo eq "delete" || $todo eq "add") { |
| ## open mail file and build hash |
| undef %thethread; |
| if ( -e "$datadir/$thethread.mail" ) { |
| ## open mail file and build hash |
| fopen( THREADNOTE, "$datadir/$thethread.mail" ); |
| if (-e "$datadir/$thethread.mail") { |
| %thethread = map /(.*)\t(.*)/, <THREADNOTE>; |
| fopen(THREADNOTE, "$datadir/$thethread.mail"); |
| fclose(THREADNOTE); |
| %thethread = map /(.*)\t(.*)/, <THREADNOTE>; |
| } |
| fclose(THREADNOTE); |
| } |
| } |
| if ( $todo eq 'add' ) { |
| } |
| $thethread{$user} = "$userlang|$notetype|$noteview"; |
| if ($todo eq "add") { |
| LoadUser($user); |
| $thethread{$user} = "$userlang|$notetype|$noteview"; |
| my %t; |
| &LoadUser($user); |
| foreach ( split /,/xsm, ${ $uid . $user }{'thread_notifications'} ) { |
| my %t; |
| $t{$_} = 1; |
| foreach (split(/,/, ${$uid.$user}{'thread_notifications'})) { |
| } |
| $t{$_} = 1; |
| $t{$thethread} = 1; |
| } |
| ${ $uid . $user }{'thread_notifications'} = join q{,}, keys %t; |
| $t{$thethread} = 1; |
| UserAccount($user); |
| ${$uid.$user}{'thread_notifications'} = join(',', keys %t); |
| } |
| &UserAccount($user); |
| elsif ( $todo eq 'update' ) { |
| } elsif ($todo eq "update") { |
| if ( exists $thethread{$user} ) { |
| if (exists $thethread{$user}) { |
| ( $memlang, $memtype, $memview ) = split /\|/xsm, $thethread{$user}; |
| ($memlang, $memtype, $memview) = split(/\|/, $thethread{$user}); |
| if ($userlang) { $memlang = $userlang; } |
| if ($userlang) { $memlang = $userlang; } |
| if ($notetype) { $memtype = $notetype; } |
| if ($notetype) { $memtype = $notetype; } |
| if ($noteview) { $memview = $noteview; } |
| if ($noteview) { $memview = $noteview; } |
| $thethread{$user} = "$memlang|$memtype|$memview"; |
| $thethread{$user} = "$memlang|$memtype|$memview"; |
| } |
| } |
| } |
| } elsif ($todo eq "delete") { |
| elsif ( $todo eq 'delete' ) { |
| my %t; |
| my %t; |
| foreach my $u (split(',', $user)) { |
| foreach my $u ( split /,/xsm, $user ) { |
| delete $thethread{$u}; |
| delete $thethread{$u}; |
| &LoadUser($u); |
| LoadUser($u); |
| foreach (split(/,/, ${$uid.$u}{'thread_notifications'})) { $t{$_} = 1; } |
| foreach ( split /,/xsm, ${ $uid . $u }{'thread_notifications'} ) { |
| if (delete $t{$thethread}) { |
| $t{$_} = 1; |
| ${$uid.$u}{'thread_notifications'} = join(',', keys %t); |
| } |
| &UserAccount($u); |
| if ( delete $t{$thethread} ) { |
| } |
| ${ $uid . $u }{'thread_notifications'} = join q{,}, keys %t; |
| undef %t; |
| UserAccount($u); |
| } |
| } |
| } |
| undef %t; |
| if ($todo eq "save" || $todo eq "update" || $todo eq "delete" || $todo eq "add") { |
| } |
| if (%thethread) { |
| } |
| fopen(THREADNOTE, ">$datadir/$thethread.mail"); |
| if ( $todo eq 'save' |
| print THREADNOTE map "$_\t$thethread{$_}\n", sort { $thethread{$a} cmp $thethread{$b} } keys %thethread; |
| || $todo eq 'update' |
| fclose(THREADNOTE); |
| || $todo eq 'delete' |
| undef %thethread; |
| || $todo eq 'add' ) |
| } else { |
| { |
| unlink("$datadir/$thethread.mail"); |
| if (%thethread) { |
| } |
| fopen( THREADNOTE, ">$datadir/$thethread.mail" ); |
| } |
| print {THREADNOTE} map { "$_\t$thethread{$_}\n" } |
| |
| sort { $thethread{$a} cmp $thethread{$b} } keys %thethread |
| |
| or croak "$croak{'print'} THREADNOTE"; |
| |
| fclose(THREADNOTE); |
| |
| undef %thethread; |
| |
| } |
| |
| else { |
| |
| unlink "$datadir/$thethread.mail"; |
| |
| } |
| |
| } |
| |
| return; |
| } |
| } |
| |
| |
| # sub Notify { delted because not needed any more since YaBB 2.3 (deti) |
| # sub Notify { deleted because not needed since YaBB 2.3 (deti) |
| |
| |
| sub Notify2 { |
| sub Notify2 { |
| if ($iamguest) { &fatal_error("members_only"); } |
| if ($iamguest) { fatal_error('members_only'); } |
| |
| |
| &ManageThreadNotify("add", $INFO{'num'}, $username, ${$uid.$username}{'language'}, 1, 1); |
| ManageThreadNotify( 'add', $INFO{'num'}, $username, |
| |
| ${ $uid . $username }{'language'}, |
| if ($INFO{'oldnotify'}) { |
| 1, 1 ); |
| &redirectinternal; |
| |
| } |
| if ( $INFO{'oldnotify'} ) { |
| $elenable = 0; |
| redirectinternal(); |
| die ""; # This is here only to avoid server error log entries! |
| } |
| |
| $elenable = 0; |
| |
| croak q{}; # This is here only to avoid server error log entries! |
| } |
| } |
| |
| |
| sub Notify3 { |
| sub Notify3 { |
| if ($iamguest) { &fatal_error("members_only"); } |
| if ($iamguest) { fatal_error('members_only'); } |
| |
| |
| &ManageThreadNotify("delete", $INFO{'num'}, $username); |
| ManageThreadNotify( 'delete', $INFO{'num'}, $username ); |
| |
| |
| if ($INFO{'oldnotify'}) { |
| if ( $INFO{'oldnotify'} ) { |
| &redirectinternal; |
| redirectinternal(); |
| } |
| } |
| $elenable = 0; |
| $elenable = 0; |
| die ""; # This is here only to avoid server error log entries! |
| croak q{}; # This is here only to avoid server error log entries! |
| } |
| } |
| |
| |
| sub Notify4 { |
| sub Notify4 { |
| if ($iamguest) { &fatal_error("members_only"); } |
| if ($iamguest) { fatal_error('members_only'); } |
| my ($variable, $notype, $threadno); |
| foreach my $variable ( keys %FORM ) { |
| foreach $variable (keys %FORM) { |
| my ( $notype, $threadno ) = split /-/xsm, $variable; |
| ($notype, $threadno) = split(/-/, $variable); |
| if ( $notype eq 'thread' ) { |
| if ($notype eq "thread") { |
| ManageThreadNotify( 'delete', $threadno, $username ); |
| &ManageThreadNotify("delete", $threadno, $username); |
| } |
| } |
| } |
| } |
| $action = 'shownotify'; |
| $action = 'shownotify'; |
| ShowNotifications(); |
| &ShowNotifications; |
| return; |
| } |
| } |
| |
| |
| sub updateLanguage { |
| sub updateLanguage { |
| my ($user,$newlang) = @_; |
| my ( $user, $newlang ) = @_; |
| &getMailFiles; |
| getMailFiles(); |
| foreach (@bmaildir) { |
| foreach (@bmaildir) { |
| &ManageBoardNotify("update", $_, $user, $newlang, "", ""); |
| ManageBoardNotify( 'update', $_, $user, $newlang, q{}, q{} ); |
| } |
| } |
| foreach (@tmaildir) { |
| foreach (@tmaildir) { |
| &ManageThreadNotify("update", $_, $user, $newlang, "", ""); |
| ManageThreadNotify( 'update', $_, $user, $newlang, q{}, q{} ); |
| } |
| } |
| |
| return; |
| } |
| } |
| |
| |
| sub removeNotifications { |
| sub removeNotifications { |
| my $user_s = shift; |
| my $user_s = shift; |
| &getMailFiles; |
| getMailFiles(); |
| foreach (@bmaildir) { |
| foreach (@bmaildir) { |
| &ManageBoardNotify("delete", $_, $user_s); |
| ManageBoardNotify( 'delete', $_, $user_s ); |
| } |
| } |
| foreach (@tmaildir) { |
| foreach (@tmaildir) { |
| &ManageThreadNotify("delete", $_, $user_s); |
| ManageThreadNotify( 'delete', $_, $user_s ); |
| } |
| } |
| |
| return; |
| } |
| } |
| |
| |
| sub getMailFiles { |
| sub getMailFiles { |
| opendir(BOARDNOT, "$boardsdir"); |
| opendir BOARDNOT, "$boardsdir"; |
| @bmaildir = map { (split(/\./, $_))[0] } grep { /\.mail$/ } readdir(BOARDNOT); |
| @bmaildir = |
| closedir(BOARDNOT); |
| map { ( split /\./xsm, $_ )[0] } grep { /\.mail$/xsm } readdir BOARDNOT; |
| opendir(THREADNOT, "$datadir"); |
| closedir BOARDNOT; |
| @tmaildir = map { (split(/\./, $_))[0] } grep { /\.mail$/ } readdir(THREADNOT); |
| opendir THREADNOT, "$datadir"; |
| closedir(THREADNOT); |
| @tmaildir = |
| |
| map { ( split /\./xsm, $_ )[0] } grep { /\.mail$/xsm } readdir THREADNOT; |
| |
| closedir THREADNOT; |
| |
| return; |
| } |
| } |
| |
| |
| sub ShowNotifications { |
| sub ShowNotifications { |
| ## bye bye guest.... |
| ## bye bye guest.... |
| if ($iamguest) { &fatal_error("members_only"); } |
| if ($iamguest) { fatal_error('members_only'); } |
| |
| |
| |
| $yynavigation = |
| |
| qq~› <a href="$scripturl?action=mycenter" class="nav">$img_txt{'mycenter'}</a> › $img_txt{'418'}~; |
| |
| |
| $yynavigation = qq~› <a href="$scripturl?action=mycenter" class="nav">$img_txt{'mycenter'}</a> › $img_txt{'418'}~; |
| LoadLanguage('Notify'); |
| |
| get_template('MyPosts'); |
| |
| |
| # Show Javascript for 'check all' notifications |
| my @oldnote = split /,/xsm, ${ $uid . $username }{'board_notifications'}; |
| $showNotifications .= qq~ |
| $curbrd = @oldnote; |
| <script language="Javascript1.2" type="text/javascript"> |
| |
| <!-- |
| $curbrd = NumberFormat($curbrd); |
| function checkAll(j) { |
| |
| for (var i = 0; i < document.threadnotify.elements.length; i++) { |
| # Show Javascript for 'check all' notifications |
| if (j == 0 ) {document.threadnotify.elements[i].checked = true;} |
| |
| } |
| ( $board_notify, $thread_notify ) = NotificationAlert(); |
| } |
| my ( $num, $new ); |
| function uncheckAll(j) { |
| getlog(); |
| for (var i = 0; i < document.threadnotify.elements.length; i++) { |
| my $dmax = $date - ( $max_log_days_old * 86400 ); |
| if (j == 0 ) {document.threadnotify.elements[i].checked = false;} |
| |
| } |
| # Board notifications |
| } |
| foreach ( keys %{$board_notify} ) { # boardname, boardnotifytype , new |
| //--> |
| $num++; |
| </script> |
| if ( $subboard{$_} ) { |
| |
| @brd = split /\|/xsm, $subboard{$_}; |
| <form action="$scripturl?action=boardnotify2" method="post" name="boardnotify"> |
| for my $i (@brd) { |
| <table border="0" width="100%" align="center" cellspacing="1" cellpadding="4" class="bordercolor"> |
| if ( |
| <tr><td colspan="2" align="left" class="titlebg"> |
| $max_log_days_old |
| <img src="$imagesdir/notify.gif" alt="$notify_txt{'136'}" title="$notify_txt{'136'}" /> <span class="text1"><b>$notify_txt{'136'}</b></span> |
| && int( ${ $uid . $i }{'lastposttime'} ) |
| </td></tr> |
| && ( |
| ~; |
| ( |
| |
| !$yyuserlog{$i} |
| ($board_notify,$thread_notify) = &NotificationAlert; |
| && ${ $uid . $i }{'lastposttime'} > $dmax |
| my ($num,$new); |
| ) |
| # Board notifications |
| || ( $yyuserlog{$i} > $dmax |
| foreach (keys %$board_notify) { # boardname, boardnotifytype , new |
| && $yyuserlog{$i} < ${ $uid . $i }{'lastposttime'} ) |
| $num++; |
| ) |
| |
| ) |
| my ($selected1, $selected2); |
| { |
| if (${$$board_notify{$_}}[1] == 1) { # new topics |
| ${ $$board_notify{$_} }[2] = 1; |
| $selected1 = qq~ selected="selected"~; |
| } |
| } else { # all new posts |
| } |
| $selected2 = qq~ selected="selected"~; |
| } |
| } |
| |
| |
| my ( $selected1, $selected2 ); |
| if (${$$board_notify{$_}}[2]) { |
| if ( ${ $$board_notify{$_} }[1] == 1 ) { # new topics |
| $new = qq~<img src="$imagesdir/on.gif" alt="$notify_txt{'333'}" title="$notify_txt{'333'}" border="0" style="vertical-align: middle;" />~; |
| $selected1 = q~ selected="selected"~; |
| } else { |
| } |
| $new = qq~<img src="$imagesdir/off.gif" alt="$notify_txt{'334'}" title="$notify_txt{'334'}" border="0" style="vertical-align: middle;" />~; |
| else { # all new posts |
| } |
| $selected2 = q~ selected="selected"~; |
| |
| } |
| ## output notify detail - option 3 = remove notify |
| |
| $boardblock .= qq~ |
| if ( ${ $$board_notify{$_} }[2] ) { |
| <tr><td align="left" width="65%" class="windowbg"> |
| $new = |
| $new <a href="$scripturl?board=$_">${$$board_notify{$_}}[0]</a> |
| qq~<img src="$imagesdir/$brdimg_new" alt="$notify_txt{'333'}" title="$notify_txt{'333'}" />~; |
| </td><td align="center" width="35%" class="windowbg"> |
| } |
| <select name="$_"> |
| else { |
| <option value="1"$selected1>$notify_txt{'132'}</option> |
| $new = |
| <option value="2"$selected2>$notify_txt{'133'}</option> |
| qq~<img src="$imagesdir/$brdimg_old" alt="$notify_txt{'334'}" title="$notify_txt{'334'}" />~; |
| <option value="3">$notify_txt{'134'}</option> |
| } |
| </select> |
| |
| </td></tr> |
| ## output notify detail - option 3 = remove notify |
| ~; |
| $boardblock .= $my_boardblock; |
| } |
| $boardblock =~ s/{yabb brd}/$_/gsm; |
| |
| $boardblock =~ s/{yabb new}/$new/gsm; |
| if (!$num) { # no board notifies up |
| $boardblock =~ s/{yabb brdnote0}/${$$board_notify{$_}}[0]/gsm; |
| $showNotifications .= qq~ |
| $boardblock =~ s/{yabb selected1}/$selected1/gsm; |
| <tr><td colspan="2" align="left" class="windowbg2"> |
| $boardblock =~ s/{yabb selected2}/$selected2/gsm; |
| <br /> |
| } |
| $notify_txt{'139'}<br /><br /> |
| |
| </td></tr> |
| if ( !$num ) { # no board notifies up |
| ~; |
| $my_showNotifications_b = $my_nonotes; |
| } else { # list boards |
| } |
| $showNotifications .= qq~ |
| else { # list boards |
| <tr><td align="left" class="catbg"> |
| $my_showNotifications_b = $my_notebrdlist; |
| <b>$notify_txt{'135'}</b> |
| $my_showNotifications_b =~ s/{yabb boardblock}/$boardblock/gsm; |
| </td><td align="center" class="catbg"> |
| } |
| <b>$notify_txt{'138'}</b> |
| |
| </td></tr> |
| $num = 0; |
| $boardblock |
| foreach ( keys %{$thread_notify} ) |
| <tr><td colspan="2" align="center" class="windowbg"> |
| { # mythread, msub, new, username_link, catname_link, boardname_link, lastpostdate |
| <input type="submit" value="$notify_txt{'124'}" class="button" /> <input type="reset" value="$notify_txt{'121'}" class="button" /> |
| $num++; |
| </td></tr> |
| |
| ~; |
| ## build block for display |
| } |
| $threadblock .= $my_threadblock; |
| |
| $threadblock =~ s/{yabb tnote0}/${$$thread_notify{$_}}[0]/gsm; |
| $showNotifications .= qq~ |
| $threadblock =~ s/{yabb tnote1}/${$$thread_notify{$_}}[1]/gsm; |
| </table> |
| $threadblock =~ s/{yabb tnote2}/${$$thread_notify{$_}}[2]/gsm; |
| </form> |
| $threadblock =~ s/{yabb tnote3}/${$$thread_notify{$_}}[3]/gsm; |
| <br /><br /> |
| $threadblock =~ s/{yabb tnote4}/${$$thread_notify{$_}}[4]/gsm; |
| |
| $threadblock =~ s/{yabb tnote5}/${$$thread_notify{$_}}[5]/gsm; |
| <form action="$scripturl?action=notify4" method="post" name="threadnotify"> |
| $threadblock =~ s/{yabb tnote6}/${$$thread_notify{$_}}[6]/gsm; |
| <table border="0" width="100%" align="center" cellspacing="1" cellpadding="4" class="bordercolor"> |
| } |
| <tr><td align="left" colspan="2" class="titlebg"> |
| |
| <img src="$imagesdir/notify.gif" alt="$notify_txt{'118'}" title="$notify_txt{'118'}" /> <span class="text1"><b>$notify_txt{'118'}</b></span> |
| if ( !$num ) { ## no threads listed |
| </td></tr> |
| $my_showNotifications_t = $my_nothreads; |
| ~; |
| } |
| |
| else { ## output details |
| $num = 0; |
| $my_showNotifications_t = $my_threadnote_b; |
| foreach (keys %$thread_notify) { # mythread, msub, new, username_link, catname_link, boardname_link, lastpostdate |
| $my_showNotifications_t =~ s/{yabb threadblock}/$threadblock/gsm; |
| $num++; |
| } |
| |
| $showNotifications = $my_boardnote; |
| ## build block for display |
| |
| $threadblock .= qq~ |
| # $showNotifications =~ s/{yabb note_brd}/$note_brd/sm; |
| <tr><td align="left" width="85%" class="windowbg2"> |
| $showNotifications =~ s/{yabb note_brd}//sm; |
| <b><a href="$scripturl?num=${$$thread_notify{$_}}[0]/new">${$$thread_notify{$_}}[2] ${$$thread_notify{$_}}[1]</a></b> $notify_txt{'120'} ${$$thread_notify{$_}}[3] |
| $showNotifications =~ |
| <br /><span class="small">${$$thread_notify{$_}}[4] » ${$$thread_notify{$_}}[5] - $notify_txt{'lastpost'} ${$$thread_notify{$_}}[6]</span> |
| s/{yabb my_showNotifications_b}/$my_showNotifications_b/sm; |
| </td><td align="center" width="15%" class="windowbg2"> |
| $showNotifications =~ |
| <input type="checkbox" name="thread-${$$thread_notify{$_}}[0]" value="1" /> |
| s/{yabb my_showNotifications_t}/$my_showNotifications_t/sm; |
| </td></tr> |
| $showNotifications .= $my_threadnote_end; |
| ~; |
| |
| } |
| $yytitle = "$notify_txt{'124'}"; |
| |
| |
| if (!$num) { ## no threads listed |
| ## and finally, add jump menu for a route back. |
| $showNotifications .= qq~ |
| if ( !$view ) { |
| <tr><td colspan="2" align="left" class="windowbg2"> |
| jumpto(); |
| <br /> |
| $yymain .= qq~$showNotifications$selecthtml~; |
| $notify_txt{'119'}<br /><br /> |
| template(); |
| </td></tr> |
| } |
| ~; |
| return; |
| } else { ## output details |
| |
| $showNotifications .= qq~ |
| |
| <tr><td align="left" class="catbg"> |
| |
| <b>$notify_txt{'140'}</b> |
| |
| </td><td align="center" class="catbg"> |
| |
| <b>$notify_txt{'134'}</b> |
| |
| </td></tr> |
| |
| $threadblock |
| |
| <tr><td align="right" width="85%" class="catbg"><span class="small"><label for="checkall">$notify_txt{'144'}</label></span></td> |
| |
| <td align="center" width="15%" class="catbg"><input type="checkbox" name="checkall" id="checkall" value="" onclick="if (this.checked) checkAll(0); else uncheckAll(0);" /></td> |
| |
| <tr><td colspan="2" align="center" class="windowbg"> |
| |
| <input type="submit" value="$notify_txt{'124'}" class="button" /> <input type="reset" value="$notify_txt{'121'}" class="button" /> |
| |
| </td></tr> |
| |
| ~; |
| |
| } |
| |
| $showNotifications .= qq~ |
| |
| </table> |
| |
| </form> |
| |
| ~; |
| |
| |
| |
| $yytitle = "$notify_txt{'124'}"; |
| |
| |
| |
| ## and finally, add jump menu for a route back. |
| |
| if (!$view) { |
| |
| &jumpto; |
| |
| $yymain .= qq~$showNotifications$selecthtml~; |
| |
| &template; |
| |
| } |
| |
| } |
| } |
| |
| |
| sub NotificationAlert { |
| sub NotificationAlert { |
| my ($myboard, %board_notify, $mythread, %thread_notify); |
| my ( $myboard, %board_notify, $mythread, %thread_notify ); |
| |
| |
| @bmaildir = split(/,/, ${$uid.$username}{'board_notifications'}); |
| @bmaildir = split /,/xsm, ${ $uid . $username }{'board_notifications'}; |
| @tmaildir = split(/,/, ${$uid.$username}{'thread_notifications'}); |
| @tmaildir = split /,/xsm, ${ $uid . $username }{'thread_notifications'}; |
| |
| |
| # needed for $new - icon (on/off/new.gif) |
| # needed for $new - icon (on/off/new) |
| my @noloadboard = grep(!exists ${$uid.$_}{'lastposttime'}, @allboards); |
| my @noloadboard = |
| &BoardTotals("load",@noloadboard) if @noloadboard; # to get ${$uid.$myboard}{'lastposttime'} |
| grep { !exists ${ $uid . $_ }{'lastposttime'} } @allboards; |
| &getlog; # sub in Subs.pl, for $yyuserlog{$myboard} |
| if (@noloadboard) { BoardTotals( 'load', @noloadboard ); } |
| my $dmax = $date - ($max_log_days_old * 86400); |
| |
| |
| # to get ${$uid.$myboard}{'lastposttime'} |
| ## run through boards list |
| getlog(); # sub in Subs.pm, for $yyuserlog{$myboard} |
| foreach $myboard (@bmaildir) { # board name from file name |
| my $dmax = $date - ( $max_log_days_old * 86400 ); |
| if (!-e "$boardsdir/$myboard.txt") { # remove from user board_notifications |
| |
| &ManageBoardNotify("delete", $myboard, $username); |
| ## run through boards list |
| next; |
| foreach my $myboard (@bmaildir) { # board name from file name |
| } |
| if ( !-e "$boardsdir/$myboard.txt" ) |
| |
| { # remove from user board_notifications |
| ## load in hash of name / detail for board |
| ManageBoardNotify( 'delete', $myboard, $username ); |
| &ManageBoardNotify("load", $myboard); |
| next; |
| |
| } |
| if (exists $theboard{$username}) { |
| |
| ## grab board name |
| ## load in hash of name / detail for board |
| my $boardname = (split(/\|/, $board{$myboard}))[0]; |
| ManageBoardNotify( 'load', $myboard ); |
| |
| |
| $board_notify{$myboard} = [ $boardname, |
| if ( exists $theboard{$username} ) { |
| (split(/\|/, $theboard{$username}))[1], # boardnotifytype |
| ## grab board name |
| (($max_log_days_old && int(${$uid.$myboard}{'lastposttime'}) && ((!$yyuserlog{$myboard} && ${$uid.$myboard}{'lastposttime'} > $dmax) || ($yyuserlog{$myboard} > $dmax && $yyuserlog{$myboard} < ${$uid.$myboard}{'lastposttime'}))) ? 1 : 0), # new == 1 |
| my $boardname = ( split /\|/xsm, $board{$myboard} )[0]; |
| ]; |
| |
| |
| $board_notify{$myboard} = [ |
| undef %theboard; |
| $boardname, |
| } |
| ( split /\|/xsm, $theboard{$username} )[1], # boardnotifytype |
| } |
| ( |
| |
| ( |
| &LoadCensorList if $action eq 'shownotify'; |
| $max_log_days_old |
| |
| && int( ${ $uid . $myboard }{'lastposttime'} ) |
| ## load board names |
| && ( |
| unless ($mloaded == 1) { require "$boardsdir/forum.master"; } # for $board{...} |
| ( |
| |
| !$yyuserlog{$myboard} |
| foreach $mythread (@tmaildir) { # number of next thread |
| && ${ $uid . $myboard }{'lastposttime'} > $dmax |
| # see if thread exists and search for it if moved |
| ) |
| if (!-e "$datadir/$mythread.txt") { |
| || ( $yyuserlog{$myboard} > $dmax |
| &ManageThreadNotify("delete", $mythread, $username); |
| && $yyuserlog{$myboard} < |
| eval { require "$datadir/movedthreads.cgi" }; |
| ${ $uid . $myboard }{'lastposttime'} ) |
| next if !exists $moved_file{$mythread} || !$moved_file{$mythread}; |
| ) |
| my $newthread; |
| ) ? 1 : 0 |
| while (exists $moved_file{$mythread}) { |
| ), # new == 1 |
| $mythread = $moved_file{$mythread}; |
| ]; |
| $newthread = $mythread if !exists $moved_file{$mythread} && -e "$datadir/$mythread.txt"; |
| |
| } |
| undef %theboard; |
| next if !$newthread; |
| } |
| &ManageThreadNotify("add", $newthread, $username, ${$uid.$username}{'language'}, 1, 1); |
| } |
| } |
| |
| |
| if ( $action eq 'shownotify' ) { LoadCensorList(); } |
| ## load threads hash |
| |
| &ManageThreadNotify("load", $mythread); |
| ## load board names |
| |
| get_forum_master(); # for $board{...} |
| if (exists $thethread{$username}) { |
| |
| ## load ctb file for board data |
| foreach my $mythread (@tmaildir) { # number of next thread |
| &MessageTotals ("load", $mythread); |
| # see if thread exists and search for it if moved |
| |
| if ( !-e "$datadir/$mythread.txt" ) { |
| ## pull out board and last post |
| ManageThreadNotify( 'delete', $mythread, $username ); |
| my $boardid = ${$mythread}{'board'}; |
| if ( eval { require Variables::Movedthreads; 1 } ) { |
| my ($msub,$mname,$musername,$new,$username_link,$catname_link,$boardname_link,$lastpostdate); |
| next |
| if ($action eq 'shownotify') { |
| if !exists $moved_file{$mythread} || !$moved_file{$mythread}; |
| unless (${${'notify'.$boardid.$mythread}}[0]) { |
| my $newthread; |
| my ($messageid,$messagesubject); |
| while ( exists $moved_file{$mythread} ) { |
| fopen(BOARDTXT, "$boardsdir/$boardid.txt") || &fatal_error("cannot_open","$boardsdir/$boardid.txt", 1); |
| $mythread = $moved_file{$mythread}; |
| foreach (<BOARDTXT>) { |
| if ( !exists $moved_file{$mythread} |
| ($messageid, $messagesubject, $mname, undef, undef, undef, $musername, undef) = split(/\|/, $_, 8); |
| && -e "$datadir/$mythread.txt" ) |
| ${'notify'.$boardid.$messageid} = [$messagesubject,$mname,$musername]; |
| { |
| } |
| $newthread = $mythread; |
| fclose(BOARDTXT); |
| } |
| } |
| } |
| $msub = ${${'notify'.$boardid.$mythread}}[0]; |
| next if !$newthread; |
| $mname = ${${'notify'.$boardid.$mythread}}[1]; |
| ManageThreadNotify( 'add', $newthread, $username, |
| $musername = ${${'notify'.$boardid.$mythread}}[2]; |
| ${ $uid . $username }{'language'}, |
| |
| 1, 1 ); |
| &ToChars($msub); |
| } |
| ($msub, undef) = &Split_Splice_Move($msub,0); |
| } |
| $msub = &Censor($msub); # censor subject text ! |
| |
| |
| ## load threads hash |
| ## run through the categories until we hit the match for category name |
| ManageThreadNotify( 'load', $mythread ); |
| my ($catname,$thiscatid,$catid); |
| |
| my $boardname = (split(/\|/, $board{$boardid}))[0]; # grab boardname from list |
| if ( exists $thethread{$username} ) { |
| checkboardname: foreach $catid (@categoryorder) { |
| ## load ctb file for board data |
| foreach (split(/\,/, $cat{$catid})) { |
| MessageTotals( 'load', $mythread ); |
| ## find the match, grab data and jump out |
| |
| if ($_ eq $boardid) { |
| ## pull out board and last post |
| $catname = (split(/\|/, $catinfo{$catid}))[0]; |
| my $boardid = ${$mythread}{'board'}; |
| $thiscatid = $catid; |
| my ( $msub, $mname, $musername, $new, $username_link, $catname_link, |
| last checkboardname; |
| $boardname_link, $lastpostdate ); |
| } |
| if ( $action eq 'shownotify' ) { |
| } |
| if ( !${ ${ 'notify' . $boardid . $mythread } }[0] ) { |
| } |
| my ( $messageid, $messagesubject ); |
| $catname_link = qq~<a href="$scripturl?catselect=$thiscatid">$catname</a>~; |
| fopen( BOARDTXT, "$boardsdir/$boardid.txt" ) |
| $boardname_link = qq~<a href="$scripturl?board=$boardid">$boardname</a>~; |
| or fatal_error( 'cannot_open', "$boardsdir/$boardid.txt", |
| |
| 1 ); |
| ## build view profile link, if real name exists |
| while ( my $brd = <BOARDTXT> ) { |
| &LoadUser($musername); # load poster |
| ( |
| if (${$uid.$musername}{'realname'}) { |
| $messageid, $messagesubject, $mname, undef, undef, |
| $username_link = qq~<a href="$scripturl?action=viewprofile;username=$useraccount{$musername}">${$uid.$musername}{'realname'}</a>~; |
| undef, $musername, undef |
| } elsif ($mname) { |
| ) = split /\|/xsm, $brd, 8; |
| $username_link = $mname; |
| ${ 'notify' . $boardid . $messageid } = |
| } else { |
| [ $messagesubject, $mname, $musername ]; |
| $username_link = $musername; |
| } |
| } |
| fclose(BOARDTXT); |
| |
| } |
| ## format last post for output |
| $msub = ${ ${ 'notify' . $boardid . $mythread } }[0]; |
| $lastpostdate = &timeformat(${$mythread}{'lastpostdate'}); |
| $mname = ${ ${ 'notify' . $boardid . $mythread } }[1]; |
| } |
| $musername = ${ ${ 'notify' . $boardid . $mythread } }[2]; |
| |
| |
| if ($max_log_days_old) { |
| ToChars($msub); |
| # Decide if thread should have the "NEW" indicator next to it. |
| ( $msub, undef ) = Split_Splice_Move( $msub, 0 ); |
| # Do this by reading the user's log for last read time on thread, |
| $msub = Censor($msub); # censor subject text ! |
| # and compare to the last post time on the thread. |
| |
| my $dlp = int($yyuserlog{$mythread}); |
| ## run through the categories until we hit the match for category name |
| my $dlpb = int($yyuserlog{"$boardid--mark"}); |
| my ( $catname, $thiscatid, $catid ); |
| $dlp = $dlp > $dlpb ? $dlp : $dlpb; |
| my $boardname = ( split /\|/xsm, $board{$boardid} )[0]; |
| if ($yyuserlog{"$mythread--unread"} || (!$dlp && ${$mythread}{'lastpostdate'} > $dmax) || ($dlp > $dmax && $dlp < ${$mythread}{'lastpostdate'})) { |
| |
| $new = qq~<img src="$imagesdir/new.gif" alt="$notify_txt{'335'}" title="$notify_txt{'335'}" border="0"/>~; |
| # grab boardname from list |
| } |
| CHECKBOARDNAME: foreach my $catid (@categoryorder) { |
| } |
| foreach ( split /\,/xsm, $cat{$catid} ) { |
| |
| ## find the match, grab data and jump out |
| $thread_notify{$mythread} = [$mythread, $msub, $new, $username_link, $catname_link, $boardname_link, $lastpostdate]; |
| if ( $_ eq $boardid ) { |
| } |
| $catname = ( split /\|/xsm, $catinfo{$catid} )[0]; |
| } |
| $thiscatid = $catid; |
| |
| last CHECKBOARDNAME; |
| |
| } |
| |
| } |
| |
| } |
| |
| $catname_link = |
| |
| qq~<a href="$scripturl?catselect=$thiscatid">$catname</a>~; |
| |
| $boardname_link = |
| |
| qq~<a href="$scripturl?board=$boardid">$boardname</a>~; |
| |
| |
| |
| ## build view profile link, if real name exists |
| |
| LoadUser($musername); # load poster |
| |
| if ( ${ $uid . $musername }{'realname'} ) { |
| |
| $username_link = |
| |
| qq~<a href="$scripturl?action=viewprofile;username=$useraccount{$musername}">$format_unbold{$musername}</a>~; |
| |
| } |
| |
| elsif ($mname) { |
| |
| $username_link = $mname; |
| |
| } |
| |
| else { |
| |
| $username_link = $musername; |
| |
| } |
| |
| |
| |
| ## format last post for output |
| |
| $lastpostdate = timeformat( ${$mythread}{'lastpostdate'} ); |
| |
| } |
| |
| |
| |
| if ($max_log_days_old) { |
| |
| |
| |
| # Decide if thread should have the "NEW" indicator next to it. |
| |
| # Do this by reading the user's log for last read time on thread, |
| |
| # and compare to the last post time on the thread. |
| |
| my $dlp = int $yyuserlog{$mythread}; |
| |
| my $dlpb = int $yyuserlog{"$boardid--mark"}; |
| |
| $dlp = $dlp > $dlpb ? $dlp : $dlpb; |
| |
| if ( $yyuserlog{"$mythread--unread"} |
| |
| || ( !$dlp && ${$mythread}{'lastpostdate'} > $dmax ) |
| |
| || ( $dlp > $dmax && $dlp < ${$mythread}{'lastpostdate'} ) ) |
| |
| { |
| |
| $new = |
| |
| qq~<img src="$imagesdir/$brdimg_new" alt="$notify_txt{'335'}" title="$notify_txt{'335'}"/>~; |
| |
| } |
| |
| } |
| |
| |
| |
| $thread_notify{$mythread} = [ |
| |
| $mythread, $msub, $new, |
| |
| $username_link, $catname_link, $boardname_link, |
| |
| $lastpostdate |
| |
| ]; |
| |
| } |
| |
| } |
| |
| |
| (\%board_notify,\%thread_notify); |
| return ( \%board_notify, \%thread_notify ); |
| } |
| } |
| |
| |
| 1; |
| 1; |
| |
| |