From 8ff3ad2f0ce178a5d3224d8a876465a6ef052bb4 Mon Sep 17 00:00:00 2001 From: maxitio Date: Sat, 31 Aug 2019 01:28:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=B7=A5=E5=8D=95=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=EF=BC=88=E6=96=B0=E9=82=AE=E4=BB=B6=E7=9A=AE=E8=82=A4?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controllers/Admin/TicketController.php | 30 ++- app/Controllers/UserController.php | 147 ++++++------ resources/email/auth/verify.tpl | 2 +- resources/email/news/warn.tpl | 2 +- resources/email/ticket/new_ticket.tpl | 221 ++++++++++++++++++ .../email/ticket/ticket_replay_admin.tpl | 221 ++++++++++++++++++ resources/email/ticket/ticket_reply.tpl | 221 ++++++++++++++++++ resources/views/malio/auth/login.tpl | 11 +- resources/views/malio/auth/register.tpl | 5 +- resources/views/malio/user/ticket_create.tpl | 2 +- 10 files changed, 766 insertions(+), 96 deletions(-) create mode 100644 resources/email/ticket/new_ticket.tpl create mode 100644 resources/email/ticket/ticket_replay_admin.tpl create mode 100644 resources/email/ticket/ticket_reply.tpl diff --git a/app/Controllers/Admin/TicketController.php b/app/Controllers/Admin/TicketController.php index a24679a6..48de53c9 100644 --- a/app/Controllers/Admin/TicketController.php +++ b/app/Controllers/Admin/TicketController.php @@ -52,23 +52,19 @@ class TicketController extends AdminController $ticket_main = Ticket::where('id', '=', $id)->where('rootid', '=', 0)->first(); - - //if($status==1&&$ticket_main->status!=$status) - { - $adminUser = User::where('id', '=', $ticket_main->userid)->get(); - foreach ($adminUser as $user) { - $subject = Config::get('appName') . '-工单被回复'; - $to = $user->email; - $text = '您好,有人回复了工单,请您查看。'; - try { - Mail::send($to, $subject, 'news/warn.tpl', [ - 'user' => $user, 'text' => $text - ], [ - ]); - } catch (Exception $e) { - echo $e->getMessage(); - } - } + $user = User::where('id','=', $ticket_main->userid)->first(); + $ticket_url = Config::get('baseUrl') . '/user/ticket/' . $ticket_main->id . '/view'; + + $subject = '您提出的工单已被回复'; + $to = $user->email; + $text = '管理员已回复您提出的工单'; + try { + Mail::send($to, $subject, 'ticket/ticket_reply.tpl', [ + 'user' => $user, 'text' => $text, 'content' => $content, 'title' => $ticket_main->title, 'ticket_url' => $ticket_url + ], [ + ]); + } catch (Exception $e) { + echo $e->getMessage(); } $antiXss = new AntiXSS(); diff --git a/app/Controllers/UserController.php b/app/Controllers/UserController.php index 745487e5..9e03f95f 100644 --- a/app/Controllers/UserController.php +++ b/app/Controllers/UserController.php @@ -1298,15 +1298,18 @@ class UserController extends BaseController $ticket->datetime = time(); $ticket->save(); - if (Config::get('mail_ticket') == 'true' && $markdown != '') { + $new_ticket = Ticket::where('userid', $this->user->id)->where('title', $ticket->title)->orderBy('id','desc')->first(); + $ticket_url = Config::get('baseUrl').'/admin/ticket/'.$new_ticket->id.'/view'; + + if (Config::get('mail_ticket') == 'true') { $adminUser = User::where('is_admin', '=', '1')->get(); foreach ($adminUser as $user) { - $subject = Config::get('appName') . '-新工单被开启'; + $subject = '新工单被开启'; $to = $user->email; - $text = '管理员,有人开启了新的工单,请您及时处理。'; + $text = '有新工单需要您处理'; try { - Mail::send($to, $subject, 'news/warn.tpl', [ - 'user' => $user, 'text' => $text + Mail::send($to, $subject, 'ticket/new_ticket.tpl', [ + 'user' => $user, 'text' => $text, 'title' => $title, 'content' => $content, 'ticket_url' =>$ticket_url ], [ ]); } catch (Exception $e) { @@ -1315,7 +1318,7 @@ class UserController extends BaseController } } - if (Config::get('useScFtqq') == 'true' && $markdown != '') { + if (Config::get('useScFtqq') == 'true') { $ScFtqq_SCKEY = Config::get('ScFtqq_SCKEY'); $postdata = http_build_query( array( @@ -1364,76 +1367,80 @@ class UserController extends BaseController return $newResponse; } - if ($status == 1 && $ticket_main->status != $status) { - if (Config::get('mail_ticket') == 'true' && $markdown != '') { - $adminUser = User::where('is_admin', '=', '1')->get(); - foreach ($adminUser as $user) { - $subject = Config::get('appName') . '-工单被重新开启'; - $to = $user->email; - $text = '管理员,有人重新开启了工单,请您及时处理。'; - try { - Mail::send($to, $subject, 'news/warn.tpl', [ - 'user' => $user, 'text' => $text - ], [ - ]); - } catch (Exception $e) { - echo $e->getMessage(); + if ($content != '这条工单已被关闭') { + if ($status == 1 && $ticket_main->status != $status) { + if (Config::get('mail_ticket') == 'true') { + $adminUser = User::where('is_admin', '=', '1')->get(); + foreach ($adminUser as $user) { + $subject = Config::get('appName') . '-工单被重新开启'; + $to = $user->email; + $text = '管理员,有人重新开启了工单,请您及时处理。'; + try { + Mail::send($to, $subject, 'news/warn.tpl', [ + 'user' => $user, 'text' => $text + ], [ + ]); + } catch (Exception $e) { + echo $e->getMessage(); + } } } - } - if (Config::get('useScFtqq') == 'true' && $markdown != '') { - $ScFtqq_SCKEY = Config::get('ScFtqq_SCKEY'); - $postdata = http_build_query( - array( - 'text' => Config::get('appName') . '-工单被重新开启', - 'desp' => $markdown - ) - ); - $opts = array('http' => - array( - 'method' => 'POST', - 'header' => 'Content-type: application/x-www-form-urlencoded', - 'content' => $postdata - )); - $context = stream_context_create($opts); - file_get_contents('https://sc.ftqq.com/' . $ScFtqq_SCKEY . '.send', false, $context); - $useScFtqq = Config::get('ScFtqq_SCKEY'); - } - } else { - if (Config::get('mail_ticket') == 'true' && $markdown != '') { - $adminUser = User::where('is_admin', '=', '1')->get(); - foreach ($adminUser as $user) { - $subject = Config::get('appName') . '-工单被回复'; - $to = $user->email; - $text = '管理员,有人回复了工单,请您及时处理。'; - try { - Mail::send($to, $subject, 'news/warn.tpl', [ - 'user' => $user, 'text' => $text - ], [ - ]); - } catch (Exception $e) { - echo $e->getMessage(); + if (Config::get('useScFtqq') == 'true') { + $ScFtqq_SCKEY = Config::get('ScFtqq_SCKEY'); + $postdata = http_build_query( + array( + 'text' => Config::get('appName') . '-工单被重新开启', + 'desp' => $markdown + ) + ); + $opts = array('http' => + array( + 'method' => 'POST', + 'header' => 'Content-type: application/x-www-form-urlencoded', + 'content' => $postdata + )); + $context = stream_context_create($opts); + file_get_contents('https://sc.ftqq.com/' . $ScFtqq_SCKEY . '.send', false, $context); + $useScFtqq = Config::get('ScFtqq_SCKEY'); + } + } else { + if (Config::get('mail_ticket') == 'true') { + $adminUser = User::where('is_admin', '=', '1')->get(); + $ticket_url = Config::get('baseUrl') . '/admin/ticket/' . $ticket_main->id . '/view'; + foreach ($adminUser as $user) { + $subject = '工单被回复'; + $to = $user->email; + $text = '有人回复了工单,请您及时处理'; + try { + Mail::send($to, $subject, 'ticket/ticket_replay_admin.tpl', [ + 'user' => $user, 'text' => $text, 'ticket_url' => $ticket_url, 'content' => $content, 'title' => $ticket_main->title + ], [ + ]); + } catch (Exception $e) { + echo $e->getMessage(); + } } } - } - if (Config::get('useScFtqq') == 'true' && $markdown != '') { - $ScFtqq_SCKEY = Config::get('ScFtqq_SCKEY'); - $postdata = http_build_query( - array( - 'text' => Config::get('appName') . '-工单被回复', - 'desp' => $markdown - ) - ); - $opts = array('http' => - array( - 'method' => 'POST', - 'header' => 'Content-type: application/x-www-form-urlencoded', - 'content' => $postdata - )); - $context = stream_context_create($opts); - file_get_contents('https://sc.ftqq.com/' . $ScFtqq_SCKEY . '.send', false, $context); + if (Config::get('useScFtqq') == 'true') { + $ScFtqq_SCKEY = Config::get('ScFtqq_SCKEY'); + $postdata = http_build_query( + array( + 'text' => Config::get('appName') . '-工单被回复', + 'desp' => $markdown + ) + ); + $opts = array('http' => + array( + 'method' => 'POST', + 'header' => 'Content-type: application/x-www-form-urlencoded', + 'content' => $postdata + )); + $context = stream_context_create($opts); + file_get_contents('https://sc.ftqq.com/' . $ScFtqq_SCKEY . '.send', false, $context); + } } } + $antiXss = new AntiXSS(); diff --git a/resources/email/auth/verify.tpl b/resources/email/auth/verify.tpl index d7e6c66b..9530c9db 100644 --- a/resources/email/auth/verify.tpl +++ b/resources/email/auth/verify.tpl @@ -123,7 +123,7 @@ - Hi, New Friend + Hi, Friend
 
