心理咨询网
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MemberCommentController.php 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. /**
  3. * @copyright (C)2016-2099 Hnaoyun Inc.
  4. * @author XingMeng
  5. * @email hnxsh@foxmail.com
  6. * @date 2020年06月27日
  7. * 文章评论控制器
  8. */
  9. namespace app\admin\controller\member;
  10. use core\basic\Controller;
  11. use app\admin\model\member\MemberCommentModel;
  12. class MemberCommentController extends Controller
  13. {
  14. private $model;
  15. public function __construct()
  16. {
  17. $this->model = new MemberCommentModel();
  18. }
  19. // 文章评论列表
  20. public function index()
  21. {
  22. if ((! ! $id = get('id', 'int')) && $result = $this->model->getComment($id)) {
  23. $this->assign('more', true);
  24. $this->assign('comment', $result);
  25. } else {
  26. $this->assign('list', true);
  27. if (! ! ($field = get('field', 'var')) && ! ! ($keyword = get('keyword', 'vars'))) {
  28. $result = $this->model->findComment($field, $keyword);
  29. } else {
  30. $result = $this->model->getList();
  31. }
  32. $this->assign('comments', $result);
  33. }
  34. $this->display('member/comment.html');
  35. }
  36. // 文章评论删除
  37. public function del()
  38. {
  39. // 执行批量删除
  40. if ($_POST) {
  41. if (! ! $list = post('list')) {
  42. if ($this->model->delCommentList($list)) {
  43. $this->log('批量删除评论成功!');
  44. success('删除成功!', - 1);
  45. } else {
  46. $this->log('批量删除评论失败!');
  47. error('删除失败!', - 1);
  48. }
  49. } else {
  50. alert_back('请选择要删除的评论!');
  51. }
  52. }
  53. if (! $id = get('id', 'int')) {
  54. error('传递的参数值错误!', - 1);
  55. }
  56. if ($this->model->delComment($id)) {
  57. $this->log('删除文章评论' . $id . '成功!');
  58. success('删除成功!', - 1);
  59. } else {
  60. $this->log('删除文章评论' . $id . '失败!');
  61. error('删除失败!', - 1);
  62. }
  63. }
  64. // 字段修改
  65. public function mod()
  66. {
  67. if (! ! $submit = post('submit')) {
  68. switch ($submit) {
  69. case 'verify1':
  70. $list = post('list');
  71. if (! $list) {
  72. alert_back('请选择要操作的评论!');
  73. }
  74. if ($this->model->modCommentList($list, "status=1")) {
  75. $this->log('评论批量审核成功!');
  76. success('审核成功!', - 1);
  77. } else {
  78. alert_back('审核失败!');
  79. }
  80. break;
  81. case 'verify0':
  82. $list = post('list');
  83. if (! $list) {
  84. alert_back('请选择要操作的评论!');
  85. }
  86. if ($this->model->modCommentList($list, "status=0")) {
  87. $this->log('评论批量禁用成功!');
  88. success('禁用成功!', - 1);
  89. } else {
  90. alert_back('禁用失败!');
  91. }
  92. break;
  93. }
  94. }
  95. if (! $id = get('id', 'int')) {
  96. error('传递的参数值错误!', - 1);
  97. }
  98. // 单独修改状态
  99. if (($field = get('field', 'var')) && ! is_null($value = get('value', 'var'))) {
  100. if ($this->model->modComment($id, "$field='$value',update_user='" . session('username') . "'")) {
  101. location(- 1);
  102. } else {
  103. alert_back('修改失败!');
  104. }
  105. }
  106. }
  107. }