AuthentListAction.class.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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 AuthentListAction extends CommonAction{
  10. public function index()
  11. {
  12. parent::index();
  13. }
  14. public function add()
  15. {
  16. $this->assign("new_sort", M("AuthentList")->max("sort")+1);
  17. $this->display();
  18. }
  19. public function edit() {
  20. $id = intval($_REQUEST ['id']);
  21. $condition['id'] = $id;
  22. $vo = M(MODULE_NAME)->where($condition)->find();
  23. $this->assign ( 'vo', $vo );
  24. $this->display ();
  25. }
  26. //彻底删除指定记录
  27. public function foreverdelete() {
  28. //彻底删除指定记录
  29. $ajax = intval($_REQUEST['ajax']);
  30. $id = $_REQUEST ['id'];
  31. if (isset ( $id )) {
  32. $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
  33. $rel_data = M(MODULE_NAME)->where($condition)->findAll();
  34. foreach($rel_data as $data)
  35. {
  36. $info[] = $data['name'];
  37. }
  38. if($info) $info = implode(",",$info);
  39. $list = M(MODULE_NAME)->where ( $condition )->delete();
  40. //删除相关预览图
  41. // foreach($rel_data as $data)
  42. // {
  43. // @unlink(get_real_path().$data['preview']);
  44. // }
  45. if ($list!==false) {
  46. save_log($info.l("FOREVER_DELETE_SUCCESS"),1);
  47. clear_auto_cache("get_help_cache");
  48. $this->success (l("FOREVER_DELETE_SUCCESS"),$ajax);
  49. } else {
  50. save_log($info.l("FOREVER_DELETE_FAILED"),0);
  51. $this->error (l("FOREVER_DELETE_FAILED"),$ajax);
  52. }
  53. } else {
  54. $this->error (l("INVALID_OPERATION"),$ajax);
  55. }
  56. }
  57. public function insert() {
  58. B('FilterString');
  59. $ajax = intval($_REQUEST['ajax']);
  60. $data = M(MODULE_NAME)->create ();
  61. //开始验证有效性
  62. $this->assign("jumpUrl",u(MODULE_NAME."/add"));
  63. if(!check_empty($data['name']))
  64. {
  65. $this->error("请输入名称");
  66. }
  67. if(!check_empty($data['icon']))
  68. {
  69. $this->error("请输入图标");
  70. }
  71. // 更新数据
  72. $log_info = $data['name'];
  73. $list=M(MODULE_NAME)->add($data);
  74. if (false !== $list) {
  75. //成功提示
  76. save_log($log_info.L("INSERT_SUCCESS"),1);
  77. clear_auto_cache("get_help_cache");
  78. $this->success(L("INSERT_SUCCESS"));
  79. } else {
  80. //错误提示
  81. save_log($log_info.L("INSERT_FAILED"),0);
  82. $this->error(L("INSERT_FAILED"));
  83. }
  84. }
  85. public function update() {
  86. B('FilterString');
  87. $data = M(MODULE_NAME)->create();
  88. // if($_FILES['preview']['name']!='')
  89. // {
  90. // $result = $this->uploadImage();
  91. // if($result['status']==0)
  92. // {
  93. // $this->error($result['info'],$ajax);
  94. // }
  95. // //删除图片
  96. // @unlink(get_real_path().M("Article")->where("id=".$data['id'])->getField("preview"));
  97. // $data['preview'] = $result['data'][0]['bigrecpath'].$result['data'][0]['savename'];
  98. // }
  99. $log_info = M(MODULE_NAME)->where("id=".intval($data['id']))->getField("name");
  100. //开始验证有效性
  101. $this->assign("jumpUrl",u(MODULE_NAME."/edit",array("id"=>$data['id'])));
  102. if(!check_empty($data['name']))
  103. {
  104. $this->error("请输入名称");
  105. }
  106. if(!check_empty($data['icon']))
  107. {
  108. $this->error("请输入图标");
  109. }
  110. // 更新数据
  111. $list=M(MODULE_NAME)->save ($data);
  112. if (false !== $list) {
  113. //成功提示
  114. save_log($log_info.L("UPDATE_SUCCESS"),1);
  115. clear_auto_cache("get_help_cache");
  116. $users = M("User")->where("authent_list_id = ".intval($data['id']))->findAll();
  117. if(sizeof($users)>0){
  118. $user_ids = array_column($users,"id");
  119. $condition['id'] = array ('in', $user_ids );
  120. $condition['is_authentication'] = 2;
  121. M("User")->where($condition)->setField("v_icon",get_spec_image($data['icon']));
  122. user_deal_to_reids($user_ids);
  123. }
  124. $this->success(L("UPDATE_SUCCESS"));
  125. } else {
  126. //错误提示
  127. save_log($log_info.L("UPDATE_FAILED"),0);
  128. $this->error(L("UPDATE_FAILED"),0,$log_info.L("UPDATE_FAILED"));
  129. }
  130. }
  131. public function set_sort()
  132. {
  133. $id = intval($_REQUEST['id']);
  134. $sort = intval($_REQUEST['sort']);
  135. $log_info = M("AuthentList")->where("id=".$id)->getField("name");
  136. if(!check_sort($sort))
  137. {
  138. $this->error(l("SORT_FAILED"),1);
  139. }
  140. M("AuthentList")->where("id=".$id)->setField("sort",$sort);
  141. save_log($log_info.l("SORT_SUCCESS"),1);
  142. clear_auto_cache("get_help_cache");
  143. $this->success(l("SORT_SUCCESS"),1);
  144. }
  145. }
  146. ?>