Bulletin.class.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <?php
  2. namespace Cas\Controller\Admin\Platform;
  3. use Cas\Module\Lottery;
  4. use Cas\Dao\PlatformBulletin;
  5. use KIF\Core\Request;
  6. use Cas\Dao\LotteryEvents;
  7. use Cas\Controller\Admin\Controller;
  8. use KIF\Page\Page;
  9. use Cas\Dao\UserInfo;
  10. use Cas\Module\User;
  11. use Cas\Dao\BackUser;
  12. /**
  13. * "平台相关" - "公告"
  14. *
  15. * @author lihuanchun
  16. * 页面: 公告列表 doPageList
  17. * 页面: 查看&修改 公告 doPageShow
  18. * 事件: 创建公告 doReqCreate
  19. * 事件: 修改公告 doReqUp
  20. * 事件: 删除公告 doReqDel  
  21. */
  22. class Bulletin extends Controller {
  23. private $objDPlatformBulletin;
  24. private $operatorData;
  25. /**
  26. *  初始化
  27. */
  28. public function __construct() {
  29. header ( "Content-Type: text/html; charset=utf-8" );
  30. $this->operatorData = $this->getUser ();
  31. $this->objDPlatformBulletin = new PlatformBulletin();
  32. }
  33. /**
  34. * 默认
  35. */
  36. public function doDefault() {
  37. }
  38. /**
  39. * 页面: 公告列表 & 创建公告
  40. * 地址:http://cas.lishuy.com/?c=Admin_Platform_Bulletin&a=PageList
  41. */
  42. public function doPageList(){
  43. $page = Request::varGetInt ( 'page', 1 );
  44. $size = 20;
  45. $offset = ($page - 1) * $size;
  46. $limit = "{$offset},{$size}";
  47. $condition = array();
  48. $total_num = $this->objDPlatformBulletin->totals ( $condition );
  49. $url_tpl = Request::schemeDomain () . "?c=Admin_Platform_Bulletin&a=PageList";
  50. $url_tpl .= "&page={page}";
  51. $objPage = new Page ( $total_num, $url_tpl, $page, $size );
  52. $page_html = $objPage->html ();
  53. $order = 'id desc';
  54. $ids = $this->objDPlatformBulletin -> findIdsBy($condition , $limit, $order );
  55. $bulletinsData = $this->objDPlatformBulletin->gets($ids);
  56. $uids = array();
  57. foreach($bulletinsData as $key=>$data){
  58. $uids[$data['operator_uid']] = $data['operator_uid'];
  59. }
  60. $objDUserInfo = new UserInfo();
  61. $thisPageUserData = $objDUserInfo -> gets($ids);
  62. $this->tpl = 'admin/platform/blletin_list';
  63. $title = '公告设置';
  64. $this->setOutput('title', $title);
  65. $this->setOutput('menu_active', array('name' => 'bulletin', 'item' => '')); //激活菜单
  66. $this->addNavMenu($title);
  67. $this->addNavMenu('平台设置');
  68. $this->setOutput ( 'page_html', $page_html ); // 分页Html
  69. $this->setOutput ( 'bulletinsData', $bulletinsData ); // 当前公告列表数据
  70. $this->setOutput ( 'thisPageUserData', $thisPageUserData );//当前页面用户ID
  71. $this->setOutput ('pagePublicData', $this->getPagePublicData()); // 后台管理相关数据
  72. $this->setOutput('isSuperadmin', $this->isSuperadmin());
  73. }
  74. /**
  75. * 页面: 查看&修改 公告
  76. * 地址:http://cas.lishuy.com/?c=Admin_Platform_Bulletin&a=PageShow&bulletin_id=nn
  77. * 参数:bulletin_id 公告id
  78. */
  79. public function doPageShow(){
  80. $objBackUser = new BackUser();
  81. $objUser = new User();
  82. $bulletin_id = Request::g('bulletin_id');
  83. $bulletinData = $this->objDPlatformBulletin->get($bulletin_id);
  84. $bulletinData['userData'] = $objBackUser->get($bulletinData['operator_uid']);
  85. $this->tpl = 'admin/platform/blletin_show';
  86. $title = '公告内容';
  87. $this->setOutput('title', $title);
  88. $this->setOutput('menu_active', array('name' => 'bulletin', 'item' => '')); //激活菜单
  89. $this->addNavMenu($title);
  90. $this->addNavMenu('平台设置');
  91. $this->setOutput ( 'bulletinData', $bulletinData ); // 当前公告内容
  92. $this->setOutput ('pagePublicData', $this->getPagePublicData()); // 后台管理相关数据
  93. }
  94. /**
  95. * 页面: 修改 公告
  96. * 地址:http://cas.lishuy.com/?c=Admin_Platform_Bulletin&a=PageUp&bulletin_id=nn
  97. * 参数:bulletin_id 公告id
  98. */
  99. public function doPageUp(){
  100. $bulletin_id = Request::g('bulletin_id');
  101. $bulletinData = $this->objDPlatformBulletin->get($bulletin_id);
  102. $this->tpl = 'admin/platform/blletin_up';
  103. $title = '公告设置';
  104. $this->setOutput('title', $title);
  105. $this->setOutput('menu_active', array('name' => 'platformset', 'item' => 'bulletin')); //激活菜单
  106. $this->addNavMenu($title);
  107. $this->addNavMenu('平台设置');
  108. $this->setOutput ( 'bulletinData', $bulletinData ); // 当前公告内容
  109. $this->setOutput ('pagePublicData', $this->getPagePublicData()); // 后台管理相关数据
  110. }
  111. /**
  112. * 事件:创建公告
  113. * 地址:http://cas.lishuy.com/index.php?c=Admin_Platform_Bulletin&a=ReqCreate
  114. * 参数:见方法内
  115. */
  116. public function doReqCreate(){
  117. $title = Request::p('title');
  118. $content = Request::p('content', null);
  119. $operator_uid = $this->operatorData['uid'];
  120. $info = array(
  121. 'title' => $title,
  122. 'content' => $content,
  123. 'operator_uid' => $operator_uid
  124. );
  125. $this->objDPlatformBulletin->add($info);
  126. $this->ajax_success_exit('添加成功');
  127. }
  128. /**
  129. * 事件: 修改公告
  130. * 地址:http://cas.lishuy.com/index.php?c=Admin_Platform_Bulletin&a=ReqUp
  131. * 参数:见方法内
  132. */
  133. public function doReqUp(){
  134. $bulletin_id = Request::p('bulletin_id');
  135. $title = Request::p('title');
  136. $content = Request::p('content', null);
  137. $operator_uid = $this->operatorData['uid'];
  138. $info = array(
  139. 'title' => $title,
  140. 'content' => $content,
  141. 'operator_uid' => $operator_uid
  142. );
  143. $this->objDPlatformBulletin->modify($info, array('id' =>$bulletin_id ));
  144. $this->ajax_success_exit('修改成功');
  145. }
  146. /**
  147. * 事件: 删除公告
  148. * 地址:http://cas.lishuy.com/index.php?c=Admin_Platform_Bulletin&a=ReqDel
  149. * 参数:见方法内
  150. */
  151. public function doReqDel(){
  152. $bulletin_id = Request::p('bulletin_id');
  153. $this->objDPlatformBulletin->delete(array('id' =>$bulletin_id ));
  154. # TODO 根据前端自定义返回结果或跳转
  155. header ( "Location: " . Request::schemeDomain () . "/?c=Admin_Platform_Bulletin&a=PageList" );
  156. exit();
  157. }
  158. public function display() {
  159. return $this->render ();
  160. }
  161. }