Merge branch 'sprint/xuanxuan_108' into 'master'
合并小喧喧通知卡片相关代码 See merge request easycorp/zentaopms!4452
This commit is contained in:
@@ -966,8 +966,9 @@ class baseJS
|
||||
{
|
||||
$cancleAction = "$cancleTarget.location = '$cancleURL';";
|
||||
}
|
||||
|
||||
$js .= <<<EOT
|
||||
if(strpos($_SERVER['HTTP_USER_AGENT'], 'xuanxuan') === false)
|
||||
{
|
||||
$js .= <<<EOT
|
||||
if(confirm("$message"))
|
||||
{
|
||||
$confirmAction
|
||||
@@ -977,6 +978,12 @@ else
|
||||
$cancleAction
|
||||
}
|
||||
EOT;
|
||||
}
|
||||
else
|
||||
{
|
||||
$js .= $confirmAction;
|
||||
}
|
||||
|
||||
$js .= self::end();
|
||||
return $js;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ class actionModel extends model
|
||||
if($this->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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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 = '构建日志';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
class xuanxuanMessage extends messageModel
|
||||
{
|
||||
public function send($objectType, $objectID, $actionType, $actionID, $actor = '')
|
||||
public function send($objectType, $objectID, $actionType, $actionID, $actor = '', $extra = '')
|
||||
{
|
||||
$messageSetting = $this->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';
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
<?php
|
||||
$this->loadExtension('xuanxuan')->send($objectType, $objectID, $actionType, $actionID, $actor);
|
||||
$this->loadExtension('xuanxuan')->send($objectType, $objectID, $actionType, $actionID, $actor, $extra);
|
||||
|
||||
Reference in New Issue
Block a user