|
|
@@ -23,45 +23,45 @@ class MessageController extends Controller
|
|
|
function Index(Req $req)
|
|
|
{
|
|
|
$request = array();
|
|
|
- $request['title'] = isset($req->title) ? trim ($req->title) : null;
|
|
|
- $request['type'] = isset($req->type) ? trim ($req->type) : null;
|
|
|
+ $request['title'] = isset($req->title) ? trim($req->title) : null;
|
|
|
+ $request['type'] = isset($req->type) ? trim($req->type) : null;
|
|
|
// $request['message_type'] = isset($req->message_type) ? trim($req->message_type) : null;
|
|
|
- $request['toname'] = isset($req->toname) ? trim ($req->toname) : null;
|
|
|
- $request['fromname'] = isset($req->fromname) ? trim ($req->fromname) : null;
|
|
|
+ $request['toname'] = isset($req->toname) ? trim($req->toname) : null;
|
|
|
+ $request['fromname'] = isset($req->fromname) ? trim($req->fromname) : null;
|
|
|
|
|
|
- $dt = \App\Lib\DataTable\DataTable::init ();
|
|
|
- $dt->setDataSource ('/admin/Message/getArticle');
|
|
|
- $dt->setLang ('notice');
|
|
|
+ $dt = \App\Lib\DataTable\DataTable::init();
|
|
|
+ $dt->setDataSource('/admin/Message/getArticle');
|
|
|
+ $dt->setLang('notice');
|
|
|
// $dt->addColsFields('id');
|
|
|
- $dt->addColsFields ('title');
|
|
|
- $dt->addColsFields ('toname');
|
|
|
- $dt->addColsFields ('group_name');
|
|
|
- $dt->addColsFields ('formname');
|
|
|
- $dt->addColsFields ('add_type');
|
|
|
- $dt->addColsFields ('is_show');
|
|
|
+ $dt->addColsFields('title');
|
|
|
+ $dt->addColsFields('toname');
|
|
|
+ $dt->addColsFields('group_name');
|
|
|
+ $dt->addColsFields('formname');
|
|
|
+ $dt->addColsFields('add_type');
|
|
|
+ $dt->addColsFields('is_show');
|
|
|
// $dt->addColsFields('content');
|
|
|
- $dt->addColsFields ('add_time');
|
|
|
+ $dt->addColsFields('add_time');
|
|
|
// $dt->addColsFields('message_type');
|
|
|
- $dt->addColsFields ('type');
|
|
|
- $dt->enableCheckBox ();
|
|
|
+ $dt->addColsFields('type');
|
|
|
+ $dt->enableCheckBox();
|
|
|
$arr[] = 'view';
|
|
|
- $dt->setToolBar ($arr, array('width' => 140));
|
|
|
- return view ('admin.Manager/arictle', $dt->render ($request));
|
|
|
+ $dt->setToolBar($arr, array('width' => 140));
|
|
|
+ return view('admin.Manager/arictle', $dt->render($request));
|
|
|
}
|
|
|
|
|
|
//获取信息
|
|
|
//获取活动信息
|
|
|
function getArticle()
|
|
|
{
|
|
|
- $limit = Request::has ('limit') ? Request::get ('limit') : 10;
|
|
|
+ $limit = Request::has('limit') ? Request::get('limit') : 10;
|
|
|
|
|
|
- $title = Request::has ('title') ? Request::get ('title') : '';
|
|
|
- $content = Request::has ('content') ? Request::get ('content') : '';
|
|
|
- $message_type = Request::has ('message_type') ? Request::get ('message_type') : '';
|
|
|
- $type = Request::has ('type') ? Request::get ('type') : '';
|
|
|
- $forname = Request::has ('forname') ? Request::get ('forname') : '';
|
|
|
- $toname = Request::has ('toname') ? Request::get ('toname') : '';
|
|
|
- $add_time = Request::has ('add_time') ? Request::get ('add_time') : '';
|
|
|
+ $title = Request::has('title') ? Request::get('title') : '';
|
|
|
+ $content = Request::has('content') ? Request::get('content') : '';
|
|
|
+ $message_type = Request::has('message_type') ? Request::get('message_type') : '';
|
|
|
+ $type = Request::has('type') ? Request::get('type') : '';
|
|
|
+ $forname = Request::has('forname') ? Request::get('forname') : '';
|
|
|
+ $toname = Request::has('toname') ? Request::get('toname') : '';
|
|
|
+ $add_time = Request::has('add_time') ? Request::get('add_time') : '';
|
|
|
|
|
|
|
|
|
$where = array();
|
|
|
@@ -71,8 +71,8 @@ class MessageController extends Controller
|
|
|
if (!empty($type)) {
|
|
|
$where[] = array('type', '=', $type);
|
|
|
} else {
|
|
|
- $where[] = array('type', '!=', 2);
|
|
|
- $where[] = array('type', '!=', 4);
|
|
|
+ //$where[] = array('type', '!=', 2);
|
|
|
+ //$where[] = array('type', '!=', 4);
|
|
|
}
|
|
|
if (!empty($content)) {
|
|
|
$where[] = array('content', 'like', '%' . $content . '%');
|
|
|
@@ -84,16 +84,18 @@ class MessageController extends Controller
|
|
|
$where[] = array('toname', 'like', '%' . $toname . '%');
|
|
|
}
|
|
|
if (!empty($add_time)) {
|
|
|
- $add_time = date ('Y-m-d H:i:s', strtotime ($add_time));
|
|
|
+ $add_time = date('Y-m-d H:i:s', strtotime($add_time));
|
|
|
$where[] = array('add_time', '<=', $add_time);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
$db = new \App\Models\Manager();
|
|
|
- $data = $db->getlist ($limit, $where);
|
|
|
+ $data = $db->getlist($limit, $where);
|
|
|
if (!($data < 0)) {
|
|
|
- $langinfo = trans ('status.manager');
|
|
|
- $messged = trans ('notice.message_status');
|
|
|
- $show = trans ('notice.show');
|
|
|
+ $langinfo = trans('status.manager');
|
|
|
+ $messged = trans('notice.message_status');
|
|
|
+ $show = trans('notice.show');
|
|
|
foreach ($data['data'] as $k => $v) {
|
|
|
$data['data'][$k]['type'] = $langinfo[$v['type']];
|
|
|
if (!empty($v['add_type'])) {
|
|
|
@@ -102,38 +104,38 @@ class MessageController extends Controller
|
|
|
$data['data'][$k]['is_show'] = $show[$v['is_show']];
|
|
|
}
|
|
|
}
|
|
|
- return \App\Lib\DataTable\DataTable::init ()->toJson ($data['data'], $data['total']);
|
|
|
+ return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
|
|
|
}
|
|
|
|
|
|
function view(Req $req)
|
|
|
{
|
|
|
- return $this->Edit ($req);
|
|
|
+ return $this->Edit($req);
|
|
|
}
|
|
|
|
|
|
function Edit(Req $req)
|
|
|
{
|
|
|
$id = $req->id;
|
|
|
// $id=Request::has('id')?Request::get('id'):'';
|
|
|
- if (intval ($id) < 1) {
|
|
|
- abort (404);
|
|
|
+ if (intval($id) < 1) {
|
|
|
+ abort(404);
|
|
|
}
|
|
|
$db = new \App\Models\Manager;
|
|
|
- $groupdata = \App\Models\Account_group::getAllInfo ();
|
|
|
- if (!$req->isMethod ('post')) {
|
|
|
- $data = $db->getDmsg ($id, 1);
|
|
|
+ $groupdata = \App\Models\Account_group::getAllInfo();
|
|
|
+ if (!$req->isMethod('post')) {
|
|
|
+ $data = $db->getDmsg($id, 1);
|
|
|
if (!$data) {
|
|
|
- return responseToJson ($data);
|
|
|
+ return responseToJson($data);
|
|
|
}
|
|
|
- return view ('admin.Manager/editNotice', ['data' => $data, 'group' => $groupdata]);
|
|
|
+ return view('admin.Manager/editNotice', ['data' => $data, 'group' => $groupdata]);
|
|
|
} else {
|
|
|
- $data['title'] = $req->input ('title');
|
|
|
+ $data['title'] = $req->input('title');
|
|
|
$data['content'] = $req->desc;
|
|
|
- $res = $db->updateMsg ($data, $id);
|
|
|
+ $res = $db->updateMsg($data, $id);
|
|
|
// $log = array(
|
|
|
// session('adminInfo.admin_name'),
|
|
|
// );
|
|
|
// OperationLog(session('adminInfo.admin_id'), 'edit_game', $log);
|
|
|
- return responseToJson ($res);
|
|
|
+ return responseToJson($res);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -144,36 +146,36 @@ class MessageController extends Controller
|
|
|
*/
|
|
|
function delete(Req $req)
|
|
|
{
|
|
|
- $id = $req->input ('id');
|
|
|
+ $id = $req->input('id');
|
|
|
if (empty($id)) {
|
|
|
- return responseToJson (-2001); //id������
|
|
|
+ return responseToJson(-2001); //id������
|
|
|
}
|
|
|
- $ids = explode (',', $id);
|
|
|
- if (!is_array ($ids) && intval ($ids) < 0) {
|
|
|
- return responseToJson (-2002); //id����
|
|
|
+ $ids = explode(',', $id);
|
|
|
+ if (!is_array($ids) && intval($ids) < 0) {
|
|
|
+ return responseToJson(-2002); //id����
|
|
|
}
|
|
|
- if (is_array ($ids) && count ($ids) > 0) {
|
|
|
+ if (is_array($ids) && count($ids) > 0) {
|
|
|
foreach ($ids as $k => $v) {
|
|
|
- if (intval ($v) < 1) {
|
|
|
+ if (intval($v) < 1) {
|
|
|
unset($ids[$k]);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- $rows = \App\Models\Manager::whereIn ('id', $ids)->delete ();
|
|
|
+ $rows = \App\Models\Manager::whereIn('id', $ids)->delete();
|
|
|
if (!$rows) {
|
|
|
- return responseToJson (-2003); //id����
|
|
|
+ return responseToJson(-2003); //id����
|
|
|
}
|
|
|
$log = array(
|
|
|
session('adminInfo.admin_name'),
|
|
|
);
|
|
|
OperationLog(session('adminInfo.admin_id'), 'del_mess', $log);
|
|
|
- return responseToJson (1); //id����
|
|
|
+ return responseToJson(1); //id����
|
|
|
}
|
|
|
|
|
|
function MessageView()
|
|
|
{
|
|
|
- $id = Request::has ('id') ? Request::get ('id') : '';
|
|
|
- $admin_id = session ('adminInfo.admin_id');
|
|
|
+ $id = Request::has('id') ? Request::get('id') : '';
|
|
|
+ $admin_id = session('adminInfo.admin_id');
|
|
|
$where = [
|
|
|
'id',
|
|
|
$id
|
|
|
@@ -185,12 +187,12 @@ class MessageController extends Controller
|
|
|
];
|
|
|
$db = new \App\Models\Manager();
|
|
|
$dbRead = new \App\Models\MessageRead;
|
|
|
- $data = $db->getlistd ($where);
|
|
|
- $dataRead = $dbRead->Messagelist ($id, $admin_id);
|
|
|
+ $data = $db->getlistd($where);
|
|
|
+ $dataRead = $dbRead->Messagelist($id, $admin_id);
|
|
|
if ($dataRead < 0) {
|
|
|
- $dat = $dbRead->addMessage ($dataWhwew);
|
|
|
+ $dat = $dbRead->addMessage($dataWhwew);
|
|
|
}
|
|
|
- return view ('admin.Manager/view', ['data' => $data]);
|
|
|
+ return view('admin.Manager/view', ['data' => $data]);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -200,27 +202,27 @@ class MessageController extends Controller
|
|
|
*/
|
|
|
function addNotice(Req $req)
|
|
|
{
|
|
|
- $groupdata = \App\Models\Account_group::getAllInfo ();
|
|
|
+ $groupdata = \App\Models\Account_group::getAllInfo();
|
|
|
|
|
|
- if (!$req->isMethod ('post')) {
|
|
|
+ if (!$req->isMethod('post')) {
|
|
|
$groupdatas = $groupdata;
|
|
|
- return view ('admin.Manager/editNotice', ['select' => 1, 'group' => $groupdatas]);
|
|
|
+ return view('admin.Manager/editNotice', ['select' => 1, 'group' => $groupdatas]);
|
|
|
} else {
|
|
|
- $data['title'] = $req->input ('title');
|
|
|
- $data['type'] = $req->type ? intval ($req->type) : '';
|
|
|
+ $data['title'] = $req->input('title');
|
|
|
+ $data['type'] = $req->type ? intval($req->type) : '';
|
|
|
if (empty($data['type'])) {
|
|
|
- return responseToJson (-3001341);
|
|
|
+ return responseToJson(-3001341);
|
|
|
}
|
|
|
$data['content'] = strip_tags($req->desc);//过滤html标签
|
|
|
$log = array(
|
|
|
- session ('adminInfo.admin_name'),
|
|
|
+ session('adminInfo.admin_name'),
|
|
|
$data['title']
|
|
|
);
|
|
|
- $data['add_time'] = date ('Y-m-d H:i:s');
|
|
|
- $data['formname'] = $req->input ('formname');
|
|
|
- $data['toname'] = str_replace (',', ',', strip_tags (trim ($req->input ('toname'))));
|
|
|
- $data['add_type'] = isset($req->add_type) ? trim ($req->add_type) : '1';
|
|
|
- $data['is_show'] = isset($req->is_show) ? trim ($req->is_show) : 0; //首页是否弹出显示
|
|
|
+ $data['add_time'] = date('Y-m-d H:i:s');
|
|
|
+ $data['formname'] = $req->input('formname');
|
|
|
+ $data['toname'] = str_replace(',', ',', strip_tags(trim($req->input('toname'))));
|
|
|
+ $data['add_type'] = isset($req->add_type) ? trim($req->add_type) : '1';
|
|
|
+ $data['is_show'] = isset($req->is_show) ? trim($req->is_show) : 0; //首页是否弹出显示
|
|
|
$groups = $req->groups;
|
|
|
$send = [
|
|
|
'name' => $data['title'],
|
|
|
@@ -232,8 +234,8 @@ class MessageController extends Controller
|
|
|
$db = new \App\Models\Manager;
|
|
|
//普通消息
|
|
|
if ($data['type'] == 1) {
|
|
|
- $dataName = explode (',', $data['toname']);
|
|
|
- $send['to'] = $this->getIdBy ($dataName);//接收者列表
|
|
|
+ $dataName = explode(',', $data['toname']);
|
|
|
+ $send['to'] = $this->getIdBy($dataName);//接收者列表
|
|
|
}
|
|
|
//系统消息
|
|
|
if ($data['type'] == 2) {
|
|
|
@@ -244,12 +246,12 @@ class MessageController extends Controller
|
|
|
if ($data['type'] == 3) {
|
|
|
$data['formname'] = '系统通知';
|
|
|
//获取发送用户组
|
|
|
- if (is_array ($groups) && count ($groups) > 0) {
|
|
|
+ if (is_array($groups) && count($groups) > 0) {
|
|
|
$data['toname'] = 'groups';
|
|
|
- $data['group_code'] = '0,' . implode (',', $groups) . ',';
|
|
|
+ $data['group_code'] = '0,' . implode(',', $groups) . ',';
|
|
|
$data['group_name'] = '|';
|
|
|
foreach ($groupdata as $k => $v) {
|
|
|
- if (in_array ($v['group_code'], $groups)) {
|
|
|
+ if (in_array($v['group_code'], $groups)) {
|
|
|
$data['group_name'] .= $v['group_name'] . '|';
|
|
|
}
|
|
|
}
|
|
|
@@ -260,12 +262,12 @@ class MessageController extends Controller
|
|
|
if (!$data['toname']) {
|
|
|
$data['toname'] = 'all';
|
|
|
}
|
|
|
- $res = $db->addNotice ($data);
|
|
|
+ $res = $db->addNotice($data);
|
|
|
if ($res < 0)
|
|
|
- return responseToJson ($res);
|
|
|
- OperationLog (session ('adminInfo.admin_id'), 'add_no', $log);
|
|
|
+ return responseToJson($res);
|
|
|
+ OperationLog(session('adminInfo.admin_id'), 'add_no', $log);
|
|
|
|
|
|
- return responseToJson (1);
|
|
|
+ return responseToJson(1);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -277,11 +279,11 @@ class MessageController extends Controller
|
|
|
*/
|
|
|
protected function getIdBy($names)
|
|
|
{
|
|
|
- if (!is_array ($names)) $names = explode (',', $names);
|
|
|
- $names = array_unique ($names);
|
|
|
+ if (!is_array($names)) $names = explode(',', $names);
|
|
|
+ $names = array_unique($names);
|
|
|
if (!$names) return null;
|
|
|
- $ids = (new Account())->whereIn ('account', $names)->pluck ('identity');
|
|
|
- return $ids ? $ids->toArray () : null;
|
|
|
+ $ids = (new Account())->whereIn('account', $names)->pluck('identity');
|
|
|
+ return $ids ? $ids->toArray() : null;
|
|
|
}
|
|
|
|
|
|
|