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 = '
' . $html . '';
-
- return $html;
- }
- else
- {
- if($type == 'view') return '';
- if($type == 'browse' && $li) return '';
-
- return html::a('javascript:;', $label, '', "class='disabled'");
- }
+ $html = '';
+ $type = $type == 'browse' ? 'list' : 'button';
+ if($enabled) $html = common::buildIconButton($module, $method, $params, $data, $type, $icon, $target, $class, $onlyBody, $misc, $title);
+ return $html;
}
/**
diff --git a/module/bug/model.php b/module/bug/model.php
index caf7542eef..1d774237ea 100644
--- a/module/bug/model.php
+++ b/module/bug/model.php
@@ -2787,15 +2787,15 @@ class bugModel extends model
* @access public
* @return void
*/
- public static function isClickable($object, $action)
+ public static function isClickable($object, $action, $module = 'bug')
{
$action = strtolower($action);
- if($action == 'confirmbug') return $object->status == 'active' and $object->confirmed == 0;
- if($action == 'resolve') return $object->status == 'active';
- if($action == 'close') return $object->status == 'resolved';
- if($action == 'activate') return $object->status != 'active';
- if($action == 'tostory') return $object->status == 'active';
+ if($module == 'bug' && $action == 'confirmbug') return $object->status == 'active' and $object->confirmed == 0;
+ if($module == 'bug' && $action == 'resolve') return $object->status == 'active';
+ if($module == 'bug' && $action == 'close') return $object->status == 'resolved';
+ if($module == 'bug' && $action == 'activate') return $object->status != 'active';
+ if($module == 'bug' && $action == 'tostory') return $object->status == 'active';
return true;
}
@@ -3233,4 +3233,35 @@ class bugModel extends model
->andWhere('deleted')->eq(0)
->fetchPairs('id');
}
+
+ public function buildOperateMenu($bug, $type = 'view')
+ {
+ $menu = '';
+ $menuType = $type == 'browse' ? 'list' : 'button';
+ $params = "bugID=$bug->id";
+ $extraParams = "extras=bugID=$bug->id";
+ if($this->app->tab == 'project') $extraParams .= ",projectID={$bug->project}";
+ if($this->app->tab == 'execution') $extraParams .= ",executionID={$bug->execution}";
+ $copyParams = "productID=$bug->product&branch=$bug->branch&$extraParams";
+ $convertParams = "productID=$bug->product&branch=$bug->branch&moduleID=0&from=bug&bugID=$bug->id";
+ $toStoryParams = "product=$bug->product&branch=$bug->branch&module=0&story=0&execution=0&bugID=$bug->id";
+
+ $menu .= $this->buildMenu('bug', 'confirmBug', $params, $bug, $menuType, 'ok', '', "iframe", true);
+ if($type == 'view') $menu .= $this->buildMenu('bug', 'assignTo', $params, $bug, $menuType, '', '', "iframe", true);
+ $menu .= $this->buildMenu('bug', 'resolve', $params, $bug, $menuType, 'checked', '', "iframe", true);
+ $menu .= $this->buildMenu('bug', 'close', $params, $bug, $menuType, '', '', "text-danger iframe showinonlybody", true);
+ $menu .= $this->buildMenu('bug', 'activate', $params, $bug, $menuType, '', '', "text-success iframe showinonlybody", true);
+ if($this->app->tab != 'product')
+ {
+ $menu .= $this->buildMenu('bug', 'toStory', $toStoryParams, $bug, $menuType, $this->lang->icons['story'], '', '', '', "data-app='product'", $this->lang->bug->toStory);
+ $menu .= $this->buildMenu('bug', 'createCase', $convertParams, $bug, $menuType, 'sitemap');
+ }
+ $menu .= "";
+ $menu .= $this->buildFlowMenu('bug', $bug, $type, 'direct');
+ $menu .= "";
+ $menu .= $this->buildMenu('bug', 'edit', $params, $bug, $menuType);
+ if($this->app->tab != 'product') $menu .= $this->buildMenu('bug', 'create', $copyParams, $bug, $menuType, 'copy');
+ $menu .= $this->buildMenu('bug', 'delete', $params, $bug, $menuType, 'trash', 'hiddenwin', "showinonlybody");
+ return $menu;
+ }
}
diff --git a/module/bug/view/view.html.php b/module/bug/view/view.html.php
index 45efbbbd1f..f80245adc1 100644
--- a/module/bug/view/view.html.php
+++ b/module/bug/view/view.html.php
@@ -96,29 +96,7 @@
deleted):?>
- app->tab != 'product')
- {
- common::printIcon('bug', 'toStory', "product=$bug->product&branch=$bug->branch&module=0&story=0&execution=0&bugID=$bug->id", $bug, 'button', $lang->icons['story'], '', '', '', "data-app='product'", $lang->bug->toStory);
- common::printIcon('bug', 'createCase', $convertParams, $bug, 'button', 'sitemap');
- }
-
- echo $this->buildOperateMenu($bug, 'view');
-
- echo "";
- common::printIcon('bug', 'edit', $params, $bug);
- if($this->app->tab != 'product')
- {
- common::printIcon('bug', 'create', $copyParams, $bug, 'button', 'copy');
- }
- common::printIcon('bug', 'delete', $params, $bug, 'button', 'trash', 'hiddenwin', 'showinonlybody');
- ?>
+ buildOperateMenu($bug, 'view');?>