AdminTrashAction.class.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Fanwe 方维直播系统
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2011 http://www.fanwe.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: 云淡风轻(1956838968@qq.com)
  8. // +----------------------------------------------------------------------
  9. class AdminTrashAction extends CommonAction{
  10. public function trash()
  11. {
  12. if(intval($_REQUEST['action_id'])!='')
  13. {
  14. $action_id= intval($_REQUEST['action_id']);
  15. }
  16. $this->assign('action_id',$action_id);
  17. $condition['is_delete'] = 1;
  18. $this->assign("default_map",$condition);
  19. $map = $this->_search ();
  20. //追加默认参数
  21. if($this->get("default_map"))
  22. $map = array_merge($map,$this->get("default_map"));
  23. if (method_exists ( $this, '_filter' )) {
  24. $this->_filter ( $map );
  25. }
  26. $name="Admin";
  27. $model = D ($name);
  28. if (! empty ( $model )) {
  29. $this->_list ( $model, $map );
  30. }
  31. $this->display ();
  32. return;
  33. }
  34. //相关操作
  35. public function set_effect()
  36. {
  37. $id = intval($_REQUEST['id']);
  38. $ajax = intval($_REQUEST['ajax']);
  39. $info = M("Admin")->where("id=".$id)->getField("adm_name");
  40. $c_is_effect = M("Admin")->where("id=".$id)->getField("is_effect"); //当前状态
  41. if(conf("DEFAULT_ADMIN")==$info)
  42. {
  43. $this->ajaxReturn($c_is_effect,l("DEFAULT_ADMIN_CANNOT_EFFECT"),1) ;
  44. }
  45. $n_is_effect = $c_is_effect == 0 ? 1 : 0; //需设置的状态
  46. M("Admin")->where("id=".$id)->setField("is_effect",$n_is_effect);
  47. save_log($info.l("SET_EFFECT_".$n_is_effect),1);
  48. $this->ajaxReturn($n_is_effect,l("SET_EFFECT_".$n_is_effect),1) ;
  49. }
  50. public function restore() {
  51. //删除指定记录
  52. $ajax = intval($_REQUEST['ajax']);
  53. $id = $_REQUEST ['id'];
  54. if (isset ( $id )) {
  55. $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
  56. $rel_data = M("Admin")->where($condition)->findAll();
  57. foreach($rel_data as $data)
  58. {
  59. $info[] = $data['adm_name'];
  60. }
  61. if($info) $info = implode(",",$info);
  62. $list = M("Admin")->where ( $condition )->setField ( 'is_delete', 0 );
  63. if ($list!==false) {
  64. save_log($info.l("RESTORE_SUCCESS"),1);
  65. $this->success (l("RESTORE_SUCCESS"),$ajax);
  66. } else {
  67. save_log($info.l("RESTORE_FAILED"),0);
  68. $this->error (l("RESTORE_FAILED"),$ajax);
  69. }
  70. } else {
  71. $this->error (l("INVALID_OPERATION"),$ajax);
  72. }
  73. }
  74. public function foreverdelete() {
  75. //彻底删除指定记录
  76. $ajax = intval($_REQUEST['ajax']);
  77. $id = $_REQUEST ['id'];
  78. if (isset ( $id )) {
  79. $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
  80. $rel_data = M("Admin")->where($condition)->findAll();
  81. foreach($rel_data as $data)
  82. {
  83. $info[] = $data['adm_name'];
  84. if(conf("DEFAULT_ADMIN")==$data['adm_name'])
  85. {
  86. $this->error ($data['adm_name'].l("DEFAULT_ADMIN_CANNOT_DELETE"),$ajax);
  87. }
  88. }
  89. if($info) $info = implode(",",$info);
  90. $list = M("Admin")->where ( $condition )->delete();
  91. if ($list!==false) {
  92. save_log($info.l("FOREVER_DELETE_SUCCESS"),1);
  93. $this->success (l("FOREVER_DELETE_SUCCESS"),$ajax);
  94. } else {
  95. save_log($info.l("FOREVER_DELETE_FAILED"),0);
  96. $this->error (l("FOREVER_DELETE_FAILED"),$ajax);
  97. }
  98. } else {
  99. $this->error (l("INVALID_OPERATION"),$ajax);
  100. }
  101. }
  102. }
  103. ?>