| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- global $app;
- helper::import($app->getModulePath('', 'message') . 'model.php');
- class extmessageModel extends messageModel
- {
- public function send($objectType, $objectID, $actionType, $actionID, $actor = '', $extra = '')
- {
- $this->loadExtension('xuanxuan')->send($objectType, $objectID, $actionType, $actionID, $actor, $extra);
- if(commonModel::isTutorialMode()) return;
- $objectType = strtolower($objectType);
- $messageSetting = $this->config->message->setting;
- if(is_string($messageSetting)) $messageSetting = json_decode($messageSetting, true);
- /* 如果是业需和用需,则使用它们的发信配置。*/
- if($objectType == 'story')
- {
- $story = $this->loadModel('story')->fetchByID($objectID);
- if($story) $objectType = $story->type;
- if($story && $story->status == 'draft') return;
- }
- if(isset($messageSetting['mail']))
- {
- $actions = $messageSetting['mail']['setting'];
- if(isset($actions[$objectType]) && in_array($actionType, $actions[$objectType]))
- {
- /* If it is an api call, get the request method set by the user. */
- global $config;
- $requestType = $config->requestType;
- if(defined('RUN_MODE') && RUN_MODE == 'api')
- {
- $configRoot = $this->app->getConfigRoot();
- include file_exists($configRoot . 'my.php') ? $configRoot . 'my.php' : $configRoot . 'config.php';
- }
- if($objectType == 'feedback' || $objectType == 'ticket')
- {
- $this->loadModel($objectType)->sendmail($objectID, $actionID);
- }
- else
- {
- $this->loadModel('mail')->sendmail($objectID, $actionID);
- }
- if(defined('RUN_MODE') && RUN_MODE == 'api') $config->requestType = $requestType;
- }
- }
- if(isset($messageSetting['webhook']))
- {
- $actions = $messageSetting['webhook']['setting'];
- if(isset($actions[$objectType]) && in_array($actionType, $actions[$objectType])) $this->loadModel('webhook')->send($objectType, $objectID, $actionType, $actionID, $actor);
- }
- if(isset($messageSetting['message']))
- {
- $isBuiltinMethod = true;
- if($this->config->edition != 'open')
- {
- $groupID = $this->loadModel('workflowgroup')->getGroupIDByDataID($objectType, $objectID);
- $method = $this->loadModel('workflowaction')->getByModuleAndAction($objectType, $this->app->rawMethod, $groupID);
- if($method && !$method->buildin) $isBuiltinMethod = false;
- }
- $actions = $messageSetting['message']['setting'];
- if($isBuiltinMethod && isset($actions[$objectType]) && in_array($actionType, $actions[$objectType])) $this->saveNotice($objectType, $objectID, $actionType, $actionID, $actor);
- }
- }
- //**//
- }
|