<?php
require_once '_admin_setting.php';

$theAction = 'add';
$theId = trim($_GET['id']);
$theId = is_numeric($theId) ? $theId : '';

$thePostData = array();

if ($theId) {
	$sql = "SELECT * FROM users WHERE id = {$theId}";
	$user = $nsodb->get_row($sql, ARRAY_A);
	$theAction = 'update';
}

addHeaderCss('swfupload/style/swfupload.css');
addHeaderJavascript('../javascripts/jquery/jquery.form.js');
addHeaderJavascript($nsoCkeditorJavascripts, $nsoSwfuploadScripts);
addHeaderJavascript('javascripts/user_form.js');
require_once '_top.php';
require_once '_header.php';
require_once '_menuPane.php';
?>
<div id="godContentContainer">
    <div class="content_part">
        <div class="title"><h2>用户</h2></div>
        <div id="topToolbar" class="toolbar">
            <div class="tool_button">
                <div class="button save_button">保存<span class="deco_left"></span><span class="deco_right"></span></div>
            </div>
            <?php if ($theCat != $nsoAboutCatId):?>
            <div class="tool_button">
                <div class="button addnew_button">新增<span class="deco_left"></span><span class="deco_right"></span></div>
            </div>
            <?php endif;?>
        </div>
        <div class="infobar">
            <div class="message_box">正在保存...</div>
        </div>
        <div class="content">
            <div class="form_content">
                <form id="postForm" action="user_edit_action.php" method="post">
                    <table>
                        <tbody>
                            <tr>
                                <td class="label">名称</td>
                                <td>
                                    <div class="form_element form_element_title">
                                        <input class="input_title" type="text" name="username" value="<?php echo $user['account'];?>" />
                                    </div>
                                </td>
                            </tr>
                            <?php if ($theAction == 'update'):?>
                            <tr>
                                <td class="label">旧密码</td>
                                <td>
                                    <div class="form_element">
                                        <input type="text" name="opassword" />
                                    </div>
                                </td>
                            </tr>
                            <?php endif;?>
                            <tr>
                                <td class="label">新密码</td>
                                <td>
                                    <div class="form_element">
                                        <input type="text" name="npassword" />
                                    </div>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                    <div class="line"></div>
                    <input type="hidden" name="id" value="<?php echo $theId?>" id="form-post-id-input" />
                    <input type="hidden" name="action" value="<?php echo $theAction?>" id="form-action-input" />
                </form>
            </div>
        </div>
        <div style="display:none">
            <div id="hiddenParamAddNewPostUri"><?php $addNewUri = explode('&', $_SERVER['REQUEST_URI']); echo $addNewUri[0];?></div>
        </div>
    </div>
</div>
<?php include_once '_bottom.php'; ?>