WarningMsgAction.class.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Fanwe 方维p2p借贷系统
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2011 http://www.fanwe.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: 云淡风轻(1956838968@qq.com)
  8. // +----------------------------------------------------------------------
  9. class WarningMsgAction extends CommonAction{
  10. public function index()
  11. {
  12. if(strim($_REQUEST['content'])!=''){
  13. $map['content'] = array('like','%'.strim($_REQUEST['content']).'%');
  14. }
  15. if (method_exists ( $this, '_filter' )) {
  16. $this->_filter ( $map );
  17. }
  18. $name=$this->getActionName();
  19. $model = D ($name);
  20. if (! empty ( $model )) {
  21. $this->_list ( $model, $map );
  22. }
  23. $this->display ();
  24. }
  25. public function add()
  26. {
  27. $this->display();
  28. }
  29. public function edit() {
  30. $id = intval($_REQUEST ['id']);
  31. $condition['id'] = $id;
  32. $vo = M(MODULE_NAME)->where($condition)->find();
  33. $this->assign ( 'vo', $vo );
  34. $this->display ();
  35. }
  36. //彻底删除指定记录
  37. public function foreverdelete() {
  38. //彻底删除指定记录
  39. $ajax = intval($_REQUEST['ajax']);
  40. $id = $_REQUEST ['id'];
  41. if (isset ( $id )) {
  42. $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
  43. $rel_data = M(MODULE_NAME)->where($condition)->findAll();
  44. foreach($rel_data as $data)
  45. {
  46. $info[] = $data['content'];
  47. }
  48. if($info) $info = implode(",",$info);
  49. $list = M(MODULE_NAME)->where ( $condition )->delete();
  50. if ($list!==false) {
  51. save_log($info.l("FOREVER_DELETE_SUCCESS"),1);
  52. $this->success (l("FOREVER_DELETE_SUCCESS"),$ajax);
  53. } else {
  54. save_log($info.l("FOREVER_DELETE_FAILED"),0);
  55. $this->error (l("FOREVER_DELETE_FAILED"),$ajax);
  56. }
  57. } else {
  58. $this->error (l("INVALID_OPERATION"),$ajax);
  59. }
  60. }
  61. public function insert() {
  62. B('FilterString');
  63. $ajax = intval($_REQUEST['ajax']);
  64. $data = M(MODULE_NAME)->create ();
  65. //开始验证有效性
  66. $this->assign("jumpUrl",u(MODULE_NAME."/add"));
  67. if(!check_empty($data['content']))
  68. {
  69. $this->error("请输入警告内容");
  70. }
  71. $log_info = $data['content'];
  72. $list=M(MODULE_NAME)->add($data);
  73. if (false !== $list) {
  74. //成功提示
  75. save_log($log_info.L("INSERT_SUCCESS"),1);
  76. $this->success(L("INSERT_SUCCESS"));
  77. } else {
  78. //错误提示
  79. save_log($log_info.L("INSERT_FAILED"),0);
  80. $this->error(L("INSERT_FAILED"));
  81. }
  82. }
  83. public function update() {
  84. B('FilterString');
  85. $data = M(MODULE_NAME)->create();
  86. $log_info = M(MODULE_NAME)->where("id=".intval($data['id']))->getField("content");
  87. $this->assign("jumpUrl",u(MODULE_NAME."/edit",array("id"=>$data['id'])));
  88. if(!check_empty($data['content']))
  89. {
  90. $this->error("请输入警告内容");
  91. }
  92. // 更新数据
  93. $list=M(MODULE_NAME)->save ($data);
  94. if (false !== $list) {
  95. //成功提示
  96. save_log($log_info.L("UPDATE_SUCCESS"),1);
  97. $this->success(L("UPDATE_SUCCESS"));
  98. } else {
  99. //错误提示
  100. save_log($log_info.L("UPDATE_FAILED"),0);
  101. $this->error(L("UPDATE_FAILED"),0,$log_info.L("UPDATE_FAILED"));
  102. }
  103. }
  104. public function set_effect()
  105. {
  106. $id = intval($_REQUEST['id']);
  107. $info = M(MODULE_NAME)->where("id=".$id)->getField("content");
  108. $c_is_effect = M(MODULE_NAME)->where("id=".$id)->getField("is_effect"); //当前状态
  109. $n_is_effect = $c_is_effect == 0 ? 1 : 0; //需设置的状态
  110. M(MODULE_NAME)->where("id=".$id)->setField("is_effect",$n_is_effect);
  111. save_log($info.l("SET_EFFECT_".$n_is_effect),1);
  112. $this->ajaxReturn($n_is_effect,l("SET_EFFECT_".$n_is_effect),1) ;
  113. }
  114. }
  115. ?>