Email_template_adminAction.class.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <?php
  2. /**
  3. * 邮件模版管理
  4. */
  5. require_once( ONU_ROOT . 'application/module/ctrl/Action.class.php');
  6. require_once ( ONU_ROOT . 'application/lib/data/adminAction.php');
  7. class Email_template_adminAction extends Action{
  8. public function __construct(){
  9. parent::__construct();
  10. if(empty($_SESSION['mds_user'])){
  11. header("Location:/?a=index&m=admin_login");
  12. exit();
  13. }
  14. // $this->checkAdministratorRight('3');
  15. }
  16. function index(){
  17. require_once (ONU_ROOT . "frame/Page.class.php");
  18. $admin = new AdvertAdminAction();
  19. $where = "where uid='{$_SESSION['user_infos']['id']}' and type=1 ";
  20. $page = $_REQUEST['page']?$_REQUEST['page']:1;
  21. $pageSize = 5;
  22. $n = ($page-1)*$pageSize;
  23. $pa = "";//查询参数
  24. $limit = " $n,$pageSize";
  25. $info = $_REQUEST['info'];
  26. $error = $_REQUEST['error'];
  27. $uname = $_SESSION['user_infos']['uname'];
  28. $list = $admin->select_msg_list($where,$limit);
  29. $all_total = $admin->select_msg_count($where);
  30. $p = new Page($all_total,$pageSize,$pa);
  31. $pp = $p->fpage();
  32. $status_array = array(
  33. '1' => '开启',
  34. '2' => '禁用',
  35. );
  36. $this->assign('status_array',$status_array);
  37. $this->assign('info',$info);
  38. $this->assign('error',$error);
  39. $this->assign('page',$page);
  40. $this->assign("show",$pp);
  41. $this->assign('list',$list);
  42. $this->assign('uname',$uname);
  43. $this->display('index.html');
  44. }
  45. function add(){
  46. $admin = new AdvertAdminAction();
  47. // $_POST['msg_content'] = str_replace("\n","<br/>",$_POST['msg_content']);
  48. $msg_content = $_POST['msg_content'];
  49. $data['uid'] = $_SESSION['user_infos']['id'];
  50. $data['msg_title'] = addslashes($_POST['msg_title']);
  51. $data['msg_content'] = addslashes($msg_content);
  52. $data['status'] = $_POST['status'];
  53. $data['add_time'] = time();
  54. $data['update_time'] = time();
  55. $data['type'] = 1;
  56. if($_POST['msg_content']|| $_POST['msg_title']){
  57. if(!empty($data['msg_title']) && !empty($data['msg_content']) ){
  58. $add = $admin->add_email_msg($data);
  59. if($add){
  60. $info = "添加邮件模板成功";
  61. header("Location:/?a=email_template_admin&m=index&info=$info");
  62. exit();
  63. }else{
  64. $info = "添加失败";
  65. }
  66. }else{
  67. $info = "模板标题、内容均不能为空";
  68. }
  69. }
  70. $this->assign('data',$data);
  71. $this->assign('info',$info);
  72. $this->display('add.html');
  73. }
  74. function update(){
  75. $admin = new AdvertAdminAction();
  76. $id = $_REQUEST['id'];
  77. $one_info = $admin->select_one_template($id);
  78. // $one_info['msg_content'] = str_replace("<br/>","\n",$one_info['msg_content']);
  79. // $_POST['msg_content'] = str_replace("\n","<br/>",$_POST['msg_content']);
  80. $msg_content = addslashes($_POST['msg_content']);
  81. $data['msg_title'] = addslashes($_POST['msg_title']);
  82. $data['msg_content'] = $msg_content;
  83. $data['status'] = $_POST['status'];
  84. $data['update_time'] = time();
  85. if($_POST['msg_title'] || $_POST['msg_content']){
  86. if(!empty($data['msg_title']) && !empty($data['msg_content']) ){
  87. $update = $admin->update_email_msg($data, $id,$_SESSION['user_infos']['id']);
  88. if($update){
  89. $info = "修改邮件模板成功";
  90. header("Location:/?a=email_template_admin&m=index&info=$info");
  91. exit();
  92. }else{
  93. $info = "修改失败";
  94. }
  95. }else{
  96. $info = "模板标题、内容均不能为空";
  97. }
  98. }
  99. $one_info = $admin->select_one_template($id);
  100. // $one_info['msg_content'] = str_replace("<br/>","\n",$one_info['msg_content']);
  101. // $one_info['msg_content'] = htmlspecialchars(stripslashes($one_info['msg_content']));
  102. $this->assign('id',$id);
  103. $this->assign('one_info',$one_info);
  104. $this->assign('info',$info);
  105. $this->display('update.html');
  106. }
  107. //删除就是改状态为禁用
  108. public function delete(){
  109. $admin = new AdvertAdminAction();
  110. $id = $_REQUEST['id'];
  111. $status = $_REQUEST['status'];
  112. if(!empty($id)){
  113. $delete = $admin->deleteEmailTemplate($status,$id,$_SESSION['user_infos']['id']);
  114. $info = "禁用成功";
  115. }else{
  116. $error = "禁用失败";
  117. }
  118. header("Location:/?a=email_template_admin&m=index&info=$info&error=$error");
  119. exit();
  120. }
  121. //end class
  122. }
  123. ?>