~;
## links for profile pages. SID is now cloaked and controls whether or not
## the action goes to authenticate or straight to the page.
## The trick is to use $page to pass the intended page through and switch over on
## positive id.
if ($page && $page ne $action) { $action = $page; }
my $profileLink;
my $sid = $INFO{'sid'};
my $thisLink = '';
my $sidLink = '';
if (!$sid) {$sid = $FORM{'sid'}; }
if ($sid) { $sidLink = ";sid=$sid"; }
if (!$sid) { $profileLink = 'action=profileCheck;page='; }
else {$profileLink = 'action=';}
$thisLink = 'action=myviewprofile;username=' . $useraccount{$username};
$MCProfMenu .= qq~
$inmes_txt{'viewprofile'}
~;
## if there are some folders to show under storage
## split the list down and show it with link to each folder
if ($enable_storefolders > 0) {
my $storeFoldersTotal = 0;
my $DelAdFolder = 0;
if (${$username}{'PMfolders'}) {
my $x = 2;
foreach my $storefolder (split(/\|/, ${$username}{'PMfolders'})) {
if ($storefolder ne 'in' && $storefolder ne 'out') {
$storeFoldersTotal++;
$MCPmMenuTemp .= qq~
~;
$yyjavascript .= qq~\nvar markallreadlang = '$inmes_txt{'500'}';\nvar markfinishedlang = '$inmes_txt{'500a'}';~;
## this allows user to add a new folder on the fly
if ($storeFoldersTotal < $enable_storefolders ) {
$MCPmMenu .= qq~
~;
}
## end PM div
}
sub drawPMView {
## column headers
## note - if broadcast messages not enabled but guest pm is, admin/gmod still
## see the broadcast split
if (($enable_PMcontrols && ${$uid.$username}{'pmviewMess'}) || (!$enable_PMcontrols && !$enable_PMviewMess) ) {
if (!$yyYaBBCloaded) { require "$sourcedir/YaBBC.pl"; }
}
if ($INFO{'sort'} ne 'gpdate' && $INFO{'sort'} ne 'thread') { &pageLinksList; }
my $dateColhead = "$inmes_txt{'317'}";
if ($action eq 'imdraft') { $dateColhead = $inmes_txt{'datesave'}; }
$mctitle = $IM_box;
$MCContent .= qq~
~;
if (($#dimmessages >= $maxmessagedisplay || $INFO{'start'} =~ /all/) && $action ne 'imstorage') {
$MCContent .= qq~
$pageindex1$pageindexjs
~;
}
if ($INFO{'viewfolder'} ne '') { $vfolder = qq~;viewfolder=$INFO{'viewfolder'}~; }
if ($INFO{'focus'} eq 'bmess') { $vbmess = qq~;focus=bmess~; }
if ($INFO{'sort'} ne 'gpdate') { $sbgpdate = qq~;sort=gpdate~; }
unless ($action eq 'imstorage' && $INFO{'viewfolder'} eq '') {
$MCContent .= qq~
~;
}
## if no messages found in file, say so
my $storeContentFound = 0;
if ($INFO{'viewfolder'} && @dimmessages) {
foreach my $checkPost (@dimmessages) {
my $thisStorefolder= (split /\|/, $checkPost)[13];
if ($thisStorefolder eq $INFO{'viewfolder'}) { $storeContentFound = 1; last; }
}
}
if (!@dimmessages || ($storeContentFound == 0 && $INFO{'viewfolder'})) {
## drop in the 'no messages' text
$MCContent .= qq~
$inmes_txt{'151'}
~;
} else {
## set colours for display
$acount++;
my $sortBy = $INFO{'sort'};
my $maxcounter;
$start = $start || 0;
## if on last page, adjust the maxcounter down
if ((($#dimmessages + 1) - $start) < $maxmessagedisplay || $sortBy eq 'gpdate' || $action eq 'imstorage') {
$maxcounter = @dimmessages;
} else {
$maxcounter = ($start + $maxmessagedisplay);
}
my $viewBMess;
my $groupByDate = 0;
my $dateSpan = 0;
my $latestPM = 0;
if ($INFO{'focus'} eq 'bmess') { $viewBMess = 1; }
if ($sortBy eq 'gpdate') {
my $topMDate = (split /\|/, $dimmessages[0])[6];
my $oldestDate = (split /\|/, $dimmessages[$#dimmessages])[6];
$groupByDate = 1;
## work out the span of days - today less oldest message, in days
$dateSpan = int(($date - $oldestDate) / 86400); # in days
$latestPM = (($date - $topMDate) / 3600); # in hours
}
## if sort is grouped, extra block is added per group
## pull date of newest pm
my $latestDateSet = 0;
my $lastWeekSet = 0;
my $twoWeeksSet = 0;
my $threeWeeksSet = 0;
my $monthSet = 0;
my $gtMonthSet = 0;
my $uselegend = "";
# work out the newest pm date soa s to put the right first block in
if ($dateSpan > 31) { $gtMonthSet = 1; $uselegend = 'older'; }
if ($dateSpan > 21 && ($latestPM / 24) < 32 ) { $monthSet = 1; $uselegend = 'fourweeks';}
if ($dateSpan > 14 && ($latestPM / 24) < 22 ) { $threeWeeksSet = 1; $uselegend = 'threeweeks';}
if ($dateSpan > 7 && ($latestPM / 24) < 15 ) { $twoWeeksSet = 1; $uselegend = 'twoweeks';}
if ($dateSpan > 1 && ($latestPM / 24) < 8 ) { $lastWeekSet = 1; $uselegend = 'oneweek';}
if ($latestPM < 24) { $latestDateSet = 1; $uselegend = 'latest'; }
if ($sortBy eq 'gpdate') {
$MCContent .= qq~
$im_sorted{$uselegend}
~;
$counterCheck = $start;
}
if ($viewBMess) { $stkDateSet = 1; }
for ($counter = $start; $counter < $maxcounter; $counter++) {
########## top of messages list ##########
# $messageid, $musername, $musernameto, $musernamecc, $musernamebcc
$class_PM_list = $class_PM_list eq 'windowbg2' ? 'windowbg' : 'windowbg2';
chomp $dimmessages[$counter];
my ($messageid, $musername, $musernameto, $musernamecc, $musernamebcc, $msub, $mdate, $immessage, $mpmessageid, $mreplyno, $mips, $messageStatus, $messageFlags, $storeFolder, $messageAttachment) = split(/\|/, $dimmessages[$counter]);
## if we are viewing one of the storage folders, filter out the
## PMs that don't match
if ($action eq 'imstorage' && $INFO{'viewfolder'} ne $storeFolder) {
$class_PM_list = $class_PM_list eq 'windowbg2' ? 'windowbg' : 'windowbg2';
next;
}
## set the status icon
my $messIconName = 'standard';
if ($messageStatus =~ /c/) { $messIconName = 'confidential'; }
elsif ($messageStatus =~ /u/) { $messIconName = 'urgent'; }
elsif ($messageStatus =~ /a/) { $messIconName = 'alertmod'; }
elsif ($messageStatus =~ /gr/) { $messIconName = 'guestpmreply'; }
elsif ($messageStatus =~ /g/) { $messIconName = 'guestpm'; }
my $messIcon = qq~~;
my ($hasMultiRecs,$multiRecs);
if ($musernameto =~ /,/ || $musernamecc || $musernamebcc ) { $hasMultiRecs = 1; }
## if store, set the from/to
# check for multiple recs (outbox/store/draft only)
## and build the to/rec string for individual callback
my %usersRec;
my $usernameto = '';
if ($action eq 'imoutbox' || $action eq 'imstorage' || $action eq 'imdraft') {
if ($hasMultiRecs) {
my $switchComma = 0;
$usernameto = '';
if ($messageStatus !~ /b/) {
## check each to see if they read the message
foreach my $muser (split(/\,/, $musernameto)) {
$userToMessRead = &checkIMS($muser, $messageid, 'messageopened');
%usersRec = {%usersRec , $muser => $userToMessRead};
if (!$yyUDLoaded{$muser}) { &LoadUser($muser); }
if ($usernameto && $switchComma == 0) { $usernameto .= qq~ ...~; $switchComma = 1; }
elsif (!$usernameto) {
$usernameto = qq~${$uid.$muser}{'realname'}~;
}
}
if ($musernamecc) {
## check each to see if they read the message
foreach my $muser (split(/\,/, $musernamecc)) {
$userToMessRead = &checkIMS($muser, $messageid, 'messageopened');
%usersRec = {%usersRec , $muser => $userToMessRead};
if (!$yyUDLoaded{$muser}) { &LoadUser($muser); }
if ($usernameto && $switchComma == 0) { $usernameto .= qq~ ...~; $switchComma = 1; }
}
}
if ($musernamebcc) {
## check each to see if they read the message
foreach my $muser (split(/\,/, $musernamebcc)) {
$userToMessRead = &checkIMS($muser, $messageid, 'messageopened');
%usersRec = {%usersRec , $muser => $userToMessRead};
if (!$yyUDLoaded{$muser}) { &LoadUser($muser); }
if($usernameto && $switchComma == 0) {$usernameto .= qq~ ...~; $switchComma = 1; }
}
}
} else {
foreach my $muser (split(/\,/, $musernameto)) {
if ($muser eq 'all') { $usernameto = $inmes_txt{'bmallmembers'}; }
elsif ($muser eq 'mods') { $usernameto = $inmes_txt{'bmmods'}; }
elsif ($muser eq 'gmods') { $usernameto = $inmes_txt{'bmgmods'}; }
elsif ($muser eq 'admins') { $usernameto = $inmes_txt{'bmadmins'}; }
else {
my $title = (split /\|/, $NoPost{$muser})[0];
$usernameto = $title;
}
if ($usernameto && $switchComma == 0) { $usernameto .= qq~ ...~; $switchComma = 1; last; }
}
}
} else {
if ($messageStatus !~ /b/) {
$userToMessRead = &checkIMS($musernameto, $messageid, 'messageopened');
if (!$yyUDLoaded{$musernameto}) { &LoadUser($musernameto); }
$usernameto = qq~${$uid.$musernameto}{'realname'}~;
} else {
if ($musernameto eq 'all') { $usernameto = $inmes_txt{'bmallmembers'}; }
elsif ($musernameto eq 'mods') { $usernameto = $inmes_txt{'bmmods'}; }
elsif ($musernameto eq 'gmods') { $usernameto = $inmes_txt{'bmgmods'}; }
elsif ($musernameto eq 'admins') { $usernameto = $inmes_txt{'bmadmins'}; }
else {
my $title = (split /\|/, $NoPost{$musernameto})[0];
$usernameto = $title;
}
}
}
}
## done multi
## kill if not needed
if (!$hasMultiRecs) { undef %usersRec; }
## time to output name
# for multi recs, have to split it down and test per user
## happens for any message sent with cc or bcc
my $checkz = 0;
my $allChecked = 0;
$msub = &Censor($msub);
&ToChars($msub);
$mydate = &timeformat($mdate);
## start of message row 1
## for inbox or store, check from
my ($fromToName, $messageIcon, $callBack, $messageAction);
if ($action ne 'imstorage' && $action ne 'imdraft' && !$viewBMess) {
## detect multi-rec
my ($imnew, $imRepliedTo, $imOpened);
## outbox - has the recp opened the message? (allow for multi)
if ($action eq 'imoutbox' && !$hasMultiRecs ) {
$imOpened = &checkIMS($musernameto, $messageid, 'messageopened');
} elsif ($action eq 'im') { ## inbox - has user opened ?
$imOpened = &checkIMS($username, $messageid, 'messageopened');
}
if ($action eq 'im') { $imRepliedTo = &checkIMS($username, $messageid, 'messagereplied'); }
## viewing inbox
if ($action eq 'im') {
## not opened
if (!$imOpened && !$hasMultiRecs) {
$messageIcon = qq~~;
}
## replied to
elsif ($imRepliedTo && !$hasMultiRecs) {
$messageIcon = qq~~;
}
## opened
elsif ($imOpened && !$hasMultiRecs) {
$messageIcon = qq~~;
}
## not opened multi
elsif (!$imOpened && $hasMultiRecs) {
$messageIcon = qq~~;
}
## opened multi
elsif ($imOpened && $hasMultiRecs) {
$messageIcon = qq~~;
}
}
## outbox
elsif ($action eq 'imoutbox') {
## not opened
if (!$imOpened && !$hasMultiRecs) {
&LoadUser($musernameto);
if (${$uid.$musernameto}{'notify_me'} < 2 || $enable_notifications < 2) {
$messageIcon = qq~~;
$callBack = qq~$inmes_imtxt{'83'} | ~;
} else {
$messageIcon = qq~~;
}
}
## opened
elsif ($imOpened && !$hasMultiRecs) {
$messageIcon = $messageFlags =~ /c/i ? qq~~ : qq~~;
}
## for multi rec, and none opened
if ($hasMultiRecs) {
my ($countrecepients,$countread,@receivers);
my $tousers = $musernameto;
$tousers .= ",$musernamecc" if $musernamecc;
$tousers .= ",$musernamebcc" if $musernamebcc;
foreach my $recname (split(/,/, $tousers)) {
$countrecepients++;
&LoadUser($recname);
if (&checkIMS($recname, $messageid, 'messageopened') || (${$uid.$recname}{'notify_me'} > 1 && $enable_notifications > 1)) { $countread++; } else { push(@receivers, $useraccount{$recname}); }
}
if (!$countread) {
$messageIcon = qq~~;
$callBack = qq~$inmes_imtxt{'83'} | ~;
} elsif ($countrecepients == $countread) {
$messageIcon = $messageFlags =~ /c/i ? qq~~ : qq~~;
} else {
$messageIcon = $messageFlags =~ /c/i ? qq~~ : qq~~;
$callBack = qq~$inmes_imtxt{'multicallback'} | ~;
}
}
}
}
## switch action if opening a draft - want this sending to the 'send' screen
my $actString = 'imshow';
if ($action eq 'imdraft') { $actString = 'imsend'; }
## if grouping, check bar here
if ($stkmess && $sortBy ne 'gpdate' && $normDateSet && $viewBMess) {
## sticky messages
$normDateSet = 0;
$MCContent .= qq~
~;
}
}
$MCContent .= qq~
~;
}
}
# load user's buddylist and show status of said members
sub LoadBuddyList {
# Load background color list
my @cssvalues = ('windowbg2', 'windowbg');
my $cssnum = @cssvalues;
my $counter = 0;
my @buddies = split('\|',${$uid.$username}{'buddylist'});
chomp @buddies;
$buddiesCurrentStatus = qq~