diff --git a/resources/email/news/warn.tpl b/resources/email/news/warn.tpl index 001912a9..12241737 100644 --- a/resources/email/news/warn.tpl +++ b/resources/email/news/warn.tpl @@ -143,7 +143,7 @@
 
- 2019 © Malio. All Rights Reserved. + 2019 © {$config['appName']}. All Rights Reserved.
 
diff --git a/resources/email/ticket/new_ticket.tpl b/resources/email/ticket/new_ticket.tpl new file mode 100644 index 00000000..0365f332 --- /dev/null +++ b/resources/email/ticket/new_ticket.tpl @@ -0,0 +1,221 @@ + + + + + + Malio + + + + + + + + + + +
+ + + + + + +
  + + + + + +
+
 
+
+ + + + + +
+
 
+ + {$config['appName']} + +
 
+
+ + + + + +
+ + Hi, 管理员 + +
 
+ + {$text} + + + + + + + + +
+
+ + + + + + +
+
 
+ +
 
+ + {$user->user_name}: {$title} + +
 
+ + {$content} + +
 
+
+
+ +
+ +
 
+ + + + +
+ + + 回复工单 + + +
+ +
 
+
+ + + + + + + + + +
+
 
+ + + + +
+
 
+ + 2019 © {$config['appName']}. All Rights Reserved. + +
 
