<?
    
//SAFE SHOW
    
    
$GLOBALS['highlight'] = 'forum';

    require_once(
'include/functions/community_permissions.php');

    
$_id = isset($_GET['i']) ? intval($_GET['i']) : 0;
    
    
$community mysql_query("SELECT * FROM community_sections, community WHERE community_sections.section_id = " sq($_id) . " AND community_sections.section_deleted = '0' AND community_sections.community_id = community.community_id");
    if (!
$community_row mysql_fetch_assoc($community))
    {
        
make_cookie('notice''Sorry, but what you are trying to access does not exist.');
        
header('Location: ./?s=community_create');
        die;
    }

    
community_permissions($community_row['community_id']);
    
    if (!
$GLOBALS['auth']['community']['administration'])
    {
        
make_cookie('notice''Sorry, you don\'t have permission to modify this community.');
        
header('Location: ./?s=community_create');
        die;
    }

    include(
'include/parts/header.php');
    
    echo 
box_outside_top('<a href="?s=community_modify&i=' $community_row['community_id'] . '">Modify Your Community</a> - Modify Section');
    echo 
box_inside_top();
?>
            
<form action="?a=community_section_modify&i=<?= $community_row['section_id'?>" method="post" class="form">
    <b>Section Name</b> (<?= COMMUNITY_SECTION_NAME_MIN ?> to <?= COMMUNITY_SECTION_NAME_MAX ?> characters in length.)
    <br /><div style="padding: 5px 0px 0px 0px;"></div>
    <input type="text" name="name" maxlength="<?= COMMUNITY_SECTION_NAME_MAX ?>" class="input_text" value="<?= htmlspecialchars($community_row['section_name_english']) ?>" style="width: 400px;">
    <div style="padding: 5px 0px 0px 0px;"></div>
    <input type="submit" value="Modfify Section" class="input_submit">
</form>

<?
    
echo box_inside_bottom();
    echo 
box_outside_bottom();
    
    echo 
box_outside_top('Forums');
    echo 
box_inside_top();    
    
    
$i 0;
    
$community_forums mysql_query("SELECT * FROM community_forums WHERE section_id = '" $community_row['section_id'] . "' AND forum_deleted = '0' ORDER BY forum_order_id");
    if (
$forum_count mysql_num_rows($community_forums))
    {
        while (
$community_forums_row mysql_fetch_assoc($community_forums))
        {
            if (
$i 0)
            {
                echo 
'<div style="padding: 5px 0px 0px 0px;"></div>';
            }
            echo 
'<div class="' . ($i 'on' 'off') . '">';
            echo 
'<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr>';
            echo 
'<td>';
            echo 
'<div style="font-size: 14px; font-weight: bold"><a href="?s=community_forum_modify&i=' $community_forums_row['forum_id'] . '">' htmlspecialchars($community_forums_row['forum_name_english']) . '</a>';
            echo 
' <span style="font-size: 10px; font-weight: normal;">[<a href="?a=community_forum_delete&i=' $community_forums_row['forum_id'] . '" onClick="return confirm(\'Are you sure you want to delete this forum?\');">Remove</a>]</span>';
            echo 
'</div>';
            echo 
'<div style="font-size: 12px;">' htmlspecialchars($community_forums_row['forum_description_english']) . '</div>';
            echo 
'</td>';
            if (
$i)
            {
                echo 
'<td width="75"><a href="?a=community_forum_up&i=' $community_forums_row['forum_id'] . '">Move Up</a></td>';
            }
            else
            {
                echo 
'<td width="75" nowrap></td>';
            }
            if (
$i $forum_count 1)
            {
                echo 
'<td width="75"><a href="?a=community_forum_down&i=' $community_forums_row['forum_id'] . '">Move Down</a></td>';
            }
            else
            {
                echo 
'<td width="75" nowrap></td>';
            }
            echo 
'</tr></table>';
            echo 
'</div>';                
            
$i++;
        }
    }
    else
    {
        echo 
'No forums exist in this section.';
    }
    
    echo 
