From 0e70771cd8e8bc070e8cb3fcc71e798f4290c55e Mon Sep 17 00:00:00 2001 From: z Date: Sun, 28 Jun 2020 13:16:47 +0800 Subject: [PATCH] * finish task #7274. --- config/filter.php | 3 ++- module/webhook/control.php | 26 +++++++++++++++++++------- module/webhook/lang/zh-cn.php | 9 +++++---- module/webhook/view/bind.html.php | 1 + 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/config/filter.php b/config/filter.php index 1dd596a878..295176f9e1 100644 --- a/config/filter.php +++ b/config/filter.php @@ -242,4 +242,5 @@ $filter->repo->diff->cookie['repoPairs'] = 'array'; $filter->repo->view->cookie['repoPairs'] = 'array'; $filter->repo->ajaxsynccommit->cookie['syncBranch'] = 'reg::any'; -$filter->webhook->bind->get['whiteListDept'] = 'reg::checked'; +$filter->webhook->bind->get['whiteListDept'] = 'reg::checked'; +$filter->webhook->bind->cookie['whiteListDept'] = 'reg::checked'; diff --git a/module/webhook/control.php b/module/webhook/control.php index b038791326..3a88451928 100644 --- a/module/webhook/control.php +++ b/module/webhook/control.php @@ -40,6 +40,9 @@ class webhook extends control $this->app->loadClass('pager', $static = true); $pager = new pager($recTotal, $recPerPage, $pageID); + /* Unset whiteListDept cookie. */ + setcookie('whiteListDept', '', 0, $this->config->webRoot, '', false, true); + $this->view->title = $this->lang->webhook->api . $this->lang->colon . $this->lang->webhook->list; $this->view->webhooks = $this->webhook->getList($orderBy, $pager); $this->view->position[] = html::a(inlink('browse'), $this->lang->webhook->api); @@ -175,11 +178,19 @@ class webhook extends control } $webhook->secret = json_decode($webhook->secret); + /* Get whiteList dept. */ + if($this->get->whiteListDept) + { + setcookie('whiteListDept', $this->get->whiteListDept, 0, $this->config->webRoot, '', false, true); + $_COOKIE['whiteListDept'] = $this->get->whiteListDept; + } + $whiteListDept = $this->cookie->whiteListDept ? $this->cookie->whiteListDept : ''; + if($webhook->type == 'dinguser') { $this->app->loadClass('dingapi', true); $dingapi = new dingapi($webhook->secret->appKey, $webhook->secret->appSecret, $webhook->secret->agentId); - $response = $dingapi->getAllUsers($this->get->whiteListDept); + $response = $dingapi->getAllUsers($whiteListDept); } elseif($webhook->type == 'wechatuser') { @@ -222,12 +233,13 @@ class webhook extends control $this->view->position[] = html::a($this->createLink('webhook', 'browse'), $this->lang->webhook->common); $this->view->position[] = $this->lang->webhook->bind; - $this->view->webhook = $webhook; - $this->view->dingUsers = $dingUsers; - $this->view->useridPairs = $useridPairs; - $this->view->users = $users; - $this->view->pager = $pager; - $this->view->bindedUsers = $bindedPairs; + $this->view->webhook = $webhook; + $this->view->dingUsers = $dingUsers; + $this->view->useridPairs = $useridPairs; + $this->view->users = $users; + $this->view->pager = $pager; + $this->view->bindedUsers = $bindedPairs; + $this->view->whiteListDept = $whiteListDept; $this->display(); } diff --git a/module/webhook/lang/zh-cn.php b/module/webhook/lang/zh-cn.php index 7f7a6aeea8..b50fffbc12 100644 --- a/module/webhook/lang/zh-cn.php +++ b/module/webhook/lang/zh-cn.php @@ -9,10 +9,11 @@ $lang->webhook->chooseDept = '选择同步部门'; $lang->webhook->assigned = '指派给'; $lang->webhook->setting = '设置'; -$lang->webhook->browse = '浏览Webhook'; -$lang->webhook->create = '添加Webhook'; -$lang->webhook->edit = '编辑Webhook'; -$lang->webhook->delete = '删除Webhook'; +$lang->webhook->browse = '浏览Webhook'; +$lang->webhook->create = '添加Webhook'; +$lang->webhook->edit = '编辑Webhook'; +$lang->webhook->delete = '删除Webhook'; +$lang->webhook->rechooseDept = '重选部门'; $lang->webhook->id = 'ID'; $lang->webhook->type = '类型'; diff --git a/module/webhook/view/bind.html.php b/module/webhook/view/bind.html.php index c79effe4e5..023c3c4b8a 100644 --- a/module/webhook/view/bind.html.php +++ b/module/webhook/view/bind.html.php @@ -48,6 +48,7 @@
save, '', 'btn btn-primary');?> createLink('webhook', 'browse'), $lang->goback, '', "class='btn'");?> + createLink('webhook', 'chooseDept', "id={$webhook->id}"), $lang->webhook->rechooseDept, '', "class='btn'");?>
show('right', 'pagerjs');?>