From 45ae4de7754e74f5df823838a2a7585c2deac7a4 Mon Sep 17 00:00:00 2001 From: wangyuting2 <851424971@qq.com> Date: Mon, 9 May 2022 09:20:01 +0800 Subject: [PATCH] * Do task 53548. --- framework/control.class.php | 70 ++++++++++++++++++++++------------- framework/model.class.php | 33 ++++++----------- module/bug/model.php | 43 ++++++++++++++++++--- module/bug/view/view.html.php | 24 +----------- 4 files changed, 94 insertions(+), 76 deletions(-) diff --git a/framework/control.class.php b/framework/control.class.php index b55e47c7fe..a545295b65 100644 --- a/framework/control.class.php +++ b/framework/control.class.php @@ -82,31 +82,49 @@ class control extends baseControl } /* If workflow is created by a normal user, set priv. */ - if(isset($this->app->user) and !$this->app->user->admin) - { - $actions = $this->dao->select('module, action')->from(TABLE_WORKFLOWACTION)->where('createdBy')->eq($this->app->user->account)->andWhere('buildin')->eq('0')->fetchGroup('module'); - $labels = $this->dao->select('module, code')->from(TABLE_WORKFLOWLABEL)->where('createdBy')->eq($this->app->user->account)->andWhere('buildin')->eq('0')->fetchGroup('module'); - if(!empty($actions)) - { - foreach($actions as $module => $actionObj) - { - foreach($actionObj as $action) $this->app->user->rights['rights'][$module][$action->action] = 1; - } - } + if(isset($this->app->user) and !$this->app->user->admin) $this->setDefaultPrivByWorkflow(); + } + } - if(!empty($labels)) + /** + * Det default priv by workflow. + * + * @access public + * @return void + */ + public function setDefaultPrivByWorkflow() + { + $actionList = $this->dao->select('module, action')->from(TABLE_WORKFLOWACTION) + ->where('createdBy')->eq($this->app->user->account) + ->andWhere('buildin')->eq('0') + ->fetchGroup('module'); + + if($actionList) + { + foreach($actionList as $module => $actions) + { + foreach($actions as $action) $this->app->user->rights['rights'][$module][$action->action] = 1; + } + } + + $labelList = $this->dao->select('module, code')->from(TABLE_WORKFLOWLABEL) + ->where('createdBy')->eq($this->app->user->account) + ->andWhere('buildin')->eq('0') + ->fetchGroup('module'); + + if($labelList) + { + foreach($labelList as $module => $labels) + { + foreach($labels as $label) { - foreach($labels as $module => $codeObj) - { - foreach($codeObj as $code) - { - $code = str_replace('browse', '', $code->code); - $this->app->user->rights['rights'][$module][$code] = 1; - } - } + $code = str_replace('browse', '', $label->code); + $this->app->user->rights['rights'][$module][$code] = 1; } } } + + return true; } /** @@ -299,14 +317,16 @@ class control extends baseControl * @access public * @return void */ - public function buildOperateMenu($object, $displayOn = 'view') + public function buildOperateMenu($object, $type = 'view') { if(!isset($this->config->bizVersion)) return false; - $flow = $this->loadModel('workflow')->getByModule($this->moduleName); - return $this->loadModel('flow')->buildOperateMenu($flow, $object, $displayOn); - //$moduleName = $this->moduleName; - //return $this->$moduleName->buildOperateMenu($object, $type); + $moduleName = $this->moduleName; + if($moduleName == 'bug') return $this->$moduleName->buildOperateMenu($object, $type); + + $flow = $this->loadModel('workflow')->getByModule($moduleName); + return $this->loadModel('flow')->buildOperateMenu($flow, $object, $type); + } /** diff --git a/framework/model.class.php b/framework/model.class.php index 8f2ef6f10e..1fe33cc6ab 100644 --- a/framework/model.class.php +++ b/framework/model.class.php @@ -59,15 +59,17 @@ class model extends baseModel * @param string $moduleName * @param string $methodName * @param string $params - * @param string $label * @param object $data * @param string $type + * @param string $icon + * @param string $target * @param string $misc - * @param bool $li + * @param bool $onlyBody * @access public * @return string */ - public function buildMenu($moduleName, $methodName, $params, $label, $data, $type = 'browse', $misc = '', $li = false) + + public function buildMenu($moduleName, $methodName, $params, $data, $type = 'view', $icon = '', $target = '', $class = '', $onlyBody = false, $misc = '' , $title = '') { if(strpos($moduleName, '.') !== false) list($appName, $moduleName) = explode('.', $moduleName); @@ -99,31 +101,18 @@ class model extends baseModel } else { - if(method_exists($this, 'isClickable')) $enabled = $this->isClickable($module, $method, $data); + if(method_exists($this, 'isClickable')) $enabled = $this->isClickable($data, $method, $module); } } else { - if(method_exists($this, 'isClickable')) $enabled = $this->isClickable($module, $method, $data); + if(method_exists($this, 'isClickable')) $enabled = $this->isClickable($data, $method, $module); } - if($enabled) $enabled = commonModel::checkPrivByVars($module, $method, $params); - - if($enabled) - { - $link = helper::createLink($module, $method, $params); - $html = html::a($link, $label, '', $misc); - if($type == 'browse' && $li) $html = '