+ + 访问官网   |   用户中心 + +
 
+
+
+ +
 
+
+ + + \ No newline at end of file diff --git a/resources/email/ticket/ticket_replay_admin.tpl b/resources/email/ticket/ticket_replay_admin.tpl new file mode 100644 index 00000000..9df02a40 --- /dev/null +++ b/resources/email/ticket/ticket_replay_admin.tpl @@ -0,0 +1,221 @@ + + + + + + Malio + + + + + + + + + + +
+ + + + + + +
  + + + + + +
+
 
+
+ + + + + +
+
 
+ + {$config['appName']} + +
 
+
+ + + + + +
+ + Hi, 管理员 + +
 
+ + {$text} + + + + + + + + +
+
+ + + + + + +
+
 
+ +
 
+ + {$user->user_name}: {$title} + +
 
+ + {$content} + +
 
+
+
+ +
+ +
 
+ + + + +
+ + + 查看工单 + + +
+ +
 
+
+ + + + + + + + + +
+
 
+ + + + +
+
 
+ + 2019 © {$config['appName']}. All Rights Reserved. + +
 
+ + 访问官网   |   用户中心 + +
 
+
+
+ +
 
+
+ + + \ No newline at end of file diff --git a/resources/email/ticket/ticket_reply.tpl b/resources/email/ticket/ticket_reply.tpl new file mode 100644 index 00000000..c7ce41ae --- /dev/null +++ b/resources/email/ticket/ticket_reply.tpl @@ -0,0 +1,221 @@ + + + + + + Malio + + + + + + + + + + +
+ + + + + + +
  + + + + + +
