0) { $r = query ("select * from groups where groupid=" . $g . ";"); $g_info = mysql_fetch_array($r, MYSQL_ASSOC) or die ("Error accessing database for group id=" . $g); } // ====================================================================================================== // PROCESS FORM RESULTS // ====================================================================================================== $forumcount = 0; while (isset($_POST["edit_forum_id_" . ++$forumcount])) { // get information $forumid = $_POST["edit_forum_id_" . $forumcount]; $forumtitle = $_POST["edit_forum_title_" . $forumcount]; $forumdescription = $_POST["edit_forum_description_" . $forumcount]; $forumpurgedays = $_POST["edit_forum_purgedays_" . $forumcount]; $forumtopicsort = $_POST["edit_forum_topicsort_" . $forumcount]; if ($_POST["edit_forum_allowhtml_" . $forumcount]) { // force to integer $forumallowhtml = 1; } else { $forumallowhtml = 0; } $forumdelete = $_POST["edit_forum_delete_" . $forumcount]; // create new forum if (!$forumid) { if ($forumtitle) { $q = 'insert into forums set title="' . sqlsafe($forumtitle) . '",'; if ($forumdescription) { $q .= ' description="' . sqlsafe($forumdescription) . '",'; } $q .= ' purgetime=' . $forumpurgedays . ','; $q .= ' defaulttopicsort=' . $forumtopicsort . ','; $q .= ' allowhtml=' . $forumallowhtml . ','; $q .= ' ownergroupid=' . $g . ';'; $r = query($q) or die ('Error installing new forum with query:

' . $q); } else if ($forumdescription) { noteerror('Forum #' . $forumcount . ' must have a title.'); } // delete forum } elseif ($forumdelete) { // get topic list of message forum $r = query ('select * from topics where ownerforumid=' . $forumid . ';') or die ('Error listing topics in forum.'); $topiccount = 0; while ($topicinfo = mysql_fetch_array($r, MYSQL_ASSOC)) { $topiclist[] = $topicinfo; $topiccount++; } // go through list of topics, deleting all messages thereof if ($topiccount) { while (list($key,$topicinfo) = each($topiclist)) { $r = query ('delete from messages where ownertopicid=' . $topicinfo["topicid"] . ';') or die ('Error deleting messages in forum'); } } // delete topics $r = query ('delete from topics where ownerforumid=' . $forumid . ';') or die ('Error deleting topics in forum'); // delete forum $r = query ('delete from forums where forumid=' . $forumid . ';') or die ('Error deleting forum.'); // edit forum } else { if ($forumtitle) { $q = 'update forums set title="' . sqlsafe($forumtitle) . '",'; $q .= ' description="' . sqlsafe($forumdescription) . '",'; $q .= ' purgetime=' . $forumpurgedays . ','; $q .= ' defaulttopicsort=' . $forumtopicsort . ','; $q .= ' allowhtml=' . $forumallowhtml; $q .= ' where forumid=' . $forumid . ';'; $r = query($q) or die ('Error updating message forum with query:

' . $q); } else { noteerror('Forum #' . $forumcount . ' must have a title.'); } } } // ====================================================================================================== // BEGIN VISIBLE PAGE // ====================================================================================================== function masthead_editforums () { global $g, $BGCOLOUR_LIGHT, $BGCOLOUR_DARK; masthead_group_search('g'); if ($g) { print ''; print ' '; print 'Browse group |'; print ' '; print 'Browse forums |'; print ' '; print 'Security |'; print ""; } } if ($g) { printhtmlheader ('Edit ' . crunchtext($g_info["groupname"]) . ' Forums'); printmasthead ('Edit Forums','masthead_editforums','f'); printeditfeedback(); } else { printhtmlheader ('Edit Group Forums'); printmasthead ('Edit Forums','masthead_editforums','f'); die(); } print '

' . crunchtext($g_info["groupname"]) . " Forums

\n"; // SHOWFORUM function // // creates arbitrary number of forum-edit form variables: // edit_forum_id_# - if zero, this is a new forum to be created // edit_forum_title_# // edit_forum_description_# // edit_forum_purgedays_# // edit_forum_topicsort_# - see $sorttypes value below for pop-up menu options // edit_forum_allowhtml_# // edit_forum_delete_# // ... where # runs from 1 to $totalforums $sorttypes[0] = "Most recent posting"; $sorttypes[1] = "Alphabetical by topic title"; $forumcount = 0; function showforum ($forumid,$forumtitle,$forumdescription,$forumpurgedays,$forumtopicsort,$forumallowhtml) { global $forumcount, $sorttypes; $forumformid="edit_forum_id_" . ++$forumcount; $_POST[$forumformid] = $forumid; $forumformtitle="edit_forum_title_" . $forumcount; $_POST[$forumformtitle] = $forumtitle; $forumformdescription="edit_forum_description_" . $forumcount; $_POST[$forumformdescription] = $forumdescription; $forumformpurgedays="edit_forum_purgedays_" . $forumcount; $_POST[$forumformpurgedays] = $forumpurgedays; $forumformtopicsort="edit_forum_topicsort_" . $forumcount; $_POST[$forumformtopicsort] = $forumtopicsort; $forumformallowhtml="edit_forum_allowhtml_" . $forumcount; $_POST[$forumformallowhtml] = $forumallowhtml; $forumformdelete="edit_forum_delete_" . $forumcount; $_POST[$forumformdelete] = false; print "
\n"; print ''; if ($forumid > 0) { print 'Forum #' . $forumcount; } else { print 'New Forum'; } print "Title:"; formhiddeninput ($forumformid); formtextinput ($forumformtitle,50,'small'); print "\n"; if ($forumid) { print ""; formcheckboxinput ($forumformdelete,'small'); print "Delete"; } print "\n"; print 'Description:' . highlighttext('*') . ''; formtextareainput ($forumformdescription,50,4,'small'); print "\nInactive Topic Deletion" . highlighttext('**') . ""; formnumberinput ($forumformpurgedays,5,'small'); print "\nSort Topics By:"; formpopupinput ($forumformtopicsort, $sorttypes, 0, 'small'); print "\nAllow HTML code:" . highlighttext('***') . ""; formcheckboxinput ($forumformallowhtml, 'small'); print "\n\n\n"; } // look up existing forums for specified group $r = query ('select * from forums where ownergroupid=' . $g); if ($r) { $totalforums = 0; while ($foruminfo = mysql_fetch_array($r, MYSQL_ASSOC)) { $forumlist[] = $foruminfo; $totalforums++; } } // list forums & properties formstart (append_url_vars_pg('')); // print "\n"; print "\n\n
TitleDescriptionMessage Duration (days)*Sort Topics By
"; if ($totalforums) { while (list($key,$foruminfo) = each ($forumlist)) { showforum ($foruminfo["forumid"],$foruminfo["title"],$foruminfo["description"],$foruminfo["purgetime"],$foruminfo["defaulttopicsort"],$foruminfo["allowhtml"]); } } showforum (0,'','',0,0,FALSE); // for creating a new forum print "
\n\n"; formend (); $footnote = '

* HTML code is supported in this field.
'; $footnote .= '

** Topics with no new messages can be deleted automatically from a forum. A nonzero value in this field indicates the number of days a topic must remain inactive before being deleted. A zero in this field indicates that the forum will perform no automatic deletions.
'; $footnote .= '

*** Allowing HTML code in a message forum is an invitation to disaster if the forum has unlimited access. Do not check this if anyone on the internet can post to this forum.
'; print highlighttext($footnote); ?>