diff --git a/lib/zfile/zfile.class.php b/lib/zfile/zfile.class.php index 38c39850b8..9ff65e0fb9 100644 --- a/lib/zfile/zfile.class.php +++ b/lib/zfile/zfile.class.php @@ -192,4 +192,40 @@ class zfile { return rename($from, $to); } + + /** + * Get file size. + * + * @param string $file + * @access public + * @return int + */ + public function getFileSize($file) + { + return abs(filesize($file)); + } + + /** + * Get directory size. + * + * @param string $dir + * @access public + * @return int + */ + public function getDirSize($dir) + { + $size = 0; + foreach(glob("$dir/*") as $file) + { + if(is_dir($file)) + { + $size += $this->getDirSize($file); + } + else + { + $size += $this->getFileSize($file); + } + } + return $size; + } } diff --git a/module/backup/control.php b/module/backup/control.php index a6460f7caa..7f8bd75900 100644 --- a/module/backup/control.php +++ b/module/backup/control.php @@ -21,7 +21,7 @@ class backup extends control { parent::__construct($moduleName, $methodName); - $this->backupPath = empty($this->config->backup->settingDir) ? $this->app->getTmpRoot() . 'backup/' : $this->config->backup->settingDir; + $this->backupPath = empty($this->config->backup->settingDir) ? $this->app->getTmpRoot() . 'backup' . DS : $this->config->backup->settingDir; if(!is_dir($this->backupPath)) { if(!mkdir($this->backupPath, 0777, true)) $this->view->error = sprintf($this->lang->backup->error->noWritable, dirname($this->backupPath)); @@ -127,7 +127,7 @@ class backup extends control $backFileName = $this->backupPath . $fileName . '.file'; if(!$nozip) $backFileName .= '.zip'; - if(!$nosafe) $backFileName .= '.php'; + if(!$nozip and !$nosafe) $backFileName .= '.php'; $result = $this->backup->backFile($backFileName); if(!$result->result) @@ -146,7 +146,7 @@ class backup extends control $backFileName = $this->backupPath . $fileName . '.code'; if(!$nozip) $backFileName .= '.zip'; - if(!$nosafe) $backFileName .= '.php'; + if(!$nozip and !$nosafe) $backFileName .= '.php'; $result = $this->backup->backCode($backFileName); if(!$result->result) @@ -353,8 +353,11 @@ class backup extends control if(isset($data->setting)) $setting = $data->setting; $this->loadModel('setting')->setItem('system.backup.setting', $setting); - $settingDir = $data->settingDir; - if($data->settingDir == $this->app->getTmpRoot() . 'backup/') $settingDir = ''; + $settingDir = rtrim($data->settingDir, DS) . DS; + if(!is_dir($settingDir) and mkdir($settingDir, 0777, true)) die(js::alert($this->lang->backup->error->noCreateDir)); + if(!is_writable($settingDir)) die(js::alert($this->lang->backup->error->noWritable)); + + if($data->settingDir == $this->app->getTmpRoot() . 'backup' . DS) $settingDir = ''; $this->setting->setItem('system.backup.settingDir', $settingDir); die(js::reload('parent.parent')); diff --git a/module/backup/lang/en.php b/module/backup/lang/en.php index efac67a838..6c4262e134 100644 --- a/module/backup/lang/en.php +++ b/module/backup/lang/en.php @@ -12,9 +12,11 @@ $lang->backup->time = 'Date'; $lang->backup->files = 'Files'; $lang->backup->size = 'Size'; -$lang->backup->setting = 'Setting'; +$lang->backup->setting = 'Setting'; +$lang->backup->settingDir = 'Backup Directory'; $lang->backup->settingList['nofile'] = 'Not backup file and code.'; -$lang->backup->settingList['nozip'] = 'Only copy file'; +$lang->backup->settingList['nozip'] = 'Only copy file, Uncompressed'; +$lang->backup->settingList['nosafe'] = 'No need to prevent downloading PHP file header.'; $lang->backup->waitting = ' In Progress. Please wait...'; $lang->backup->confirmDelete = 'Do you want to delete the backup?'; @@ -27,6 +29,7 @@ $lang->backup->success->backup = 'Done!'; $lang->backup->success->restore = 'Restored!'; $lang->backup->error = new stdclass(); +$lang->backup->error->noCreateDir = 'Directory is not exists, and can not create it'; $lang->backup->error->noWritable = "%s is not writable! Please check the privilege, or backup cannot be done."; $lang->backup->error->noDelete = "%s cannot be deleted. Please modify the privilege or manually delete it."; $lang->backup->error->restoreSQL = "Database library restoration failed. Error %s."; diff --git a/module/backup/lang/zh-cn.php b/module/backup/lang/zh-cn.php index 73d1f89ddb..cd7932cd71 100644 --- a/module/backup/lang/zh-cn.php +++ b/module/backup/lang/zh-cn.php @@ -16,8 +16,8 @@ $lang->backup->size = '大小'; $lang->backup->setting = '设置'; $lang->backup->settingDir = '备份目录'; $lang->backup->settingList['nofile'] = '不备份附件和代码'; -$lang->backup->settingList['nozip'] = '只拷贝文件'; -$lang->backup->settingList['nosafe'] = '不需要防下载设置'; +$lang->backup->settingList['nozip'] = '只拷贝文件,不压缩'; +$lang->backup->settingList['nosafe'] = '不需要防下载PHP文件头'; $lang->backup->waitting = '正在进行中,请稍候...'; $lang->backup->progressSQL = '

SQL备份中,已备份%s

'; @@ -33,6 +33,7 @@ $lang->backup->success->backup = '备份成功!'; $lang->backup->success->restore = '还原成功!'; $lang->backup->error = new stdclass(); +$lang->backup->error->noCreateDir = '备份目录不存在,也无法创建该目录'; $lang->backup->error->noWritable = "%s 不可写!请检查该目录权限,否则无法备份。"; $lang->backup->error->noDelete = "文件 %s 无法删除,修改权限或手工删除。"; $lang->backup->error->restoreSQL = "数据库还原失败,错误:%s"; diff --git a/module/backup/model.php b/module/backup/model.php index 613a908896..3a99b051f4 100644 --- a/module/backup/model.php +++ b/module/backup/model.php @@ -186,7 +186,7 @@ class backupModel extends model public function addFileHeader($fileName) { $firstline = false; - $die = "\n"; + $die = "\n"; $fileSize = filesize($fileName); $fh = fopen($fileName, 'c+'); @@ -229,7 +229,7 @@ class backupModel extends model public function removeFileHeader($fileName) { $firstline = false; - $die = "\n"; + $die = "\n"; $fileSize = filesize($fileName); $fh = fopen($fileName, 'c+'); @@ -270,18 +270,8 @@ class backupModel extends model */ public function getDirSize($dir) { - $size = 0; - foreach(glob("$dir/*") as $file) - { - if(is_dir($file)) - { - $size += $this->getDirSize($file); - } - else - { - $size += abs(filesize($file)); - } - } - return $size; + $zfile = $this->app->loadClass('zfile'); + if(!is_dir($dir)) return $zfile->getFileSize($dir); + return $zfile->getDirSize($dir); } } diff --git a/module/common/view/pastetext.html.php b/module/common/view/pastetext.html.php index 70bf23ecb4..8a34f24345 100644 --- a/module/common/view/pastetext.html.php +++ b/module/common/view/pastetext.html.php @@ -28,7 +28,7 @@ $(function() var lastIndex = parseInt($formTbody.find('tr:last > td:first').text()); var $newRow = $(rowTpl.replace(/%s/g, lastIndex + 1)); $newRow.find('.chosen').chosen(); - $newRow.find('.iframe').modalTrigger({iframe:true});; + $newRow.find('.iframe').modalTrigger({iframe:true}); $newRow.find('[data-provide="colorpicker-later"]').colorPicker(); $newRow.datepickerAll(); $formTbody.append($newRow); diff --git a/module/doc/control.php b/module/doc/control.php index 22ae79100f..92b9bcac0a 100644 --- a/module/doc/control.php +++ b/module/doc/control.php @@ -387,22 +387,6 @@ class doc extends control $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->createLink('doc', 'view', "docID=$docID"))); } - $libs = $this->doc->getLibs(); - foreach($libs as $id => $libName) - { - $lib = $this->doc->getLibById($id); - if($lib->project != 0) - { - $project = $this->loadModel('project')->getByID($lib->project); - $libs[$id] = $project->name . '/' . $libName; - } - if($lib->product != 0) - { - $product = $this->loadModel('product')->getByID($lib->product); - $libs[$id] = $product->name . '/' . $libName; - } - } - /* Get doc and set menu. */ $doc = $this->doc->getById($docID); $libID = $doc->lib; @@ -420,7 +404,7 @@ class doc extends control $this->view->doc = $doc; $this->view->moduleOptionMenu = $this->tree->getOptionMenu($libID, 'doc', $startModuleID = 0); $this->view->type = $type; - $this->view->libs = $libs; + $this->view->libs = $this->doc->getCompleteLibName(); $this->view->groups = $this->loadModel('group')->getPairs(); $this->view->users = $this->user->getPairs('noletter', $doc->users); $this->display(); diff --git a/module/doc/model.php b/module/doc/model.php index a571687f67..4f5ff54510 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -1523,4 +1523,24 @@ class docModel extends model return $actions; } + + public function getCompleteLibName() + { + $libPairs = array(); + $products = $this->loadModel('product')->getPairs(); + $projects = $this->loadModel('project')->getPairs(); + $stmt = $this->dao->select('id,project,product,name')->from(TABLE_DOCLIB)->where('deleted')->eq(0)->query(); + + while($lib = $stmt->fetch()) + { + if($this->checkPrivLib($lib)) + { + if($lib->product != 0) $lib->name = zget($products, $lib->product) . '/' . $lib->name; + if($lib->project != 0) $lib->name = zget($projects, $lib->project) . '/' . $lib->name; + $libPairs[$lib->id] = $lib->name; + } + } + + return $libPairs; + } } diff --git a/module/doc/view/view.html.php b/module/doc/view/view.html.php index 7bee092a44..98931f105f 100644 --- a/module/doc/view/view.html.php +++ b/module/doc/view/view.html.php @@ -123,6 +123,7 @@ + fetch('file', 'printFiles', array('files' => $doc->files, 'fieldset' => 'true'));?>
@@ -206,9 +207,6 @@ createLink('action', 'comment', "objectType=doc&objectID=$doc->id");?>
-
- fetch('file', 'printFiles', array('files' => $doc->files, 'fieldset' => 'true'));?> -
diff --git a/module/product/view/create.html.php b/module/product/view/create.html.php index e766a394ae..e3aa0d7034 100644 --- a/module/product/view/create.html.php +++ b/module/product/view/create.html.php @@ -33,15 +33,10 @@ product->line;?>
- "; - echo html::a($this->createLink('tree', 'browse', "rootID=$rootID&view=line", '', true), $lang->tree->manageLine, '', "class='text-primary' data-toggle='modal' data-type='iframe' data-width='95%'"); - echo '  '; - echo html::a("javascript:void(0)", $lang->refresh, '', "class='refresh' onclick='loadProductLines($rootID)'"); - echo ''; - ?> + + createLink('tree', 'browse', "rootID=$rootID&view=line", '', true), $lang->tree->manageLine, '', "class='text-primary' data-toggle='modal' data-type='iframe' data-width='95%'");?>
+ diff --git a/module/project/view/bug.html.php b/module/project/view/bug.html.php index 9b8e1df398..b6f6923ced 100644 --- a/module/project/view/bug.html.php +++ b/module/project/view/bug.html.php @@ -117,7 +117,7 @@
1; + $withSearch = count($memberPairs) > 10; $actionLink = $this->createLink('bug', 'batchAssignTo', "projectID={$project->id}&type=project"); if($withSearch) diff --git a/module/story/js/review.js b/module/story/js/review.js index 14126ccacd..9a1e92950e 100644 --- a/module/story/js/review.js +++ b/module/story/js/review.js @@ -1,5 +1,7 @@ function switchShow(result) { + $('#priBox').hide(); + $('#estimateBox').hide(); if(result == 'reject') { $('#rejectedReasonBox').show(); @@ -9,10 +11,8 @@ function switchShow(result) $('#assignedTo').val('closed'); $('#assignedTo').trigger("chosen:updated"); } - else if(result == 'clarify') + else if(result == 'revert') { - $('#priBox').hide(); - $('#estimateBox').hide(); $('#preVersionBox').show(); $('#rejectedReasonBox').hide(); $('#duplicateStoryBox').hide(); @@ -22,8 +22,11 @@ function switchShow(result) } else { - $('#priBox').show(); - $('#estimateBox').show(); + if(result == 'pass') + { + $('#priBox').show(); + $('#estimateBox').show(); + } $('#preVersionBox').hide(); $('#rejectedReasonBox').hide(); $('#duplicateStoryBox').hide(); diff --git a/module/story/model.php b/module/story/model.php index c486442d5d..9d9819d1e6 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -1939,7 +1939,7 @@ class storyModel extends model { $property = '(' . $this->lang->story->pri . ':' . (!empty($this->lang->story->priList[$story->pri]) ? $this->lang->story->priList[$story->pri] : 0) . ',' . $this->lang->story->estimate . ':' . $story->estimate . ')'; } - $storyPairs[$story->id] = $story->id . ':' . $story->title . ' '. $property; + $storyPairs[$story->id] = $story->id . ':' . $story->title . ' ' . $property; if($limit > 0 && ++$i > $limit) { diff --git a/module/task/model.php b/module/task/model.php index 0546b721ac..fb8e87b03a 100644 --- a/module/task/model.php +++ b/module/task/model.php @@ -688,6 +688,7 @@ class taskModel extends model { $this->dao->update(TABLE_TASK)->set('parent')->eq(-1)->where('id')->eq($task->parent)->exec(); $this->updateParentStatus($taskID); + $this->computeBeginAndEnd($task->parent); } $this->file->updateObjectID($this->post->uid, $taskID, 'task'); return common::createChanges($oldTask, $task); diff --git a/module/testsuite/config.php b/module/testsuite/config.php index 2c7f23bba7..4e325d3cf8 100644 --- a/module/testsuite/config.php +++ b/module/testsuite/config.php @@ -18,5 +18,5 @@ $config->testsuite->datatable = new stdclass(); $config->testsuite->datatable->defaultField = array('id', 'pri', 'title', 'type', 'assignedTo', 'lastRunner', 'lastRunDate', 'lastRunResult', 'status', 'bugs', 'results', 'actions'); $config->testsuite->custom = new stdclass(); -$config->testsuite->custom->createFields = 'stage,pri,keywords'; -$config->testsuite->customCreateFields = 'stage,pri,keywords'; +$config->testsuite->custom->createFields = 'stage,pri,keywords'; +$config->testsuite->customCreateFields = 'stage,pri,keywords'; diff --git a/module/tree/control.php b/module/tree/control.php index accb265a91..cd2a732c34 100644 --- a/module/tree/control.php +++ b/module/tree/control.php @@ -238,25 +238,9 @@ class tree extends control $this->view->optionMenu = $this->tree->getOptionMenu($module->root, $module->type, 0, $branch); } - $libs = $this->loadModel('doc')->getLibs(); - foreach($libs as $id => $libName) - { - $lib = $this->doc->getLibById($id); - if($lib->project != 0) - { - $project = $this->loadModel('project')->getByID($lib->project); - $libs[$id] = $project->name . '/' . $libName; - } - if($lib->product != 0) - { - $product = $this->loadModel('product')->getByID($lib->product); - $libs[$id] = $product->name . '/' . $libName; - } - } - $this->view->module = $module; $this->view->type = $type; - $this->view->libs = $libs; + $this->view->libs = $this->loadModel('doc')->getCompleteLibName(); $this->view->branch = $branch; $this->view->users = $this->loadModel('user')->getPairs('noclosed|nodeleted', $module->owner); @@ -371,19 +355,31 @@ class tree extends control } if($returnType == 'html') { - $changeFunc = ''; - if($viewType == 'task' or $viewType == 'bug' or $viewType == 'case') $changeFunc = "onchange='loadModuleRelated()'"; - $field = $fieldID ? "modules[$fieldID]" : 'module'; - if($viewType == 'line') $field = 'line'; - $output = html::select("$field", $optionMenu, '', "class='form-control' $changeFunc"); - if(count($optionMenu) == 1 and $needManage) + //Code for task #5081. + if($viewType == 'line') { - $output .= ""; + $lineID = $this->dao->select('id')->from(TABLE_MODULE)->where('type')->eq('line')->andWhere('deleted')->eq(0)->orderBy('id_desc')->limit(1)->fetch('id'); + $output = html::select("line", $optionMenu, $lineID, "class='form-control'"); + $output .= ""; $output .= html::a($this->createLink('tree', 'browse', "rootID=$rootID&view=$viewType¤tModuleID=0&branch=$branch", '', true), $viewType == 'line' ? $this->lang->tree->manageLine : $this->lang->tree->manage, '', "class='text-primary' data-toggle='modal' data-type='iframe' data-width='95%'"); - $output .= '  '; - $output .= $viewType == 'line' ? html::a("javascript:void(0)", $this->lang->refresh, '', "class='refresh' onclick='loadProductLines($rootID)'") : html::a("javascript:void(0)", $this->lang->refresh, '', "class='refresh' onclick='loadProductModules($rootID)'"); $output .= ''; } + else + { + $changeFunc = ''; + if($viewType == 'task' or $viewType == 'bug' or $viewType == 'case') $changeFunc = "onchange='loadModuleRelated()'"; + $field = $fieldID ? "modules[$fieldID]" : 'module'; + $output = html::select("$field", $optionMenu, '', "class='form-control' $changeFunc"); + if(count($optionMenu) == 1 and $needManage) + { + $output .= ""; + $output .= html::a($this->createLink('tree', 'browse', "rootID=$rootID&view=$viewType¤tModuleID=0&branch=$branch", '', true), $this->lang->tree->manage, '', "class='text-primary' data-toggle='modal' data-type='iframe' data-width='95%'"); + $output .= '  '; + $output .= html::a("javascript:void(0)", $this->lang->refresh, '', "class='refresh' onclick='loadProductModules($rootID)'"); + $output .= ''; + } + } + die($output); } if($returnType == 'mhtml')