From d4c77d8769947614bcfd44a266c2bd73bd99efa2 Mon Sep 17 00:00:00 2001 From: daitingting Date: Wed, 10 May 2017 15:46:21 +0800 Subject: [PATCH 1/2] * Adjust codes. --- module/bug/config.php | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/module/bug/config.php b/module/bug/config.php index 577157c0a7..a90f8faefe 100644 --- a/module/bug/config.php +++ b/module/bug/config.php @@ -23,7 +23,6 @@ $config->bug->list->allFields = 'id, module, project, story, task, lastEditedBy, lastEditedDate'; -if($config->global->flow == 'onlyTest') $config->bug->list->allFields = str_replace(array('project, ', 'story, ', 'task,'), '', $config->bug->list->allFields); $config->bug->list->defaultFields = 'id,severity,pri,title,openedBy,assignedTo,resolvedBy,resolution'; $config->bug->list->exportFields = 'id, product, branch, module, project, story, task, @@ -37,7 +36,6 @@ $config->bug->list->exportFields = 'id, product, branch, module, project, story, case, lastEditedBy, lastEditedDate, files'; -if($config->global->flow == 'onlyTest') $config->bug->list->exportFields = str_replace(array('project, ', 'story, ', 'task,'), '', $config->bug->list->exportFields); $config->bug->list->customCreateFields = 'project,story,task,pri,severity,os,browser,deadline,mailto,keywords'; $config->bug->list->customBatchCreateFields = 'module,project,steps,type,pri,severity,os,browser,keywords'; @@ -50,9 +48,13 @@ $config->bug->custom->batchEditFields = 'type,severity,pri,branch,assignedTo,d if($config->global->flow == 'onlyTest') { + $config->bug->list->allFields = str_replace(array('project, ', 'story, ', 'task,'), '', $config->bug->list->allFields); + $config->bug->list->exportFields = str_replace(array('project, ', 'story, ', 'task,'), '', $config->bug->list->exportFields); + $config->bug->list->customCreateFields = str_replace(array('project,', 'story,', 'task,'), '', $config->bug->list->customCreateFields); $config->bug->list->customBatchCreateFields = str_replace('project,', '', $config->bug->list->customBatchCreateFields); - $config->bug->custom->batchCreateFields = str_replace('project,', '', $config->bug->custom->batchCreateFields); + + $config->bug->custom->batchCreateFields = str_replace('project,', '', $config->bug->custom->batchCreateFields); } $config->bug->editor = new stdclass(); @@ -79,9 +81,9 @@ $config->bug->search['fields']['confirmed'] = $lang->bug->confirmed; $config->bug->search['fields']['product'] = $lang->bug->product; $config->bug->search['fields']['branch'] = ''; -$config->bug->search['fields']['plan'] = $lang->bug->productplan; + $config->bug->search['fields']['plan'] = $lang->bug->productplan; $config->bug->search['fields']['module'] = $lang->bug->module; -if($config->global->flow != 'onlyTest') $config->bug->search['fields']['project'] = $lang->bug->project; +$config->bug->search['fields']['project'] = $lang->bug->project; $config->bug->search['fields']['severity'] = $lang->bug->severity; $config->bug->search['fields']['pri'] = $lang->bug->pri; @@ -92,11 +94,8 @@ $config->bug->search['fields']['resolution'] = $lang->bug->resolution; $config->bug->search['fields']['activatedCount'] = $lang->bug->activatedCount; -if($config->global->flow != 'onlyTest') -{ - $config->bug->search['fields']['toTask'] = $lang->bug->toTask; - $config->bug->search['fields']['toStory'] = $lang->bug->toStory; -} +$config->bug->search['fields']['toTask'] = $lang->bug->toTask; +$config->bug->search['fields']['toStory'] = $lang->bug->toStory; $config->bug->search['fields']['openedBy'] = $lang->bug->openedBy; $config->bug->search['fields']['closedBy'] = $lang->bug->closedBy; @@ -114,6 +113,14 @@ $config->bug->search['fields']['closedDate'] = $lang->bug->closedDate; $config->bug->search['fields']['lastEditedDate'] = $lang->bug->lastEditedDateAB; $config->bug->search['fields']['deadline'] = $lang->bug->deadline; +if($config->global->flow != 'onlyTest') +{ + unset($config->bug->search['fields']['project']); + unset($config->bug->search['fields']['plan']); + unset($config->bug->search['fields']['toTask']); + unset($config->bug->search['fields']['toStory']); +} + $config->bug->search['params']['title'] = array('operator' => 'include', 'control' => 'input', 'values' => ''); $config->bug->search['params']['keywords'] = array('operator' => 'include', 'control' => 'input', 'values' => ''); $config->bug->search['params']['steps'] = array('operator' => 'include', 'control' => 'input', 'values' => ''); From 19e38659635f1ba382c6c3ae782bac1c30f0bfd9 Mon Sep 17 00:00:00 2001 From: chenfeiCF Date: Thu, 11 May 2017 08:59:19 +0800 Subject: [PATCH 2/2] * adjust for task #3000. --- module/file/control.php | 6 +- module/file/model.php | 109 +++++++------------------ module/file/view/uploadimages.html.php | 11 ++- www/js/uploader/min.js | 12 +-- 4 files changed, 46 insertions(+), 92 deletions(-) diff --git a/module/file/control.php b/module/file/control.php index c6a04b61d5..1e1320664c 100644 --- a/module/file/control.php +++ b/module/file/control.php @@ -366,7 +366,7 @@ class file extends control } /** - * Upload zip of Images. + * Upload Images. * * @param string $module * @param string $params @@ -386,14 +386,14 @@ class file extends control if($_FILES) { - $file = $this->file->getUploadImageFile('file'); + $file = $this->file->getUploadFile('file'); if(!$file) die(json_encode(array('result' => 'fail', 'message' => $this->lang->error->noData))); if(empty($file['extension']) or !in_array($file['extension'], $this->config->file->imageExtensions)) { die(json_encode(array('result' => 'fail', 'message' => $this->lang->file->errorFileFormate))); } - $imageFile = $this->file->saveUploadImageFile($file, $uid); + $imageFile = $this->file->saveUploadFile($file, $uid); if($imageFile === false) { die(json_encode(array('result' => 'fail', 'message' => $this->lang->file->errorFileMove))); diff --git a/module/file/model.php b/module/file/model.php index 60ccc86013..871563a383 100644 --- a/module/file/model.php +++ b/module/file/model.php @@ -172,13 +172,13 @@ class fileModel extends model } /** - * get uploaded image file from zui.uploader. + * get uploaded file from zui.uploader. * * @param string $htmlTagName * @access public * @return array */ - public function getUploadImageFile($htmlTagName = 'file') + public function getUploadFile($htmlTagName = 'file') { if(!isset($_FILES[$htmlTagName]) || empty($_FILES[$htmlTagName]['name'])) return; @@ -208,70 +208,70 @@ class fileModel extends model } /** - * Save uploaded image file. + * Save uploaded file from zui.uploader. * * @param int $file * @param int $uid * @access public * @return array|bool */ - public function saveUploadImageFile($file, $uid) + public function saveUploadFile($file, $uid) { - $imageFile = array(); + $uploadFile = array(); - $cachePath = $this->app->getCacheRoot() . 'uploadimages/'; - if(!is_dir($cachePath)) mkdir($cachePath, 0777, true); + $tmpFilePath = $this->app->getTmpRoot() . 'uploadfiles/'; + if(!is_dir($tmpFilePath)) mkdir($tmpFilePath, 0777, true); - $imageFilePath = $cachePath . $uid . '/'; - if(!is_dir($imageFilePath)) mkdir($imageFilePath); + $tmpFileSavePath = $tmpFilePath . $uid . '/'; + if(!is_dir($tmpFileSavePath)) mkdir($tmpFileSavePath); $fileName = basename($file['pathname']); - $file['realpath'] = $imageFilePath . $fileName; + $file['realpath'] = $tmpFileSavePath . $fileName; if($file['chunks'] > 1) { - $fileSavePath = $cachePath . $file['chunkpath']; - if(!file_exists($fileSavePath)) mkdir(dirname($fileSavePath)); + $tmpFileChunkPath = $tmpFilePath . $file['chunkpath']; + if(!file_exists($tmpFileChunkPath)) mkdir(dirname($tmpFileChunkPath)); if($file['chunk'] > 0) { - $uploadFile = fopen($fileSavePath, 'a+b'); + $fileChunk = fopen($tmpFileChunkPath, 'a+b'); $tmpChunkFile = fopen($file['tmpname'], 'rb'); while($buff = fread($tmpChunkFile, 4069)) { - fwrite($uploadFile, $buff); + fwrite($fileChunk, $buff); } - fclose($uploadFile); + fclose($fileChunk); fclose($tmpChunkFile); } else { - if(!move_uploaded_file($file['tmpname'], $fileSavePath)) return false; + if(!move_uploaded_file($file['tmpname'], $tmpFileChunkPath)) return false; } if($file['chunk'] == ($file['chunks'] - 1)) { - rename($fileSavePath, $file['realpath']); + rename($tmpFileChunkPath, $file['realpath']); - $imageFile['extension'] = $file['extension']; - $imageFile['pathname'] = $file['pathname']; - $imageFile['title'] = $file['title']; - $imageFile['realpath'] = $file['realpath']; - $imageFile['size'] = $file['size']; + $uploadFile['extension'] = $file['extension']; + $uploadFile['pathname'] = $file['pathname']; + $uploadFile['title'] = $file['title']; + $uploadFile['realpath'] = $file['realpath']; + $uploadFile['size'] = $file['size']; } } else { if(!move_uploaded_file($file['tmpname'], $file['realpath'])) return false; - $imageFile['extension'] = $file['extension']; - $imageFile['pathname'] = $file['pathname']; - $imageFile['title'] = $file['title']; - $imageFile['realpath'] = $file['realpath']; - $imageFile['size'] = $file['size']; + $uploadFile['extension'] = $file['extension']; + $uploadFile['pathname'] = $file['pathname']; + $uploadFile['title'] = $file['title']; + $uploadFile['realpath'] = $file['realpath']; + $uploadFile['size'] = $file['size']; } - return $imageFile; + return $uploadFile; } /** @@ -569,59 +569,6 @@ class fileModel extends model return str_replace('""', '"', $matchs[1]) . str_replace(',', ',', $matchs[2]); } - /** - * Extract zip. - * - * @param string $zipFile - * @access public - * @return string - */ - public function extractZip($zipFile) - { - $classFile = $this->app->loadClass('zfile'); - $parentPath = $this->app->getCacheRoot() . 'uploadimages/'; - if(!is_dir($parentPath)) mkdir($parentPath, 0777, true); - - $filePath = $parentPath . str_replace('.zip', '', basename($zipFile)) . '/'; - if(is_dir($filePath)) $classFile->removeDir($filePath); - mkdir($filePath); - - $this->app->loadClass('pclzip', true); - $zip = new pclzip($zipFile); - $files = $zip->listContent(); - foreach($files as $i => $uploadFile) - { - if($uploadFile['folder']) continue; - $extension = strtolower(substr(strrchr($uploadFile['filename'], '.'), 1)); - if(empty($extension) or !in_array($extension, $this->config->file->imageExtensions)) return false; - } - - $extractedFiles = array(); - foreach($files as $i => $uploadFile) - { - if($uploadFile['folder']) continue; - $fileName = $uploadFile['filename']; - $fileName = helper::convertEncoding($fileName, 'gbk', 'utf-8//TRANSLIT'); - if(($pos = strrpos($fileName, '/')) !== false) $fileName = substr($fileName, $pos + 1); - - $file = array(); - $file['extension'] = $this->getExtension($fileName); - $file['pathname'] = $this->setPathName($i, $file['extension']); - $file['title'] = str_replace(".{$file['extension']}", '', $fileName); - $file['size'] = $uploadFile['size']; - - $fileName = basename($file['pathname']); - $file['realpath'] = $filePath . $fileName; - $list = $zip->extract(PCLZIP_OPT_BY_INDEX, $i, PCLZIP_OPT_EXTRACT_AS_STRING); - if($list) - { - file_put_contents($file['realpath'], $list[0]['content']); - $extractedFiles[$fileName] = $file; - } - } - return $extractedFiles; - } - /** * Process editor. * diff --git a/module/file/view/uploadimages.html.php b/module/file/view/uploadimages.html.php index 1fe8a4f155..40ece425a3 100644 --- a/module/file/view/uploadimages.html.php +++ b/module/file/view/uploadimages.html.php @@ -14,6 +14,9 @@