WeiboIndexAction.class.php 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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 WeiboIndexAction extends CommonAction{
  10. private $type_list;
  11. private $position;
  12. public function __construct(){
  13. parent::__construct();
  14. $position = array(
  15. '4'=>'启动广告',
  16. '10'=>'首页-美女轮播图',
  17. '11'=>'首页-写真轮播图',
  18. );
  19. $type_list =array('0'=>'网页url链接');
  20. //教育直播
  21. if( defined("OPEN_EDU_MODULE") && OPEN_EDU_MODULE){
  22. $type_list[10] = '会员动态跳转';
  23. $type_list[11] = '动态详情跳转';
  24. }
  25. $this->type_list = $type_list;
  26. $this->position = $position;
  27. }
  28. public function index()
  29. {
  30. $condition = ' show_position in(4,10,11)';
  31. $count = M('index_image')->where($condition)->count();
  32. $p = new Page($count, $listRows = 20);
  33. //举报类型
  34. $weibo = M('index_image')->where($condition)->order('id desc')->limit($p->firstRow . ',' . $p->listRows)->findAll();
  35. $page = $p->show();
  36. $this->assign("page", $page);
  37. $this->assign ( 'list', $weibo );
  38. $this->display ();
  39. }
  40. public function add()
  41. {
  42. $family = M("Family")->where("status = 1")->findAll();
  43. $this->assign("family",$family);
  44. $this->assign("position",$this->position);
  45. $this->assign("type_list",$this->type_list);
  46. $this->assign("new_sort", M("IndexImage")->max("sort")+1);
  47. $this->display();
  48. }
  49. public function edit() {
  50. $family = M("Family")->where("status = 1")->findAll();
  51. $this->assign("family",$family);
  52. $this->assign("position",$this->position);
  53. $this->assign("type_list",$this->type_list);
  54. $id = intval($_REQUEST ['id']);
  55. $condition['id'] = $id;
  56. $vo = M('index_image')->where($condition)->find();
  57. $this->assign ( 'vo', $vo );
  58. $this->display ();
  59. }
  60. public function foreverdelete() {
  61. //彻底删除指定记录
  62. $ajax = intval($_REQUEST['ajax']);
  63. $id = $_REQUEST ['id'];
  64. if (isset ( $id )) {
  65. $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
  66. $rel_data = M('index_image')->where($condition)->findAll();
  67. foreach($rel_data as $data)
  68. {
  69. $info[] = $data['title'];
  70. }
  71. if($info) $info = implode(",",$info);
  72. $list = M('index_image')->where ( $condition )->delete();
  73. if ($list!==false) {
  74. clear_auto_cache("banner_list_xr");
  75. load_auto_cache("banner_list_xr");
  76. save_log($info.l("FOREVER_DELETE_SUCCESS"),1);
  77. $this->success (l("FOREVER_DELETE_SUCCESS"),$ajax);
  78. } else {
  79. save_log($info.l("FOREVER_DELETE_FAILED"),0);
  80. $this->error (l("FOREVER_DELETE_FAILED"),$ajax);
  81. }
  82. } else {
  83. $this->error (l("INVALID_OPERATION"),$ajax);
  84. }
  85. }
  86. public function insert() {
  87. B('FilterString');
  88. $ajax = intval($_REQUEST['ajax']);
  89. $data = M('index_image')->create ();
  90. //开始验证有效性
  91. $this->assign("jumpUrl",u('WeiboIndex'."/add"));
  92. if($data['show_position']==4){
  93. $index_image = M('index_image')->where("show_position = 4")->find();
  94. if($index_image){
  95. $this->error("启动广告只能添加一个,已添加可编辑!");
  96. }
  97. }
  98. if(!check_empty($data['image']))
  99. {
  100. $this->error("请上传广告图");
  101. }
  102. if(!check_empty($data['title']))
  103. {
  104. $this->error("请输入标题");
  105. }
  106. if($data['type']==1|| $data['type']==6 || $data['type']==7 || $data['type']==8 || $data['type']==10 || $data['type']==11){
  107. if($data['type']==8)
  108. $error_title="请输入房间号";
  109. elseif($data['type']==6)
  110. $error_title="请输入机构id";
  111. elseif($data['type']==7)
  112. $error_title="请输入会员id";
  113. elseif($data['type']==1)
  114. $error_title="请选择家族";
  115. elseif($data['type']==10)
  116. $error_title="请输入会员ID";
  117. elseif($data['type']==11)
  118. $error_title="请输入动态";
  119. if(!$data['show_id']){
  120. $this->error($error_title);
  121. }
  122. }else{
  123. $data['show_id'] = '';
  124. }
  125. // 更新数据
  126. $log_info = $data['title'];
  127. $list=M('index_image')->add($data);
  128. if (false !== $list) {
  129. //load_auto_cache("index_image",'',false);
  130. //redis缓存
  131. clear_auto_cache("banner_list_xr");
  132. load_auto_cache("banner_list_xr");
  133. //成功提示
  134. save_log($log_info.L("INSERT_SUCCESS"),1);
  135. $this->success(L("INSERT_SUCCESS"));
  136. } else {
  137. //错误提示
  138. save_log($log_info.L("INSERT_FAILED"),0);
  139. $this->error(L("INSERT_FAILED"));
  140. }
  141. }
  142. public function update() {
  143. B('FilterString');
  144. $data = M('index_image')->create ();
  145. $log_info = M('index_image')->where("id=".intval($data['id']))->getField("title");
  146. //开始验证有效性
  147. $this->assign("jumpUrl",u('WeiboIndex'."/edit",array("id"=>$data['id'])));
  148. if($data['show_position']==4){
  149. $index_image = M('index_image')->where("show_position = 4")->find();
  150. if(isset($index_image['id']) && $index_image['id']!=$data['id']){
  151. $this->error("启动广告只能添加一个,已添加可编辑!");
  152. }
  153. }
  154. if(!check_empty($data['image']))
  155. {
  156. $this->error("请上传广告图");
  157. }
  158. if(!check_empty($data['title']))
  159. {
  160. $this->error("请输入标题");
  161. }
  162. if($data['type']==1|| $data['type']==6 || $data['type']==7 || $data['type']==8 || $data['type']==10 || $data['type']==11){
  163. if($data['type']==8)
  164. $error_title="请输入房间号";
  165. elseif($data['type']==6)
  166. $error_title="请输入机构id";
  167. elseif($data['type']==7)
  168. $error_title="请输入会员id";
  169. elseif($data['type']==1)
  170. $error_title="请选择家族";
  171. elseif($data['type']==10)
  172. $error_title="请输入会员ID";
  173. elseif($data['type']==11)
  174. $error_title="请输入动态";
  175. if(!$data['show_id']){
  176. $this->error($error_title);
  177. }
  178. }else{
  179. $data['show_id'] = '';
  180. }
  181. $list=M('index_image')->save ($data);
  182. if (false !== $list) {
  183. //成功提示
  184. //load_auto_cache("index_image",'',false);
  185. //redis缓存
  186. clear_auto_cache("banner_list_xr");
  187. load_auto_cache("banner_list_xr");
  188. save_log($log_info.L("UPDATE_SUCCESS"),1);
  189. $this->success(L("UPDATE_SUCCESS"));
  190. } else {
  191. //错误提示
  192. save_log($log_info.L("UPDATE_FAILED"),0);
  193. $this->error(L("UPDATE_FAILED"),0,$log_info.L("UPDATE_FAILED"));
  194. }
  195. }
  196. public function set_sort()
  197. {
  198. $id = intval($_REQUEST['id']);
  199. $sort = intval($_REQUEST['sort']);
  200. $log_info = M("IndexImage")->where("id=".$id)->getField("title");
  201. if(!check_sort($sort))
  202. {
  203. $this->error(l("SORT_FAILED"),1);
  204. }
  205. M("IndexImage")->where("id=".$id)->setField("sort",$sort);
  206. save_log($log_info.l("SORT_SUCCESS"),1);
  207. clear_auto_cache("banner_list_xr");
  208. $this->success(l("SORT_SUCCESS"),1);
  209. }
  210. }
  211. ?>