diff --git a/module/bug/model.php b/module/bug/model.php index 5783aed7f6..dfd5705ccd 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -2509,14 +2509,14 @@ class bugModel extends model /* Check the product is closed. */ $changeAllowed = common::checkObjectChangeAllowed('bug', $bug); - $canBatchEdit = common::hasPriv('bug', 'batchEdit'); - $canBatchConfirm = common::hasPriv('bug', 'batchConfirm'); + $canBatchEdit = ($changeAllowed and common::hasPriv('bug', 'batchEdit')); + $canBatchConfirm = ($changeAllowed and common::hasPriv('bug', 'batchConfirm')); $canBatchClose = common::hasPriv('bug', 'batchClose'); - $canBatchActivate = common::hasPriv('bug', 'batchActivate'); - $canBatchChangeBranch = common::hasPriv('bug', 'batchChangeBranch'); - $canBatchChangeModule = common::hasPriv('bug', 'batchChangeModule'); - $canBatchResolve = common::hasPriv('bug', 'batchResolve'); - $canBatchAssignTo = common::hasPriv('bug', 'batchAssignTo'); + $canBatchActivate = ($changeAllowed and common::hasPriv('bug', 'batchActivate')); + $canBatchChangeBranch = ($changeAllowed and common::hasPriv('bug', 'batchChangeBranch')); + $canBatchChangeModule = ($changeAllowed and common::hasPriv('bug', 'batchChangeModule')); + $canBatchResolve = ($changeAllowed and common::hasPriv('bug', 'batchResolve')); + $canBatchAssignTo = ($changeAllowed and common::hasPriv('bug', 'batchAssignTo')); $canBatchAction = ($canBatchEdit or $canBatchConfirm or $canBatchClose or $canBatchActivate or $canBatchChangeBranch or $canBatchChangeModule or $canBatchResolve or $canBatchAssignTo); @@ -2578,8 +2578,7 @@ class bugModel extends model case 'id': if($canBatchAction) { - $disabled = $changeAllowed ? '' : 'disabled'; - echo html::checkbox('bugIDList', array($bug->id => ''), '', $disabled) . html::a(helper::createLink('bug', 'view', "bugID=$bug->id"), sprintf('%03d', $bug->id)); + echo html::checkbox('bugIDList', array($bug->id => ''), '') . html::a(helper::createLink('bug', 'view', "bugID=$bug->id"), sprintf('%03d', $bug->id)); } else { @@ -2730,15 +2729,19 @@ class bugModel extends model echo substr($bug->lastEditedDate, 5, 11); break; case 'actions': + $params = "bugID=$bug->id"; if($changeAllowed) { - $params = "bugID=$bug->id"; common::printIcon('bug', 'confirmBug', $params, $bug, 'list', 'confirm', '', 'iframe', true); common::printIcon('bug', 'resolve', $params, $bug, 'list', 'checked', '', 'iframe', true); common::printIcon('bug', 'close', $params, $bug, 'list', '', '', 'iframe', true); common::printIcon('bug', 'edit', $params, $bug, 'list'); common::printIcon('bug', 'create', "product=$bug->product&branch=$bug->branch&extra=$params", $bug, 'list', 'copy'); } + else + { + common::printIcon('bug', 'close', $params, $bug, 'list', '', '', 'iframe', true); + } break; } echo ''; diff --git a/module/bug/view/browse.html.php b/module/bug/view/browse.html.php index b901159e36..b37104f9d1 100644 --- a/module/bug/view/browse.html.php +++ b/module/bug/view/browse.html.php @@ -211,14 +211,15 @@ $currentBrowseType = isset($lang->bug->mySelects[$browseType]) && in_array($brow $widths = $this->datatable->setFixedFieldWidth($setting); $columns = 0; - $canBatchEdit = common::hasPriv('bug', 'batchEdit'); - $canBatchConfirm = common::hasPriv('bug', 'batchConfirm'); + $changeAllowed = (empty($config->global->closedProductStatus) or $product->status != 'closed'); + $canBatchEdit = ($changeAllowed and common::hasPriv('bug', 'batchEdit')); + $canBatchConfirm = ($changeAllowed and common::hasPriv('bug', 'batchConfirm')); $canBatchClose = common::hasPriv('bug', 'batchClose'); - $canBatchActivate = common::hasPriv('bug', 'batchActivate'); - $canBatchChangeBranch = common::hasPriv('bug', 'batchChangeBranch'); - $canBatchChangeModule = common::hasPriv('bug', 'batchChangeModule'); - $canBatchResolve = common::hasPriv('bug', 'batchResolve'); - $canBatchAssignTo = common::hasPriv('bug', 'batchAssignTo'); + $canBatchActivate = ($changeAllowed and common::hasPriv('bug', 'batchActivate')); + $canBatchChangeBranch = ($changeAllowed and common::hasPriv('bug', 'batchChangeBranch')); + $canBatchChangeModule = ($changeAllowed and common::hasPriv('bug', 'batchChangeModule')); + $canBatchResolve = ($changeAllowed and common::hasPriv('bug', 'batchResolve')); + $canBatchAssignTo = ($changeAllowed and common::hasPriv('bug', 'batchAssignTo')); $canBatchAction = ($canBatchEdit or $canBatchConfirm or $canBatchClose or $canBatchActivate or $canBatchChangeBranch or $canBatchChangeModule or $canBatchResolve or $canBatchAssignTo); ?> diff --git a/module/common/model.php b/module/common/model.php index 9f4897a508..f64440276f 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -1490,7 +1490,7 @@ EOD; global $app, $lang; /* Check the parent object is closed. */ - if(!commonModel::checkObjectChangeAllowed($module, $object)) return false; + if(strpos('close|batchClose', $method) === false and !commonModel::checkObjectChangeAllowed($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; @@ -1855,32 +1855,18 @@ EOD; global $app, $config; /* Check the product is closed. */ - if(!empty($object->product) and !empty($config->global->closedProductStatus)) + if(!empty($object->product) and is_numeric($object->product) and !empty($config->global->closedProductStatus)) { $productID = trim($object->product, ','); $product = $app->control->loadModel('product')->getByID($productID); if($product->status == 'closed') return false; - - /* Get the projects associated with the story. */ - if($module == 'story' and empty($object->project)) - { - $projects = $app->dbh->query('SELECT project FROM ' . TABLE_PROJECTSTORY . " WHERE `story` = '$object->id'")->fetchAll(); - $projectIDList = array(); - foreach($projects as $project) $projectIDList[] = $project->project; - - $object->project = implode(',', $projectIDList); - } } /* Check the project is closed. */ - if(!empty($object->project) and !empty($config->global->closedProjectStatus)) + if(strpos('story|bug|testtask', $module) === false and !empty($object->project) and is_numeric($object->project) and !empty($config->global->closedProjectStatus)) { - $projectIDList = explode(',', $object->project); - $projects = $app->control->loadModel('project')->getByIDList($projectIDList); - foreach($projects as $project) - { - if($project->status == 'closed') return false; - } + $project = $app->control->loadModel('project')->getByID($object->project); + if($project->status == 'closed') return false; } return true; diff --git a/module/product/view/browse.html.php b/module/product/view/browse.html.php index 05a1e4be15..3068fc47e1 100644 --- a/module/product/view/browse.html.php +++ b/module/product/view/browse.html.php @@ -189,14 +189,15 @@ js::set('foldAll', $lang->project->treeLevel['root']); $widths = $this->datatable->setFixedFieldWidth($setting); $columns = 0; - $canBatchEdit = common::hasPriv('story', 'batchEdit'); - $canBatchClose = common::hasPriv('story', 'batchClose') and strtolower($browseType) != 'closedbyme' and strtolower($browseType) != 'closedstory'; - $canBatchReview = common::hasPriv('story', 'batchReview'); - $canBatchChangeStage = common::hasPriv('story', 'batchChangeStage'); - $canBatchChangeBranch = common::hasPriv('story', 'batchChangeBranch'); - $canBatchChangeModule = common::hasPriv('story', 'batchChangeModule'); - $canBatchChangePlan = common::hasPriv('story', 'batchChangePlan'); - $canBatchAssignTo = common::hasPriv('story', 'batchAssignTo'); + $changeAllowed = (empty($config->global->closedProductStatus) or $product->status != 'closed'); + $canBatchEdit = ($changeAllowed and common::hasPriv('story', 'batchEdit')); + $canBatchClose = (common::hasPriv('story', 'batchClose') and strtolower($browseType) != 'closedbyme' and strtolower($browseType) != 'closedstory'); + $canBatchReview = ($changeAllowed and common::hasPriv('story', 'batchReview')); + $canBatchChangeStage = ($changeAllowed and common::hasPriv('story', 'batchChangeStage')); + $canBatchChangeBranch = ($changeAllowed and common::hasPriv('story', 'batchChangeBranch')); + $canBatchChangeModule = ($changeAllowed and common::hasPriv('story', 'batchChangeModule')); + $canBatchChangePlan = ($changeAllowed and common::hasPriv('story', 'batchChangePlan')); + $canBatchAssignTo = ($changeAllowed and common::hasPriv('story', 'batchAssignTo')); $canBatchAction = ($canBatchEdit or $canBatchClose or $canBatchReview or $canBatchChangeStage or $canBatchChangeModule or $canBatchChangePlan or $canBatchAssignTo); ?> diff --git a/module/project/control.php b/module/project/control.php index 7672abbd4e..18b28157d9 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -696,6 +696,10 @@ class project extends control $project = $this->commonAction($projectID); $projectID = $project->id; + /* Determines whether an object is editable. */ + $changeAllowed = true; + if(!empty($this->config->global->closedProjectStatus) and $project->status == 'closed') $changeAllowed = false; + /* Load pager. */ $this->app->loadClass('pager', $static = true); $pager = new pager($recTotal, $recPerPage, $pageID); @@ -756,24 +760,25 @@ class project extends control if($productPairs) $productID = key($productPairs); /* Assign. */ - $this->view->title = $title; - $this->view->position = $position; - $this->view->productID = $productID; - $this->view->project = $project; - $this->view->stories = $stories; - $this->view->allPlans = $allPlans; - $this->view->summary = $this->product->summary($stories); - $this->view->orderBy = $orderBy; - $this->view->type = $this->session->projectStoryBrowseType; - $this->view->param = $param; - $this->view->moduleTree = $this->loadModel('tree')->getProjectStoryTreeMenu($projectID, $startModuleID = 0, array('treeModel', 'createProjectStoryLink')); - $this->view->tabID = 'story'; - $this->view->storyTasks = $storyTasks; - $this->view->storyBugs = $storyBugs; - $this->view->storyCases = $storyCases; - $this->view->users = $users; - $this->view->pager = $pager; - $this->view->branchGroups = $branchGroups; + $this->view->title = $title; + $this->view->position = $position; + $this->view->productID = $productID; + $this->view->project = $project; + $this->view->stories = $stories; + $this->view->allPlans = $allPlans; + $this->view->summary = $this->product->summary($stories); + $this->view->orderBy = $orderBy; + $this->view->type = $this->session->projectStoryBrowseType; + $this->view->param = $param; + $this->view->moduleTree = $this->loadModel('tree')->getProjectStoryTreeMenu($projectID, $startModuleID = 0, array('treeModel', 'createProjectStoryLink')); + $this->view->tabID = 'story'; + $this->view->storyTasks = $storyTasks; + $this->view->storyBugs = $storyBugs; + $this->view->storyCases = $storyCases; + $this->view->users = $users; + $this->view->pager = $pager; + $this->view->branchGroups = $branchGroups; + $this->view->changeAllowed = $changeAllowed; $this->display(); } @@ -933,6 +938,10 @@ class project extends control $project = $this->commonAction($projectID); $projectID = $project->id; + /* Determines whether an object is editable. */ + $changeAllowed = true; + if(!empty($this->config->global->closedProjectStatus) and $project->status == 'closed') $changeAllowed = false; + /* Load pager. */ $this->app->loadClass('pager', $static = true); $pager = pager::init($recTotal, $recPerPage, $pageID); @@ -942,17 +951,18 @@ class project extends control $tasks = $this->testtask->getProjectTasks($projectID, $orderBy, $pager); foreach($tasks as $key => $task) $productTasks[$task->product][] = $task; - $this->view->title = $this->projects[$projectID] . $this->lang->colon . $this->lang->testtask->common; - $this->view->position[] = html::a($this->createLink('project', 'testtask', "projectID=$projectID"), $this->projects[$projectID]); - $this->view->position[] = $this->lang->testtask->common; - $this->view->project = $project; - $this->view->projectID = $projectID; - $this->view->projectName = $this->projects[$projectID]; - $this->view->pager = $pager; - $this->view->orderBy = $orderBy; - $this->view->tasks = $productTasks; - $this->view->users = $this->loadModel('user')->getPairs('noclosed|noletter'); - $this->view->products = $this->loadModel('product')->getPairs(); + $this->view->title = $this->projects[$projectID] . $this->lang->colon . $this->lang->testtask->common; + $this->view->position[] = html::a($this->createLink('project', 'testtask', "projectID=$projectID"), $this->projects[$projectID]); + $this->view->position[] = $this->lang->testtask->common; + $this->view->project = $project; + $this->view->projectID = $projectID; + $this->view->projectName = $this->projects[$projectID]; + $this->view->pager = $pager; + $this->view->orderBy = $orderBy; + $this->view->tasks = $productTasks; + $this->view->users = $this->loadModel('user')->getPairs('noclosed|noletter'); + $this->view->products = $this->loadModel('product')->getPairs(); + $this->view->changeAllowed = $changeAllowed; $this->display(); } diff --git a/module/project/view/story.html.php b/module/project/view/story.html.php index 40811dea4c..d198df8f4f 100644 --- a/module/project/view/story.html.php +++ b/module/project/view/story.html.php @@ -119,7 +119,7 @@ $canBatchUnlink = common::hasPriv('project', 'batchUnlinkStory'); $canBatchToTask = common::hasPriv('story', 'batchToTask'); - $canBatchAction = ($canBatchEdit or $canBatchClose or $canBatchChangeStage or $canBatchUnlink or $canBatchToTask); + $canBatchAction = ($changeAllowed and ($canBatchEdit or $canBatchClose or $canBatchChangeStage or $canBatchUnlink or $canBatchToTask)); ?> id}&orderBy=%s&type=$type¶m=$param&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}"; ?> @@ -149,16 +149,13 @@ $story):?> createLink('story', 'view', "storyID=$story->id&version=$story->version&from=project¶m=$project->id"); $totalEstimate += $story->estimate; ?> - id => ''), '', $disabled) . html::a(helper::createLink('story', 'view', "storyID=$story->id"), sprintf('%03d', $story->id));?> + id => '')) . html::a(helper::createLink('story', 'view', "storyID=$story->id"), sprintf('%03d', $story->id));?> id);?> @@ -199,9 +196,9 @@ id}&story={$story->id}&moduleID={$story->module}"; $lang->task->create = $lang->project->wbs; @@ -221,7 +218,7 @@ $lang->testcase->batchCreate = $lang->testcase->create; if($productID && $hasDBPriv) common::printIcon('testcase', 'batchCreate', "productID=$story->product&branch=$story->branch&moduleID=$story->module&storyID=$story->id", '', 'list', 'sitemap'); - if(common::hasPriv('project', 'unlinkStory', $project)) + if($changeAllowed and common::hasPriv('project', 'unlinkStory', $project)) { $unlinkURL = $this->createLink('project', 'unlinkStory', "projectID=$project->id&storyID=$story->id&confirm=yes"); echo html::a("javascript:ajaxDelete(\"$unlinkURL\", \"storyList\", confirmUnlinkStory)", '', '', "class='btn' title='{$lang->project->unlinkStory}'"); diff --git a/module/project/view/testtask.html.php b/module/project/view/testtask.html.php index 15a068dc73..ed6506631c 100644 --- a/module/project/view/testtask.html.php +++ b/module/project/view/testtask.html.php @@ -49,7 +49,7 @@ recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}";?> - + '> > ';
testtask->product);?> @@ -73,10 +73,6 @@ $productTasks):?> -
@@ -86,7 +82,7 @@ - id => sprintf('%03d', $task->id)), '', $disabled);?> + id => sprintf('%03d', $task->id)));?> id);?> diff --git a/module/story/model.php b/module/story/model.php index cc898f8a6d..a2117a4bc7 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -3094,8 +3094,7 @@ class storyModel extends model case 'id': if($canBatchAction) { - $disabled = $changeAllowed ? '' : 'disabled'; - echo html::checkbox('storyIdList', array($story->id => ''), '', $disabled) . html::a(helper::createLink('story', 'view', "storyID=$story->id"), sprintf('%03d', $story->id)); + echo html::checkbox('storyIdList', array($story->id => ''), '') . html::a(helper::createLink('story', 'view', "storyID=$story->id"), sprintf('%03d', $story->id)); } else { @@ -3216,9 +3215,9 @@ class storyModel extends model echo $story->version; break; case 'actions': + $vars = "story={$story->id}"; if($changeAllowed) { - $vars = "story={$story->id}"; common::printIcon('story', 'change', $vars, $story, 'list', 'fork'); common::printIcon('story', 'review', $vars, $story, 'list', 'glasses'); common::printIcon('story', 'close', $vars, $story, 'list', '', '', 'iframe', true); @@ -3226,6 +3225,10 @@ class storyModel extends model if($this->config->global->flow != 'onlyStory') common::printIcon('story', 'createCase', "productID=$story->product&branch=$story->branch&module=0&from=¶m=0&$vars", $story, 'list', 'sitemap'); common::printIcon('story', 'batchCreate', "productID=$story->product&branch=$story->branch&module=0&storyID=$story->id", $story, 'list', 'treemap-alt', '', '', '', '', $this->lang->story->subdivide); } + else + { + common::printIcon('story', 'close', $vars, $story, 'list', '', '', 'iframe', true); + } break; } echo '