diff --git a/lib/base/front/front.class.php b/lib/base/front/front.class.php index fff699c0a3..b71849b423 100644 --- a/lib/base/front/front.class.php +++ b/lib/base/front/front.class.php @@ -966,8 +966,9 @@ class baseJS { $cancleAction = "$cancleTarget.location = '$cancleURL';"; } - - $js .= <<post->uid) $this->file->updateObjectID($this->post->uid, $objectID, $objectType); /* Call the message notification function. */ - $this->loadModel('message')->send(strtolower($objectType), $objectID, $actionType, $actionID, $actor); + $this->loadModel('message')->send(strtolower($objectType), $objectID, $actionType, $actionID, $actor, $extra); /* Add index for global search. */ $this->saveIndex($objectType, $objectID, $actionType); diff --git a/module/message/model.php b/module/message/model.php index a5f2cccd7f..b640916bc4 100755 --- a/module/message/model.php +++ b/module/message/model.php @@ -59,10 +59,12 @@ class messageModel extends model * @param int $objectID * @param string $actionType * @param int $actionID + * @param string $actor + * @param string $extra * @access public * @return void */ - public function send($objectType, $objectID, $actionType, $actionID, $actor = '') + public function send($objectType, $objectID, $actionType, $actionID, $actor = '', $extra = '') { $objectType = strtolower($objectType); $messageSetting = $this->config->message->setting; diff --git a/xuanxuan/extension/xuan/im/ext/model/class/xuanxuan.class.php b/xuanxuan/extension/xuan/im/ext/model/class/xuanxuan.class.php index f134a049b4..8391277656 100644 --- a/xuanxuan/extension/xuan/im/ext/model/class/xuanxuan.class.php +++ b/xuanxuan/extension/xuan/im/ext/model/class/xuanxuan.class.php @@ -207,14 +207,22 @@ class xuanxuanIm extends imModel foreach($userMessages as $message) { /* Group by $message->content->content->objectType, ...->parentType, ...->action, ...->actor */ - $contentData = json_decode($message->content); - $contentData = json_decode($contentData->content); + $contentDataOuter = json_decode($message->content); + $contentData = json_decode($contentDataOuter->content); if(isset($contentData->contentType) && $contentData->contentType == 'text') { $messageGroups[$contentData->contentType][] = $message; continue; } - $messageGroups["$contentData->objectType-$contentData->parentType-$contentData->action-$contentData->actor"][] = $message; + if ($contentData->objectType == 'story' && $contentData->action == 'reviewed') + { + $extra = explode(',', $contentDataOuter->extra)[0]; + $messageGroups["$contentData->objectType-$contentData->parentType-$contentData->action-$contentData->actor-$extra"][] = $message; + } + else + { + $messageGroups["$contentData->objectType-$contentData->parentType-$contentData->action-$contentData->actor"][] = $message; + } } foreach($messageGroups as $groupKey => $messages) { @@ -225,25 +233,24 @@ class xuanxuanIm extends imModel $notificationContent = json_decode($notification->content); $notificationInnerContent = json_decode($notificationContent->content); - /* Inner content: array($parentID => array($content1, $content2)) */ - $objectGroups = array($notificationInnerContent->parent => array($notificationInnerContent)); + /* Inner content: array($id => array($content1, $content2)) */ + $objectGroups = array($notificationInnerContent->id => array($notificationInnerContent)); foreach($messages as $message) { $messageContent = json_decode($message->content); $messageInnerContent = json_decode($messageContent->content); - $objectGroups[$messageInnerContent->parent][] = $messageInnerContent; + $objectGroups[$messageInnerContent->id][] = $messageInnerContent; } - $objectTotal = 0; - foreach($objectGroups as $parent => $objectGroup) + foreach($objectGroups as $id => $objectGroup) { $object = current($objectGroup); $object->count = count($objectGroup); $object->url = $object->parentURL; unset($object->title); - $objectGroups[$parent] = $object; - $objectTotal += $object->count; + $objectGroups[$id] = $object; } + $objectTotal = count($objectGroups); $notificationContent->content = json_encode(array_values($objectGroups)); /* Hack alert: title count replacement currently assumes that default count is 1. */ $notification->title = substr_replace($notification->title, "$objectTotal", strrpos($notification->title, '1'), 1); diff --git a/xuanxuan/extension/xuan/message/ext/lang/de/xuanxuan.php b/xuanxuan/extension/xuan/message/ext/lang/de/xuanxuan.php index 7fbcf17e93..8fbd39f334 100644 --- a/xuanxuan/extension/xuan/message/ext/lang/de/xuanxuan.php +++ b/xuanxuan/extension/xuan/message/ext/lang/de/xuanxuan.php @@ -3,7 +3,10 @@ $lang->message->typeList['xuanxuan'] = 'Chat'; $lang->message->sender = 'ZenTao'; -$lang->message->notifyTitle = '%s %s%d %s'; +$lang->message->notifyTitle = '%s %s%d %s'; +$lang->message->notifyPassTitle = '%s passed %d stories'; +$lang->message->notifyClarifyTitle = '%s clarify %d stories'; +$lang->message->notifyRejectTitle = '%s reject %d stories'; $lang->message->mr = new stdClass(); $lang->message->mr->logTitle = 'Build log'; diff --git a/xuanxuan/extension/xuan/message/ext/lang/en/xuanxuan.php b/xuanxuan/extension/xuan/message/ext/lang/en/xuanxuan.php index 7fbcf17e93..8fbd39f334 100644 --- a/xuanxuan/extension/xuan/message/ext/lang/en/xuanxuan.php +++ b/xuanxuan/extension/xuan/message/ext/lang/en/xuanxuan.php @@ -3,7 +3,10 @@ $lang->message->typeList['xuanxuan'] = 'Chat'; $lang->message->sender = 'ZenTao'; -$lang->message->notifyTitle = '%s %s%d %s'; +$lang->message->notifyTitle = '%s %s%d %s'; +$lang->message->notifyPassTitle = '%s passed %d stories'; +$lang->message->notifyClarifyTitle = '%s clarify %d stories'; +$lang->message->notifyRejectTitle = '%s reject %d stories'; $lang->message->mr = new stdClass(); $lang->message->mr->logTitle = 'Build log'; diff --git a/xuanxuan/extension/xuan/message/ext/lang/fr/xuanxuan.php b/xuanxuan/extension/xuan/message/ext/lang/fr/xuanxuan.php index 7fbcf17e93..8fbd39f334 100644 --- a/xuanxuan/extension/xuan/message/ext/lang/fr/xuanxuan.php +++ b/xuanxuan/extension/xuan/message/ext/lang/fr/xuanxuan.php @@ -3,7 +3,10 @@ $lang->message->typeList['xuanxuan'] = 'Chat'; $lang->message->sender = 'ZenTao'; -$lang->message->notifyTitle = '%s %s%d %s'; +$lang->message->notifyTitle = '%s %s%d %s'; +$lang->message->notifyPassTitle = '%s passed %d stories'; +$lang->message->notifyClarifyTitle = '%s clarify %d stories'; +$lang->message->notifyRejectTitle = '%s reject %d stories'; $lang->message->mr = new stdClass(); $lang->message->mr->logTitle = 'Build log'; diff --git a/xuanxuan/extension/xuan/message/ext/lang/zh-cn/xuanxuan.php b/xuanxuan/extension/xuan/message/ext/lang/zh-cn/xuanxuan.php index 32599f2ce7..7503db0276 100644 --- a/xuanxuan/extension/xuan/message/ext/lang/zh-cn/xuanxuan.php +++ b/xuanxuan/extension/xuan/message/ext/lang/zh-cn/xuanxuan.php @@ -3,7 +3,10 @@ $lang->message->typeList['xuanxuan'] = '聊天'; $lang->message->sender = '禅道项目管理'; -$lang->message->notifyTitle = '%s %s%d个%s'; +$lang->message->notifyTitle = '%s %s%d个%s'; +$lang->message->notifyPassTitle = '%s 通过了%d个研发需求'; +$lang->message->notifyClarifyTitle = '%s 驳回了%d个研发需求'; +$lang->message->notifyRejectTitle = '%s 拒绝了%d个研发需求'; $lang->message->mr = new stdClass(); $lang->message->mr->logTitle = '构建日志'; diff --git a/xuanxuan/extension/xuan/message/ext/model/class/xuanxuan.class.php b/xuanxuan/extension/xuan/message/ext/model/class/xuanxuan.class.php index ad3d677375..5ec9449fb8 100644 --- a/xuanxuan/extension/xuan/message/ext/model/class/xuanxuan.class.php +++ b/xuanxuan/extension/xuan/message/ext/model/class/xuanxuan.class.php @@ -1,7 +1,7 @@ config->message->setting; if(is_string($messageSetting)) $messageSetting = json_decode($messageSetting, true); @@ -44,6 +44,22 @@ class xuanxuanMessage extends messageModel ->fetch(); $field = $this->config->action->objectNameFields[$objectType]; $title = $objectType == 'mr' ? '' : sprintf($this->lang->message->notifyTitle, $this->app->user->realname, $this->lang->action->label->$actionType, 1, $this->lang->action->objectTypes[$objectType]); + if ($objectType == 'story' && $actionType == 'reviewed' && !empty($extra)) + { + $notifyType = strtolower(explode(',', $extra)[0]); + if ($notifyType == 'pass') + { + $title = $objectType == 'mr' ? '' : sprintf($this->lang->message->notifyPassTitle, $this->app->user->realname, 1); + } + else if($notifyType == 'clarify') + { + $title = $objectType == 'mr' ? '' : sprintf($this->lang->message->notifyClarifyTitle, $this->app->user->realname, 1); + } + else if($notifyType == 'reject') + { + $title = $objectType == 'mr' ? '' : sprintf($this->lang->message->notifyRejectTitle, $this->app->user->realname, 1); + } + } $server = $this->loadModel('im')->getServer('zentao'); $onlybody = isset($_GET['onlybody']) ? $_GET['onlybody'] : ''; @@ -52,7 +68,7 @@ class xuanxuanMessage extends messageModel $url = $server . helper::createLink($objectType == 'kanbancard' ? 'kanban' : $objectType, 'view', "id=$dataID", 'html'); $target = ''; - if(!empty($object->assignedTo)) $target .= $object->assignedTo; + if(!empty($object->assignedTo)) $target .= $object->assignedTo == 'closed' ? $object->openedBy : $object->assignedTo; if(!empty($object->mailto)) $target .= ",{$object->mailto}"; if(($objectType == 'mr' or $objectType == 'kanbancard') and !empty($object->createdBy)) $target .= ",{$object->createdBy}"; $target = trim($target, ','); @@ -130,6 +146,7 @@ class xuanxuanMessage extends messageModel $contentData->actions = array(); $contentData->url = "xxc:openInApp/zentao-integrated/" . urlencode($url); } + $contentData->extra = $extra; $content = json_encode($contentData); $avatarUrl = $server . $this->app->getWebRoot() . 'favicon.ico'; diff --git a/xuanxuan/extension/xuan/message/ext/model/hook/send.xuanxuan.php b/xuanxuan/extension/xuan/message/ext/model/hook/send.xuanxuan.php index 23d82e1381..ef1529ceaa 100644 --- a/xuanxuan/extension/xuan/message/ext/model/hook/send.xuanxuan.php +++ b/xuanxuan/extension/xuan/message/ext/model/hook/send.xuanxuan.php @@ -1,2 +1,2 @@ loadExtension('xuanxuan')->send($objectType, $objectID, $actionType, $actionID, $actor); +$this->loadExtension('xuanxuan')->send($objectType, $objectID, $actionType, $actionID, $actor, $extra);