<?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 " ";
|
}
|
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 " ";
|
}
|
} 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>
|