From a34f925fc57b57f8927638b07122ad224fa480ed Mon Sep 17 00:00:00 2001 From: wangyidong Date: Fri, 7 Dec 2018 14:51:47 +0800 Subject: [PATCH 01/10] * finish task #5158. --- xuanxuan/module/message/ext/lang/en/xuanxuan.php | 2 ++ xuanxuan/module/message/ext/lang/zh-cn/xuanxuan.php | 2 ++ xuanxuan/module/message/ext/model/class/xuanxuan.class.php | 4 +++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/xuanxuan/module/message/ext/lang/en/xuanxuan.php b/xuanxuan/module/message/ext/lang/en/xuanxuan.php index bf45e30825..2cc831d314 100644 --- a/xuanxuan/module/message/ext/lang/en/xuanxuan.php +++ b/xuanxuan/module/message/ext/lang/en/xuanxuan.php @@ -1,2 +1,4 @@ message->typeList['xuanxuan'] = 'Xuanxuan'; + +$lang->message->sender = 'ZentaoPMS'; diff --git a/xuanxuan/module/message/ext/lang/zh-cn/xuanxuan.php b/xuanxuan/module/message/ext/lang/zh-cn/xuanxuan.php index d5daca9d76..abff61c208 100644 --- a/xuanxuan/module/message/ext/lang/zh-cn/xuanxuan.php +++ b/xuanxuan/module/message/ext/lang/zh-cn/xuanxuan.php @@ -1,2 +1,4 @@ message->typeList['xuanxuan'] = '喧喧'; + +$lang->message->sender = '禅道项目管理'; diff --git a/xuanxuan/module/message/ext/model/class/xuanxuan.class.php b/xuanxuan/module/message/ext/model/class/xuanxuan.class.php index a92ecae9a1..4051ae9bc8 100644 --- a/xuanxuan/module/message/ext/model/class/xuanxuan.class.php +++ b/xuanxuan/module/message/ext/model/class/xuanxuan.class.php @@ -21,8 +21,10 @@ class xuanxuanMessage extends messageModel if(!empty($object->assignedTo)) $target .= $object->assignedTo; if(!empty($object->mailto)) $target .= ",{$object->mailto}"; $target = trim($target, ','); + $target = $this->dao->select('id')->from(TABLE_USER)->where('account')->in($target)->fetchAll('id'); + $target = array_keys($target); - if($target) $this->loadModel('chat')->createNotify($target, $text, '', $text, 'text', $url); + if($target) $this->loadModel('chat')->createNotify($target, $text, '', '', 'text', $url, array(), array('id' => 'zentao', 'realname' => $this->lang->message->sender, 'name' => $this->lang->message->sender)); } } } From 3e74b163984954998b0373e6554af4c2603324d7 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Fri, 7 Dec 2018 14:52:59 +0800 Subject: [PATCH 02/10] * adjust for Notification. --- module/common/view/footer.html.php | 2 +- module/message/control.php | 6 ++++-- module/testtask/model.php | 6 +++--- www/js/my.full.js | 22 ++++++++++++++++++++-- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/module/common/view/footer.html.php b/module/common/view/footer.html.php index 3f8a1bae88..410772b229 100755 --- a/module/common/view/footer.html.php +++ b/module/common/view/footer.html.php @@ -48,7 +48,7 @@ $(function() if(data) { if(typeof data == 'string') data = $.parseJSON(data); - if(typeof data.message == 'string') notifyMessage(data.message); + if(typeof data.message == 'string') notifyMessage(data); } } }); diff --git a/module/message/control.php b/module/message/control.php index c214f35193..9b36897266 100644 --- a/module/message/control.php +++ b/module/message/control.php @@ -86,11 +86,13 @@ class message extends control $this->dao->update(TABLE_NOTIFY)->set('status')->eq('sended')->set('sendTime')->eq(helper::now())->where('id')->in($idList)->exec(); foreach($todos as $todo) $messages .= $todo->data . $newline; - if($windowBlur) $messages = strip_tags($messages); if($windowBlur) { - echo json_encode(array('message' => $messages)); + preg_match_all("/ $messages, 'url' => $link)); } else { diff --git a/module/testtask/model.php b/module/testtask/model.php index 31ea1eb449..ef8c9daeb4 100644 --- a/module/testtask/model.php +++ b/module/testtask/model.php @@ -1338,15 +1338,15 @@ class testtaskModel extends model /* Set email title. */ if($actionType == 'opened') { - return sprintf($this->lang->testtask->mail->create->title, $this->app->user->realname, $testtask->id, $testtask->name); + return sprintf($this->lang->testtask->mail->create->title, $this->app->user->realname, $testtask->id, $testtask->title); } elseif($actionType == 'closed') { - return sprintf($this->lang->testtask->mail->close->title, $this->app->user->realname, $testtask->id, $testtask->name); + return sprintf($this->lang->testtask->mail->close->title, $this->app->user->realname, $testtask->id, $testtask->title); } else { - return sprintf($this->lang->testtask->mail->edit->title, $this->app->user->realname, $testtask->id, $testtask->name); + return sprintf($this->lang->testtask->mail->edit->title, $this->app->user->realname, $testtask->id, $testtask->title); } } diff --git a/www/js/my.full.js b/www/js/my.full.js index 2b1302d749..7c8e3bb17c 100644 --- a/www/js/my.full.js +++ b/www/js/my.full.js @@ -667,17 +667,35 @@ function notifyMessage(data) { if(window.Notification) { + var notify = null; + + message = data; + if(typeof data.message == 'string') message = data.message; if(Notification.permission == "granted") { - new Notification("", {body:data}); + notify = new Notification("", {body:message, tag:'zentao', data:data}); } else if(Notification.permission != "denied") { Notification.requestPermission(function(permission) { - new Notification("", {body:data}); + notify = new Notification("", {body:message, tag:'zentao', data:data}); }); } + + if(notify) + { + notify.onclick = function() + { + window.focus(); + if(typeof notify.data.url == 'string' && notify.data.url) window.location.href = notify.data.url; + notify.close(); + } + setTimeout(function() + { + notify.close(); + }, 3000); + } } } From ba34a24db6a7898cef6af5bb88599d677ad820f5 Mon Sep 17 00:00:00 2001 From: chenfeiCF Date: Sun, 9 Dec 2018 19:16:09 +0800 Subject: [PATCH 03/10] * Code for task #5162. --- module/misc/control.php | 150 +++++++++++++++-------- module/misc/lang/zh-cn.php | 5 +- module/misc/view/downloadclient.html.php | 46 +++++-- 3 files changed, 141 insertions(+), 60 deletions(-) diff --git a/module/misc/control.php b/module/misc/control.php index 5fcff88926..1fcc6581c3 100644 --- a/module/misc/control.php +++ b/module/misc/control.php @@ -90,56 +90,44 @@ class misc extends control * @access public * @return void */ - public function downloadClient($os = '', $confirm = 'no', $send = 'no') + public function downloadClient($action = 'selectPackage', $os = '', $uid = '') { - if($_POST) die(js::locate($this->createLink('misc', 'downloadClient', "os={$this->post->os}&confirm=yes"), 'parent')); - - if($send == 'yes') + if($_POST) { - $clientDir = $this->app->getBasePath() . 'tmp/cache/client/tmp/'; + $os = $this->post->os; + die(js::locate($this->createLink('misc', 'downloadClient', "action=getPackage&os=$os"), 'parent')); + } + + if($action == 'getPackage') + { + $this->view->os = $os; + $this->view->uid = uniqid(); + } + + if($action == 'downloadPackage') + { + $clientDir = $this->app->getBasePath() . 'tmp/cache/client/' . "$uid/"; if(!is_dir($clientDir)) mkdir($clientDir, 0755, true); - /* write login info into config file. */ - $defaultUser = new stdclass(); - $defaultUser->server = common::getSysURL(); - $defaultUser->account = $this->app->user->account; - - $loginInfo = new stdclass(); - $loginInfo->ui = $defaultUser; - $loginInfo = json_encode($loginInfo); - - $loginFile = $clientDir . 'config.json'; - file_put_contents($loginFile, $loginInfo); - - define('PCLZIP_TEMPORARY_DIR', $clientDir); - $this->app->loadClass('pclzip', true); $clientFile = $clientDir . 'zentaoClient.zip'; - $archive = new pclzip($clientFile); - - if($os == 'mac') + $zipContent = file_get_contents($clientFile); + if(is_dir($clientDir)) { - $result = $archive->add($loginFile, PCLZIP_OPT_REMOVE_ALL_PATH, PCLZIP_OPT_ADD_PATH, 'xuanxuan.app/Contents/Resouces'); + $zfile = $this->app->loadClass('zfile'); + $zfile->removeDir($clientDir); } - else - { - $result = $archive->add($loginFile, PCLZIP_OPT_REMOVE_ALL_PATH, PCLZIP_OPT_ADD_PATH, 'resources/build-in'); - } - - if($result == 0) die("Error : " . $archive->errorInfo(true)); - - unlink($clientDir); $this->fetch('file', 'sendDownHeader', array('fileName' => 'client.zip', 'zip', $zipContent)); } - $this->view->os = $os; - $this->view->confirm = $confirm; + $this->view->action = $action; $this->display(); } - public function ajaxGetClient($os) + public function ajaxGetClient($os = '', $uid = '') { set_time_limit (0); + session_write_close(); $clientDir = $this->app->getBasePath() . 'tmp/cache/client/'; if(!is_dir($clientDir)) mkdir($clientDir, 0755, true); @@ -150,36 +138,41 @@ class misc extends control if($os == 'linux32') $clientName = "xuanxuan.linux.ia32.zip"; if($os == 'mac') $clientName = "xuanxuan.mac.zip"; - $tmpDir = $clientDir . '/tmp/'; + $tmpDir = $clientDir . "/$uid/"; if(!is_dir($tmpDir)) mkdir($tmpDir, 0755, true); + $needCache = false; $packageFile = $clientDir . $clientName; if(!file_exists($packageFile)) { - $handle = "http://dl.pts.com/xuanxuan/xuanxuan.win64.zip"; + $url = "http://dl.pts.com/xuanxuan/"; + $xxFile = $url . $clientName; + $needCache = true; } else { - $handle = $packageFile; + $xxFile = $packageFile; } - $client = $tmpDir . 'zentaoClient.zip'; + $clientFile = $tmpDir . 'zentaoClient.zip'; - $clientHd = fopen($handle, "rb"); - if($clientHd) + $xxHd= fopen($xxFile, "rb"); + if($xxHd) { - $newf = fopen($client, "wb"); - if($newf) + $clientHd = fopen($clientFile, "wb"); + if($clientHd) { - while(!feof($clientHd)) + while(!feof($xxHd)) { - fwrite($newf, fread($clientHd, 1024 * 8 ), 1024 * 8 ); + fwrite($clientHd, fread($xxHd, 1024 * 8 ), 1024 * 8 ); } } } - if ($clientHd) fclose($clientHd); - if ($newf) fclose($newf); + if($xxHd) fclose($xxHd); + if($clientHd) fclose($clientHd); + + if($needCache) file_put_contents($packageFile, file_get_contents($clientFile)); $response = array(); $response['result'] = 'success'; @@ -187,10 +180,71 @@ class misc extends control $this->send($response); } - public function ajaxGetDownProgress($os = '') + public function ajaxSetClientConfig($os = '', $uid = '') { + $response['result'] = 'success'; + + $clientDir = $this->app->getBasePath() . 'tmp/cache/client/' . "$uid/"; + if(!is_dir($clientDir)) mkdir($clientDir, 0755, true); + + /* write login info into config file. */ + $defaultUser = new stdclass(); + $defaultUser->server = common::getSysURL(); + $defaultUser->account = $this->app->user->account; + + $loginInfo = new stdclass(); + $loginInfo->ui = $defaultUser; + $loginInfo = json_encode($loginInfo); + + $loginFile = $clientDir . 'config.json'; + file_put_contents($loginFile, $loginInfo); + + define('PCLZIP_TEMPORARY_DIR', $clientDir); + $this->app->loadClass('pclzip', true); + $clientFile = $clientDir . 'zentaoClient.zip'; + $archive = new pclzip($clientFile); + + if($os == 'mac') + { + $result = $archive->add($loginFile, PCLZIP_OPT_REMOVE_ALL_PATH, PCLZIP_OPT_ADD_PATH, 'xuanxuan.app/Contents/Resouces'); + } + else + { + $result = $archive->add($loginFile, PCLZIP_OPT_REMOVE_ALL_PATH, PCLZIP_OPT_ADD_PATH, 'resources/build-in'); + } + + $zipContent = file_get_contents($clientFile); + + if($result == 0) + { + $response['result'] = 'fail'; + $response['message'] = $archive->errorInfo(true); + + if(is_dir($clientDir)) + { + $zfile = $this->app->loadClass('zfile'); + $zfile->removeDir($clientDir); + } + $this->send($response); + } + + $this->send($response); + } + + public function ajaxGetDownProgress($os = '', $uid = '') + { + $packageFile = $this->app->getBasePath() . 'tmp/cache/client/' . $uid . '/zentaoClient.zip'; + + $size = 0; + if(file_exists($packageFile)) + { + $size = filesize($packageFile); + $size = $size ? round($size / 1048576, 2) : 0; + } + $response = array(); - $response['result'] = 'unfinished'; + $response['result'] = 'success'; + $response['size'] = $size; $this->send($response); } diff --git a/module/misc/lang/zh-cn.php b/module/misc/lang/zh-cn.php index 24eb26bd7c..5b5fec75f3 100644 --- a/module/misc/lang/zh-cn.php +++ b/module/misc/lang/zh-cn.php @@ -16,7 +16,10 @@ $lang->misc->api = 'https://api.zentao.net'; $lang->misc->enApi = 'http://api.zentao.pm'; $lang->misc->client = new stdclass(); -$lang->misc->client->download = '下载'; +$lang->misc->client->download = '下载'; +$lang->misc->client->downloading = '正在获取安装包:'; +$lang->misc->client->downloaded = '成功获取安装包'; +$lang->misc->client->setConfig = '成功设置配置信息'; $lang->misc->client->osList['windows64'] = 'Windows 64位'; $lang->misc->client->osList['windows32'] = 'Windows 32位'; diff --git a/module/misc/view/downloadclient.html.php b/module/misc/view/downloadclient.html.php index 8f0dda4e65..c71de2f1cf 100644 --- a/module/misc/view/downloadclient.html.php +++ b/module/misc/view/downloadclient.html.php @@ -3,7 +3,7 @@

downloadClient;?>

- +
@@ -13,31 +13,55 @@
- misc->client->download, '', 'btn btn-primary');?> + select, '', 'btn btn-primary');?>
- + + -
+ +
+
    +
  • misc->client->downloading;?>0M
  • + + + +