diff --git a/module/webhook/config.php b/module/webhook/config.php index d05234651b..5341d96dfb 100644 --- a/module/webhook/config.php +++ b/module/webhook/config.php @@ -5,7 +5,7 @@ $config->webhook->create->requiredFields = 'name, url'; $config->webhook->edit = new stdclass(); $config->webhook->edit->requiredFields = 'name, url'; -$config->webhook->dingapiUrl = 'https://oapi.dingtalk.com/'; +$config->webhook->dingapiUrl = 'https://oapi.dingtalk.com/'; $config->webhook->wechatApiUrl = 'https://qyapi.weixin.qq.com/cgi-bin/'; /* Unset entry to hide actions. */ diff --git a/module/webhook/control.php b/module/webhook/control.php index 742e73ae83..f996bb7616 100644 --- a/module/webhook/control.php +++ b/module/webhook/control.php @@ -166,7 +166,7 @@ class webhook extends control } $webhook = $this->webhook->getById($id); - if($webhook->type != 'dingapi' && $webhook->type != 'weixin') + if($webhook->type != 'dingapi' && $webhook->type != 'wechatApi') { echo js::alert($this->lang->webhook->note->bind); die(js::locate($this->createLink('webhook', 'browse'))); @@ -177,11 +177,11 @@ class webhook extends control $this->app->loadClass('dingapi', true); $dingapi = new dingapi($webhook->secret->appKey, $webhook->secret->appSecret, $webhook->secret->agentId); $response = $dingapi->getAllUsers(); - }elseif ($webhook->type == 'weixin') + }elseif ($webhook->type == 'wechatApi') { $this->app->loadClass('wechatapi', true); - $weichatapi = new wechatapi($webhook->secret->appKey, $webhook->secret->appSecret, $webhook->secret->agentId); - $response = $weichatapi->getAllUsers(); + $wechatApi = new wechatapi($webhook->secret->appKey, $webhook->secret->appSecret, $webhook->secret->agentId); + $response = $wechatApi->getAllUsers(); } if($response['result'] == 'fail') diff --git a/module/webhook/js/create.js b/module/webhook/js/create.js index c0ab1944c2..535c006460 100644 --- a/module/webhook/js/create.js +++ b/module/webhook/js/create.js @@ -5,10 +5,10 @@ $(function() var type = $(this).val(); $('#sendTypeTR').toggle(type != 'dingding' && type != 'dingapi'); $('#secretTR').toggle(type == 'dingding'); - $('#urlTR').toggle(type != 'dingapi' && type != 'weixin'); + $('#urlTR').toggle(type != 'dingapi' && type != 'wechatApi'); $('.dingapiTR').toggle(type == 'dingapi'); - $('.wechatTR').toggle(type == 'weixin'); - $('#paramsTR').toggle(type != 'bearychat' && type != 'dingding' && type != 'dingapi' && type != 'weixin' && type != 'wxRobot'); + $('.wechatTR').toggle(type == 'wechatApi'); + $('#paramsTR').toggle(type != 'bearychat' && type != 'dingding' && type != 'dingapi' && type != 'wechatApi' && type != 'weixin'); $('#urlNote').html(urlNote[type]); }); diff --git a/module/webhook/lang/zh-cn.php b/module/webhook/lang/zh-cn.php index 51cc575e30..7dccca914b 100644 --- a/module/webhook/lang/zh-cn.php +++ b/module/webhook/lang/zh-cn.php @@ -34,12 +34,12 @@ $lang->webhook->date = '发送时间'; $lang->webhook->data = '数据'; $lang->webhook->result = '结果'; -$lang->webhook->typeList[''] = ''; -$lang->webhook->typeList['dingding'] = '钉钉群通知机器人'; -$lang->webhook->typeList['dingapi'] = '钉钉工作消息通知'; -$lang->webhook->typeList['weixin'] = '企业微信应用消息'; -$lang->webhook->typeList['wxRobot'] = '企业微信机器人'; -$lang->webhook->typeList['default'] = '其他'; +$lang->webhook->typeList[''] = ''; +$lang->webhook->typeList['dingding'] = '钉钉群通知机器人'; +$lang->webhook->typeList['dingapi'] = '钉钉工作消息通知'; +$lang->webhook->typeList['weixin'] = '企业微信群机器人'; +$lang->webhook->typeList['wechatApi'] = '企业微信应用消息'; +$lang->webhook->typeList['default'] = '其他'; $lang->webhook->sendTypeList['sync'] = '同步'; $lang->webhook->sendTypeList['async'] = '异步'; @@ -84,7 +84,7 @@ $lang->webhook->note->wechatSecret = " webhook->note->typeList['dingding'] = '请在钉钉中添加一个自定义机器人,并将其webhook填写到此处。'; -$lang->webhook->note->typeList['wechatRobot'] = '请在企业微信中添加一个自定义机器人,并将其webhook填写到此处。'; +$lang->webhook->note->typeList['weixin'] = '请在企业微信中添加一个自定义机器人,并将其webhook填写到此处。'; $lang->webhook->note->typeList['default'] = '从第三方系统获取webhook并填写到此处。'; $lang->webhook->error = new stdclass(); diff --git a/module/webhook/lang/zh-tw.php b/module/webhook/lang/zh-tw.php index 1b1d706afe..7cee556fe8 100644 --- a/module/webhook/lang/zh-tw.php +++ b/module/webhook/lang/zh-tw.php @@ -37,7 +37,8 @@ $lang->webhook->result = '結果'; $lang->webhook->typeList[''] = ''; $lang->webhook->typeList['dingding'] = '釘釘群通知機器人'; $lang->webhook->typeList['dingapi'] = '釘釘工作消息通知'; -$lang->webhook->typeList['weixin'] = '企業微信'; +$lang->webhook->typeList['weixin'] = '企業微信群機器人'; +$lang->webhook->typeList['wechatApi'] = '企業微信應用消息'; $lang->webhook->typeList['default'] = '其他'; $lang->webhook->sendTypeList['sync'] = '同步'; @@ -49,6 +50,12 @@ $lang->webhook->dingAppSecret = '釘釘AppSecret'; $lang->webhook->dingUserid = '釘釘Userid'; $lang->webhook->dingBindStatus = '釘釘綁定狀態'; +$lang->webhook->wechatCorpId = '企業ID'; +$lang->webhook->wechatCorpSecret = '應用的憑證密鑰'; +$lang->webhook->wechatAgentId = '企業應用的ID'; +$lang->webhook->wechatUserid = '微信Userid'; +$lang->webhook->wechatBindStatus = '微信綁定狀態'; + $lang->webhook->dingBindStatusList['0'] = '未綁定'; $lang->webhook->dingBindStatusList['1'] = '已綁定'; @@ -68,10 +75,12 @@ $lang->webhook->trimWords = '了'; $lang->webhook->note = new stdClass(); $lang->webhook->note->async = '非同步需要打開計劃任務'; -$lang->webhook->note->bind = '只有釘釘工作通知類型才需要綁定用戶。'; +$lang->webhook->note->bind = '只有[釘釘/微信]工作通知類型才需要綁定用戶。'; $lang->webhook->note->product = "此項為空時所有{$lang->productCommon}的動作都會觸發鈎子,否則只有關聯{$lang->productCommon}的動作才會觸發。"; $lang->webhook->note->project = "此項為空時所有{$lang->projectCommon}的動作都會觸發鈎子,否則只有關聯{$lang->projectCommon}的動作才會觸發。"; $lang->webhook->note->dingKey = " "; +$lang->webhook->note->wechatCorpid = " "; +$lang->webhook->note->wechatSecret = " "; $lang->webhook->note->typeList['bearychat'] = '請在倍洽中添加一個禪道機器人,並將其webhook填寫到此處。'; $lang->webhook->note->typeList['dingding'] = '請在釘釘中添加一個自定義機器人,並將其webhook填寫到此處。'; diff --git a/module/webhook/model.php b/module/webhook/model.php index 1477098e4b..ab4ede7039 100644 --- a/module/webhook/model.php +++ b/module/webhook/model.php @@ -161,23 +161,23 @@ class webhookModel extends model $webhook->secret = json_encode($webhook->secret); $webhook->url = $this->config->webhook->dingapiUrl; - }elseif ($webhook->type == 'weixin') + }elseif ($webhook->type == 'wechatApi') { $webhook->secret = array(); - $webhook->secret['agentId'] = $webhook->wechatAppId; + $webhook->secret['agentId'] = $webhook->wechatAgentId; $webhook->secret['appKey'] = $webhook->wechatCorpId; - $webhook->secret['appSecret'] = $webhook->wechatSecret; + $webhook->secret['appSecret'] = $webhook->wechatCorpSecret; - if(empty($webhook->wechatCorpId)) dao::$errors['wechatCorpId'] = sprintf($this->lang->error->notempty, $this->lang->webhook->wechatCorpId); - if(empty($webhook->wechatSecret)) dao::$errors['wechatSecret'] = sprintf($this->lang->error->notempty, $this->lang->webhook->wechatCorpSecret); - if(empty($webhook->wechatAppId)) dao::$errors['wechatAppId'] = sprintf($this->lang->error->notempty, $this->lang->webhook->wechatAgentId); + if(empty($webhook->wechatCorpId)) dao::$errors['wechatCorpId'] = sprintf($this->lang->error->notempty, $this->lang->webhook->wechatCorpId); + if(empty($webhook->wechatCorpSecret)) dao::$errors['wechatCorpSecret'] = sprintf($this->lang->error->notempty, $this->lang->webhook->wechatCorpSecret); + if(empty($webhook->wechatAgentId)) dao::$errors['wechatAgentId'] = sprintf($this->lang->error->notempty, $this->lang->webhook->wechatAgentId); if(dao::isError()) return false; $webhook->secret = json_encode($webhook->secret); $webhook->url = $this->config->webhook->wechatApiUrl; } - unset($webhook->wechatCorpId, $webhook->wechatSecret, $webhook->wechatAppId); + unset($webhook->wechatCorpId, $webhook->wechatCorpSecret, $webhook->wechatAgentId); $this->dao->insert(TABLE_WEBHOOK)->data($webhook, 'agentId,appKey,appSecret') ->batchCheck($this->config->webhook->create->requiredFields, 'notempty') @@ -219,22 +219,22 @@ class webhookModel extends model if(dao::isError()) return false; $webhook->secret = json_encode($webhook->secret); - }elseif ($webhook->type == 'weixin') + }elseif ($webhook->type == 'wechatApi') { $webhook->secret = array(); - $webhook->secret['agentId'] = $webhook->wechatCorpId; - $webhook->secret['appKey'] = $webhook->wechatSecret; - $webhook->secret['appSecret'] = $webhook->wechatAppId; + $webhook->secret['agentId'] = $webhook->wechatAgentId; + $webhook->secret['appKey'] = $webhook->wechatCorpId; + $webhook->secret['appSecret'] = $webhook->wechatCorpSecret; - if(empty($webhook->wechatCorpId)) dao::$errors['wechatCorpId'] = sprintf($this->lang->error->notempty, $this->lang->webhook->wechatCorpId); - if(empty($webhook->wechatSecret)) dao::$errors['wechatSecret'] = sprintf($this->lang->error->notempty, $this->lang->webhook->wechatCorpSecret); - if(empty($webhook->wechatAppId)) dao::$errors['wechatAppId'] = sprintf($this->lang->error->notempty, $this->lang->webhook->wechatAgentId); + if(empty($webhook->wechatCorpId)) dao::$errors['wechatCorpId'] = sprintf($this->lang->error->notempty, $this->lang->webhook->wechatCorpId); + if(empty($webhook->wechatCorpSecret)) dao::$errors['wechatCorpSecret'] = sprintf($this->lang->error->notempty, $this->lang->webhook->wechatCorpSecret); + if(empty($webhook->wechatAgentId)) dao::$errors['wechatAgentId'] = sprintf($this->lang->error->notempty, $this->lang->webhook->wechatAgentId); if(dao::isError()) return false; $webhook->secret = json_encode($webhook->secret); } - unset($webhook->wechatCorpId, $webhook->wechatSecret, $webhook->wechatAppId); + unset($webhook->wechatCorpId, $webhook->wechatCorpSecret, $webhook->wechatAgentId); $this->dao->update(TABLE_WEBHOOK)->data($webhook, 'agentId,appKey,appSecret') ->batchCheck($this->config->webhook->edit->requiredFields, 'notempty') @@ -378,7 +378,7 @@ class webhookModel extends model { $data = $this->getBearychatData($text, $mobile, $email, $objectType, $objectID); } - elseif($webhook->type == 'weixin' or $webhook->type == 'wxRobot') + elseif($webhook->type == 'weixin' or $webhook->type == 'wechatApi') { $data = $this->getWeixinData($title, $text, $mobile); } @@ -546,7 +546,7 @@ class webhookModel extends model { if(!extension_loaded('curl')) die(helper::jsonEncode($this->lang->webhook->error->curl)); - if($webhook->type == 'dingapi' || $webhook->type == 'weixin') + if($webhook->type == 'dingapi' || $webhook->type == 'wechatApi') { if(is_string($webhook->secret)) $webhook->secret = json_decode($webhook->secret); @@ -557,7 +557,7 @@ class webhookModel extends model $dingapi = new dingapi($webhook->secret->appKey, $webhook->secret->appSecret, $webhook->secret->agentId); $result = $dingapi->send($openIdList, $sendData); return json_encode($result); - }elseif ($webhook->type == 'weixin') + }elseif ($webhook->type == 'wechatApi') { $this->app->loadClass('wechatapi', true); $wechatapi = new wechatapi($webhook->secret->appKey, $webhook->secret->appSecret, $webhook->secret->agentId); diff --git a/module/webhook/view/browse.html.php b/module/webhook/view/browse.html.php index e117ebee96..381e3abd15 100644 --- a/module/webhook/view/browse.html.php +++ b/module/webhook/view/browse.html.php @@ -34,7 +34,7 @@ url;?> type == 'dingapi' or $webhook->type == 'weixin') common::printIcon('webhook', 'bind', "webhookID=$id", '', 'list', 'link'); + if($webhook->type == 'dingapi' or $webhook->type == 'wechatApi') common::printIcon('webhook', 'bind', "webhookID=$id", '', 'list', 'link'); common::printIcon('webhook', 'log', "webhookID=$id", '', 'list', 'file-text'); common::printIcon('webhook', 'edit', "webhookID=$id", '', 'list'); if(common::hasPriv('webhook', 'delete')) diff --git a/module/webhook/view/create.html.php b/module/webhook/view/create.html.php index c9813b38e1..872cce5684 100644 --- a/module/webhook/view/create.html.php +++ b/module/webhook/view/create.html.php @@ -59,12 +59,12 @@ webhook->wechatCorpSecret;?> - + webhook->note->wechatSecret;?> webhook->wechatAgentId;?> - + diff --git a/module/webhook/view/edit.html.php b/module/webhook/view/edit.html.php index 1bba3f3054..fe60b8b68f 100644 --- a/module/webhook/view/edit.html.php +++ b/module/webhook/view/edit.html.php @@ -29,7 +29,7 @@ name, "class='form-control'");?> - '> + '> webhook->url;?> url, "class='form-control'");?> webhook->note->typeList, $webhook->type, '');?> @@ -55,21 +55,21 @@ appSecret, "class='form-control'");?> - type == 'weixin'):?> + type == 'wechatApi'):?> secret);?> webhook->wechatCorpId;?> - agentId, "class='form-control'")?> + appKey, "class='form-control'")?> webhook->note->wechatCorpid;?> webhook->wechatCorpSecret;?> - appKey, "class='form-control'")?> - webhook->note->wechatSecret;?> + appSecret, "class='form-control'")?> + webhook->note->wechatCorpSecret;?> webhook->wechatAgentId;?> - appSecret, "class='form-control'")?> + agentId, "class='form-control'")?> @@ -95,7 +95,7 @@ projects, "class='form-control chosen' multiple");?> webhook->note->project;?> - type,") === false):?> + type,") === false):?>