1 (edited by Pihtt 2007-11-19 21:51)

Topic: admin_forums.php display

When all forums are deleted in admin_forums.php, it becomes "not valid!"
But here is an easy fix :

if ($db->num_rows($result)):

select lines 403 to 456 IF NO MODIFICATIONS BEFORE
403 starting with

        <h2 class="block2"><span>Edit forums</span></h2>

456 starting with

    <div class="clearer"></div>

-->REPLACE WITH :

<?php
// Display all the categories and forums
$result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.disp_position FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id ORDER BY c.disp_position, c.id, f.disp_position') or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());

if ($db->num_rows($result)):
?>
        <h2 class="block2"><span>Edit forums</span></h2>
        <div class="box">
            <form id="edforum" method="post" action="admin_forums.php?action=edit">
                <p class="submittop"><input type="submit" name="update_positions" value="Update positions" tabindex="3" /></p>
<?php

    $tabindex_count = 4;

    $cur_category = 0;
    while ($cur_forum = $db->fetch_assoc($result))
    {
        if ($cur_forum['cid'] != $cur_category)    // A new category since last iteration?
        {
            if ($cur_category != 0)
                echo "\t\t\t\t\t\t\t".'</table>'."\n\t\t\t\t\t\t".'</div>'."\n\t\t\t\t\t".'</fieldset>'."\n\t\t\t\t".'</div>'."\n";

?>
                <div class="inform">
                    <fieldset>
                        <legend>Category: <?php echo pun_htmlspecialchars($cur_forum['cat_name']) ?></legend>
                        <div class="infldset">
                            <table cellspacing="0">
<?php

            $cur_category = $cur_forum['cid'];
        }

?>
                                <tr>
                                    <th><a href="admin_forums.php?edit_forum=<?php echo $cur_forum['fid'] ?>">Edit</a> - <a href="admin_forums.php?del_forum=<?php echo $cur_forum['fid'] ?>">Delete</a></th>
                                    <td>Position  <input type="text" name="position[<?php echo $cur_forum['fid'] ?>]" size="3" maxlength="3" value="<?php echo $cur_forum['disp_position'] ?>" tabindex="<?php echo $tabindex_count ?>" />
                                      <strong><?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?></strong></td>
                                </tr>
<?php

        $tabindex_count += 2;
    }

?>
                            </table>
                        </div>
                    </fieldset>
                </div>
                <p class="submitend"><input type="submit" name="update_positions" value="Update positions" tabindex="<?php echo $tabindex_count ?>" /></p>
            </form>
        </div>
<?php endif; ?>        </div>
    <div class="clearer"></div>