From 280fe761f5c8ee318db83cdb3a154be1ff7c6798 Mon Sep 17 00:00:00 2001 From: "chencongzhi520@gmail.com" Date: Mon, 17 Dec 2012 09:06:33 +0000 Subject: [PATCH] * code for task#957. --- module/common/lang/en.php | 1 + module/common/lang/zh-cn.php | 1 + module/common/view/footer.html.php | 1 + module/misc/control.php | 32 ++++++++++++++++++++++++++++++ 4 files changed, 35 insertions(+) diff --git a/module/common/lang/en.php b/module/common/lang/en.php index 74c23fc6b1..07520bf6e6 100644 --- a/module/common/lang/en.php +++ b/module/common/lang/en.php @@ -353,6 +353,7 @@ $lang->chinaScrum = "Training "; $lang->donate = "Donate "; $lang->proVersion = "Try pro version! "; +$lang->downNotify = "Down notify"; $lang->suhosinInfo = "Warming:data is too large! Please enlarge the setting of sohusin.post.max_vars and sohusin.request.max_vars in php.ini. Otherwise partial data can't be saved."; diff --git a/module/common/lang/zh-cn.php b/module/common/lang/zh-cn.php index ed1d183923..36bd7235e4 100644 --- a/module/common/lang/zh-cn.php +++ b/module/common/lang/zh-cn.php @@ -353,6 +353,7 @@ $lang->chinaScrum = "培训 "; $lang->donate = "捐赠 "; $lang->proVersion = "购买专业版(特惠)! "; +$lang->downNotify = "下载桌面提醒"; $lang->suhosinInfo = "警告:数据太多,请在php.ini中修改sohusin.post.max_vars和sohusin.request.max_vars(设置更大的数)。 保存并重新启动apache,否则会造成部分数据无法保存。"; diff --git a/module/common/view/footer.html.php b/module/common/view/footer.html.php index d6e8fa4651..979cae6696 100644 --- a/module/common/view/footer.html.php +++ b/module/common/view/footer.html.php @@ -11,6 +11,7 @@ Powered by ZenTaoPMS (version;?>) proVersion;?> + createLink('misc', 'downNotify'), $lang->downNotify);?> diff --git a/module/misc/control.php b/module/misc/control.php index cd08c04dd1..b87cd51d26 100644 --- a/module/misc/control.php +++ b/module/misc/control.php @@ -83,4 +83,36 @@ class misc extends control echo $this->misc->hello(); echo $this->misc->hello2(); } + + /** + * Down notify. + * + * @access public + * @return void + */ + public function downNotify() + { + $notifyDir = $this->app->getBasePath() . 'www/data/notify/'; + $packageFile = $notifyDir . 'notify.zip'; + $tmpDir = $notifyDir . 'notify'; + $loginFile = $tmpDir . '/notify/logininfo'; + + $this->app->loadClass('pclzip', true); + $sourceZip = new pclzip($packageFile); + $files = $sourceZip->extract(PCLZIP_OPT_PATH, $notifyDir); + if($files == 0) die("Error : ".$archive->errorInfo(true)); + + $currentUser = $this->app->user; + $loginInfo = json_encode(array('account' => $currentUser->account, 'password' => $currentUser->password, 'zentaoRoot' => 'http://' . $this->config->default->domain)); + file_put_contents($loginFile, $loginInfo); + + unlink($packageFile); + $newZip = new pclzip($packageFile); + if($newZip->create($tmpDir, PCLZIP_OPT_REMOVE_PATH, $notifyDir)) + { + $this->zfile = $this->app->loadClass('zfile'); + $this->zfile->removeDir($tmpDir); + } + $this->fetch('file', 'sendDownHeader', array('fileName' => 'notify.zip', 'zip', file_get_contents($packageFile))); + } }