| ############################################################################### |
| ############################################################################### |
| # MyCenter.pl # |
| # MyCenter.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 strict; |
| |
| # use warnings; |
| |
| no warnings qw(uninitialized once); |
| |
| use CGI::Carp qw(fatalsToBrowser); |
| |
| our $VERSION = '2.6.12'; |
| |
| |
| |
| $mycenterpmver = 'YaBB 2.6.12 $Revision: 1710 $'; |
| |
| if ( $action eq 'detailedversion' ) { return 1; } |
| |
| |
| |
| LoadLanguage('InstantMessage'); |
| |
| LoadLanguage('MyCenter'); |
| |
| LoadLanguage('Profile'); |
| |
| get_micon(); |
| |
| get_template('MyCenter'); |
| |
| get_gmod(); |
| |
| $pm_lev = PMlev(); |
| |
| |
| |
| $mycenter_txt{'welcometxt'} =~ s/USERLABEL/${$uid.$username}{'realname'}/gxsm; |
| |
| |
| |
| $showIM = q{}; |
| |
| $IM_box = q{}; |
| |
| $showProfile = q{}; |
| |
| $PMfileToOpen = q{}; |
| |
| $sendBMess = q{}; |
| |
| $isBMess = q{}; |
| |
| $showFavorites = q{}; |
| |
| $showNotifications = q{}; |
| |
| |
| $mycenterplver = 'YaBB 2.5.2 $Revision: 1.1 $'; |
| |
| if ($action eq 'detailedversion') { return 1; } |
| |
| |
| |
| &LoadLanguage('InstantMessage'); |
| |
| &LoadLanguage('MyCenter'); |
| |
| require "$templatesdir/$usemycenter/MyCenter.template"; |
| |
| if (-e "$vardir/gmodsettings.txt" && $iamgmod) { require "$vardir/gmodsettings.txt"; } |
| |
| $mycenter_txt{'welcometxt'} =~ s/USERLABEL/${$uid.$username}{'realname'}/g; |
| |
| |
| |
| $showIM = ''; |
| |
| $IM_box = ''; |
| |
| $showProfile = ''; |
| |
| $PMfileToOpen = ''; |
| |
| $sendBMess = ''; |
| |
| $isBMess = ''; |
| |
| $showFavorites = ''; |
| |
| $showNotifications = ''; |
| |
| |
| |
| ## here begins the user centre, from the old IMIndex |
| |
| sub mycenter { |
| sub mycenter { |
| if ($iamguest) { &fatal_error('members_only'); } |
| if ($iamguest) { fatal_error('im_members_only'); } |
| |
| |
| &LoadBroadcastMessages($username); # get the BM infos |
| LoadBroadcastMessages($username); # get the BM infos |
| |
| |
| $IM_box = ''; |
| $IM_box = q{}; |
| my $PMfileToOpen = ''; |
| my $PMfileToOpen = q{}; |
| my @otherStoreFolders = (); |
| my @otherStoreFolders = (); |
| my $otherStoreSelect = ''; |
| my $otherStoreSelect = q{}; |
| $replyguest = $INFO{'replyguest'} || $FORM{'replyguest'}; |
| $replyguest = $INFO{'replyguest'} || $FORM{'replyguest'}; |
| ## select view by action |
| ## select view by action |
| if ($action =~ /^im/ || $action eq 'deletemultimessages' || $action eq 'pmsearch') { $view = 'pm'; } |
| if ( $action =~ /^im/sm |
| elsif ($action eq 'mycenter') { $view = 'mycenter'; } |
| || $action eq 'deletemultimessages' |
| elsif ($action eq 'shownotify' || $action=~ /^notify/ || $action eq 'boardnotify2') { $view = 'notify'; $mctitle = $img_txt{'418'}; } |
| || $action eq 'pmsearch' ) |
| elsif ($action eq 'myusersrecentposts') { $view = 'recentposts'; } |
| { |
| elsif ($action eq 'favorites') { $view = 'favorites'; $mctitle = $img_txt{'70'}; } |
| $view = 'pm'; |
| elsif ($action =~ /^my/) { $view = 'profile'; } |
| } |
| ## viewing PMs |
| elsif ( $action eq 'mycenter' ) { $view = 'mycenter'; } |
| if ($view eq 'pm') { # pm views |
| elsif ($action eq 'shownotify' |
| ## viewing a message box |
| || $action =~ /^notify/xsm |
| require "$sourcedir/InstantMessage.pl"; |
| || $action eq 'boardnotify2' ) |
| if ($action eq 'im' || $action eq 'imoutbox' || $action eq 'imstorage') { |
| { |
| my $foundextra = 0; |
| $view = 'notify'; |
| foreach my $storefolder (split(/\|/, ${$username}{'PMfolders'})) { |
| $mctitle = $img_txt{'418'}; |
| if($storefolder ne $INFO{'viewfolder'}) { |
| } |
| push (@otherStoreFolders, $storefolder); |
| elsif ( $action eq 'myusersrecentposts' ) { $view = 'recentposts'; } |
| $foundextra = 1; |
| elsif ( $action eq 'favorites' ) { |
| } |
| $view = 'favorites'; |
| } |
| $mctitle = $img_txt{'70'}; |
| if ($foundextra > 0) { |
| } |
| $otherStoreSelect = qq~ $inmes_txt{'storein'} <select name="tostorefolder" id="tostorefolder">~; |
| elsif ( $action =~ /^my/xsm ) { $view = 'profile'; } |
| foreach my $otherFolder (@otherStoreFolders) { |
| ## viewing PMs |
| my $otherFolderName = $otherFolder; |
| if ( $view eq 'pm' ) { # pm views |
| if ($otherFolder eq 'in') { $otherFolderName = $im_folders_txt{'in'}; } |
| ## viewing a message box |
| elsif ($otherFolder eq 'out') { $otherFolderName = $im_folders_txt{'out'}; } |
| require Sources::InstantMessage; |
| $otherStoreSelect .= qq~<option value="$otherFolder">$otherFolderName</option>~; |
| if ( $action eq 'im' |
| } |
| || $action eq 'imoutbox' |
| $otherStoreSelect .= qq~</select>~; |
| || $action eq 'imstorage' ) |
| } |
| { |
| } |
| my $foundextra = 0; |
| ## inbox |
| foreach my $storefolder ( split /\|/xsm, ${$username}{'PMfolders'} ) |
| if ($action eq 'im' || ($action eq 'imshow' && $INFO{'caller'} == 1)) { |
| { |
| $mctitle = $inmes_txt{'inbox'}; |
| if ( $storefolder ne $INFO{'viewfolder'} ) { |
| $status = $inmes_imtxt{'status'}; |
| push @otherStoreFolders, $storefolder; |
| $senderinfo = $inmes_txt{'318'}; |
| $foundextra = 1; |
| $callerid = 1; |
| } |
| $boxtxt = $inmes_txt{'316'}; |
| } |
| $movebutton = qq~<input type="submit" name="imaction" value="$inmes_imtxt{'store'}" class="button" />$otherStoreSelect $inmes_txt{'storeor'}~; |
| if ( $foundextra > 0 ) { |
| $IM_box = $inmes_txt{'inbox'}; |
| $otherStoreSelect = |
| if($INFO{'focus'} eq 'bmess' || $INFO{'bmess'} eq 'yes') { $IM_box = $inmes_txt{'broadcast'}; $callerid = 5; } |
| qq~ $inmes_txt{'storein'} <select name="tostorefolder" id="tostorefolder">~; |
| $PMfileToOpen = 'msg'; |
| foreach my $otherFolder (@otherStoreFolders) { |
| } |
| my $otherFolderName = $otherFolder; |
| ## draft box |
| if ( $otherFolder eq 'in' ) { |
| elsif ($action eq 'imdraft') { |
| $otherFolderName = $im_folders_txt{'in'}; |
| $mctitle = $inmes_txt{'draft'}; |
| } |
| $status = $inmes_imtxt{'status'}; |
| elsif ( $otherFolder eq 'out' ) { |
| $senderinfo = $inmes_txt{'324'}; |
| $otherFolderName = $im_folders_txt{'out'}; |
| $callerid = 4; |
| } |
| $boxtxt = $inmes_txt{'draft'}; |
| $otherStoreSelect .= |
| $movebutton = ''; |
| qq~<option value="$otherFolder">$otherFolderName</option>~; |
| $IM_box = $inmes_txt{'draft'}; |
| } |
| $PMfileToOpen = 'imdraft'; |
| $otherStoreSelect .= q~</select>~; |
| } |
| } |
| ## outbox |
| } |
| elsif ($action eq 'imoutbox' || ($action eq 'imshow' && $INFO{'caller'} == 2)) { |
| ## inbox |
| $mctitle = $inmes_txt{'773'}; |
| if ( $action eq 'im' |
| $status = $inmes_imtxt{'status'}; |
| || ( $action eq 'imshow' && $INFO{'caller'} == 1 ) ) |
| $senderinfo = $inmes_txt{'324'}; |
| { |
| $callerid = 2; |
| $mctitle = $inmes_txt{'inbox'}; |
| $boxtxt = $inmes_txt{'outbox'}; |
| $status = $inmes_imtxt{'status'}; |
| $movebutton = qq~<input type="submit" name="imaction" value="$inmes_imtxt{'store'}" class="button" />$otherStoreSelect $inmes_txt{'storeor'}~; |
| $senderinfo = $inmes_txt{'318'}; |
| $IM_box = $inmes_txt{'outbox'}; |
| $callerid = 1; |
| $PMfileToOpen = 'outbox'; |
| $boxtxt = $inmes_txt{'316'}; |
| } |
| $movebutton = |
| # store |
| qq~<input type="submit" name="imaction" value="$inmes_imtxt{'store'}" class="button" />$otherStoreSelect $inmes_txt{'storeor'}~; |
| elsif ($action eq 'imstorage' || ($action eq 'imshow' && $INFO{'caller'} == 3)) { |
| $IM_box = $inmes_txt{'inbox'}; |
| $mctitle = $inmes_txt{'774'}; |
| if ( $INFO{'focus'} eq 'bmess' || $INFO{'bmess'} eq 'yes' ) { |
| $status = ''; |
| $IM_box = $inmes_txt{'broadcast'}; |
| $senderinfo = $inmes_txt{'318'}; |
| $callerid = 5; |
| if ($INFO{'viewfolder'} eq 'out') { $senderinfo = $inmes_txt{'324'}; } |
| } |
| elsif ($INFO{'viewfolder'} ne 'in') { $senderinfo = qq~$inmes_txt{'318'} / $inmes_txt{'324'}~; } |
| $PMfileToOpen = 'msg'; |
| $callerid = 3; |
| } |
| $boxtxt = $inmes_txt{'storage'}; |
| ## draft box |
| $movebutton = qq~<input type="submit" name="imaction" value="$inmes_imtxt{'store'}" class="button" />$otherStoreSelect $inmes_txt{'storeor'}~; |
| elsif ( $action eq 'imdraft' ) { |
| $IM_box = $inmes_txt{'storage'}; |
| $mctitle = $inmes_txt{'draft'}; |
| if ($INFO{'viewfolder'} eq 'in' || $INFO{'viewfolder'} eq 'out') { $IM_box .= qq~ › $im_folders_txt{"$INFO{'viewfolder'}"}~; } |
| $status = $inmes_imtxt{'status'}; |
| elsif ($INFO{'viewfolder'}) { $IM_box .= qq~ › $INFO{'viewfolder'}~; } |
| $senderinfo = $inmes_txt{'324'}; |
| $PMfileToOpen = 'imstore'; |
| $callerid = 4; |
| } |
| $boxtxt = $inmes_txt{'draft'}; |
| ## sending a message / previewing |
| $movebutton = q{}; |
| elsif ($action eq 'imsend' || ($action eq 'imsend2' && $FORM{'previewim'})) { |
| $IM_box = $inmes_txt{'draft'}; |
| $IM_box = $inmes_txt{'148'}; |
| $PMfileToOpen = 'imdraft'; |
| if ($INFO{'forward'} == 1) { $IM_box = $inmes_txt{'forward'}; } |
| } |
| if ($INFO{'reply'}) { $IM_box = $inmes_txt{'replymess'}; } |
| ## outbox |
| &IMPost; |
| elsif ( $action eq 'imoutbox' |
| &buildIMsend; |
| || ( $action eq 'imshow' && $INFO{'caller'} == 2 ) ) |
| &doshowims; |
| { |
| } |
| $mctitle = $inmes_txt{'773'}; |
| ## posting the message or draft |
| $status = $inmes_imtxt{'status'}; |
| elsif ($action eq 'imsend2' || $FORM{'draft'}) { |
| $senderinfo = $inmes_txt{'324'}; |
| $IM_box = $inmes_txt{'148'}; |
| $callerid = 2; |
| if($INFO{'forward'} == 1) { $IM_box = $inmes_txt{'forward'}; } |
| $boxtxt = $inmes_txt{'outbox'}; |
| if($INFO{'reply'}) { $IM_box = $inmes_txt{'replymess'}; } |
| $movebutton = |
| &IMsendMessage; |
| qq~<input type="submit" name="imaction" value="$inmes_imtxt{'store'}" class="button" />$otherStoreSelect $inmes_txt{'storeor'}~; |
| } |
| $IM_box = $inmes_txt{'outbox'}; |
| elsif ($action eq 'imshow' && $INFO{'caller'} == 5) { |
| $PMfileToOpen = 'outbox'; |
| $mctitle = $inmes_txt{'broadcast'}; |
| } |
| $status = $inmes_imtxt{'status'}; |
| |
| $senderinfo = $inmes_txt{'318'}; |
| # store |
| $callerid = 5; |
| elsif ( $action eq 'imstorage' |
| $boxtxt = $inmes_txt{'316'}; |
| || ( $action eq 'imshow' && $INFO{'caller'} == 3 ) ) |
| $movebutton = qq~<input type="submit" name="imaction" value="$inmes_imtxt{'store'}" class="button" />$otherStoreSelect $inmes_txt{'storeor'}~; |
| { |
| $IM_box = $inmes_txt{'broadcast'}; |
| $mctitle = $inmes_txt{'storage'}; |
| $PMfileToOpen = 'msg'; |
| $status = q{}; |
| } |
| $senderinfo = $inmes_txt{'318'}; |
| } |
| if ( $INFO{'viewfolder'} eq 'out' ) { |
| ## viewing front page |
| $senderinfo = $inmes_txt{'324'}; |
| elsif ($view eq "mycenter") { |
| } |
| $mctitle = "$inmes_txt{'mycenter'}"; |
| elsif ( $INFO{'viewfolder'} ne 'in' ) { |
| } |
| $senderinfo = qq~$inmes_txt{'318'} / $inmes_txt{'324'}~; |
| ## viewing my profile |
| } |
| elsif ($view eq "profile") { |
| $callerid = 3; |
| $mctitle = "$mc_menus{'profile'}"; |
| |
| } |
| $boxtxt = $inmes_txt{'storage'}; |
| ## viewing my recent posts |
| $movebutton = |
| elsif ($view eq 'recentposts') { |
| qq~<input type="submit" name="imaction" value="$inmes_imtxt{'store'}" class="button" />$otherStoreSelect $inmes_txt{'storeor'}~; |
| $mctitle = "$inmes_txt{'viewrecentposts'} $inmes_txt{'viewrecentposts2'}"; |
| $IM_box = $inmes_txt{'storage'}; |
| } |
| |
| |
| fopen( THREADS, "$memberdir/$username.imstore" ); |
| ## draw the container |
| @threads = <THREADS>; |
| &drawPMbox($PMfileToOpen); |
| fclose(THREADS); |
| &LoadIMs; |
| $threadid = $INFO{'id'}; |
| |
| foreach my $thread (@threads) { |
| # navigation link |
| chomp $thread; |
| $yynavigation = qq~› <a href="$scripturl?action=mycenter" class="nav">$img_txt{'mycenter'}</a> › $mctitle~; |
| if ( $thread =~ /$threadid/xsm ) { |
| |
| @fold = split /\|/xsm, $thread; |
| ## set template up |
| if ( $fold[13] eq 'in' || $fold[13] eq 'out' ) { |
| $mycenter_template =~ s/({|<)yabb mcviewmenu(}|>)/$MCViewMenu/g; |
| $folder = qq~$im_folders_txt{$fold[13]}~; |
| $mycenter_template =~ s/({|<)yabb mcmenu(}|>)/$yymcmenu/g; |
| } |
| $mycenter_template =~ s/({|<)yabb mcpmmenu(}|>)/$MCPmMenu/g; |
| else { $folder = $fold[13]; } |
| $mycenter_template =~ s/({|<)yabb mcprofmenu(}|>)/$MCProfMenu/g; |
| } |
| $mycenter_template =~ s/({|<)yabb mcpostsmenu(}|>)/$MCPostsMenu/g; |
| } |
| $mycenter_template =~ s/({|<)yabb mcglobformstart(}|>)/$MCGlobalFormStart/g; |
| if ( $INFO{'viewfolder'} eq 'in' || $INFO{'viewfolder'} eq 'out' ) { |
| $mycenter_template =~ s/({|<)yabb mcglobformend(}|>)/ ($MCGlobalFormStart ? "<\/form>" : "") /e; |
| $IM_box .= qq~ › $im_folders_txt{"$INFO{'viewfolder'}"}~; |
| $mycenter_template =~ s/({|<)yabb mcextrasmilies(}|>)/$MCExtraSmilies/g; |
| } |
| $mycenter_template =~ s/({|<)yabb mccontent(}|>)/$MCContent/g; |
| elsif ( $INFO{'viewfolder'} ) { |
| $mycenter_template =~ s/({|<)yabb mctitle(}|>)/$mctitle/g; |
| $IM_box .= qq~ › $INFO{'viewfolder'}~; |
| $mycenter_template =~ s/({|<)yabb selecthtml(}|>)/$selecthtml/g; |
| } |
| $mycenter_template =~ s/({|<)yabb forumjump(}|>)//g; |
| $mctitle .= qq~ › $folder~; |
| |
| $PMfileToOpen = 'imstore'; |
| ## end new style box |
| } |
| $yymain .= $mycenter_template; |
| ## sending a message / previewing |
| if (%usernames_life_quote) { # for display names in Quotes in LivePreview |
| elsif ( $action eq 'imsend' ) |
| $yymain .= qq~ |
| { |
| <script language="JavaScript" type="text/javascript"> |
| $IM_box = $inmes_txt{'148'}; |
| <!-- // |
| if ( $INFO{'forward'} == 1 ) { $IM_box = $inmes_txt{'forward'}; } |
| ~ . join(';', map { qq~LivePrevDisplayNames['$_'] = "$usernames_life_quote{$_}"~ } keys %usernames_life_quote) . qq~; |
| if ( $INFO{'reply'} ) { $IM_box = $inmes_txt{'replymess'}; } |
| // --> |
| IMPost(); |
| </script>\n\n~; |
| buildIMsend(); |
| } |
| doshowims(); |
| &template; |
| } |
| |
| ## posting the message or draft |
| |
| elsif ( $action eq 'imsend2' || $FORM{'draft'} ) { |
| |
| $IM_box = $inmes_txt{'148'}; |
| |
| if ( $INFO{'forward'} == 1 ) { $IM_box = $inmes_txt{'forward'}; } |
| |
| if ( $INFO{'reply'} ) { $IM_box = $inmes_txt{'replymess'}; } |
| |
| IMsendMessage(); |
| |
| } |
| |
| elsif ( $action eq 'imshow' && $INFO{'caller'} == 5 ) { |
| |
| $mctitle = $inmes_txt{'broadcast'}; |
| |
| $status = $inmes_imtxt{'status'}; |
| |
| $senderinfo = $inmes_txt{'318'}; |
| |
| $callerid = 5; |
| |
| $boxtxt = $inmes_txt{'316'}; |
| |
| $movebutton = |
| |
| qq~<input type="submit" name="imaction" value="$inmes_imtxt{'store'}" class="button" />$otherStoreSelect $inmes_txt{'storeor'}~; |
| |
| $IM_box = $inmes_txt{'broadcast'}; |
| |
| $PMfileToOpen = 'msg'; |
| |
| } |
| |
| } |
| |
| ## viewing front page |
| |
| elsif ( $view eq 'mycenter' ) { |
| |
| $mctitle = "$inmes_txt{'mycenter'}"; |
| |
| } |
| |
| ## viewing my profile |
| |
| elsif ( $view eq 'profile' ) { |
| |
| $mctitle = "$mc_menus{'profile'}"; |
| |
| } |
| |
| ## viewing my recent posts |
| |
| elsif ( $view eq 'recentposts' ) { |
| |
| $mctitle = |
| |
| "$inmes_txt{'viewrecentposts'} $inmes_txt{'viewrecentposts2'}"; |
| |
| } |
| |
| |
| |
| ## draw the container |
| |
| drawPMbox($PMfileToOpen); |
| |
| LoadIMs(); |
| |
| |
| |
| # navigation link |
| |
| $yynavigation = |
| |
| qq~› <a href="$scripturl?action=mycenter" class="nav">$img_txt{'mycenter'}</a> › $mctitle~; |
| |
| |
| |
| ## set template up |
| |
| $mycenter_template =~ s/{yabb mcviewmenu}/$MCViewMenu/gsm; |
| |
| $mycenter_template =~ s/{yabb mcmenu}/$yymcmenu/gsm; |
| |
| $mycenter_template =~ s/{yabb mcpmmenu}/$MCPmMenu/gsm; |
| |
| $mycenter_template =~ s/{yabb mcprofmenu}/$MCProfMenu/gsm; |
| |
| $mycenter_template =~ s/{yabb mcpostsmenu}/$MCPostsMenu/gsm; |
| |
| $mycenter_template =~ |
| |
| s/{yabb mcglobformstart}/$MCGlobalFormStart/gsm; |
| |
| $mycenter_template =~ |
| |
| s/{yabb mcglobformend}/ ($MCGlobalFormStart ? "<\/form>" : q{}) /esm; |
| |
| |
| |
| $mycenter_template =~ s/{yabb mccontent}/$MCContent/gsm; |
| |
| $mycenter_template =~ s/{yabb mctitle}/$mctitle/gsm; |
| |
| $mycenter_template =~ s/{yabb selecthtml}/$selecthtml/gsm; |
| |
| $mycenter_template =~ s/{yabb forumjump}//gsm; |
| |
| |
| |
| ## end new style box |
| |
| $yymain .= $mycenter_template; |
| |
| template(); |
| |
| return; |
| } |
| } |
| |
| |
| sub AddFolder { |
| sub AddFolder { |
| if ($iamguest) { &fatal_error("im_members_only"); } |
| if ($iamguest) { fatal_error('im_members_only'); } |
| my $storefolders = ${$username}{'PMfolders'}; |
| my $storefolders = ${$username}{'PMfolders'}; |
| my @currStoreFolders = split(/\|/, ${$username}{'PMfolders'}); |
| my @currStoreFolders = split /\|/xsm, ${$username}{'PMfolders'}; |
| my $newStoreFolders = "in|out"; |
| my $newStoreFolders = 'in|out'; |
| |
| |
| my $newFolderName = $FORM{'newfolder'}; |
| my $newFolderName = $FORM{'newfolder'}; |
| chomp $newFolderName; |
| chomp $newFolderName; |
| |
| |
| my $x = 0; |
| my $x = 0; |
| nxtfdr: foreach my $currStoreFolder (@currStoreFolders) { |
| NXTFDR: foreach my $currStoreFolder (@currStoreFolders) { |
| if ($FORM{'newfolder'}) { |
| if ( $FORM{'newfolder'} ) { |
| if ($newFolderName =~ /[^0-9A-Za-z \-_]/) { &fatal_error('invalid_character', $inmes_txt{'foldererror'}); } |
| if ( $newFolderName =~ /[^0-9A-Za-z \-_]/xsm ) { |
| if ($FORM{'newfolder'} eq $currStoreFolder) { &fatal_error('im_folder_exists'); } |
| fatal_error( 'invalid_character', $inmes_txt{'foldererror'} ); |
| } elsif ($FORM{'delfolders'}) { |
| } |
| if ($currStoreFolder ne 'in' && $currStoreFolder ne 'out' && $FORM{"delfolder$x"} ne 'del') { |
| if ( $FORM{'newfolder'} eq $currStoreFolder ) { |
| $newStoreFolders .= qq~|$currStoreFolder~; |
| fatal_error('im_folder_exists'); |
| } |
| } |
| } |
| } |
| $x++; |
| elsif ( $FORM{'delfolders'} ) { |
| } |
| if ( $currStoreFolder ne 'in' |
| if ($FORM{'newfolder'}) { ${$username}{'PMfolders'} = qq~$storefolders|$FORM{'newfolder'}~; } |
| && $currStoreFolder ne 'out' |
| elsif ($FORM{'delfolders'}) { ${$username}{'PMfolders'} = $newStoreFolders; } |
| && $FORM{"delfolder$x"} ne 'del' ) |
| &buildIMS($username, 'update'); |
| { |
| $yySetLocation = qq~$scripturl?action=mycenter~; |
| $newStoreFolders .= qq~|$currStoreFolder~; |
| &redirectexit; |
| } |
| |
| } |
| |
| $x++; |
| |
| } |
| |
| if ( $FORM{'newfolder'} ) { |
| |
| ${$username}{'PMfolders'} = qq~$storefolders|$FORM{'newfolder'}~; |
| |
| } |
| |
| elsif ( $FORM{'delfolders'} ) { |
| |
| ${$username}{'PMfolders'} = $newStoreFolders; |
| |
| } |
| |
| buildIMS( $username, 'update' ); |
| |
| $yySetLocation = qq~$scripturl?action=mycenter~; |
| |
| redirectexit(); |
| |
| return; |
| } |
| } |
| |
| |
| ## call an unopened message back |
| ## call an unopened message back |
| sub CallBack { |
| sub CallBack { |
| if ($iamguest) { &fatal_error("im_members_only"); } |
| if ($iamguest) { fatal_error('im_members_only'); } |
| |
| |
| my $receiver = $INFO{'receiver'}; # set variables from GET - localised |
| |
| |
| |
| if ($receiver && $receiver !~ /,/) { |
| my $receiver = $INFO{'receiver'}; # set variables from GET - localised |
| my $receiver = &decloak($receiver); |
| |
| if (&CallBackRec($receiver,$INFO{'rid'},1)) { &fatal_error("im_deleted"); } |
| |
| &updateIMS($receiver,$INFO{'rid'},'callback'); |
| |
| } elsif ($receiver) { |
| |
| my $rec; |
| |
| foreach $rec (split(/,/, $receiver)) { |
| |
| $rec = &decloak($rec); |
| |
| if (&CallBackRec($rec,$INFO{'rid'},0)) { &fatal_error("im_deleted_multi"); } |
| |
| } |
| |
| foreach $rec (split(/,/, $receiver)) { |
| |
| $rec = &decloak($rec); |
| |
| &CallBackRec($rec,$INFO{'rid'},1); |
| |
| &updateIMS($rec,$INFO{'rid'},'callback'); |
| |
| } |
| |
| } |
| |
| |
| |
| &updateMessageFlag($username, $INFO{'rid'}, 'outbox', '', 'c'); |
| if ( $receiver && $receiver !~ /,/xsm ) { |
| |
| $receiver = decloak($receiver); |
| $yySetLocation = qq~$scripturl?action=imoutbox~; |
| if ( CallBackRec( $receiver, $INFO{'rid'}, 1 ) ) { |
| &redirectexit; |
| fatal_error('im_deleted'); |
| |
| } |
| |
| updateIMS( $receiver, $INFO{'rid'}, 'callback' ); |
| |
| } |
| |
| elsif ($receiver) { |
| |
| foreach my $rec ( split /,/xsm, $receiver ) { |
| |
| $rec = decloak($rec); |
| |
| if ( CallBackRec( $rec, $INFO{'rid'}, 0 ) ) { |
| |
| fatal_error('im_deleted_multi'); |
| |
| } |
| |
| } |
| |
| foreach my $rec ( split /,/xsm, $receiver ) { |
| |
| $rec = decloak($rec); |
| |
| CallBackRec( $rec, $INFO{'rid'}, 1 ); |
| |
| updateIMS( $rec, $INFO{'rid'}, 'callback' ); |
| |
| } |
| |
| } |
| |
| |
| |
| updateMessageFlag( $username, $INFO{'rid'}, 'outbox', q{}, 'c' ); |
| |
| |
| |
| $yySetLocation = qq~$scripturl?action=imoutbox~; |
| |
| redirectexit(); |
| |
| return; |
| } |
| } |
| |
| |
| sub CallBackRec { |
| sub CallBackRec { |
| my ($receiver,$rid,$do_it) = @_; |
| my ( $receiver, $rid, $do_it ) = @_; |
| |
| |
| fopen(RECMSG, "$memberdir/$receiver.msg"); |
| fopen( RECMSG, "$memberdir/$receiver.msg" ); |
| my @rims = <RECMSG>; |
| my @rims = <RECMSG>; |
| fclose(RECMSG); |
| fclose(RECMSG); |
| |
| |
| my ($nodel,$rmessageid,$fromuser,$flags); |
| my ( $nodel, $rmessageid, $fromuser, $flags ); |
| fopen(REVMSG, ">$memberdir/$receiver.msg") if $do_it; |
| if ($do_it) { fopen( REVMSG, ">$memberdir/$receiver.msg" ); } |
| ## run through and drop the message line |
| ## run through and drop the message line |
| foreach (@rims) { |
| foreach (@rims) { |
| ($rmessageid,$fromuser, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, $flags, undef) = split(/\|/, $_, 14); |
| ( |
| if (!$do_it) { |
| $rmessageid, $fromuser, undef, undef, undef, |
| if ($rmessageid == $rid && $fromuser eq $username) { |
| undef, undef, undef, undef, undef, |
| if ($flags !~ /u/i) { $nodel = 1; } |
| undef, undef, $flags, undef |
| last; |
| ) = split /\|/xsm, $_, 14; |
| } |
| if ( !$do_it ) { |
| } else { |
| if ( $rmessageid == $rid && $fromuser eq $username ) { |
| if ($rmessageid != $rid || $fromuser ne $username) { print REVMSG $_; } |
| if ( $flags !~ /u/ism ) { $nodel = 1; } |
| elsif ($flags !~ /u/i) { print REVMSG $_; $nodel = 1;} |
| last; |
| } |
| } |
| } |
| } |
| fclose(REVMSG) if $do_it; |
| else { |
| $nodel; |
| if ( $rmessageid != $rid || $fromuser ne $username ) { |
| } |
| print {REVMSG} $_ or croak "$croak{'print'} REVMSG"; |
| |
| } |
| sub checkIMS { # lookup value in pm file |
| elsif ( $flags !~ /u/ism ) { |
| my $user = $_[0]; |
| print {REVMSG} $_ or croak "$croak{'print'} REVMSG"; |
| my $id = $_[1]; |
| $nodel = 1; |
| my $checkfor = $_[2]; |
| } |
| |
| } |
| ## has the message been opened by the receiver? 1 = yes 0 = no |
| } |
| if ($checkfor eq 'messageopened') { |
| if ($do_it) { fclose(REVMSG); } |
| my $messageFoundFlag = &checkMessageFlag($user, $id, 'msg', 'u'); |
| return $nodel; |
| if ($messageFoundFlag == 1) { return 0; } |
| } |
| else {$messageFoundFlag = &checkMessageFlag($user, $id, 'imstore', 'u'); } |
| |
| if ($messageFoundFlag == 1) { return 0; } |
| sub checkIMS { # lookup value in pm file |
| else { return 1; } |
| my ( $user, $id, $checkfor ) = @_; |
| |
| |
| ## has the message been replied to? 1 = yes 0 = no |
| ## has the message been opened by the receiver? 1 = yes 0 = no |
| } elsif ($checkfor eq 'messagereplied') { |
| if ( $checkfor eq 'messageopened' ) { |
| ## check in msg and imstore |
| my $messageFoundFlag = checkMessageFlag( $user, $id, 'msg', 'u' ); |
| my $messageFoundFlag = &checkMessageFlag($user, $id, 'msg', 'r'); |
| if ( $messageFoundFlag == 1 ) { return 0; } |
| if ($messageFoundFlag == 1) { return 1; } |
| else { |
| else {$messageFoundFlag = &checkMessageFlag($user, $id, 'imstore', 'r'); } |
| $messageFoundFlag = checkMessageFlag( $user, $id, 'imstore', 'u' ); |
| if ($messageFoundFlag == 1) { return 1; } |
| } |
| else { return 0; } |
| if ( $messageFoundFlag == 1 ) { return 0; } |
| } |
| else { return 1; } |
| } |
| |
| |
| ## has the message been replied to? 1 = yes 0 = no |
| sub checkMessageFlag { # look for $user.$pmFile, find $id message and check for $messageFlag |
| } |
| my ($user, $id, $pmFile, $messageFlag) = @_; |
| elsif ( $checkfor eq 'messagereplied' ) { |
| my $messageFoundFlag = 0; |
| ## check in msg and imstore |
| if (%{'MF' . $user . $pmFile}) { |
| my $messageFoundFlag = checkMessageFlag( $user, $id, 'msg', 'r' ); |
| if (exists ${'MF' . $user . $pmFile}{$id} && ${'MF' . $user . $pmFile}{$id} =~ /$messageFlag/i) { $messageFoundFlag = 1; } |
| if ( $messageFoundFlag == 1 ) { return 1; } |
| } elsif (-e "$memberdir/$user.$pmFile") { |
| else { |
| fopen ("USERMSG", "$memberdir/$user.$pmFile"); |
| $messageFoundFlag = checkMessageFlag( $user, $id, 'imstore', 'r' ); |
| my @userMessages = <USERMSG>; |
| } |
| fclose ("USERMSG"); |
| if ( $messageFoundFlag == 1 ) { return 1; } |
| my ($uMessageId,$uMessageFlags); |
| else { return 0; } |
| foreach (@userMessages) { |
| } |
| ($uMessageId, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, $uMessageFlags, undef) = split(/\|/, $_, 14); |
| return; |
| ${'MF' . $user . $pmFile}{$uMessageId} = $uMessageFlags; |
| } |
| if ($uMessageId == $id && $uMessageFlags =~ /$messageFlag/i) { $messageFoundFlag = 1; } |
| |
| } |
| sub checkMessageFlag { |
| } |
| |
| $messageFoundFlag; |
| # look for $user.$pmFile, find $id message and check for $messageFlag |
| } |
| my ( $user, $id, $pmFile, $messageFlag ) = @_; |
| |
| my $messageFoundFlag = 0; |
| sub updateMessageFlag { # look for $user.$pmFile, find $id message and check for $messageFlag. change to $newMessageFlag |
| if ( %{ 'MF' . $user . $pmFile } ) { |
| my ($user, $id, $pmFile, $messageFlag, $newMessageFlag) = @_; |
| if ( exists ${ 'MF' . $user . $pmFile }{$id} |
| my $messageFoundFlag = 0; |
| && ${ 'MF' . $user . $pmFile }{$id} =~ /$messageFlag/ism ) |
| if ((!exists ${'MF' . $user . $pmFile}{$id} || ($messageFlag ne '' && ${'MF' . $user . $pmFile}{$id} =~ /$messageFlag/) || ($messageFlag eq '' && !${'MF' . $user . $pmFile}{$id} =~ /$newMessageFlag/)) && -e "$memberdir/$user.$pmFile") { |
| { |
| fopen ("USERFILE", "+<$memberdir/$user.$pmFile"); |
| $messageFoundFlag = 1; |
| my @userFile = <USERFILE>; |
| } |
| seek USERFILE, 0, 0; |
| } |
| truncate USERFILE, 0; |
| elsif ( -e "$memberdir/$user.$pmFile" ) { |
| foreach my $userMessage (@userFile) { |
| fopen( USERMSG, "$memberdir/$user.$pmFile" ); |
| my ($uMessageId, $uFrom, $uToUser, $uTocc, $uTobcc, $uSubject, $uDate, $uMessage, $uPid, $uReply , $uip, $uStatus, $uMessageFlags, $uStorefolder, $uAttach) = split(/\|/, $userMessage); |
| my @userMessages = <USERMSG>; |
| if ($uMessageId == $id) { |
| fclose(USERMSG); |
| $uMessageFlags =~ s/$newMessageFlag//gi if $newMessageFlag ne ''; |
| my ( $uMessageId, $uMessageFlags ); |
| if ($uMessageFlags =~ s/$messageFlag/$newMessageFlag/i) { |
| foreach (@userMessages) { |
| $messageFoundFlag = 1; |
| ( |
| } else { |
| $uMessageId, undef, undef, undef, undef, |
| $uMessageFlags .= $newMessageFlag; |
| undef, undef, undef, undef, undef, |
| } |
| undef, undef, $uMessageFlags, undef |
| $userMessage = "$uMessageId|$uFrom|$uToUser|$uTocc|$uTobcc|$uSubject|$uDate|$uMessage|$uPid|$uReply|$uip|$uStatus|$uMessageFlags|$uStorefolder|$uAttach"; |
| ) = split /\|/xsm, $_, 14; |
| } |
| ${ 'MF' . $user . $pmFile }{$uMessageId} = $uMessageFlags; |
| ${'MF' . $user . $pmFile}{$uMessageId} = $uMessageFlags; |
| if ( $uMessageId == $id && $uMessageFlags =~ /$messageFlag/ism ) { |
| print USERFILE $userMessage; |
| $messageFoundFlag = 1; |
| } |
| } |
| fclose("USERFILE"); |
| } |
| } |
| } |
| $messageFoundFlag; |
| return $messageFoundFlag; |
| } |
| } |
| |
| |
| sub updateIMS { # update .ims file for user: &updateIMS(<user>,<PM msgid>,[target/action]) |
| sub updateMessageFlag { |
| my ($user,$id,$target) = @_; |
| |
| |
| # look for $user.$pmFile, find $id message and check for $messageFlag. change to $newMessageFlag |
| # load the user who is processed here, if not allready loaded |
| my ( $user, $id, $pmFile, $messageFlag, $newMessageFlag ) = @_; |
| &buildIMS($user, 'load') unless exists ${$user}{'PMmnum'}; |
| my $messageFoundFlag = 0; |
| |
| if ( |
| # new msg received - add to the inbox lists and increment the counts |
| ( |
| if ($target eq 'messagein') { |
| !exists ${ 'MF' . $user . $pmFile }{$id} |
| # read the lines into temp variables |
| || ( $messageFlag ne q{} |
| ${$user}{'PMmnum'}++; |
| && ${ 'MF' . $user . $pmFile }{$id} =~ /$messageFlag/xsm ) |
| ${$user}{'PMimnewcount'}++; |
| || ( $messageFlag eq q{} |
| |
| && !${ 'MF' . $user . $pmFile }{$id} =~ /$newMessageFlag/xsm ) |
| # message sent - add to the outbox list and increment count |
| ) |
| } elsif ($target eq 'messageout') { |
| && -e "$memberdir/$user.$pmFile" |
| ${$user}{'PMmoutnum'}++; |
| ) |
| |
| { |
| # reading msg in inbox - newcount -1, remove from unread list |
| fopen( USERFILE, "<$memberdir/$user.$pmFile" ); |
| } elsif ($target eq 'inread') { |
| my @userFile = <USERFILE>; |
| if (&updateMessageFlag($user, $id, 'msg', 'u', '')) { ${$user}{'PMimnewcount'}--; } |
| fclose( USERFILE ); |
| else { return; } |
| my @newpmfile = (); |
| |
| foreach my $userMessage (@userFile) { |
| # callback message - take off imnewcount, mnum |
| my ( |
| } elsif ($target eq 'callback') { |
| $uMessageId, $uFrom, $uToUser, $uTocc, |
| ${$user}{'PMmnum'}--; |
| $uTobcc, $uSubject, $uDate, $uMessage, |
| ${$user}{'PMimnewcount'}--; |
| $uPid, $uReply, $uip, $uStatus, |
| |
| $uMessageFlags, $uStorefolder, $uAttach |
| # draft added |
| ) = split /\|/xsm, $userMessage; |
| } elsif ($target eq 'draftadd') { |
| if ( $uMessageId == $id ) { |
| ${$user}{'PMdraftnum'}++; |
| if ( $newMessageFlag ne q{} ) { |
| |
| $uMessageFlags =~ s/$newMessageFlag//gism; |
| # draft send |
| } |
| } elsif ($target eq 'draftsend') { |
| if ( $uMessageFlags =~ s/$messageFlag/$newMessageFlag/ixsm ) { |
| ${$user}{'PMdraftnum'}--; |
| $messageFoundFlag = 1; |
| } |
| } |
| |
| else { |
| |
| $uMessageFlags .= $newMessageFlag; |
| |
| } |
| |
| $userMessage = |
| |
| "$uMessageId|$uFrom|$uToUser|$uTocc|$uTobcc|$uSubject|$uDate|$uMessage|$uPid|$uReply|$uip|$uStatus|$uMessageFlags|$uStorefolder|$uAttach"; |
| |
| } |
| |
| ${ 'MF' . $user . $pmFile }{$uMessageId} = $uMessageFlags; |
| |
| push @newpmfile, $userMessage; |
| |
| |
| |
| } |
| |
| fopen( USERFILE, ">$memberdir/$user.$pmFile" ); |
| |
| print {USERFILE} @newpmfile or croak "$croak{'print'} USERFILE"; |
| |
| fclose(USERFILE); |
| |
| } |
| |
| return $messageFoundFlag; |
| |
| } |
| |
| |
| |
| sub updateIMS { |
| |
| |
| |
| # update .ims file for user: &updateIMS(<user>,<PM msgid>,[target/action]) |
| |
| my ( $user, $id, $target ) = @_; |
| |
| |
| |
| # load the user who is processed here, if not already loaded |
| |
| if ( !exists ${$user}{'PMmnum'} ) { buildIMS( $user, 'load' ); } |
| |
| |
| |
| # new msg received - add to the inbox lists and increment the counts |
| |
| if ( $target eq 'messagein' ) { |
| |
| |
| |
| # read the lines into temp variables |
| |
| ${$user}{'PMmnum'}++; |
| |
| ${$user}{'PMimnewcount'}++; |
| |
| |
| |
| # message sent - add to the outbox list and increment count |
| |
| } |
| |
| elsif ( $target eq 'messageout' ) { |
| |
| ${$user}{'PMmoutnum'}++; |
| |
| |
| |
| # reading msg in inbox - newcount -1, remove from unread list |
| |
| } |
| |
| elsif ( $target eq 'inread' ) { |
| |
| if ( updateMessageFlag( $user, $id, 'msg', 'u', q{} ) ) { |
| |
| ${$user}{'PMimnewcount'}--; |
| |
| } |
| |
| else { return; } |
| |
| |
| |
| # callback message - take off imnewcount, mnum |
| |
| } |
| |
| elsif ( $target eq 'callback' ) { |
| |
| ${$user}{'PMmnum'}--; |
| |
| ${$user}{'PMimnewcount'}--; |
| |
| |
| |
| # draft added |
| |
| } |
| |
| elsif ( $target eq 'draftadd' ) { |
| |
| ${$user}{'PMdraftnum'}++; |
| |
| |
| |
| # draft send |
| |
| } |
| |
| elsif ( $target eq 'draftsend' ) { |
| |
| ${$user}{'PMdraftnum'}--; |
| |
| } |
| |
| |
| &buildIMS($user, 'update'); # rebuild the .ims file it with the new values |
| buildIMS( $user, 'update' ); # rebuild the .ims file it with the new values |
| |
| return; |
| } |
| } |
| |
| |
| # delete|move IMs |
| # delete|move IMs |
| sub Del_Some_IM { |
| sub Del_Some_IM { |
| &LoadLanguage('InstantMessage'); |
| LoadLanguage('InstantMessage'); |
| if ($iamguest) { &fatal_error('im_members_only'); } |
| if ($iamguest) { fatal_error('im_members_only'); } |
| |
| |
| my $fileToOpen = "$username.msg"; |
| |
| if ($INFO{'caller'} == 2) { $fileToOpen = "$username.outbox"; } |
| |
| elsif ($INFO{'caller'} == 3) { $fileToOpen = "$username.imstore"; } |
| |
| elsif ($INFO{'caller'} == 4) { $fileToOpen = "$username.imdraft"; } |
| |
| elsif ($INFO{'caller'} == 5) { $fileToOpen = "broadcast.messages"; } |
| |
| |
| |
| fopen(USRFILE, "+<$memberdir/$fileToOpen"); |
| |
| seek USRFILE, 0, 0; |
| |
| my @messages = <USRFILE>; |
| |
| seek USRFILE, 0, 0; |
| |
| truncate USRFILE, 0; |
| |
| |
| |
| # deleting |
| |
| if ($FORM{'imaction'} eq $inmes_txt{'remove'} || $INFO{'action'} eq $inmes_txt{'remove'} || $INFO{'deleteid'}) { |
| |
| my %CountStore; |
| |
| if ($INFO{'caller'} == 2) { ${$username}{'PMmoutnum'} = 0; } |
| |
| elsif ($INFO{'caller'} == 4) { ${$username}{'PMdraftnum'} = 0; } |
| |
| elsif ($INFO{'caller'} != 3 && $INFO{'caller'} != 5) { ${$username}{'PMmnum'} = 0; ${$username}{'PMimnewcount'} = 0; } |
| |
| |
| |
| if ($INFO{'deleteid'}) { $FORM{"message" . $INFO{'deleteid'}} = 1; } # singel delete |
| |
| |
| |
| foreach (@messages) { |
| |
| my @m = split(/\|/, $_); |
| |
| if (!exists $FORM{"message" . $m[0]}) { |
| |
| print USRFILE $_; |
| |
| |
| |
| if ($INFO{'caller'} == 2) { ${$username}{'PMmoutnum'}++; } |
| |
| elsif ($INFO{'caller'} == 3) { $CountStore{$m[13]}++; } |
| |
| elsif ($INFO{'caller'} == 4) { ${$username}{'PMdraftnum'}++; } |
| |
| elsif ($INFO{'caller'} != 5) { ${$username}{'PMmnum'}++; ${$username}{'PMimnewcount'}++ if $m[12] =~ /u/; } |
| |
| } else { |
| |
| if ($INFO{'caller'} == 3) { |
| |
| $INFO{'viewfolder'} = $m[13]; |
| |
| } elsif ($INFO{'caller'} == 5) { |
| |
| ${$username}{'PMbcRead'} =~ s/$m[0]\b//g unless ${$username}{'PMbcRead'} =~ s/\b$m[0]$//; |
| |
| } |
| |
| } |
| |
| } |
| |
| fclose(USRFILE); |
| |
| if ($INFO{'caller'} == 3) { |
| |
| ${$username}{'PMfoldersCount'} = ''; |
| |
| ${$username}{'PMstorenum'} = 0; |
| |
| foreach (split(/\|/, ${$username}{'PMfolders'})) { |
| |
| $CountStore{$_} ||= 0; |
| |
| ${$username}{'PMfoldersCount'} .= ${$username}{'PMfoldersCount'} eq '' ? $CountStore{$_} : "|$CountStore{$_}"; |
| |
| ${$username}{'PMstorenum'} += $CountStore{$_}; |
| |
| } |
| |
| } |
| |
| &buildIMS($username, 'update'); |
| |
| |
| |
| # moving messages |
| |
| } elsif ($FORM{'imaction'} eq $inmes_imtxt{'store'} || $INFO{'imaction'} eq $inmes_imtxt{'store'}) { |
| |
| my (@newmessages,%CountStore,$imstorefolder); |
| |
| if ($FORM{'tostorefolder'}) { $imstorefolder = $FORM{'tostorefolder'}; } |
| |
| elsif ($INFO{'caller'} == 1) { $imstorefolder = 'in'; } |
| |
| else { $imstorefolder = 'out'; } |
| |
| |
| |
| foreach (@messages) { |
| |
| if (!$FORM{"message" . (split(/\|/, $_, 2))[0]}) { |
| |
| if ($INFO{'caller'} != 3) { |
| |
| print USRFILE $_; |
| |
| } else { |
| |
| my @m = split(/\|/, $_); |
| |
| push(@newmessages, [@m]); |
| |
| $CountStore{$m[13]}++; |
| |
| } |
| |
| } else { |
| |
| my @m = split(/\|/, $_); |
| |
| $m[13] = $imstorefolder; |
| |
| push(@newmessages, [@m]); |
| |
| $CountStore{$imstorefolder}++; |
| |
| if ($INFO{'caller'} != 3) { |
| |
| ${$username}{'PMstorenum'}++; |
| |
| if ($INFO{'caller'} == 1) { ${$username}{'PMmnum'}--; } |
| |
| elsif ($INFO{'caller'} == 2) { ${$username}{'PMmoutnum'}--; } |
| |
| ${$username}{'PMimnewcount'}-- if $m[12] =~ /u/; |
| |
| } |
| |
| } |
| |
| } |
| |
| fclose(USRFILE); |
| |
| |
| |
| if (@newmessages) { |
| |
| if ($INFO{'caller'} != 3) { |
| |
| fopen(IUSRFILE, "$memberdir/$username.imstore"); |
| |
| foreach (<IUSRFILE>) { |
| |
| my @m = split(/\|/, $_); |
| |
| push(@newmessages, [@m]); |
| |
| $CountStore{$m[13]}++; |
| |
| } |
| |
| fclose(IUSRFILE); |
| |
| } |
| |
| fopen(TRANSFER, ">$memberdir/$username.imstore"); |
| |
| print TRANSFER map({ join('|', @$_) } sort { $$b[6] <=> $$a[6] } @newmessages); |
| |
| fclose(TRANSFER); |
| |
| |
| |
| ${$username}{'PMfoldersCount'} = ''; |
| |
| foreach (split(/\|/, ${$username}{'PMfolders'})) { |
| |
| $CountStore{$_} ||= 0; |
| |
| ${$username}{'PMfoldersCount'} .= ${$username}{'PMfoldersCount'} eq '' ? $CountStore{$_} : "|$CountStore{$_}"; |
| |
| } |
| |
| &buildIMS($username, 'update'); |
| |
| } |
| |
| } |
| |
| |
| |
| my $redirect = 'im'; |
| |
| if ($INFO{'caller'} == 2) { $redirect = 'imoutbox'; } |
| |
| elsif ($INFO{'caller'} == 3) { $redirect = "imstorage;viewfolder=$INFO{'viewfolder'}"; } |
| |
| elsif ($INFO{'caller'} == 4) { $redirect = 'imdraft'; } |
| |
| elsif ($INFO{'caller'} == 5) { $redirectview = ';focus=bmess'; } |
| |
| |
| |
| $yySetLocation = qq~$scripturl?action=$redirect~; |
| my $fileToOpen = "$username.msg"; |
| &redirectexit; |
| if ( $INFO{'caller'} == 2 ) { $fileToOpen = "$username.outbox"; } |
| |
| elsif ( $INFO{'caller'} == 3 ) { $fileToOpen = "$username.imstore"; } |
| |
| elsif ( $INFO{'caller'} == 4 ) { $fileToOpen = "$username.imdraft"; } |
| |
| elsif ( $INFO{'caller'} == 5 ) { $fileToOpen = 'broadcast.messages'; } |
| |
| |
| |
| fopen( USRFILE, "<$memberdir/$fileToOpen" ); |
| |
| my @messages = <USRFILE>; |
| |
| fclose( USRFILE ); |
| |
| my @delpost = (); |
| |
| # deleting |
| |
| if ( $FORM{'imaction'} eq $inmes_txt{'remove'} |
| |
| || $INFO{'action'} eq $inmes_txt{'remove'} |
| |
| || $INFO{'deleteid'} ) |
| |
| { |
| |
| my %CountStore; |
| |
| if ( $INFO{'caller'} == 2 ) { ${$username}{'PMmoutnum'} = 0; } |
| |
| elsif ( $INFO{'caller'} == 4 ) { ${$username}{'PMdraftnum'} = 0; } |
| |
| elsif ( $INFO{'caller'} != 3 && $INFO{'caller'} != 5 ) { |
| |
| ${$username}{'PMmnum'} = 0; |
| |
| ${$username}{'PMimnewcount'} = 0; |
| |
| } |
| |
| |
| |
| if ( $INFO{'deleteid'} ) { |
| |
| $FORM{ 'message' . $INFO{'deleteid'} } = 1; |
| |
| } # single delete |
| |
| @delpost = (); |
| |
| foreach (@messages) { |
| |
| my @m = split /\|/xsm, $_; |
| |
| chomp @m; |
| |
| if ( $INFO{'caller'} != 1 && $m[14] ne q{} ) { |
| |
| foreach ( split /,/xsm, $m[14] ) { |
| |
| my ( $pmAttachFile, $pmAttachUser ) = split /~/xsm, $_; |
| |
| if ( $username eq $pmAttachUser ) { |
| |
| unlink "$pmuploaddir/$pmAttachFile"; |
| |
| } |
| |
| } |
| |
| } |
| |
| if ( !exists $FORM{ 'message' . $m[0] } ) { |
| |
| push @delpost, $_; |
| |
| |
| |
| if ( $INFO{'caller'} == 2 ) { ${$username}{'PMmoutnum'}++; } |
| |
| elsif ( $INFO{'caller'} == 3 ) { $CountStore{ $m[13] }++; } |
| |
| elsif ( $INFO{'caller'} == 4 ) { ${$username}{'PMdraftnum'}++; } |
| |
| elsif ( $INFO{'caller'} != 5 ) { |
| |
| ${$username}{'PMmnum'}++; |
| |
| if ( $m[12] =~ /u/sm ) { ${$username}{'PMimnewcount'}++; } |
| |
| } |
| |
| } |
| |
| else { |
| |
| if ( $INFO{'caller'} == 3 ) { |
| |
| $INFO{'viewfolder'} = $m[13]; |
| |
| } |
| |
| elsif ( $INFO{'caller'} == 5 ) { |
| |
| if ( ${$username}{'PMbcRead'} !~ s/\b$m[0]$//gsm ) { |
| |
| ${$username}{'PMbcRead'} =~ s/$m[0]\b//gsm; |
| |
| } |
| |
| } |
| |
| } |
| |
| } |
| |
| fopen( USRFILE, ">$memberdir/$fileToOpen" ); |
| |
| print {USRFILE} @delpost or croak "$croak{'print'} USRFILE"; |
| |
| fclose(USRFILE); |
| |
| |
| |
| if ( $INFO{'caller'} == 3 ) { |
| |
| ${$username}{'PMfoldersCount'} = q{}; |
| |
| ${$username}{'PMstorenum'} = 0; |
| |
| foreach ( split /\|/xsm, ${$username}{'PMfolders'} ) { |
| |
| |