+
 
+
+ + + + + +
+
 
+ + {$config['appName']} + +
 
+
+ + + + + +
+ + Hi, {$user->user_name} + +
 
+ + {$text} + + + + + + + + +
+
+ + + + + + +
+
 
+ +
 
+ + 标题: {$title} + +
 
+ + {$content} + +
 
+
+
+ +
+ +
 
+ + + + +
+ + + 查看工单 + + +
+ +
 
+
+ + + + + + + + + +
+
 
+ + + + +
+
 
+ + 2019 © {$config['appName']}. All Rights Reserved. + +
 
+ + 访问官网   |   用户中心 + +
 
+
+
+ +
 
+
+ + + \ No newline at end of file diff --git a/resources/views/malio/auth/login.tpl b/resources/views/malio/auth/login.tpl index 45a0f325..2c0bbeb2 100644 --- a/resources/views/malio/auth/login.tpl +++ b/resources/views/malio/auth/login.tpl @@ -13,7 +13,6 @@ - {if $malio_config['enable_crisp'] == true && $malio_config['enable_crisp_outside'] == true} {include file='crisp.tpl'} @@ -312,9 +311,7 @@ if (data.ret == 1) { window.location.assign('/user') } else if(data.ret == 2) { - - $('.login-form-item').addClass('animated fadeOut faster') - $('.login-form-item').hide('300'); + $('.login-form-item').hide('500'); $('form').removeClass('was-validated'); $('#2fa-form').show('fast'); {if $geetest_html != null} @@ -330,7 +327,11 @@ {if $recaptcha_sitekey != null} grecaptcha.reset(); {/if} - swal('出错了', '密码或邮箱不正确', 'error'); + var errorMsg = '密码或邮箱不正确'; + if (twoFA == true) { + errorMsg = '两步验证码错误' + } + swal('出错了', errorMsg, 'error'); } } }); diff --git a/resources/views/malio/auth/register.tpl b/resources/views/malio/auth/register.tpl index f5301387..1506c9c4 100644 --- a/resources/views/malio/auth/register.tpl +++ b/resources/views/malio/auth/register.tpl @@ -196,8 +196,11 @@
- + +
+ 请阅读服务条款并勾选 +
diff --git a/resources/views/malio/user/ticket_create.tpl b/resources/views/malio/user/ticket_create.tpl index fb9acba7..2dd801f8 100644 --- a/resources/views/malio/user/ticket_create.tpl +++ b/resources/views/malio/user/ticket_create.tpl @@ -54,7 +54,7 @@
- +