box_inside_bottom();
    echo 
'<div style="padding: 5px 0px 0px 0px;"></div>';
    echo 
box_inside_top();
?>

<form action="?a=community_forum_add&i=<?= $community_row['section_id'?>" method="post" class="form">        
    <b>Add A Forum</b> (<?= COMMUNITY_FORUM_NAME_MIN ?> to <?= COMMUNITY_FORUM_NAME_MAX ?> characters in length.)
    <div style="padding: 5px 0px 0px 0px;"></div>
    <input type="text" name="name" maxlength="<?= COMMUNITY_FORUM_NAME_MAX?>" class="input_text" style="width: 400px;">
    <div style="padding: 5px 0px 0px 0px;"></div>
    <b>Forum Description</b> (<?= COMMUNITY_FORUM_DESC_MIN ?> to <?= COMMUNITY_FORUM_DESC_MAX ?> characters in length.)
    <div style="padding: 5px 0px 0px 0px;"></div>
    <input type="text" name="description" maxlength="<?= COMMUNITY_FORUM_DESC_MAX?>" class="input_text" style="width: 400px;">    
    <div style="padding: 5px 0px 0px 0px;"></div>
    <input type="submit" value="Add Forum" class="input_submit">                    
</form>

<?
    
echo box_inside_bottom();
    echo 
box_outside_bottom();
    
    echo 
box_outside_top('Section Moderators');
    echo 
box_inside_top();

    
$i 0;
    
$community_sections_permissions mysql_query("SELECT DISTINCT(user_id) FROM community_sections_permissions WHERE section_id = '" $community_row['section_id'] . "'");
    if (
mysql_num_rows($community_sections_permissions))
    {
        while (
$community_sections_permissions_row mysql_fetch_assoc($community_sections_permissions))
        {
            if (
$i++)
            {
                echo 
'<div style="padding: 5px 0px 0px 0px;"></div>';
            }
            echo 
'[' $community_sections_permissions_row['user_id'] . '] <span style="font-size: 14px; font-weight: bold;">';
            echo 
'<a href="?s=community_admin_modify_section&i=' $community_row['section_id'] . '&admin_name=' get_username($community_sections_permissions_row['user_id']) . '">' get_username($community_sections_permissions_row['user_id']) . '</a></span>';
            echo 
' [<a href="?a=community_admin_delete_section&i=' $community_row['section_id'] . '&admin_name=' get_username($community_sections_permissions_row['user_id']) . '" onClick="return confirm(\'Are you sure you want to remove this admin?\')">remove</a>]';
            echo 
'<div style="padding: 5px 0px 0px 0px;"></div>';
            
$j 0;
            
$permissions mysql_query("SELECT permission FROM community_sections_permissions WHERE section_id = '" $community_row['section_id'] . "' AND user_id = '" $community_sections_permissions_row['user_id'] . "' ORDER BY permission");
            while (
$permissions_row mysql_fetch_array($permissions))
            {
                if (
$j++)
                {
                    echo 
', ';
                }
                echo 
$permissions_row['permission'];
            }
        }
    }
    else
    {
        echo 
'There are no section moderators.';
    }
    
    echo 
box_inside_bottom();
    echo 
'<div style="padding: 5px 0px 0px 0px;"></div>';
    echo 
box_inside_top();
?>

<form action="?a=community_admin_add_section&i=<?= $community_row['section_id'?>" method="post" class="form">
<b>Add A Moderator</b> (enter username)
<div style="padding: 5px 0px 0px 0px;"></div>
<input type="text" name="admin_name" class="input_text" style="width: 400px;">
<div style="padding: 5px 0px 0px 0px;"></div>
<input type="submit" value="Add Moderator" class="input_submit">
</form>

<?
    
echo box_inside_bottom();
    echo 
box_outside_bottom();

    include(
'include/parts/footer.php');
?>