pretop();
// include("dataStuff.inc");
// include("userStuff.inc");
include("flagStuff.inc");
include("fileStuff.inc");
include("districtStuff.inc");
include("ownerStuff.inc");
include("$inc/messageboardStuff.inc");
include("messageboard/treeBuilder.inc");
// include("groupStuff.inc");
# use disclosure triangles (mainly for testing)
$dts = 1;
if ( empty($fID) )
{
header("Location: " . $sess->url("index.php") );
exit;
}
if ( !isset($viewby) ) $viewby = "thread";
function printLocalNav()
{
global $sess, $auth, $folder, $fID;
if ( $folder < 0 && isModerator($fID, $auth->auth[uid]) )
{
# we are looking at a list of folders
echo "url("post.php?re=0&fID=$fID") . "\">Add a " . folder() . "";
echo " ";
}
$cr = getCanReply($folder, $fID);
$hr = haveReplied($folder, $fID, $auth->auth[uid]);
#debug("cr: $cr hr: $hr");
if ( $folder > 0 &&
!( $cr == "once" && $hr ) &&
( $cr != "expire" || ( $cr == "expire" && !$hr ) ) &&
( $cr != "no" )
): ?>
// new as of 9/23/00 : print which cohort they're viewing from
// is the user an admin?
if (msgbd_is_partitioned($fID))
{
if (isModerator($fID, $auth->auth["uid"]))
{
global $admin_partition; // doh, that'd kinda be important, now wouldn't it?
// we need to see if they've got their $admin_partition goin' on
if (is_array($admin_partition) && count($admin_partition) > 0 )
{
$curgrplist = $admin_partition;
}
else
{
$curgrplist = array();
}
}
else
{
$curgrplist = msgbd_user_groups($fID);
}
$main_partition_list = msgbd_partition_groups($fID);
$partition_type_name = getGroupName(msgbd_partition_type($fID));
#print "partition type name = $partition_type_name
\n";
if (count($curgrplist) == 0)
{
if (isModerator($fID, $auth->auth["uid"]))
{
print "Currently viewing All " . $partition_type_name . "s'\n";
print (" ". forum() . "s.");
}
else
{
print "You are not currently a member of any " . $partition_type_name . "s. You will only see messages from moderators and other non-" .$partition_type_name . "-assigned users.";
}
}
else
{
print "Currently viewing the ";
for ($j = 0; $j < count($curgrplist); $j++)
{
print getGroupName($curgrplist[$j]);
if ($j < (count($curgrplist) - 1))
{
print ", ";
}
}
print "\n";
print $partition_type_name;
print (count($curgrplist) == 1) ? "'s" : "s'";
print (" ". forum() . ".");
}
print "
\n";
// new as of 9/23/00 : print moderator choices
if (isModerator($fID, $auth->auth["uid"]))
{
print "Choose a " . $partition_type_name . ": \n";
global $REQUEST_URI,$PHP_SELF;
$r_uri = $REQUEST_URI;
// we have to strip any mod_partition crap out of r_uri in case
// they're flipping around through the menu
$r_path = $PHP_SELF;
$r_uri = ereg_replace(("^" . $PHP_SELF . "\?"), "", $r_uri);
$r_uri_array = split("&", $r_uri);
$new_uri_array = array();
for ($m = 0; $m < count($r_uri_array); $m++)
{
if (ereg("^mID=(.*)$", $r_uri_array[$m], $uri_regs))
{
global $masterList;
$this_mID = $uri_regs[1];
$parent_mID = findFolderInTree($this_mID, $masterList);
#debug ("got to the mID through the ereg and this_mID is " . $this_mID . " and parent_mID is ". $parent_mID);
// have to find parent folder of this message if we're going to
// switch Cohorts now.
$new_uri_array[] = "mID=" . $parent_mID;
}
else if (!ereg("^mod_partition\[\]=", $r_uri_array[$m]))
{
$new_uri_array[] = $r_uri_array[$m];
}
}
# debug ("request URI right here is " . $r_uri);
# debug ("r_uri_array is " . dump_array($r_uri_array));
# debug ("new_uri_array is " . dump_array($new_uri_array));
$r_uri = $r_path ."?". join("&", $new_uri_array);
# debug ("request URI right here is " . $r_uri);
$num_partition_groups = count($main_partition_list);
$num_cur_groups = count($curgrplist);
if ( $num_cur_groups == 0)
{
// we see them all right now
print "All | \n";
}
else
{ // let them see them all if they want
$currentallurl = $r_uri . "&mod_partition[]="; // empty == all
print "url($currentallurl) . "\">All | \n";
}
for ($k = 0; $k < $num_partition_groups; $k++)
{
$curgroup = $main_partition_list[$k];
$curgroupname = getGroupName($curgroup);
if (in_array($curgroup, $curgrplist))
{
print "" . $curgroupname . "\n";
}
else
{
$currenturl = $r_uri . "&mod_partition[]=" . $curgroup;
print "url($currenturl) . "\">" . $curgroupname . "\n";
}
// for now, only exclusive groups or all. later, matthew says, it can get funky like that
if ($k < ($num_partition_groups - 1))
{
print " | ";
}
}
print "
\n";
}
}
?>
">Post a New echo message(); ?>
endif; ?>
if ( $folder > 0 && $masterList[$folder][parent] == 0 ): ?>
">Back to echo folder(); ?>s
endif; ?>
// print the "Back to this challenge" link, given the forum we're in right now.
// Potential problem: What if multiple challenges dump to one forum, or something like that,
// someday? Perhaps would be better to build in the generic 'back in history' instead...
backToLink($fID);
}
function has_children($mID, $fID)
{
global $instr;
$query = "select ID from message where parent=$mID and forum=$fID
and ID in ($instr)";
$tmp = doQuery($query);
return count($tmp);
}
function printSub($mID, $data, $lev)
{
global $com, $sess, $COLOR_THREE;
global $fID, $PHP_SELF, $instr;
global $folder, $taghere;
global $tree_all, $viewby;
#if ( $data[parent] == 0 && $mID > 1)
# echo "
|
";
echo "\n\n";
echo "| " . getFlag($data[flag]) . " | ";
echo "";
if ($lev > 0)
{
$width = ($lev) * 15;
echo " ";
}
if ( $data[parent] != 0 )
$page = "view";
else
$page = "list";
#echo "$data[parent] ";
#debug("the folder is: $folder");
if ( $folder > 0 && ( ( $viewby != "thread" && ereg("[a-zA-Z-]", $mID) ) ||
( has_children($mID, $fID) && $viewby == "thread" ) ) )
{
# disclosure triangles go here
global $focus, $isopen;
/*
if ( ereg("[a-zA-Z-]", $mID) )
{
ereg("^([0-9]+)", $instr, $regs);
$thisID = $regs[1];
}
else
$thisID = $mID;
*/
if ( in_array($mID, $isopen) )
{
$tri = " ";
switch ($viewby)
{
case "thread":
$open = $data[parent];
break;
case "date":
case "author":
$open = "";
break;
}
}
else
{
$tri = " ";
switch ($viewby)
{
case "thread":
case "date":
$open = $mID;
break;
case "author":
$open = rawurlencode($mID);
break;
}
#$open = $mID;
}
echo "$tri";
# some space
echo " ";
}
else if ( $folder > 0 )
echo " ";
if ( $taghere )
#debug("taghere: $taghere");
if ( $taghere == $mID )
{
#debug("taging mID: $mID");
echo "\n\n";
}
if ( ereg("[a-zA-Z-]", $mID) )
{
switch ($viewby)
{
case "author":
#echo getUserName_comma(ereg_replace("a", "", $mID));
echo $mID;
break;
case "date":
echo date("l, M j, Y", sql_date_to_mktime($mID));
# echo $mID;
break;
}
}
else
{
echo "url("$page.php?mID=$mID&fID=$fID") . "\">";
if ( $data[status] == "deleted" )
echo "";
echo stripslashes($data[subject]);
echo "";
}
if ( !ereg("[a-zA-Z-]", $mID) && $data[parent] != 0 )
{
echo " | ";
echo getUser($data[author]);
echo " | ";
if ( $viewby == "date" )
echo date("g:i:s a \E\S\T", sql_date_to_mktime($data[postdate]));
else
echo formatShortDate($data[postdate]);
}
echo "\n | ";
if ( $data[parent] == 0 && !ereg("[a-zA-Z-]", $mID) )
#echo "" . rcount($tree_all[$mID]) . " | ";
echo "
\n";
}
function printMsgs($branch, $level, &$raw)
{
while ( list($mID, $leaves) = each($branch) )
{
printSub($mID, $raw[$mID], $level);
if( gettype($leaves) == "array" )
printMsgs($leaves, $level + 1, $raw);
}
}
$db = new $DATABASE;
if ( isset($fID) && !boardExists($fID) )
$err = "That " . forum() . " does not exist.";
else if ( !canEnter($fID, $auth->auth[uid]) )
$err = "You do not have access to this " . forum() . ".";
# take care of moderation changes
if ( empty($err) && isModerator($fID, $auth->auth[uid]) && $folder > 0 )
handleModeratorChanges($folder, $fID, $submit);
$sec = "messageboard:list";
while ( getSectionHistory() != "" && getSectionHistory() != $sec )
popHistory();
// $history_accept = array("messageboard:post", "messageboard:view");
$extra = getExtraHistory();
if (!is_array($extra))
$extra = array();
$admin_partition = $extra["admin_partition"];
// make sure the person IS an administrator first, for THIS message board...
// they might only be in the moderator table for a different one
if (isModerator($fID, $auth->auth["uid"]))
{
// see if they have specified which partition group(s) to view this page as
// override admin_partition with command line arguments and save until we hear otherwise
if (!empty($mod_partition) && is_array($mod_partition))
{
# debug ("mod partition is " . dump_array($mod_partition));
if (empty($mod_partition[0]))
{
unset( $extra["admin_partition"]);
unset ($admin_partition);
# debug( "mod partition[0] was empty.");
}
else
{
$admin_partition = $mod_partition;
$extra["admin_partition"] = $admin_partition;
}
}
}
$defhist = 1;
top(forum(), $sec);
if (!empty($err))
fatalError($err);
$masterList = makeMessageArray($fID);
saveHistory($extra);
#print_array($masterList);
if ( ! isset($masterList[$folder]) )
unset($folder);
if ( $mID )
$folder = findFolderInTree($mID, $masterList);
if ( $folder > 0 && $masterList[$folder][parent] == 0 )
$justFolders = 0;
else
{
$justFolders = 1;
$tree_all = makeMessageTree($masterList, -1, 0);
}
$old_tree = makeMessageTree($masterList, $folder, $justFolders);
if ( !$folder )
$folder = -1;
#$parent = $masterList[$mID][parent];
if ( $focus && $focus != $folder )
$parent = $focus;
else if ( $folder > 0 )
$parent = $folder;
else
$parent = 0;
# debug("folder: $folder, mID: $mID, the parent: $parent
");
$tmp = array();
squish($old_tree, $tmp);
$first = 0;
#debug ("count of tmp is: " . count($tmp));
while ( list(, $id) = each ($tmp) )
{
if ($first++ > 0)
$instr .= ", ";
$instr .= $id;
}
#debug("the messages: $instr" );
$isopen = array(stripslashes($focus));
// attempt by Thom to circumvent the whole ugly business
if (!empty($instr))
{
switch ($viewby)
{
case "thread":
while ( isset($parent) && ( $parent != 0 || $folder == -1 ) )
{
$query = "select ID from message where parent=$parent and forum=$fID";
if (!empty($instr))
{
$query .= " and ID in ($instr)";
}
#debug("thread query: $query");
$tmp = doQuery($query);
#print_array($tmp);
$tree_var = "tree" . $parent;
while ( list(, $key) = each($tmp) )
{
$id = $key[ID];
if ( is_array(${"tree" . $id}) )
{
$isopen[] = $id;
$branch = ${"tree" . $id};
unset(${"tree" . $id});
if ( $parent == $folder )
$taghere = $id;
}
else
$branch = array();
${$tree_var}[$id] = $branch;
}
$parent = $masterList[$parent][parent];
}
$tree = ${$tree_var};
break;
case "date":
$query = "select distinct postdate from message where forum=$fID and ";
if (!empty($instr))
{
$query .= " ID in ($instr) and ";
}
$query .= " parent != 0 order by postdate desc";
#debug("date query: $query");
$tmp = doQuery($query);
while ( list(,$ary) = each ( $tmp ) )
{
#$date = date("D, n / j / Y", sql_date_to_mktime($ary[postdate]));
list($date, ) = explode(" ", $ary[postdate]);
if ( $date == $focus )
{
$query = "select ID from message where forum=$fID and ";
if (!empty($instr))
{
$query .= " ID in ($instr) and ";
}
$query .= " postdate <= '$date 23:59:59' and postdate >= '$date 00:00:00' and ";
$query .= " parent != 0 order by postdate desc";
$tmp2 = doQuery($query);
while ( list(,$ary) = each ( $tmp2 ) )
$branch[$ary[ID]] = array();
$taghere = $date;
}
else
$branch = array();
if ( $date )
$tree[$date] = $branch;
}
#debug("date tree:" . dump_array($tree));
break;
case "author":
$query = "select distinct author from message where forum=$fID and ";
if (!empty($instr))
{
$query .= "ID in (" . $instr . ") and ";
}
$query .= " parent != 0";
$tmp = doQuery($query);
while ( list(,$ary) = each ( $tmp ) )
{
$author = $ary[author];
$name = getUserName_comma($author);
if ( $name == stripslashes($focus) )
{
$query = "select ID from message where forum=$fID and ";
if (!empty($instr))
{
$query .= " ID in ($instr) and ";
}
$query .=" author=$author and parent != 0 order by postdate desc";
$tmp2 = doQuery($query);
while ( list(,$ary) = each ( $tmp2 ) )
$branch[$ary[ID]] = array();
$taghere = $name;
}
else
$branch = array();
if ( $name )
$tree[$name] = $branch;
}
ksort($tree);
break;
}
} // end if (!empty($instr))
else
{
$tree = array();
}
// debug ("Tree, BTW, is " .dump_array($tree));
$query = "select name from forum where ID=$fID";
$db->query($query);
$db->next_record();
?>
echo $db->f("name"); ?> - echo forum(); ?>
if ( $folder > 0 && $masterList[$folder][parent] == 0 )
{
# show title and body of "folder"
$mdata = getMessageData($folder, $fID);
$subject = stripslashes($mdata[subject]);
$flag = $mdata[flag];
$status = $mdata[status];
$msgCount = rcount($tree);
if ( $viewby == "author" )
$msgCount -= count($tree);
if ($msgCount != 1) $s = "s";
if ( $status == "deleted" )
{
$strike = "";
$strike2 = "";
}
echo "" . getFlag($flag) . " $strike$subject$strike2" .
# " - $msgCount message$s" .
"";
echo "
";
printMessageBody($mdata);
}
else
{
echo getBody($fID);
}
?>
printLocalNav();
?>
>
if ( $folder > 0 && $masterList[$folder][parent] == 0 ) { ?>
| Subject |
Author |
Posted On |
} else { ?>
echo folder(); ?>s |
} ?>
if (count($tree) != 0) // thom 9/24
{
printMsgs($tree, 0, $masterList);
}
else
{
print "| This " . folder() . " does not have any messages. |
";
}
echo "
";
#if ($perm->have_perm("uberadmin") )
#{
if ($folder > 0)
{
echo "";
if ($viewby != "thread")
echo "url("$PHP_SELF?folder=$folder&fID=$fID&viewby=thread") . "\">";
echo "View by thread\n";
echo " \n";
if ($viewby != "author")
echo "url("$PHP_SELF?folder=$folder&fID=$fID&viewby=author") . "\">";
echo "View by author\n";
echo " \n";
if ($viewby != "date")
echo "url("$PHP_SELF?folder=$folder&fID=$fID&viewby=date") . "\">";
echo "View by date\n";
echo "
";
}
#}
echo "";
printLocalNav();
$moder = isModerator($fID, $auth->auth[uid]);
if ( $folder && $moder )
{
printModerForm($folder, $fID);
}
else if ($moder)
{
echo "
";
}
bottom();
?>