diff --git a/module/bug/view/browse.html.php b/module/bug/view/browse.html.php
index 150243cbfc..057916cdfb 100644
--- a/module/bug/view/browse.html.php
+++ b/module/bug/view/browse.html.php
@@ -117,7 +117,7 @@ $currentBrowseType = isset($lang->bug->mySelects[$browseType]) && in_array($brow
?>
- config->CRProduct) or $product->status != 'closed'):?>
+
" . $lang->bug->batchCreate, '', "class='btn btn-secondary'");
@@ -189,7 +189,7 @@ $currentBrowseType = isset($lang->bug->mySelects[$browseType]) && in_array($brow
bug->noBug;?>
- config->CRProduct) or $product->status != 'closed') and common::hasPriv('bug', 'create')):?>
+
createLink('bug', 'create', "productID=$productID&branch=$branch&extra=moduleID=$moduleID"), " " . $lang->bug->create, '', "class='btn btn-info'");?>
@@ -211,7 +211,7 @@ $currentBrowseType = isset($lang->bug->mySelects[$browseType]) && in_array($brow
$widths = $this->datatable->setFixedFieldWidth($setting);
$columns = 0;
- $canBeChanged = (!empty($config->CRProduct) or $product->status != 'closed');
+ $canBeChanged = common::canModify('product', $product);
$canBatchEdit = ($canBeChanged and common::hasPriv('bug', 'batchEdit'));
$canBatchConfirm = ($canBeChanged and common::hasPriv('bug', 'batchConfirm'));
$canBatchClose = common::hasPriv('bug', 'batchClose');
diff --git a/module/bug/view/view.html.php b/module/bug/view/view.html.php
index e038ea7a29..5e27574682 100644
--- a/module/bug/view/view.html.php
+++ b/module/bug/view/view.html.php
@@ -30,7 +30,7 @@
- config->CRProduct) or $product->status != 'closed'):?>
+
product}&branch={$bug->branch}&extra=moduleID={$bug->module}", "" . $lang->bug->create, '', "class='btn btn-primary'"); ?>
diff --git a/module/common/model.php b/module/common/model.php
index 1e1d28c44c..7d726df500 100644
--- a/module/common/model.php
+++ b/module/common/model.php
@@ -1487,19 +1487,18 @@ EOD;
*/
public static function hasPriv($module, $method, $object = null)
{
- $module = strtolower($module);
- $method = strtolower($method);
-
global $app, $lang;
/* Check the parent object is closed. */
- if(strpos('close|batchclose', $method) === false and !commonModel::canBeChanged($module, $object)) return false;
+ if(strpos('close|batchClose', $method) === false and !commonModel::canBeChanged($module, $object)) return false;
/* Check is the super admin or not. */
if(!empty($app->user->admin) || strpos($app->company->admins, ",{$app->user->account},") !== false) return true;
/* If not super admin, check the rights. */
$rights = $app->user->rights['rights'];
$acls = $app->user->rights['acls'];
+ $module = strtolower($module);
+ $method = strtolower($method);
if((($app->user->account != 'guest') or ($app->company->guest and $app->user->account == 'guest')) and $module == 'report' and $method == 'annualdata') return true;
@@ -1873,6 +1872,25 @@ EOD;
return true;
}
+ /**
+ * check object can Modify.
+ *
+ * @param string $type product|project
+ * @param object $object
+ * @static
+ * @access public
+ * @return void
+ */
+ public static function canModify($type, $object)
+ {
+ global $config;
+
+ if($type == 'product' and empty($config->CRProduct) and $object->status == 'closed') return false;
+ if($type == 'project' and empty($config->CRProject) and $object->status == 'closed') return false;
+
+ return true;
+ }
+
/**
* Response.
*
diff --git a/module/doc/control.php b/module/doc/control.php
index 5f0cdc16e9..3708b6dbd9 100644
--- a/module/doc/control.php
+++ b/module/doc/control.php
@@ -754,11 +754,6 @@ class doc extends control
$table = $type == 'product' ? TABLE_PRODUCT : TABLE_PROJECT;
$object = $this->dao->select('id,name,status')->from($table)->where('id')->eq($objectID)->fetch();
- /* Determines whether an object is editable. */
- $canBeChanged = true;
- if($type == 'product' and empty($this->config->CRProduct) and $object->status == 'closed') $canBeChanged = false;
- if($type == 'project' and empty($this->config->CRProject) and $object->status == 'closed') $canBeChanged = false;
-
/* According the from, set menus. */
if($this->from == 'product')
{
@@ -813,7 +808,7 @@ class doc extends control
$this->view->viewType = $viewType;
$this->view->orderBy = $orderBy;
$this->view->objectID = $objectID;
- $this->view->canBeChanged = $canBeChanged;
+ $this->view->canBeChanged = common::canModify($type, $object); // Determines whether an object is editable.
$this->display();
}
@@ -854,11 +849,6 @@ class doc extends control
$object = $this->dao->select('id,name,status')->from($table)->where('id')->eq($objectID)->fetch();
if(empty($object)) $this->locate($this->createLink($type, 'create'));
- /* Determines whether an object is editable. */
- $canBeChanged = true;
- if($type == 'product' and empty($this->config->CRProduct) and $object->status == 'closed') $canBeChanged = false;
- if($type == 'project' and empty($this->config->CRProject) and $object->status == 'closed') $canBeChanged = false;
-
if($from == 'product')
{
$this->lang->doc->menu = $this->lang->product->menu;
@@ -899,7 +889,7 @@ class doc extends control
$this->view->object = $object;
$this->view->from = $from;
$this->view->libs = $this->doc->getLibsByObject($type, $objectID);
- $this->view->canBeChanged = $canBeChanged;
+ $this->view->canBeChanged = common::canModify($type, $object); // Determines whether an object is editable.
$this->display();
}
}
diff --git a/module/product/view/browse.html.php b/module/product/view/browse.html.php
index 5b30688c39..97fec2787d 100644
--- a/module/product/view/browse.html.php
+++ b/module/product/view/browse.html.php
@@ -94,7 +94,7 @@ js::set('foldAll', $lang->project->treeLevel['root']);
?>
- config->CRProduct) or $product->status != 'closed'):?>
+
createLink('story', 'batchCreate', "productID=$productID&branch=$branch&moduleID=$moduleID"), "
story->noStory;?>
- config->CRProduct) or $product->status != 'closed') and common::hasPriv('story', 'create')):?>
+
createLink('story', 'create', "productID={$productID}&branch={$branch}&moduleID={$moduleID}"), " " . $lang->story->create, '', "class='btn btn-info'");?>
@@ -189,7 +189,7 @@ js::set('foldAll', $lang->project->treeLevel['root']);
$widths = $this->datatable->setFixedFieldWidth($setting);
$columns = 0;
- $canBeChanged = (!empty($config->CRProduct) or $product->status != 'closed');
+ $canBeChanged = common::canModify('product', $product);
$canBatchEdit = ($canBeChanged and common::hasPriv('story', 'batchEdit'));
$canBatchClose = (common::hasPriv('story', 'batchClose') and strtolower($browseType) != 'closedbyme' and strtolower($browseType) != 'closedstory');
$canBatchReview = ($canBeChanged and common::hasPriv('story', 'batchReview'));
diff --git a/module/product/view/roadmap.html.php b/module/product/view/roadmap.html.php
index 90ebd428d0..fdfb13fba3 100644
--- a/module/product/view/roadmap.html.php
+++ b/module/product/view/roadmap.html.php
@@ -41,7 +41,7 @@
release->noRelease;?>
- config->CRProduct) or $product->status != 'closed') and common::hasPriv('release', 'create')):?>
+
createLink('release', 'create', "productID=$product->id&branch=$branchKey"), " " . $lang->release->create, '', "class='btn btn-info'");?>
diff --git a/module/productplan/view/browse.html.php b/module/productplan/view/browse.html.php
index 7c732cfa8a..d7e5d9773e 100644
--- a/module/productplan/view/browse.html.php
+++ b/module/productplan/view/browse.html.php
@@ -24,7 +24,7 @@
- config->CRProduct) or $product->status != 'closed'):?>
+
id&branch=$branch", " {$lang->productplan->create}", '', "class='btn btn-primary'");?>
@@ -34,7 +34,7 @@
productplan->noPlan;?>
- config->CRProduct) or $product->status != 'closed') and common::hasPriv('productplan', 'create')):?>
+
createLink('productplan', 'create', "productID=$product->id&branch=$branch"), " " . $lang->productplan->create, '', "class='btn btn-info'");?>
diff --git a/module/project/control.php b/module/project/control.php
index 472e050b46..6c406fa7ae 100644
--- a/module/project/control.php
+++ b/module/project/control.php
@@ -128,10 +128,6 @@ class project extends control
$products = $this->config->global->flow == 'onlyTask' ? array() : $this->loadModel('product')->getProductsByProject($projectID);
setcookie('preProjectID', $projectID, $this->config->cookieLife, $this->config->webRoot, '', false, true);
- /* Determines whether an object is editable. */
- $canBeChanged = true;
- if(empty($this->config->CRProject) and $project->status == 'closed') $canBeChanged = false;
-
if($this->cookie->preProjectID != $projectID)
{
$_COOKIE['moduleBrowseParam'] = $_COOKIE['productBrowseParam'] = 0;
@@ -221,7 +217,7 @@ class project extends control
$this->view->memberPairs = $memberPairs;
$this->view->branchGroups = $this->loadModel('branch')->getByProducts(array_keys($products), 'noempty');
$this->view->setModule = true;
- $this->view->canBeChanged = $canBeChanged;
+ $this->view->canBeChanged = common::canModify('project', $project); // Determines whether an object is editable.
$this->display();
}
@@ -701,10 +697,6 @@ class project extends control
$project = $this->commonAction($projectID);
$projectID = $project->id;
- /* Determines whether an object is editable. */
- $canBeChanged = true;
- if(empty($this->config->CRProject) and $project->status == 'closed') $canBeChanged = false;
-
/* Load pager. */
$this->app->loadClass('pager', $static = true);
$pager = new pager($recTotal, $recPerPage, $pageID);
@@ -783,7 +775,7 @@ class project extends control
$this->view->users = $users;
$this->view->pager = $pager;
$this->view->branchGroups = $branchGroups;
- $this->view->canBeChanged = $canBeChanged;
+ $this->view->canBeChanged = common::canModify('project', $project); // Determines whether an object is editable.
$this->display();
}
@@ -943,10 +935,6 @@ class project extends control
$project = $this->commonAction($projectID);
$projectID = $project->id;
- /* Determines whether an object is editable. */
- $canBeChanged = true;
- if(empty($this->config->CRProject) and $project->status == 'closed') $canBeChanged = false;
-
/* Load pager. */
$this->app->loadClass('pager', $static = true);
$pager = pager::init($recTotal, $recPerPage, $pageID);
@@ -967,7 +955,7 @@ class project extends control
$this->view->tasks = $productTasks;
$this->view->users = $this->loadModel('user')->getPairs('noclosed|noletter');
$this->view->products = $this->loadModel('product')->getPairs();
- $this->view->canBeChanged = $canBeChanged;
+ $this->view->canBeChanged = common::canModify('project', $project); // Determines whether an object is editable.
$this->display();
}
@@ -1063,17 +1051,13 @@ class project extends control
$project = $this->commonAction($projectID);
$projectID = $project->id;
- /* Determines whether an object is editable. */
- $canBeChanged = true;
- if(empty($this->config->CRProject) and $project->status == 'closed') $canBeChanged = false;
-
$title = $project->name . $this->lang->colon . $this->lang->project->team;
$position[] = html::a($this->createLink('project', 'browse', "projectID=$projectID"), $project->name);
$position[] = $this->lang->project->team;
$this->view->title = $title;
$this->view->position = $position;
- $this->view->canBeChanged = $canBeChanged;
+ $this->view->canBeChanged = common::canModify('project', $project); // Determines whether an object is editable.
$this->display();
}
@@ -1591,10 +1575,6 @@ class project extends control
$project = $this->project->getById($projectID, true);
if(!$project) die(js::error($this->lang->notFound) . js::locate('back'));
- /* Determines whether an object is editable. */
- $canBeChanged = true;
- if(empty($this->config->CRProject) and $project->status == 'closed') $canBeChanged = false;
-
$products = $this->project->getProducts($project->id);
$linkedBranches = array();
foreach($products as $product)
@@ -1631,7 +1611,7 @@ class project extends control
$this->view->docLibs = $this->loadModel('doc')->getLibsByObject('project', $projectID);
$this->view->statData = $this->project->statRelatedData($projectID);
$this->view->chartData = $chartData;
- $this->view->canBeChanged = $canBeChanged;
+ $this->view->canBeChanged = common::canModify('project', $project); // Determines whether an object is editable.
$this->display();
}
@@ -1663,8 +1643,7 @@ class project extends control
$stories = $this->loadModel('story')->getProjectStories($projectID, $orderBy);
/* Determines whether an object is editable. */
- $canBeChanged = true;
- if(empty($this->config->CRProject) and $project->status == 'closed') $canBeChanged = false;
+ $canBeChanged = common::canModify('project', $project);
$kanbanGroup = $this->project->getKanbanGroupData($stories, $tasks, $bugs, $type);
$kanbanSetting = $this->project->getKanbanSetting();
@@ -1855,10 +1834,6 @@ class project extends control
$stories = $this->loadModel('story')->getProjectStories($projectID);
$this->loadModel('common')->saveQueryCondition($this->dao->get(), 'story', false);
- /* Determines whether an object is editable. */
- $canBeChanged = true;
- if(empty($this->config->CRProject) and $project->status == 'closed') $canBeChanged = false;
-
/* Get project's product. */
$productID = 0;
$productPairs = $this->loadModel('product')->getProductsByProject($projectID);
@@ -1872,7 +1847,7 @@ class project extends control
$this->view->projectID = $projectID;
$this->view->project = $project;
$this->view->productID = $productID;
- $this->view->canBeChanged = $canBeChanged;
+ $this->view->canBeChanged = common::canModify('project', $project); // Determines whether an object is editable.
$this->display();
}
diff --git a/module/project/view/bug.html.php b/module/project/view/bug.html.php
index c94559635d..9423ad5e81 100644
--- a/module/project/view/bug.html.php
+++ b/module/project/view/bug.html.php
@@ -22,7 +22,7 @@
id", " " . $lang->bug->export, '', "class='btn btn-link export'");?>
- config->CRProject) or $project->status != 'closed') common::printLink('bug', 'create', "productID=$productID&branch=$branchID&extra=projectID=$project->id", " " . $lang->bug->create, '', "class='btn btn-primary'");?>
+ id", " " . $lang->bug->create, '', "class='btn btn-primary'");?>
@@ -31,7 +31,7 @@
bug->noBug;?>
- config->CRProject) or $project->status != 'closed') and common::hasPriv('bug', 'create')):?>
+
createLink('bug', 'create', "productID=$productID&branch=$branchID&extra=projectID=$project->id"), " " . $lang->bug->create, '', "class='btn btn-info'");?>
diff --git a/module/project/view/build.html.php b/module/project/view/build.html.php
index 35c0ea8330..f62eca6e14 100644
--- a/module/project/view/build.html.php
+++ b/module/project/view/build.html.php
@@ -29,7 +29,7 @@
project->byQuery;?>
- config->CRProject) or $project->status != 'closed') common::printLink('build', 'create', "project=$project->id", " " . $lang->build->create, '', "class='btn btn-primary'");?>
+ id", " " . $lang->build->create, '', "class='btn btn-primary'");?>
@@ -38,7 +38,7 @@
build->noBuild;?>
- config->CRProject) or $project->status != 'closed') and common::hasPriv('build', 'create')):?>
+
createLink('build', 'create', "project=$project->id"), " " . $lang->build->create, '', "class='btn btn-info'");?>
diff --git a/module/project/view/burn.html.php b/module/project/view/burn.html.php
index 6eb3e3385b..a992d0ca7b 100644
--- a/module/project/view/burn.html.php
+++ b/module/project/view/burn.html.php
@@ -25,7 +25,7 @@
common::printLink('project', 'computeBurn', 'reload=yes', '
' . $lang->project->computeBurn, 'hiddenwin', "title='{$lang->project->computeBurn}{$lang->project->burn}' class='btn btn-primary' id='computeBurn'");
echo '
';
echo html::a($this->createLink('project', 'burn', "projectID=$projectID&type=$weekend&interval=$interval"), $lang->project->$weekend, '', "class='btn btn-link'");
- if(!empty($this->config->CRProject) or $project->status != 'closed') common::printLink('project', 'fixFirst', "project=$project->id", $lang->project->fixFirst, '', "class='btn btn-link iframe' data-width='700'");
+ if(common::canModify('project', $project)) common::printLink('project', 'fixFirst', "project=$project->id", $lang->project->fixFirst, '', "class='btn btn-link iframe' data-width='700'");
echo $lang->project->howToUpdateBurn;
?>
diff --git a/module/project/view/grouptask.html.php b/module/project/view/grouptask.html.php
index 53cb155ac2..47cb024004 100644
--- a/module/project/view/grouptask.html.php
+++ b/module/project/view/grouptask.html.php
@@ -53,7 +53,7 @@
?>
- config->CRProject) or $project->status != 'closed'):?>
+