hxp
2025-06-09 6c3f6335c70859ded94a1ad8d218acb0ac34239c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
<?php
include_once "/Common/Logging.php";
include_once "/Account/User.php";
include_once "/db/DBOper.php";
include_once "/language/lang.php";
 
\Logging\CreateLogging("account.useredit.php");
$Permission = \User\Permission::P_UserMgr;
 
$UserAccount = $_SESSION['UserAccount'];
$user = new \User\User($UserAccount);
if (!$user->HavePermission($Permission)) {
    exit;
}
 
$opType = $_GET["opType"];
 
$editInfo = array();
$pageTitle = \Lang\gettext("后台账号添加");
if ($opType == "upd") {
    $pageTitle = \Lang\gettext("后台账号修改");
    \DBOper\FindOne("GMTUser", array("UserAccount" => $_GET["UserAccount"]), $editInfo);
} else {
    $editInfo = $_GET;
}
 
$UserLV = $user->GetAttr("UserLV");
 
$Organization = array_key_exists("Organization", $editInfo) ? $editInfo["Organization"] : "";
\DBOper\Find("GMTPermissionGroup", array("Organization" => $Organization), $OrganizationPGroups);
 
// echo "_GET:" . print_r($_GET, true), "<br/>";
// echo "editInfo:" . var_dump($editInfo), "<br/>";
// echo "OrganizationPGroups:" . print_r($OrganizationPGroups, true), "<br/>";
 
?>
 
<html>
 
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title><?php echo $pageTitle; ?></title>
    <link rel="stylesheet" type="text/css" href="/css/tableform.css">
</head>
 
