ApiListAction.class.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 ApiListAction extends CommonAction{
  10. public function index()
  11. {
  12. parent::index();
  13. }
  14. public function add()
  15. {
  16. //输出分组列表
  17. $this->assign("apilist",M("ApiList")->findAll());
  18. $this->display();
  19. }
  20. public function edit() {
  21. $id = intval($_REQUEST ['id']);
  22. $condition['id'] = $id;
  23. $vo = M(MODULE_NAME)->where($condition)->find();
  24. $this->assign ( 'vo', $vo );
  25. $this->display ();
  26. }
  27. //相关操作
  28. public function insert() {
  29. B('FilterString');
  30. $data = M(MODULE_NAME)->create ();
  31. //开始验证有效性
  32. $this->assign("jumpUrl",u(MODULE_NAME."/add"));
  33. if(!check_empty($data['name']))
  34. {
  35. $this->error(L("ADM_NAME_EMPTY_TIP"));
  36. }
  37. if(M("ApiList")->where("name='".$data['name']."'")->count()>0)
  38. {
  39. $this->error(L("ADMIN_EXIST_TIP"));
  40. }
  41. // 更新数据
  42. $log_info = $data['name'];
  43. $list=M(MODULE_NAME)->add($data);
  44. if (false !== $list) {
  45. //成功提示
  46. save_log($log_info.L("INSERT_SUCCESS"),1);
  47. $this->success(L("INSERT_SUCCESS"));
  48. } else {
  49. //错误提示
  50. save_log($log_info.L("INSERT_FAILED"),0);
  51. $this->error(L("INSERT_FAILED"));
  52. }
  53. }
  54. public function update() {
  55. B('FilterString');
  56. $data = M(MODULE_NAME)->create ();
  57. $log_info = M(MODULE_NAME)->where("id=".intval($data['id']))->getField("name");
  58. //开始验证有效性
  59. $this->assign("jumpUrl",u(MODULE_NAME."/edit",array("id"=>$data['id'])));
  60. // 更新数据
  61. $list=M(MODULE_NAME)->save ($data);
  62. if (false !== $list) {
  63. //成功提示
  64. save_log($log_info.L("UPDATE_SUCCESS"),1);
  65. $this->success(L("UPDATE_SUCCESS"));
  66. } else {
  67. //错误提示
  68. save_log($log_info.L("UPDATE_FAILED"),0);
  69. $this->error(L("UPDATE_FAILED"),0,$log_info.L("UPDATE_FAILED"));
  70. }
  71. }
  72. public function foreverdelete() {
  73. //彻底删除指定记录
  74. $ajax = intval($_REQUEST['ajax']);
  75. $id = $_REQUEST ['id'];
  76. if (isset ( $id )) {
  77. $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
  78. $rel_data = M(MODULE_NAME)->where($condition)->findAll();
  79. foreach($rel_data as $data)
  80. {
  81. $info[] = $data['name'];
  82. }
  83. if($info) $info = implode(",",$info);
  84. $list = M(MODULE_NAME)->where ( $condition )->delete();
  85. if ($list!==false) {
  86. save_log($info.l("FOREVER_DELETE_SUCCESS"),1);
  87. $this->success (l("FOREVER_DELETE_SUCCESS"),$ajax);
  88. } else {
  89. save_log($info.l("FOREVER_DELETE_FAILED"),0);
  90. $this->error (l("FOREVER_DELETE_FAILED"),$ajax);
  91. }
  92. } else {
  93. $this->error (l("INVALID_OPERATION"),$ajax);
  94. }
  95. }
  96. }
  97. ?>