MenuClass.php 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. <?php
  2. define('EmpireCMSAdmin','1');
  3. require("../../class/connect.php");
  4. require("../../class/db_sql.php");
  5. require("../../class/functions.php");
  6. $link=db_connect();
  7. $empire=new mysqlquery();
  8. $editor=1;
  9. //验证用户
  10. $lur=is_login();
  11. $logininid=$lur['userid'];
  12. $loginin=$lur['username'];
  13. $loginrnd=$lur['rnd'];
  14. $loginlevel=$lur['groupid'];
  15. $loginadminstyleid=$lur['adminstyleid'];
  16. //ehash
  17. $ecms_hashur=hReturnEcmsHashStrAll();
  18. //验证权限
  19. CheckLevel($logininid,$loginin,$classid,"menu");
  20. //显示导航
  21. function MenuClassToShow(){
  22. global $empire,$dbtbpre;
  23. //常用菜单
  24. $showfastmenu=$empire->gettotal("select count(*) as total from {$dbtbpre}enewsmenuclass where classtype=1 limit 1");
  25. if($showfastmenu)
  26. {
  27. echo"<script>if(parent.document.getElementById('dofastmenu')==null||parent.document.getElementById('dofastmenu')=='undefined'){}else{parent.document.getElementById('dofastmenu').style.display='';}</script>";
  28. }
  29. $showextmenu=$empire->gettotal("select count(*) as total from {$dbtbpre}enewsmenuclass where classtype=3 limit 1");
  30. if($showextmenu)
  31. {
  32. echo"<script>if(parent.document.getElementById('doextmenu')==null||parent.document.getElementById('doextmenu')=='undefined'){}else{parent.document.getElementById('doextmenu').style.display='';}</script>";
  33. }
  34. }
  35. //增加菜单分类
  36. function AddMenuClass($add,$userid,$username){
  37. global $empire,$dbtbpre;
  38. $classtype=(int)$add['classtype'];
  39. if(!$add[classname])
  40. {
  41. printerror("EmptyMenuClass","history.go(-1)");
  42. }
  43. //验证权限
  44. CheckLevel($userid,$username,$classid,"menu");
  45. $myorder=(int)$add['myorder'];
  46. $add['classname']=hRepPostStr($add['classname'],1);
  47. $sql=$empire->query("insert into {$dbtbpre}enewsmenuclass(classname,myorder,classtype) values('".$add[classname]."','$myorder','$classtype');");
  48. $lastid=$empire->lastid();
  49. if($sql)
  50. {
  51. MenuClassToShow();
  52. //操作日志
  53. insert_dolog("classid=".$lastid."<br>classname=".$add[classname]);
  54. printerror("AddMenuClassSuccess","MenuClass.php".hReturnEcmsHashStrHref2(1));
  55. }
  56. else
  57. {printerror("DbError","history.go(-1)");}
  58. }
  59. //修改菜单分类
  60. function EditMenuClass($add,$userid,$username){
  61. global $empire,$dbtbpre;
  62. $classid=$add['classid'];
  63. $delclassid=$add['delclassid'];
  64. $classname=$add['classname'];
  65. $myorder=$add['myorder'];
  66. $classtype=$add['classtype'];
  67. $count=count($classid);
  68. if(!$count)
  69. {
  70. printerror("EmptyMenuClass","history.go(-1)");
  71. }
  72. //验证权限
  73. CheckLevel($userid,$username,$classid,"menu");
  74. //删除
  75. $del=0;
  76. $ids='';
  77. $delcount=count($delclassid);
  78. if($delcount)
  79. {
  80. $dh='';
  81. for($j=0;$j<$delcount;$j++)
  82. {
  83. $ids.=$dh.intval($delclassid[$j]);
  84. $dh=',';
  85. }
  86. $empire->query("delete from {$dbtbpre}enewsmenuclass where classid in (".$ids.")");
  87. $empire->query("delete from {$dbtbpre}enewsmenu where classid in (".$ids.")");
  88. $del=1;
  89. }
  90. //修改
  91. for($i=0;$i<$count;$i++)
  92. {
  93. $classid[$i]=(int)$classid[$i];
  94. if(strstr(','.$ids.',',','.$classid[$i].','))
  95. {
  96. continue;
  97. }
  98. $myorder[$i]=(int)$myorder[$i];
  99. $classtype[$i]=(int)$classtype[$i];
  100. $classname[$i]=hRepPostStr($classname[$i],1);
  101. $empire->query("update {$dbtbpre}enewsmenuclass set classname='".$classname[$i]."',myorder='".$myorder[$i]."',classtype='".$classtype[$i]."' where classid='".$classid[$i]."'");
  102. }
  103. MenuClassToShow();
  104. //操作日志
  105. insert_dolog("del=$del");
  106. printerror("EditMenuClassSuccess","MenuClass.php".hReturnEcmsHashStrHref2(1));
  107. }
  108. //修改菜单分类用户权限
  109. function EditMenuClassGroup($add,$userid,$username){
  110. global $empire,$dbtbpre;
  111. $classid=(int)$add['classid'];
  112. if(!$classid)
  113. {
  114. printerror("EmptyMenuClass","history.go(-1)");
  115. }
  116. //验证权限
  117. CheckLevel($userid,$username,$classid,"menu");
  118. $cr=$empire->fetch1("select classid,classname from {$dbtbpre}enewsmenuclass where classid='$classid'");
  119. if(!$cr['classid'])
  120. {
  121. printerror("EmptyMenuClass","history.go(-1)");
  122. }
  123. $groupid=$add['groupid'];
  124. $groupids='';
  125. $count=count($groupid);
  126. if($count)
  127. {
  128. for($i=0;$i<$count;$i++)
  129. {
  130. $gid=(int)$groupid[$i];
  131. if(!$gid)
  132. {
  133. continue;
  134. }
  135. $groupids.=','.$gid;
  136. }
  137. if($groupids)
  138. {
  139. $groupids.=',';
  140. }
  141. }
  142. $sql=$empire->query("update {$dbtbpre}enewsmenuclass set groupids='$groupids' where classid='$classid';");
  143. if($sql)
  144. {
  145. MenuClassToShow();
  146. //操作日志
  147. insert_dolog("classid=".$classid."<br>classname=".$cr[classname]);
  148. printerror("EditMenuClassSuccess","ListMenu.php?classid=$classid".hReturnEcmsHashStrHref2(0));
  149. }
  150. else
  151. {printerror("DbError","history.go(-1)");}
  152. }
  153. $enews=$_POST['enews'];
  154. if(empty($enews))
  155. {$enews=$_GET['enews'];}
  156. if($enews)
  157. {
  158. hCheckEcmsRHash();
  159. }
  160. if($enews=="AddMenuClass")//增加菜单分类
  161. {
  162. AddMenuClass($_POST,$logininid,$loginin);
  163. }
  164. elseif($enews=="EditMenuClass")//修改菜单分类
  165. {
  166. EditMenuClass($_POST,$logininid,$loginin);
  167. }
  168. elseif($enews=="EditMenuClassGroup")//修改菜单分类用户权限
  169. {
  170. EditMenuClassGroup($_POST,$logininid,$loginin);
  171. }
  172. else
  173. {}
  174. $sql=$empire->query("select classid,classname,issys,myorder,classtype from {$dbtbpre}enewsmenuclass order by myorder,classid");
  175. ?>
  176. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  177. <html>
  178. <head>
  179. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  180. <title>管理菜单</title>
  181. <link href="../adminstyle/<?=$loginadminstyleid?>/adminstyle.css" rel="stylesheet" type="text/css">
  182. <script>
  183. function CheckAll(form)
  184. {
  185. for (var i=0;i<form.elements.length;i++)
  186. {
  187. var e = form.elements[i];
  188. if (e.name != 'chkall')
  189. e.checked = form.chkall.checked;
  190. }
  191. }
  192. </script>
  193. </head>
  194. <body>
  195. <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
  196. <tr>
  197. <td width="38%">
  198. <p>位置:<a href="MenuClass.php<?=$ecms_hashur['whehref']?>">管理菜单</a></p></td>
  199. <td><div align="right"> </div></td>
  200. </tr>
  201. </table>
  202. <br>
  203. <table width="100%" border="0" cellpadding="3" cellspacing="1" class="tableborder">
  204. <form name="form2" method="post" action="MenuClass.php" onsubmit="return confirm('确认要提交?');">
  205. <?=$ecms_hashur['form']?>
  206. <tr class="header">
  207. <td width="6%"><div align="center">删除</div></td>
  208. <td width="8%">显示顺序</td>
  209. <td width="40%" height="25">分类名称</td>
  210. <td width="14%">菜单类型</td>
  211. <td width="32%" height="25"><div align="center">管理菜单</div></td>
  212. </tr>
  213. <?php
  214. while($r=$empire->fetch($sql))
  215. {
  216. if($r['issys'])
  217. {
  218. $checkbox='';
  219. }
  220. else
  221. {
  222. $checkbox='<input name="delclassid[]" type="checkbox" id="delclassid[]" value="'.$r[classid].'">';
  223. }
  224. ?>
  225. <tr bgcolor="#FFFFFF" onmouseout="this.style.backgroundColor='#ffffff'" onmouseover="this.style.backgroundColor='#DBEAF5'">
  226. <td><div align="center">
  227. <?=$checkbox?>
  228. </div></td>
  229. <td> <input name="myorder[]" type="text" id="myorder[]" value="<?=$r[myorder]?>" size="4">
  230. </td>
  231. <td height="25"> <input name="classname[]" type="text" id="classname[]" value="<?=$r[classname]?>">
  232. <input name="classid[]" type="hidden" id="classid[]" value="<?=$r[classid]?>">
  233. </td>
  234. <td><select name="classtype[]" id="classtype[]">
  235. <option value="1"<?=$r[classtype]==1?' selected':''?>>常用操作</option>
  236. <option value="2"<?=$r[classtype]==2?' selected':''?>>插件菜单</option>
  237. <option value="3"<?=$r[classtype]==3?' selected':''?>>扩展菜单</option>
  238. </select></td>
  239. <td height="25"><div align="center">[<a href="ListMenu.php?classid=<?=$r[classid]?><?=$ecms_hashur['ehref']?>">管理菜单</a>]</div></td>
  240. </tr>
  241. <?php
  242. }
  243. ?>
  244. <tr bgcolor="#FFFFFF">
  245. <td><div align="center">
  246. <input type=checkbox name=chkall value=on onclick=CheckAll(this.form)>
  247. </div></td>
  248. <td height="25" colspan="4"><input type="submit" name="Submit2" value="提交">
  249. <input name="enews" type="hidden" id="enews" value="EditMenuClass"> &nbsp;
  250. &nbsp; <font color="#666666">(说明:顺序值越小显示越前面) </font></td>
  251. </tr>
  252. </form>
  253. </table>
  254. <br>
  255. <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
  256. <form name="form1" method="post" action="MenuClass.php">
  257. <?=$ecms_hashur['form']?>
  258. <tr class="header">
  259. <td height="25">增加菜单分类:
  260. <input name=enews type=hidden id="enews" value=AddMenuClass>
  261. </td>
  262. </tr>
  263. <tr>
  264. <td height="25" bgcolor="#FFFFFF"> 分类名称:
  265. <input name="classname" type="text" id="classname">
  266. 类型:
  267. <select name="classtype" id="classtype">
  268. <option value="1">常用操作</option>
  269. <option value="2">插件菜单</option>
  270. <option value="3" selected>扩展菜单</option>
  271. </select>
  272. 显示顺序:
  273. <input name="myorder" type="text" id="myorder" value="0" size="4">
  274. <input type="submit" name="Submit" value="增加">
  275. </td>
  276. </tr>
  277. </form>
  278. </table>
  279. </body>
  280. </html>
  281. <?php
  282. db_close();
  283. $empire=null;
  284. ?>