<body>
    <center>
        <p><b><?php echo $pageTitle; ?></b></P>
    </center>
    <hr />
 
    <form action="userlist.php" method="post">
        <table id="tt" class="formTable">
            <tr>
                <td class="formTableTDName"><?php echo \Lang\gettext("所属组织"); ?>: </td>
                <td class="formTableTDValue">
                    <?php
                    echo "<input type=\"text\" name=\"Organization\" id=\"Organization\" value=\"" . $Organization . "\" readonly/>";
                    ?>
                </td>
            </tr>
            <tr>
                <td class="formTableTDName"><?php echo \Lang\gettext("账号"); ?>: </td>
                <td class="formTableTDValue">
                    <input type="text" name="UserAccount" id="UserAccount" value="<?php echo array_key_exists("UserAccount", $editInfo)  ? $editInfo["UserAccount"] : "" ?>" placeholder="<?php echo \Lang\gettext("最少长度3"); ?>" <?php echo $opType == "upd" ? "readonly" : "" ?> />
                </td>
            </tr>
            <tr>
                <td class="formTableTDName"><?php echo \Lang\gettext("密码"); ?>: </td>
                <td class="formTableTDValue">
                    <input type="password" name="Psw" id="Psw" value="" placeholder="<?php echo $opType == "upd" ? \Lang\gettext("需要修改时才需要输入") : "" ?>" />
                </td>
            </tr>
            <tr>
                <td class="formTableTDName"><?php echo \Lang\gettext("重复输入密码"); ?>: </td>
                <td class="formTableTDValue">
                    <input type="password" name="PswConfirm" id="PswConfirm" value="" placeholder="<?php echo $opType == "upd" ? \Lang\gettext("需要修改时才需要输入") : "" ?>" />
                </td>
            </tr>
            <tr>
                <td class="formTableTDName"><?php echo \Lang\gettext("账号等级"); ?>: </td>
                <td class="formTableTDValue">
                    <?php
                    echo "<select id=\"UserLV\" name=\"UserLV\" onchange='OnSelectUserLVChange(this.value)'>";
                    $selected = array_key_exists("UserLV", $editInfo)  ? $editInfo["UserLV"] : \User\UserLV::COMM;
                    foreach (\User\UserLV::LVNameInfo() as $key => $value) {
                        if ($UserLV < $key || $key == \User\UserLV::ADMIN_SUPER) {
                            continue;
                        }
                        echo "<option value='" . $key . "'";
                        if ($key == $selected) {
                            echo " selected";
                        }
                        echo ">" . $value . "</option>";
                    }
                    echo "</select>";
                    ?>
                </td>
            </tr>
            <tr>
                <td class="formTableTDName"><?php echo \Lang\gettext("可管理渠道列表"); ?>: </td>
                <td class="formTableTDValue">
                    <?php
                    $editSPIDAll = array_key_exists("SPList", $editInfo)  ? $editInfo["SPList"] : array();
                    echo "<div id=\"ChannelChoose\">";
                    foreach (\CommFunc\GetOrganizationChannel($Organization) as $value) {
                        echo "<input type=\"checkbox\" name=\"SPID_" . $value . "\"";
                        if (in_array($value, $editSPIDAll)) {
                            echo " checked=\"checked\"";
                        }
                        echo "/>" . $value;
                        echo "&nbsp;&nbsp;";
                    }
                    echo "</div>";
 
                    echo "<div id=\"ChannelAdmin\">";
                    echo \Lang\gettext("管理员默认管理所有渠道");
                    echo "</div>";
                    ?>
                </td>
            </tr>
            <tr>
                <td class="formTableTDName"><?php echo \Lang\gettext("权限"); ?>: </td>
                <td class="formTableTDValue">
                    <?php
                    echo "<div id=\"PerGroupChoose\">";
                    $editPermissionGroups = array_key_exists("PermissionGroups", $editInfo)  ? $editInfo["PermissionGroups"] : array();
                    if (isset($OrganizationPGroups) && count($OrganizationPGroups) > 0) {
                        foreach ($OrganizationPGroups as $value) {
                            $GroupName = $value["GroupName"];
                            if ($GroupName == \User\Permission::GroupAdmin) {
                                continue;
                            }
                            $checkBoxName = "PGroup_" . urlencode($GroupName);
                            echo "<input type=\"checkbox\" name=\"" . $checkBoxName . "\"";
                            if (in_array($GroupName, $editPermissionGroups)) {
                                echo " checked=\"checked\"";
                            }
                            echo "/>" . $GroupName;
                            echo "&nbsp;&nbsp;";
                        }
                    } else {
                        echo "<a href=\"pergroup.php?Organization=" . $Organization . "\">" . \Lang\gettext("前往编辑权限分组") . "</a>";
                    }
                    echo "</div>";
 
                    echo "<div id=\"PerGroupAdmin\">";
                    echo \Lang\gettext("管理员默认拥有所有权限");
                    echo "</div>";
                    ?>
                </td>
            </tr>
            <tr>
                <td class="formTableTDName"><?php echo \Lang\gettext("您的登录密码"); ?>: </td>
                <td class="formTableTDValue">
                    <input type="password" name="PswAdmin" id="PswAdmin" value="" placeholder="<?php echo \Lang\gettext("请输入您的登录密码"); ?>" />
                </td>
            </tr>
            <tr>
                <td class="formTableTDName"></td>
                <td class="formTableTDValue">
                    <input type="submit" name="submit" align="center" value="<?php echo \Lang\gettext("提交"); ?>" onclick="return CheckSubmit()" />
                </td>
            </tr>
            <input type="hidden" name="opType" id="opType" value="<?php echo $opType ?>" />
        </table>
    </form>
 
    <script type="text/javascript">
        window.onload = function() {
            var UserLV = document.getElementById("UserLV").value;
            OnSelectUserLVChange(UserLV);
        }
 
        function OnSelectUserLVChange(UserLV) {
            var adminOrgLV = <?php echo \User\UserLV::ADMIN_ORG; ?>;
            if (UserLV == adminOrgLV) {
                document.getElementById("ChannelAdmin").style.display = "";
                document.getElementById("ChannelChoose").style.display = "none";
 
                document.getElementById("PerGroupAdmin").style.display = "";
                document.getElementById("PerGroupChoose").style.display = "none";
            } else {
                document.getElementById("ChannelAdmin").style.display = "none";
                document.getElementById("ChannelChoose").style.display = "";
 
                document.getElementById("PerGroupAdmin").style.display = "none";
                document.getElementById("PerGroupChoose").style.display = "";
            }
        }
 
        function CheckSubmit() {
            var opType = "<?php echo $opType ?>";
            if (!document.getElementById("UserAccount").value || document.getElementById("UserAccount").value.length < 3) {
                alert("<?php echo \Lang\gettext("账号不符合要求"); ?>");
                document.getElementById('UserAccount').focus();
                return false;
            }
            if (opType == "add" || document.getElementById("Psw").value != "") {
                if (!document.getElementById("Psw").value) {
                    alert("<?php echo \Lang\gettext("密码不能为空"); ?>");
                    document.getElementById('Psw').focus();
                    return false;
                }
                if (!document.getElementById("PswConfirm").value) {
                    alert("<?php echo \Lang\gettext("密码不能为空"); ?>");
                    document.getElementById('PswConfirm').focus();
                    return false;
                }
                if (document.getElementById("Psw").value != document.getElementById("PswConfirm").value) {
                    alert("<?php echo \Lang\gettext("密码不一致"); ?>");
                    document.getElementById('PswConfirm').focus();
                    return false;
                }
            }
            if (!document.getElementById("PswAdmin").value) {
                alert("<?php echo \Lang\gettext("您的密码不能为空"); ?>");
                document.getElementById('PswAdmin').focus();
                return false;
            }
            return true;
        }
    </script>
</body>
 
</html>