function WriteForumEditContents($fid) { global $loguser; //Get all categories. $rCats = Query("SELECT * FROM {categories} ORDER BY board, corder, id"); $cats = array(); while ($cat = Fetch($rCats)) { $cats[$cat['id']] = $cat; } $rFora = Query("SELECT * FROM {forums} ORDER BY l"); $fora = array(); $cid = -1; while ($forum = Fetch($rFora)) { if ($forum['catid'] >= 0) { $cid = $forum['catid']; } $fora[$cid][] = $forum; } $g = Query("SELECT id,name,type,color_unspec FROM {usergroups} ORDER BY type, rank"); $groups = array(); while ($group = Fetch($g)) { $name = htmlspecialchars($group['name']); if ($group['type'] == 0) { $name = '<strong style="color:' . htmlspecialchars($group['color_unspec']) . ';">' . $name . '</strong>'; } $groups[$group['id']] = array('name' => $name, 'permFields' => ''); } if ($fid != -1) { $rForum = Query("SELECT * FROM {forums} WHERE id={0}", $fid); if (!NumRows($rForum)) { Kill(__("Forum not found.")); } $forum = Fetch($rForum); $candelete = FetchResult("SELECT COUNT(*) FROM {threads} WHERE forum={0}", $fid) == 0; $c = FetchResult("SELECT COUNT(*) FROM {forums} WHERE l>{0} AND r<{1}", $forum['l'], $forum['r']); if ($c > 0) { $candelete = false; } $title = htmlspecialchars($forum['title']); $description = htmlspecialchars($forum['description']); $catselect = MakeCatSelect('cat', $cats, $fora, $forum['catid'], $forum['id']); $forder = $forum['forder']; $fperms = GetForumPerms($fid); foreach ($groups as $gid => $group) { $groups[$gid]['permFields'] = PermFields($gid, $fperms[$gid]); } $boxtitle = __("Editing forum ") . $title; $fields = array('title' => '<input type="text" name="title" value="' . $title . '" size=64>', 'description' => '<input type="text" name="description" value="' . $description . '" size=80>', 'parent' => $catselect, 'order' => '<input type="text" name="forder" value="' . $forder . '" size=3>', 'redirect' => '<input type="text" name="redirect" value="' . htmlspecialchars($forum['redirect']) . '" size=80>', 'hidden' => '<label><input type="checkbox" name="hidden" value="1"' . ($forum['hidden'] ? ' checked="checked"' : '') . '> ' . __('Hidden') . '</label>', 'offtopic' => '<label><input type="checkbox" name="offtopic" value="1"' . ($forum['offtopic'] ? ' checked="checked"' : '') . '> ' . __('Off-topic') . '</label>', 'btnSave' => '<button onclick="changeForumInfo(' . $fid . '); return false;">Save</button>', 'btnDelete' => '<button ' . ($candelete ? 'onclick="deleteForum(); return false;"' : 'disabled="disabled"') . '>Delete</button>'); $delMessage = $candelete ? '' : ($c ? __('Before deleting a forum, delete or move its subforums.') : __('Before deleting a forum, remove all threads from it.')); } else { $catselect = MakeCatSelect('cat', $cats, $fora, 1, -1); $fperms = GetForumPerms(0); foreach ($groups as $gid => $group) { $groups[$gid]['permFields'] = PermFields($gid, $fperms[$gid]); } $boxtitle = __("New forum"); $fields = array('title' => '<input type="text" name="title" value="" size=64>', 'description' => '<input type="text" name="description" value="" size=80>', 'parent' => $catselect, 'order' => '<input type="text" name="forder" value="0" size=3>', 'redirect' => '<input type="text" name="redirect" value="" size=80>', 'hidden' => '<label><input type="checkbox" name="hidden" value="1"> ' . __('Hidden') . '</label>', 'offtopic' => '<label><input type="checkbox" name="offtopic" value="1"> ' . __('Off-topic') . '</label>', 'btnSave' => '<button onclick="addForum(); return false;">Save</button>', 'btnDelete' => ''); $delMessage = ''; } echo "\n\t<form method=\"post\" id=\"forumform\" action=\"" . htmlentities(actionLink("editfora")) . "\">\n\t<input type=\"hidden\" name=\"key\" value=\"" . $loguser['token'] . "\">\n\t<input type=\"hidden\" name=\"id\" value=\"{$fid}\">"; RenderTemplate('form_editforum', array('formtitle' => $boxtitle, 'fields' => $fields, 'groups' => $groups, 'delMessage' => $delMessage)); echo "\n\t</form>"; }
function WriteForumEditContents($fid) { global $loguser; //Get all categories. $rCats = Query("SELECT * FROM {categories} ORDER BY corder, id"); $cats = array(); while ($cat = Fetch($rCats)) { $cats[$cat['id']] = $cat; } $rFora = Query("SELECT * FROM {forums} ORDER BY forder, id"); $fora = array(); while ($forum = Fetch($rFora)) { $fora[$forum['id']] = $forum; } if (count($cats) == 0) { $cats[0] = __("No categories"); } if ($fid != -1) { $rForum = Query("SELECT * FROM {forums} WHERE id={0}", $fid); if (!NumRows($rForum)) { Kill(__("Forum not found.")); } $forum = Fetch($rForum); $title = htmlspecialchars($forum['title']); $description = htmlspecialchars($forum['description']); $catselect = MakeCatSelect('cat', $cats, $fora, $forum['catid'], $forum['id']); $minpower = PowerSelect('minpower', $forum['minpower']); $minpowerthread = PowerSelect("minpowerthread", $forum['minpowerthread']); $minpowerreply = PowerSelect('minpowerreply', $forum['minpowerreply']); $forder = $forum['forder']; $func = "changeForumInfo"; $button = __("Save"); $boxtitle = __("Edit Forum"); $delbutton = "\n\t\t\t<button onclick='showDeleteForum(); return false;'>\n\t\t\t\t" . __("Delete") . "\n\t\t\t</button>"; $localmods = ""; $rMods = query("SELECT u.(_userfields)\n\t\t\t\t\t\tFROM {forummods} m\n\t\t\t\t\t\tLEFT JOIN {users} u ON u.id = m.user\n\t\t\t\t\t\tWHERE m.forum={0}\n\t\t\t\t\t\tORDER BY m.user", $fid); $addedMods = array(); if (!numRows($rMods)) { $localmods .= "(No local moderators assigned to this forum)<br /><br />"; } else { $localmods .= "<ul>"; while ($mod = fetch($rMods)) { $mod = getDataPrefix($mod, "u_"); $localmods .= "<li>" . UserLink($mod); $mid = $mod["id"]; $addedMods[$mid] = 1; $localmods .= " <sup><a href=\"\" onclick=\"deleteMod({$mid}); return false;\">✘</a></li>"; } $localmods .= "</ul>"; } $rMods = query("SELECT u.(_userfields)\n\t\t\t\t\t\tFROM {users} u\n\t\t\t\t\t\tWHERE u.powerlevel = 1\n\t\t\t\t\t\tORDER BY u.id"); $canAddMods = false; $addmod = "Add a mod: "; $addmod .= "<select name=\"addmod\" id=\"addmod\">"; while ($mod = fetch($rMods)) { $mod = getDataPrefix($mod, "u_"); if (isset($addedMods[$mod["id"]])) { continue; } $canAddMods = true; $mid = $mod["id"]; $mname = $mod["displayname"]; if (!$mname) { $mname = $mod["name"]; } $addmod .= "<option value=\"{$mid}\">{$mname} ({$mid})</option>"; } $addmod .= "</select>"; $addmod .= "<button type=\"button\" onclick=\"addMod(); return false;\">Add</button>"; if (!$canAddMods) { $addmod = "<br>No moderators available for adding.<br>To add a mod, set his powerlevel to Local Mod first."; } $localmods .= $addmod; } else { $title = __("New Forum"); $description = __("Description goes here. <strong>HTML allowed.</strong>"); $catselect = MakeCatSelect('cat', $cats, $fora, 1, -1); $minpower = PowerSelect('minpower', 0); $minpowerthread = PowerSelect("minpowerthread", 0); $minpowerreply = PowerSelect('minpowerreply', 0); $forder = 0; $func = "addForum"; $button = __("Add"); $boxtitle = __("New Forum"); $delbutton = ""; $localmods = "(Create the forum before managing mods)"; $privusers = '<small>(create the forum before adding users here)</small>'; } echo "\n\t<form method=\"post\" id=\"forumform\" action=\"" . actionLink("editfora") . "\">\n\t<input type=\"hidden\" name=\"key\" value=\"" . $loguser['token'] . "\">\n\t<input type=\"hidden\" name=\"id\" value=\"{$fid}\">\n\t<table class=\"outline margin\">\n\t\t<tr class=\"header1\">\n\t\t\t<th colspan=\"2\">\n\t\t\t\t{$boxtitle}\n\t\t\t</th>\n\t\t</tr>\n\t\t<tr class=\"cell1\">\n\t\t\t<td style=\"width: 25%;\">\n\t\t\t\t" . __("Title") . "\n\t\t\t</td>\n\t\t\t<td>\n\t\t\t\t<input type=\"text\" style=\"width: 98%;\" name=\"title\" value=\"{$title}\" />\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr class=\"cell0\">\n\n\t\t\t<td>\n\t\t\t\t" . __("Description") . "\n\t\t\t</td>\n\t\t\t<td>\n\t\t\t\t<input type=\"text\" style=\"width: 98%;\" name=\"description\" value=\"{$description}\" />\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr class=\"cell1\">\n\t\t\t<td>\n\t\t\t\t" . __("Parent") . "\n\t\t\t</td>\n\t\t\t<td>\n\t\t\t\t{$catselect}\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr class=\"cell0\">\n\t\t\t<td>\n\t\t\t\t" . __("Listing order") . "\n\t\t\t</td>\n\t\t\t<td>\n\t\t\t\t<input type=\"text\" size=\"2\" name=\"forder\" value=\"{$forder}\" />\n\t\t\t\t<img src=\"" . resourceLink("img/icons/icon5.png") . "\" title=\"" . __("Everything is sorted by listing order first, then by ID. If everything has its listing order set to 0, they will therefore be sorted by ID only.") . "\" alt=\"[?]\" />\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr class=\"cell1\">\n\t\t\t<td>\n\t\t\t\t" . __("Powerlevel required") . "\n\t\t\t</td>\n\t\t\t<td>\n\n\t\t\t\t{$minpower}\n\t\t\t\t" . __("to view") . "\n\t\t\t\t<br />\n\t\t\t\t{$minpowerthread}\n\t\t\t\t" . __("to post threads") . "\n\t\t\t\t<br />\n\t\t\t\t{$minpowerreply}\n\t\t\t\t" . __("to reply") . "\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr class=\"cell0\">\n\t\t\t<td>\n\t\t\t\t" . __("Local moderators") . "\n\t\t\t</td>\n\t\t\t<td>\n\t\t\t\t{$localmods}\n\t\t\t</td>\n\t\t</tr>\n\n\t\t<tr class=\"cell2\">\n\t\t\t<td>\n\t\t\t\t \n\t\t\t</td>\n\t\t\t<td>\n\t\t\t\t<button onclick=\"{$func}(); return false;\">\n\t\t\t\t\t{$button}\n\t\t\t\t</button>\n\t\t\t\t{$delbutton}\n\t\t\t</td>\n\t\t</tr>\n\t</table></form>\n\n\t<form method=\"post\" id=\"deleteform\" action=\"" . actionLink("editfora") . "\">\n\t<input type=\"hidden\" name=\"key\" value=\"" . $loguser['token'] . "\">\n\t<input type=\"hidden\" name=\"id\" value=\"{$fid}\">\n\t<div id=\"deleteforum\" style=\"display:none\">\n\t\t<table class=\"outline margin\">\n\t\t\t<tr class=\"header1\">\n\n\t\t\t\t<th>\n\t\t\t\t\t" . __("Delete forum") . "\n\t\t\t\t</th>\n\t\t\t</tr>\n\t\t\t<tr class=\"cell0\">\n\t\t\t\t<td>\n\t\t\t\t\t" . __("Instead of deleting a forum, you might want to consider archiving it: Change its name or description to say so, and raise the minimum powerlevel to reply and create threads so it's effectively closed.") . "<br><br>\n\t\t\t\t\t" . __("If you still want to delete it, click below:") . "<br>\n\t\t\t\t\t<button onclick=\"deleteForum('delete'); return false;\">\n\t\t\t\t\t\t" . __("Delete forum") . "\n\t\t\t\t\t</button>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t</table>\n\t</div>\n\t</form>"; // , $title, $description, $catselect, $minpower, $minpowerthread, $minpowerreply, $fid, $forder, $loguser['token'], $func, $button, $boxtitle, $delbutton); }