usergroup.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. class usergroup_c extends Control
  3. {
  4. function __construct()
  5. {
  6. parent::Control();
  7. $this->load_model("usergroup");
  8. }
  9. //兼容PHP4的写法
  10. function user_c()
  11. {
  12. $this->__construct();
  13. }
  14. function index_f()
  15. {
  16. sys_popedom("usergroup:list","tpl");//查看权限
  17. $rslist = $this->usergroup_m->get_all();
  18. $this->tpl->assign("rslist",$rslist);
  19. $this->tpl->display("user/group_list.html");
  20. }
  21. function set_f()
  22. {
  23. $id = $this->trans_lib->int("id");
  24. $id ? sys_popedom("usergroup:modify","tpl") : sys_popedom("usergroup:add","tpl");
  25. if($id)
  26. {
  27. $rs = $this->usergroup_m->get_one($id);
  28. $this->tpl->assign("rs",$rs);
  29. $this->tpl->assign("id",$id);
  30. }
  31. $this->tpl->display("user/group_set.html");
  32. }
  33. //存储信息
  34. function setok_f()
  35. {
  36. $id = $this->trans_lib->int("id");
  37. $id ? sys_popedom("usergroup:modify","tpl") : sys_popedom("usergroup:add","tpl");
  38. $title = $this->trans_lib->safe("title");
  39. if(!$title)
  40. {
  41. error("组名称不允许为空!",$this->url("usergroup,set","id=".$id));
  42. }
  43. $array = array();
  44. $array["title"] = $title;
  45. if(!$id)
  46. {
  47. $array["group_type"] = "user";
  48. $array["ifsystem"] = 0;
  49. $array["ifdefault"] = 0;
  50. }
  51. $this->usergroup_m->save($array,$id);
  52. error("会员组信息添加/存储成功",$this->url("usergroup"));
  53. }
  54. //设置默认
  55. function ajax_default_f()
  56. {
  57. $id = $this->trans_lib->int("id");
  58. if(!$id)
  59. {
  60. exit("error:没有指定ID");
  61. }
  62. $rs = $this->usergroup_m->set_default($id);
  63. exit("ok");
  64. }
  65. function ajax_del_f()
  66. {
  67. $id = $this->trans_lib->int("id");
  68. if(!$id)
  69. {
  70. exit("error:没有指定ID");
  71. }
  72. sys_popedom("usergroup:delete","ajax");
  73. $rs = $this->usergroup_m->get_one($id);
  74. if($rs["ifdefault"])
  75. {
  76. exit("默认组不允许删除!");
  77. }
  78. if($rs["ifsystem"])
  79. {
  80. exit("系统组不允许删除!");
  81. }
  82. $this->usergroup_m->del($id);
  83. exit("ok");
  84. }
  85. }
  86. ?>