123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- <?php
- namespace app\admin\controller;
- use think\facade\View;
- use think\facade\Lang;
- class Notice extends AdminControl
- {
- public function initialize()
- {
- parent::initialize();
- Lang::load(base_path().'admin/lang/'.config('lang.default_lang').'/notice.lang.php');
- }
-
- public function index()
- {
- $special_condition = array();
- $special_condition['message_type'] = 1;
- $message_model = model('message');
- $message_list = $message_model->getMessageList($special_condition,10);
- foreach($message_list as $key=>$val){
- $message_list[$key]['message_body'] = preg_replace("/<a[^>]*>(.*?)<\/a>/is","$1", htmlspecialchars_decode($val['message_body']));
- }
- View::assign('message_list', $message_list);
- View::assign('show_page', $message_model->page_info->render());
- $this->setAdminCurItem('index');
- return View::fetch();
- }
-
- public function notice(){
-
- if (request()->isPost()) {
- $notice_validate = ds_validate('notice');
- $content = trim(input('param.content1'));
- $send_type = intval(input('param.send_type'));
-
- switch ($send_type) {
-
- case 1:
- $data = [
- "user_name" => input("param.user_name")
- ];
- if (!$notice_validate->scene('notice1')->check($data)) {
- $this->error($notice_validate->getError());
- }
- break;
-
- case 2:
- break;
- }
- $data = [
- "content1" => $content
- ];
- if (!$notice_validate->scene('notice2')->check($data)) {
- $this->error($notice_validate->getError());
- } else {
-
- $memberid_list = array();
-
-
- if ($send_type == 1) {
- $member_model = model('member');
- $tmp = explode("\n", input('param.user_name'));
- if (!empty($tmp)) {
- foreach ($tmp as $k => $v) {
- $tmp[$k] = trim($v);
- }
-
- $member_list = $member_model->getMemberList(array(array('member_name' ,'in', $tmp)));
- unset($membername_str);
- if (!empty($member_list)) {
- foreach ($member_list as $k => $v) {
- $memberid_list[] = $v['member_id'];
- }
- }
- unset($member_list);
- }
- unset($tmp);
- }
- if (empty($memberid_list) && $send_type != 2) {
- $this->error(lang('notice_index_member_error'));
- }
-
- $array = array();
- $array['send_mode'] = 1;
- $array['user_name'] = $memberid_list;
- $array['content'] = $content;
-
- $message_model = model('message');
- $insert_arr = array();
- $insert_arr['from_member_id'] = 0;
- if ($send_type == 2) {
- $insert_arr['member_id'] = 'all';
- } else {
- $insert_arr['member_id'] = "," . implode(',', $memberid_list) . ",";
- }
- $insert_arr['msg_content'] = $content;
- $insert_arr['message_type'] = 1;
- $insert_arr['message_ismore'] = 1;
- $message_model->addMessage($insert_arr);
-
- $this->log(lang('notice_index_send'), 1);
- dsLayerOpenSuccess(lang('notice_index_send_succ'));
- }
- } else {
- return View::fetch('notice_add');
- }
- }
- protected function getAdminItemList()
- {
- $menu_array=array(
- array(
- 'name'=>'index','text'=>lang('notice_index_member_notice'),'url'=>(string)url('Notice/index')
- ),
- array(
- 'name'=>'notice','text'=>lang('notice_index_send'),'url'=>"javascript:dsLayerOpen('".(string)url('Notice/notice')."','".lang('notice_index_send')."')"
- )
- );
- return $menu_array;
- }
- }
|