diff --git a/module/block/control.php b/module/block/control.php index 2b167b98b4..d74da8364d 100755 --- a/module/block/control.php +++ b/module/block/control.php @@ -283,17 +283,17 @@ class block extends control if(empty($block)) return $html; + if(isset($block->params->num) and !isset($block->params->count)) $block->params->count = $block->params->num; + $code = $block->code; if($code == 'statistic' or $code == 'list' or $code == 'overview') $code = $block->module . ucfirst($code); $function = 'print' . ucfirst($code) . 'Block'; - if(method_exists('blockZen', $function)) $this->blockZen->$function($blockID); + if(method_exists('blockZen', $function)) $this->blockZen->$function($block); - $params = $block->params; - if(isset($params->num) and !isset($params->count)) $params->count = $params->num; if(!$this->selfCall) { - $this->app->user = $this->dao->select('*')->from(TABLE_USER)->where('ranzhi')->eq($params->account)->fetch(); + $this->app->user = $this->dao->select('*')->from(TABLE_USER)->where('ranzhi')->eq($block->params->account)->fetch(); if(empty($this->app->user)) { $this->app->user = new stdclass(); @@ -318,12 +318,12 @@ class block extends control $moreLink = ''; if(isset($this->config->block->modules[$module]->moreLinkList->{$code})) { - list($moduleName, $method, $vars) = explode('|', sprintf($this->config->block->modules[$module]->moreLinkList->{$code}, isset($params->type) ? $params->type : '')); + list($moduleName, $method, $vars) = explode('|', sprintf($this->config->block->modules[$module]->moreLinkList->{$code}, isset($block->params->type) ? $block->params->type : '')); $this->view->moreLink = $this->createLink($moduleName, $method, $vars); } $this->view->moreLink = $moreLink; - $viewType = (isset($params->viewType) and $params->viewType == 'json') ? 'json' : 'html'; + $viewType = (isset($block->params->viewType) and $block->params->viewType == 'json') ? 'json' : 'html'; if($viewType == 'json') { unset($this->view->app); diff --git a/module/block/zen.php b/module/block/zen.php index 62cb90473c..40cc9bcf61 100644 --- a/module/block/zen.php +++ b/module/block/zen.php @@ -756,18 +756,16 @@ class blockZen extends block /** * Print product statistic block. * + * @param object $block * @access public - * @param string $storyType requirement|story * @return void */ - public function printProductStatisticBlock($storyType = 'story') + public function printProductStatisticBlock($block) { - if(!empty($this->params->type) and preg_match('/[^a-zA-Z0-9_]/', $this->params->type)) return; + $status = isset($block->params->type) ? $block->params->type : ''; + $count = isset($block->params->count) ? $block->params->count : ''; - $status = isset($this->params->type) ? $this->params->type : ''; - $count = isset($this->params->count) ? $this->params->count : ''; - - $products = $this->loadModel('product')->getOrderedProducts($status, $count); + $products = $this->loadModel('product')->getOrderedProducts($status, (int)$count); $productIdList = array_keys($products); if(empty($products)) @@ -780,7 +778,7 @@ class blockZen extends block $stories = $this->dao->select('product, stage, COUNT(status) AS count')->from(TABLE_STORY) ->where('deleted')->eq(0) ->andWhere('product')->in($productIdList) - ->beginIF($storyType)->andWhere('type')->eq($storyType)->fi() + ->andWhere('type')->eq('story') ->groupBy('product, stage') ->fetchGroup('product', 'stage'); diff --git a/module/product/model.php b/module/product/model.php index cabb0e51c8..d50484f001 100755 --- a/module/product/model.php +++ b/module/product/model.php @@ -432,7 +432,7 @@ class productModel extends model } else { - $products = $this->getList('', $status, $num, 0, $shadow); + $products = $this->getList(0, $status, $num, 0, $shadow); } if(empty($products)) return $products; diff --git a/module/project/model.php b/module/project/model.php index 5bc0632991..e7d83132ad 100755 --- a/module/project/model.php +++ b/module/project/model.php @@ -52,20 +52,6 @@ class projectModel extends model return $this->app->user->admin || str_contains(",{$this->app->user->view->projects},", ",{$projectID},"); } - /** - * Show accessDenied response. - * - * @access private - * @return void - */ - public function accessDenied() - { - if(defined('TUTORIAL')) return true; - - $this->session->set('project', ''); - return print(js::alert($this->lang->project->accessDenied) . js::locate(helper::createLink('project', 'index'))); - } - /** * Judge an action is clickable or not. * @@ -123,7 +109,7 @@ class projectModel extends model } $this->session->set('project', (int)key($projects), $this->app->tab); - $this->accessDenied(); + print($this->projectTao->accessDenied()); } else { diff --git a/module/project/tao.php b/module/project/tao.php index 7fd79831d8..c1a5a670eb 100755 --- a/module/project/tao.php +++ b/module/project/tao.php @@ -797,6 +797,19 @@ class projectTao extends projectModel ->fetchAll('project'); } + /** + * 返回请求被拒绝的跳转信息。 + * return accessDenied response. + * + * @access protected + * @return string + */ + protected function accessDenied(): string + { + $this->session->set('project', ''); + return js::alert($this->lang->project->accessDenied) . js::locate(helper::createLink('project', 'index')); + } + /** * 通过项目ID获取Bug数量统计。 * Get the number of bugs associated with the project. diff --git a/module/project/test/tao/accessdenied.php b/module/project/test/tao/accessdenied.php new file mode 100755 index 0000000000..e8d6eac6e6 --- /dev/null +++ b/module/project/test/tao/accessdenied.php @@ -0,0 +1,31 @@ +#!/usr/bin/env php +id->range('2-3'); +$project->type->range("project"); +$project->gen(2); + +/** + +title=测试 projectModel->accessDenied(); +timeout=0 +cid=1 + +- 执行$_SESSION['project'] @2 + +- 执行$_SESSION['project'] @0 + +*/ + +global $tester; +$tester->loadModel('project'); + +$tester->project->saveState(2, array(2 => '')); +r($_SESSION['project']) && p() && e('2'); + +$tester->project->accessDenied(); +r($_SESSION['project']) && p() && e('0'); diff --git a/test/data/case.yaml b/test/data/case.yaml index 1a6832d914..41c6640ab3 100644 --- a/test/data/case.yaml +++ b/test/data/case.yaml @@ -67,7 +67,6 @@ fields: note: "脚本创建日期" range: "(M)-(w)" type: timestamp - prefix: "DateTime" postfix: "" format: "YY/MM/DD" - field: scriptStatus diff --git a/test/data/effort.yaml b/test/data/effort.yaml index 1e458fa1d5..16699b5e26 100644 --- a/test/data/effort.yaml +++ b/test/data/effort.yaml @@ -57,7 +57,6 @@ fields: note: "创建日期" range: "(M)-(w)" type: timestamp - prefix: "DateTime" postfix: "" format: "YY/MM/DD" - field: left diff --git a/test/data/file.yaml b/test/data/file.yaml index 2dffc90296..658f0ff050 100644 --- a/test/data/file.yaml +++ b/test/data/file.yaml @@ -58,7 +58,6 @@ fields: note: "添加时间" range: "(M)-(w)" type: timestamp - prefix: "DateTime" postfix: "" format: "YY/MM/DD" - field: downloads diff --git a/test/data/job.yaml b/test/data/job.yaml index 091d65a815..8590337505 100644 --- a/test/data/job.yaml +++ b/test/data/job.yaml @@ -114,7 +114,6 @@ fields: note: "创建日期" range: "(M)-(w)" type: timestamp - prefix: "DateTime" postfix: "" format: "YY/MM/DD" - field: editedBy diff --git a/test/lib/yaml.class.php b/test/lib/yaml.class.php index 53367eb46b..8744b4d538 100644 --- a/test/lib/yaml.class.php +++ b/test/lib/yaml.class.php @@ -163,10 +163,10 @@ class fields if(!empty($rule['range']) or $rule['range'] === '0') $ruleArr[$index]['range'] = $rule['range']; } - if(!empty($rule['prefix']) or $rule['range'] === '0') $ruleArr[$index]['prefix'] = $rule['prefix']; - if(!empty($rule['postfix']) or $rule['range'] === '0') $ruleArr[$index]['postfix'] = $rule['postfix']; - if(!empty($rule['type']) or $rule['range'] === '0') $ruleArr[$index]['type'] = $rule['type']; - if(!empty($rule['format']) or $rule['range'] === '0') $ruleArr[$index]['format'] = $rule['format']; + if(!empty($rule['prefix']) or $rule['prefix'] === '0') $ruleArr[$index]['prefix'] = $rule['prefix']; + if(!empty($rule['postfix']) or $rule['postfix'] === '0') $ruleArr[$index]['postfix'] = $rule['postfix']; + if(!empty($rule['type']) or $rule['type'] === '0') $ruleArr[$index]['type'] = $rule['type']; + if(!empty($rule['format']) or $rule['format'] === '0') $ruleArr[$index]['format'] = $rule['format']; $index ++; }