From 41a2fc9a8f2a66a245195a9eb5444c4adc957db7 Mon Sep 17 00:00:00 2001 From: pengjiangxiu Date: Tue, 19 Sep 2017 13:56:39 +0800 Subject: [PATCH] * Finish task #3210. --- db/update9.5.sql | 2 + lib/base/front/front.class.php | 2 +- module/bug/model.php | 2 + module/bug/view/browsedata.html.php | 2 +- module/bug/view/view.html.php | 12 +-- module/build/model.php | 15 +++ module/build/view/view.html.php | 8 +- module/common/model.php | 109 +++++++++++++++------ module/doc/model.php | 15 +++ module/doc/view/browse.html.php | 4 +- module/doc/view/showfiles.html.php | 4 +- module/doc/view/view.html.php | 6 +- module/my/view/profile.html.php | 4 + module/product/model.php | 2 + module/product/view/browsedata.html.php | 2 +- module/product/view/view.html.php | 4 +- module/productplan/control.php | 12 +-- module/productplan/model.php | 21 +++- module/productplan/view/browse.html.php | 4 +- module/productplan/view/view.html.php | 6 +- module/project/control.php | 25 ++--- module/project/lang/en.php | 4 + module/project/lang/zh-cn.php | 6 +- module/project/lang/zh-tw.php | 6 +- module/project/model.php | 38 +++++-- module/project/view/bug.html.php | 2 +- module/project/view/build.html.php | 10 +- module/project/view/linkstory.html.php | 2 +- module/project/view/managemembers.html.php | 10 +- module/project/view/story.html.php | 16 +-- module/project/view/task.html.php | 10 +- module/project/view/taskdata.html.php | 2 +- module/project/view/taskheader.html.php | 8 +- module/project/view/team.html.php | 8 +- module/project/view/testtask.html.php | 10 +- module/project/view/view.html.php | 4 +- module/release/model.php | 15 +++ module/release/view/browse.html.php | 6 +- module/release/view/view.html.php | 6 +- module/story/lang/en.php | 1 + module/story/lang/zh-cn.php | 1 + module/story/lang/zh-tw.php | 1 + module/story/model.php | 40 ++++---- module/story/view/view.html.php | 24 ++--- module/task/model.php | 2 + module/task/view/view.html.php | 8 +- module/testcase/model.php | 2 + module/testcase/view/browsedata.html.php | 6 +- module/testcase/view/view.html.php | 18 ++-- module/testsuite/model.php | 15 +++ module/testsuite/view/browse.html.php | 6 +- module/testsuite/view/view.html.php | 6 +- module/testtask/model.php | 2 + module/testtask/view/browse.html.php | 10 +- module/testtask/view/casesdata.html.php | 6 +- module/testtask/view/view.html.php | 4 +- module/user/config.php | 4 +- module/user/lang/zh-cn.php | 17 ++-- module/user/model.php | 11 ++- module/user/view/batchcreate.html.php | 4 +- module/user/view/batchedit.html.php | 2 + module/user/view/create.html.php | 5 + module/user/view/edit.html.php | 6 +- 63 files changed, 418 insertions(+), 207 deletions(-) diff --git a/db/update9.5.sql b/db/update9.5.sql index cc8564ed48..41d9aef0af 100644 --- a/db/update9.5.sql +++ b/db/update9.5.sql @@ -1 +1,3 @@ ALTER TABLE `zt_bug` ADD `activatedDate` datetime NOT NULL AFTER `activatedCount`; +ALTER TABLE `zt_user` ADD `limitedUser` varchar(8) NOT NULL default 'no' AFTER `role`; +ALTER TABLE `zt_team` ADD `limitedUser` varchar(8) NOT NULL default 'no' AFTER `role`; diff --git a/lib/base/front/front.class.php b/lib/base/front/front.class.php index a7afcbbfb5..4200dcb6a8 100644 --- a/lib/base/front/front.class.php +++ b/lib/base/front/front.class.php @@ -112,7 +112,7 @@ class baseHTML if(empty($title)) $title = $href; $newline = $newline ? "\n" : ''; - + return "$title$newline"; } diff --git a/module/bug/model.php b/module/bug/model.php index e3527c97d9..c52e931da7 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -2243,6 +2243,8 @@ class bugModel extends model { $action = strtolower($action); + if(!common::limitedUser($object)) return false; + 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'; diff --git a/module/bug/view/browsedata.html.php b/module/bug/view/browsedata.html.php index 39d2aaca3d..46c59e165b 100644 --- a/module/bug/view/browsedata.html.php +++ b/module/bug/view/browsedata.html.php @@ -100,7 +100,7 @@ id"; common::printIcon('bug', 'confirmBug', $params, $bug, 'list', 'search', '', 'iframe', true); - common::printIcon('bug', 'assignTo', $params, '', 'list', '', '', 'iframe', true); + common::printIcon('bug', 'assignTo', $params, $bug, 'list', '', '', 'iframe', true); common::printIcon('bug', 'resolve', $params, $bug, 'list', '', '', 'iframe', true); common::printIcon('bug', 'close', $params, $bug, 'list', '', '', 'iframe', true); common::printIcon('bug', 'edit', $params, $bug, 'list'); diff --git a/module/bug/view/view.html.php b/module/bug/view/view.html.php index 24427f43a6..971a665670 100644 --- a/module/bug/view/view.html.php +++ b/module/bug/view/view.html.php @@ -31,20 +31,20 @@ ob_start(); echo "
"; common::printIcon('bug', 'confirmBug', $params, $bug, 'button', 'search', '', 'iframe', true); - common::printIcon('bug', 'assignTo', $params, '', 'button', '', '', 'iframe', true); + common::printIcon('bug', 'assignTo', $params, $bug, 'button', '', '', 'iframe', true); common::printIcon('bug', 'resolve', $params, $bug, 'button', '', '', 'iframe showinonlybody', true); common::printIcon('bug', 'close', $params, $bug, 'button', '', '', 'text-danger iframe showinonlybody', true); common::printIcon('bug', 'activate', $params, $bug, 'button', '', '', 'text-success iframe showinonlybody', true); if($this->config->global->flow != 'onlyTest') common::printIcon('bug', 'toStory', "product=$bug->product&branch=$bug->branch&module=0&story=0&project=0&bugID=$bug->id", $bug, 'button', $lang->icons['story']); - common::printIcon('bug', 'createCase', $convertParams, '', 'button', 'sitemap'); + common::printIcon('bug', 'createCase', $convertParams, $bug, 'button', 'sitemap'); echo '
'; echo "
"; - common::printIcon('bug', 'edit', $params); - common::printCommentIcon('bug'); - common::printIcon('bug', 'create', $copyParams, '', 'button', 'copy'); - common::printIcon('bug', 'delete', $params, '', 'button', '', 'hiddenwin'); + common::printIcon('bug', 'edit', $params, $bug); + common::printCommentIcon('bug', $bug); + common::printIcon('bug', 'create', $copyParams, $bug, 'button', 'copy'); + common::printIcon('bug', 'delete', $params, $bug, 'button', '', 'hiddenwin'); echo '
'; echo "
"; diff --git a/module/build/model.php b/module/build/model.php index 7215c274c8..f6d1cb1999 100644 --- a/module/build/model.php +++ b/module/build/model.php @@ -407,4 +407,19 @@ class buildModel extends model $this->loadModel('action')->create('bug', $unlinkBugID, 'unlinkedfrombuild', '', $buildID); } } + + /** + * Judge an action is clickable or not. + * + * @param object $project + * @param string $action + * @access public + * @return bool + */ + public static function isClickable($build, $action) + { + if(!common::limitedUser($build)) return false; + + return true; + } } diff --git a/module/build/view/view.html.php b/module/build/view/view.html.php index c0a4059f57..469bec757f 100644 --- a/module/build/view/view.html.php +++ b/module/build/view/view.html.php @@ -46,8 +46,8 @@ tfoot tr td .table-actions .btn{display:none;} echo '
'; } echo "
"; - common::printIcon('build', 'edit', "buildID=$build->id"); - common::printIcon('build', 'delete', "buildID=$build->id", '', 'button', '', 'hiddenwin'); + common::printIcon('build', 'edit', "buildID=$build->id", $build); + common::printIcon('build', 'delete', "buildID=$build->id", $build, 'button', '', 'hiddenwin'); echo '
'; } echo common::printRPN($browseLink); @@ -69,8 +69,8 @@ tfoot tr td .table-actions .btn{display:none;} $browseLink = $this->session->buildList ? $this->session->buildList : $this->createLink('product', 'build', "productID=$build->product"); if(!$build->deleted) { - common::printIcon('build', 'edit', "buildID=$build->id"); - common::printIcon('build', 'delete', "buildID=$build->id", '', 'button', '', 'hiddenwin'); + common::printIcon('build', 'edit', "buildID=$build->id", $build); + common::printIcon('build', 'delete', "buildID=$build->id", $build, 'button', '', 'hiddenwin'); } echo common::printRPN($browseLink); ?> diff --git a/module/common/model.php b/module/common/model.php index 8d627c8c7a..aa28cb7b24 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -598,9 +598,9 @@ class commonModel extends model * @access public * @return bool */ - public static function printLink($module, $method, $vars = '', $label, $target = '', $misc = '', $newline = true, $onlyBody = false) + public static function printLink($module, $method, $vars = '', $label, $target = '', $misc = '', $newline = true, $onlyBody = false, $object = null) { - if(!commonModel::hasPriv($module, $method)) return false; + if(!commonModel::hasPriv($module, $method, $object)) return false; echo html::a(helper::createLink($module, $method, $vars, '', $onlyBody), $label, $target, $misc, $newline); return true; } @@ -625,29 +625,29 @@ class commonModel extends model * @access public * @return void */ - public static function printCommentIcon($module) + public static function printCommentIcon($module, $object = null) { if(isonlybody()) return false; global $lang; - if(!commonModel::hasPriv($module, 'edit')) return false; + if(!commonModel::hasPriv($module, 'edit', $object)) return false; echo html::a('#commentBox', '', '', "title='$lang->comment' onclick='setComment()' class='btn'"); } /** * Build icon button. - * - * @param string $module - * @param string $method - * @param string $vars - * @param object $object - * @param string $type button|list - * @param string $icon - * @param string $target - * @param string $extraClass - * @param bool $onlyBody - * @param string $misc + * + * @param string $module + * @param string $method + * @param string $vars + * @param object $object + * @param string $type button|list + * @param string $icon + * @param string $target + * @param string $extraClass + * @param bool $onlyBody + * @param string $misc * @static * @access public * @return void @@ -736,17 +736,17 @@ class commonModel extends model /** * Print link icon. - * - * @param string $module - * @param string $method - * @param string $vars - * @param object $object - * @param string $type button|list - * @param string $icon - * @param string $target - * @param string $extraClass - * @param bool $onlyBody - * @param string $misc + * + * @param string $module + * @param string $method + * @param string $vars + * @param object $object + * @param string $type button|list + * @param string $icon + * @param string $target + * @param string $extraClass + * @param bool $onlyBody + * @param string $misc * @static * @access public * @return void @@ -758,9 +758,9 @@ class commonModel extends model /** * Print backLink and preLink and nextLink. - * - * @param string $backLink - * @param object $preAndNext + * + * @param string $backLink + * @param object $preAndNext * @access public * @return void */ @@ -1125,7 +1125,7 @@ class commonModel extends model * @access public * @return bool */ - public static function hasPriv($module, $method) + public static function hasPriv($module, $method, $object = null) { global $app, $lang; @@ -1140,6 +1140,8 @@ class commonModel extends model if(isset($rights[$module][$method])) { + if(!commonModel::limitedUser($object, $module, $method)) return false; + if(empty($acls['views'])) return true; $menu = isset($lang->menugroup->$module) ? $lang->menugroup->$module : $module; $menu = strtolower($menu); @@ -1148,8 +1150,55 @@ class commonModel extends model if($module == 'company' and $method == 'dynamic') return true; if($module == 'action' and $method == 'editcomment') return true; if(!isset($acls['views'][$menu])) return false; + return true; } + + return false; + } + + public static function limitedUser($object, $module = null, $method = null) + { + global $app; + + if(!empty($app->user->admin) || $app->user->account == 'guest') return true; + + // limited project + $limitedProject = false; + if(!empty($module) && $module == 'task' && !empty($object->project) || + !empty($module) && $module == 'task' && !empty($object->id)) + { + $objectID = ''; + if(!empty($object->id)) $objectID = $object->id; + if(!empty($object->id) && !empty($object->project)) $objectID = $object->project; + + $sessionKey = $app->user->account . 'project' . $objectID; + if(!empty($_SESSION[$sessionKey]) && $_SESSION[$sessionKey] == $objectID) + { + $limitedProject = true; + } + } + + if(!empty($app->user->limitedUser) && $app->user->limitedUser === 'no' && !$limitedProject) return true; + + if(!is_null($method) && strpos($method, 'batch') === 0) return false; + if(!is_null($method) && strpos($method, 'link') === 0) return false; + if(!is_null($method) && strpos($method, 'create') === 0) return false; + if(!is_null($method) && strpos($method, 'import') === 0) return false; + + if(is_null($object)) return true; + + if(!empty($object->openedBy) && $object->openedBy == $app->user->account || + !empty($object->addedBy) && $object->addedBy == $app->user->account || + !empty($object->assignedTo) && $object->assignedTo == $app->user->account || + !empty($object->finishedBy) && $object->finishedBy == $app->user->account || + !empty($object->canceledBy) && $object->canceledBy == $app->user->account || + !empty($object->closedBy) && $object->closedBy == $app->user->account || + !empty($object->lastEditedBy) && $object->lastEditedBy == $app->user->account) + { + return true; + } + return false; } diff --git a/module/doc/model.php b/module/doc/model.php index b28231f121..36745064fa 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -1158,4 +1158,19 @@ class docModel extends model return $teams; } + + /** + * Judge an action is clickable or not. + *- + * @param object $product- + * @param string $action- + * @access public + * @return void + */ + public static function isClickable($doc, $action) + { + if(!common::limitedUser($doc)) return false; + + return true; + } } diff --git a/module/doc/view/browse.html.php b/module/doc/view/browse.html.php index 4fb764ba47..18df8a5cae 100644 --- a/module/doc/view/browse.html.php +++ b/module/doc/view/browse.html.php @@ -93,8 +93,8 @@ var browseType = ''; editedDate, 5, 11);?> id}", '', 'list'); - if(common::hasPriv('doc', 'delete')) + common::printIcon('doc', 'edit', "doc={$doc->id}", $doc, 'list'); + if(common::hasPriv('doc', 'delete', $doc)) { $deleteURL = $this->createLink('doc', 'delete', "docID=$doc->id&confirm=yes"); echo html::a("javascript:ajaxDelete(\"$deleteURL\",\"docList\",confirmDelete)", '', '', "class='btn-icon' title='{$lang->doc->delete}'"); diff --git a/module/doc/view/showfiles.html.php b/module/doc/view/showfiles.html.php index 16f5133739..2a024e0daf 100644 --- a/module/doc/view/showfiles.html.php +++ b/module/doc/view/showfiles.html.php @@ -76,8 +76,8 @@ addedDate) ? substr($file->addedDate, 0, 10) : '';?> id", $lang->doc->download, "data-toggle='modal'"); - common::printLink('file', 'delete', "fileID=$file->id", $lang->delete, 'hiddenwin'); + common::printLink('file', 'download', "fileID=$file->id", $lang->doc->download, "data-toggle='modal'", '', true, false, $file); + common::printLink('file', 'delete', "fileID=$file->id", $lang->delete, 'hiddenwin', '', true, false, $file); ?> diff --git a/module/doc/view/view.html.php b/module/doc/view/view.html.php index b3d5c35d2b..fc4192bd38 100644 --- a/module/doc/view/view.html.php +++ b/module/doc/view/view.html.php @@ -68,9 +68,9 @@ { ob_start(); echo "
"; - common::printCommentIcon('doc'); - common::printIcon('doc', 'edit', $params); - common::printIcon('doc', 'delete', $params, '', 'button', '', 'hiddenwin'); + common::printCommentIcon('doc', $doc); + common::printIcon('doc', 'edit', $params, $doc); + common::printIcon('doc', 'delete', $params, $doc, 'button', '', 'hiddenwin'); echo '
'; echo "
"; common::printRPN($browseLink, $preAndNext); diff --git a/module/my/view/profile.html.php b/module/my/view/profile.html.php index 65d9a20ae0..666e0c54bd 100644 --- a/module/my/view/profile.html.php +++ b/module/my/view/profile.html.php @@ -54,6 +54,10 @@ group->priv;?> name . ' '; ?> + + user->limitedUser;?> + user->limitedUserList[$user->limitedUser];?> + user->commiter;?> commiter;?> diff --git a/module/product/model.php b/module/product/model.php index c6c579931d..e98e20a91f 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -830,6 +830,8 @@ class productModel extends model { $action = strtolower($action); + if(!common::limitedUser($product)) return false; + if($action == 'close') return $product->status != 'closed'; return true; diff --git a/module/product/view/browsedata.html.php b/module/product/view/browsedata.html.php index 58a86d1727..fe73a5445a 100644 --- a/module/product/view/browsedata.html.php +++ b/module/product/view/browsedata.html.php @@ -85,7 +85,7 @@ ?> - id}"; common::printIcon('story', 'change', $vars, $story, 'list', 'random'); common::printIcon('story', 'review', $vars, $story, 'list', 'review'); diff --git a/module/product/view/view.html.php b/module/product/view/view.html.php index c31108b359..ac5c808e5f 100644 --- a/module/product/view/view.html.php +++ b/module/product/view/view.html.php @@ -29,8 +29,8 @@ common::printIcon('product', 'close', "productID=$product->id", $product, 'button', '', '', 'iframe text-danger', true); echo "
"; - common::printIcon('product', 'edit', $params); - common::printIcon('product', 'delete', $params, '', 'button', '', 'hiddenwin'); + common::printIcon('product', 'edit', $params, $product); + common::printIcon('product', 'delete', $params, $product, 'button', '', 'hiddenwin'); echo '
'; common::printRPN($browseLink); diff --git a/module/productplan/control.php b/module/productplan/control.php index 2f92ea24cf..40b9ebc602 100644 --- a/module/productplan/control.php +++ b/module/productplan/control.php @@ -203,10 +203,10 @@ class productplan extends control /** * View plan. - * - * @param int $planID - * @param string $type - * @param string $orderBy + * + * @param int $planID + * @param string $type + * @param string $orderBy * @access public * @return void */ @@ -264,8 +264,8 @@ class productplan extends control /** * Link stories. - * - * @param int $planID + * + * @param int $planID * @access public * @return void */ diff --git a/module/productplan/model.php b/module/productplan/model.php index 1f127c6a4b..31631c9369 100644 --- a/module/productplan/model.php +++ b/module/productplan/model.php @@ -292,9 +292,9 @@ class productplanModel extends model } /** - * Unlink bug. - * - * @param int $bugID + * Unlink bug. + * + * @param int $bugID * @access public * @return void */ @@ -304,4 +304,19 @@ class productplanModel extends model $this->dao->update(TABLE_BUG)->set('plan')->eq(0)->where('id')->eq((int)$bugID)->exec(); $this->loadModel('action')->create('bug', $bugID, 'unlinkedfromplan', '', $planID); } + + /** + * Judge an action is clickable or not. + *- + * @param object $product- + * @param string $action- + * @access public + * @return void + */ + public static function isClickable($productPlan, $action) + { + if(!common::limitedUser($productPlan)) return false; + + return true; + } } diff --git a/module/productplan/view/browse.html.php b/module/productplan/view/browse.html.php index 08357d84be..33b940c84d 100644 --- a/module/productplan/view/browse.html.php +++ b/module/productplan/view/browse.html.php @@ -72,9 +72,9 @@ id&type=story&orderBy=id_desc&link=true"), '', '', "class='btn-icon' title='{$lang->productplan->linkStory}'"); if(common::hasPriv('productplan', 'linkBug') and $config->global->flow != 'onlyStory') echo html::a(inlink('view', "planID=$plan->id&type=bug&orderBy=id_desc&link=true"), '', '', "class='btn-icon' title='{$lang->productplan->linkBug}'"); - common::printIcon('productplan', 'edit', "planID=$plan->id", '', 'list'); + common::printIcon('productplan', 'edit', "planID=$plan->id", $plan, 'list'); - if(common::hasPriv('productplan', 'delete')) + if(common::hasPriv('productplan', 'delete', $plan)) { $deleteURL = $this->createLink('productplan', 'delete', "planID=$plan->id&confirm=yes"); echo html::a("javascript:ajaxDelete(\"$deleteURL\",\"productplan\",confirmDelete)", '', '', "class='btn-icon' title='{$lang->productplan->delete}'"); diff --git a/module/productplan/view/view.html.php b/module/productplan/view/view.html.php index 64d3a55f1d..409baeefa6 100644 --- a/module/productplan/view/view.html.php +++ b/module/productplan/view/view.html.php @@ -30,13 +30,13 @@ { ob_start(); echo "
"; - common::printIcon('story', 'create', "productID=$plan->product&branch=$plan->branch&moduleID=0&storyID=0&projectID=0&bugID=0&planID=$plan->id", '', 'button', 'plus'); + common::printIcon('story', 'create', "productID=$plan->product&branch=$plan->branch&moduleID=0&storyID=0&projectID=0&bugID=0&planID=$plan->id", $plan, 'button', 'plus'); if(common::hasPriv('productplan', 'linkStory')) echo html::a(inlink('view', "planID=$plan->id&type=story&orderBy=id_desc&link=true"), ' ' . $lang->productplan->linkStory, '', "class='btn'"); if(common::hasPriv('productplan', 'linkBug') and $config->global->flow != 'onlyStory') echo html::a(inlink('view', "planID=$plan->id&type=bug&orderBy=id_desc&link=true"), ' ' . $lang->productplan->linkBug, '', "class='btn'"); echo '
'; echo "
"; - common::printIcon('productplan', 'edit', "planID=$plan->id"); - common::printIcon('productplan', 'delete', "planID=$plan->id", '', 'button', '', 'hiddenwin'); + common::printIcon('productplan', 'edit', "planID=$plan->id", $plan); + common::printIcon('productplan', 'delete', "planID=$plan->id", $plan, 'button', '', 'hiddenwin'); echo '
'; $actionLinks = ob_get_contents(); ob_end_clean(); diff --git a/module/project/control.php b/module/project/control.php index 7e342dd956..e9cda0e0f1 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -126,6 +126,8 @@ class project extends control $this->loadModel('task'); $this->loadModel('datatable'); + $this->project->getLimitedProject(); + /* Set browse type. */ $browseType = strtolower($status); if($this->config->global->flow == 'onlyTask' and $browseType == 'byproduct') $param = 0; @@ -608,6 +610,7 @@ class project extends control $this->view->users = $users; $this->view->pager = $pager; $this->view->branchGroups = $branchGroups; + $this->view->limitedUser = $this->app->user->limitedUser == 'yes' ? true : false; $this->display(); } @@ -1932,15 +1935,15 @@ class project extends control } /** - * All project. - * - * @param string $status - * @param int $projectID - * @param string $orderBy - * @param int $productID - * @param int $recTotal - * @param int $recPerPage - * @param int $pageID + * All project. + * + * @param string $status + * @param int $projectID + * @param string $orderBy + * @param int $productID + * @param int $recTotal + * @param int $recPerPage + * @param int $pageID * @access public * @return void */ @@ -1974,8 +1977,8 @@ class project extends control /** * Doc for compatible. - * - * @param int $projectID + * + * @param int $projectID * @access public * @return void */ diff --git a/module/project/lang/en.php b/module/project/lang/en.php index e4b0628afb..449372822c 100644 --- a/module/project/lang/en.php +++ b/module/project/lang/en.php @@ -79,6 +79,10 @@ $lang->team->hours = 'Hour/Day'; $lang->team->days = 'Workdays'; $lang->team->totalHours = 'Total'; +$lang->team->limitedUser = 'limited User'; +$lang->team->limitedUserList['no'] = 'No'; +$lang->team->limitedUserList['yes'] = 'Yes'; + $lang->project->basicInfo = 'Basic Info'; $lang->project->otherInfo = 'Other Info'; diff --git a/module/project/lang/zh-cn.php b/module/project/lang/zh-cn.php index 2ec73ee143..832032b3a9 100644 --- a/module/project/lang/zh-cn.php +++ b/module/project/lang/zh-cn.php @@ -78,7 +78,11 @@ $lang->team->join = '加盟日'; $lang->team->hours = '可用工时/天'; $lang->team->days = '可用工日'; $lang->team->totalHours = '总计'; - + +$lang->team->limitedUser = '受限用户'; +$lang->team->limitedUserList['no'] = '否'; +$lang->team->limitedUserList['yes'] = '是'; + $lang->project->basicInfo = '基本信息'; $lang->project->otherInfo = '其他信息'; diff --git a/module/project/lang/zh-tw.php b/module/project/lang/zh-tw.php index 70face33d6..cd6b3baf38 100644 --- a/module/project/lang/zh-tw.php +++ b/module/project/lang/zh-tw.php @@ -78,7 +78,11 @@ $lang->team->join = '加盟日'; $lang->team->hours = '可用工時/天'; $lang->team->days = '可用工日'; $lang->team->totalHours = '總計'; - + +$lang->team->limitedUser = '受限用戶'; +$lang->team->limitedUserList['no'] = '否'; +$lang->team->limitedUserList['yes'] = '是'; + $lang->project->basicInfo = '基本信息'; $lang->project->otherInfo = '其他信息'; diff --git a/module/project/model.php b/module/project/model.php index 42bd04c951..8cdf7cba71 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -574,6 +574,7 @@ class projectModel extends model $firstProject = $projects[0]; $pairs[$firstProject->id] = $firstProject->name; } + return $pairs; } @@ -1453,8 +1454,8 @@ class projectModel extends model /** * Manage team members. - * - * @param int $projectID + * + * @param int $projectID * @access public * @return void */ @@ -1469,9 +1470,10 @@ class projectModel extends model if(empty($account)) continue; $member = new stdclass(); - $member->role = $roles[$key]; - $member->days = $days[$key]; - $member->hours = $hours[$key]; + $member->role = $roles[$key]; + $member->days = $days[$key]; + $member->hours = $hours[$key]; + $member->limitedUser = $limitedUser[$key]; $mode = $modes[$key]; if($mode == 'update') @@ -1749,6 +1751,8 @@ class projectModel extends model { $action = strtolower($action); + if(!common::limitedUser($project, 'project')) return false; + if($action == 'start') return $project->status == 'wait'; if($action == 'close') return $project->status != 'done'; if($action == 'suspend') return $project->status == 'wait' or $project->status == 'doing'; @@ -1771,7 +1775,7 @@ class projectModel extends model { $link = ''; if($module == 'task' and ($method == 'view' || $method == 'edit' || $method == 'batchedit')) - { + { $module = 'project'; $method = 'task'; } @@ -1865,9 +1869,29 @@ class projectModel extends model return round($estimate); } + /** + * Check the privilege. + * + * @param object $project + * @access public + * @return bool + */ + public function getLimitedProject() + { + /* If is admin, return true. */ + if($this->app->user->admin) return true; + + /* Get all teams of all projects and group by projects, save it as static. */ + $teams = $this->dao->select('project, limitedUser')->from(TABLE_TEAM)->where('account')->eq($this->app->user->account)->fetchAll('project'); + foreach($teams as $projectID => $object) + { + if($object->limitedUser == 'yes') $this->session->set($this->app->user->account . 'project' . $object->project, $object->project); + } + } + /** * Fix order. - * + * * @access public * @return void */ diff --git a/module/project/view/bug.html.php b/module/project/view/bug.html.php index 621123ea58..7c9f974f12 100644 --- a/module/project/view/bug.html.php +++ b/module/project/view/bug.html.php @@ -56,7 +56,7 @@ id"; common::printIcon('bug', 'confirmBug', $params, $bug, 'list', 'search', '', 'iframe', true); - common::printIcon('bug', 'assignTo', $params, '', 'list', '', '', 'iframe', true); + common::printIcon('bug', 'assignTo', $params, $bug, 'list', '', '', 'iframe', true); common::printIcon('bug', 'resolve', $params, $bug, 'list', '', '', 'iframe', true); common::printIcon('bug', 'close', $params, $bug, 'list', '', '', 'iframe', true); common::printIcon('bug', 'edit', $params, $bug, 'list'); diff --git a/module/project/view/build.html.php b/module/project/view/build.html.php index c7c0ee7818..b49659195f 100644 --- a/module/project/view/build.html.php +++ b/module/project/view/build.html.php @@ -49,16 +49,16 @@ date?> builder]?> - createLink('build', 'view', "buildID=$build->id&type=story&link=true"), "", '', "class='btn-icon' title='{$lang->build->linkStory}'"); } - common::printIcon('testtask', 'create', "product=$build->product&project=$project->id&build=$build->id", '', 'list', 'bullhorn'); + common::printIcon('testtask', 'create', "product=$build->product&project=$project->id&build=$build->id", $build, 'list', 'bullhorn'); $lang->project->bug = $lang->project->viewBug; - common::printIcon('project', 'bug', "project=$project->id&orderBy=status&build=$build->id", '', 'list'); - common::printIcon('build', 'edit', "buildID=$build->id", '', 'list'); - if(common::hasPriv('build', 'delete')) + common::printIcon('project', 'bug', "project=$project->id&orderBy=status&build=$build->id", $build, 'list'); + common::printIcon('build', 'edit', "buildID=$build->id", $build, 'list'); + if(common::hasPriv('build', 'delete', $build)) { $deleteURL = $this->createLink('build', 'delete', "buildID=$build->id&confirm=yes"); echo html::a("javascript:ajaxDelete(\"$deleteURL\",\"buildList\",confirmDelete)", '', '', "class='btn-icon' title='{$lang->build->delete}'"); diff --git a/module/project/view/linkstory.html.php b/module/project/view/linkstory.html.php index 1f43cf6df0..05d0653d84 100644 --- a/module/project/view/linkstory.html.php +++ b/module/project/view/linkstory.html.php @@ -58,7 +58,7 @@ product][$story->branch])) echo $branchGroups[$story->product][$story->branch];?> - openedBy];?> + openedBy, $story->openedBy);?> estimate;?> diff --git a/module/project/view/managemembers.html.php b/module/project/view/managemembers.html.php index 14e9340a06..58a1112c82 100644 --- a/module/project/view/managemembers.html.php +++ b/module/project/view/managemembers.html.php @@ -41,11 +41,12 @@ team->role;?> team->days;?> team->hours;?> + team->limitedUser;?> actions;?> delete;?> - + account])) continue;?> account]);?> @@ -58,6 +59,7 @@ + team->limitedUserList, $member->limitedUser);?> @@ -73,6 +75,7 @@ + team->limitedUserList, 'no');?> @@ -89,6 +92,7 @@ + team->limitedUserList, 'no');?> @@ -105,6 +109,7 @@ + team->limitedUserList, 'no');?> @@ -113,7 +118,7 @@ - + @@ -131,6 +136,7 @@ + team->limitedUserList, $member->realname ? $member->limitedUser : 'no');?> diff --git a/module/project/view/story.html.php b/module/project/view/story.html.php index fadb5d57c3..cf81b8a1ba 100644 --- a/module/project/view/story.html.php +++ b/module/project/view/story.html.php @@ -104,21 +104,21 @@ createLink('story', 'tasks', "storyID=$story->id&projectID=$project->id"); $storyTasks[$story->id] > 0 ? print(html::a($tasksLink, $storyTasks[$story->id], '', 'class="iframe"')) : print(0); - ?> + ?> - createLink('story', 'bugs', "storyID=$story->id&projectID=$project->id"); $storyBugs[$story->id] > 0 ? print(html::a($bugsLink, $storyBugs[$story->id], '', 'class="iframe"')) : print(0); ?> - createLink('story', 'cases', "storyID=$story->id&projectID=$project->id"); $storyCases[$story->id] > 0 ? print(html::a($casesLink, $storyCases[$story->id], '', 'class="iframe"')) : print(0); ?> - id}&story={$story->id}&moduleID={$story->module}"; $lang->task->create = $lang->project->wbs; @@ -129,16 +129,16 @@ } else { - common::printIcon('task', 'create', $param, '', 'list', 'plus-border', '', 'btn-task-create'); + if(!$limitedUser) common::printIcon('task', 'create', $param, $story, 'list', 'plus-border', '', 'btn-task-create'); } $lang->task->batchCreate = $lang->project->batchWBS; - common::printIcon('task', 'batchCreate', "projectID={$project->id}&story={$story->id}", '', 'list', 'plus-sign'); + if(!$limitedUser) common::printIcon('task', 'batchCreate', "projectID={$project->id}&story={$story->id}", $story, 'list', 'plus-sign'); $lang->testcase->batchCreate = $lang->testcase->create; - if($productID) common::printIcon('testcase', 'batchCreate', "productID=$story->product&branch=$story->branch&moduleID=$story->module&storyID=$story->id", '', 'list', 'sitemap'); + if($productID && !$limitedUser) common::printIcon('testcase', 'batchCreate', "productID=$story->product&branch=$story->branch&moduleID=$story->module&storyID=$story->id", $story, 'list', 'sitemap'); - if(common::hasPriv('project', 'unlinkStory')) + if(common::hasPriv('project', 'unlinkStory') && !$limitedUser) { $unlinkURL = $this->createLink('project', 'unlinkStory', "projectID=$project->id&storyID=$story->id&confirm=yes"); echo html::a("javascript:ajaxDelete(\"$unlinkURL\",\"storyList\",confirmUnlinkStory)", '', '', "class='btn-icon' title='{$lang->project->unlinkStory}'"); diff --git a/module/project/view/task.html.php b/module/project/view/task.html.php index 32fa210107..68533a4616 100644 --- a/module/project/view/task.html.php +++ b/module/project/view/task.html.php @@ -55,11 +55,11 @@ js::set('browseType', $browseType);
id", $task, 'list', '', '', 'iframe', true); common::printIcon('task', 'close', "taskID=$task->id", $task, 'list', '', '', 'iframe', true); - common::printIcon('task', 'edit', "taskID=$task->id", '', 'list'); + common::printIcon('task', 'edit', "taskID=$task->id", $task, 'list'); ?> diff --git a/module/project/view/taskheader.html.php b/module/project/view/taskheader.html.php index 685fd877ab..21227f499c 100644 --- a/module/project/view/taskheader.html.php +++ b/module/project/view/taskheader.html.php @@ -123,8 +123,8 @@
createLink('task', 'create', "project=$projectID" . (isset($moduleID) ? "&storyID=&moduleID=$moduleID" : '')) : '#'; + $misc = common::hasPriv('task', 'create', $project) ? "class='btn btn-primary'" : "class='btn btn-primary disabled'"; + $link = common::hasPriv('task', 'create', $project) ? $this->createLink('task', 'create', "project=$projectID" . (isset($moduleID) ? "&storyID=&moduleID=$moduleID" : '')) : '#'; echo html::a($link, "" . $lang->task->create, '', $misc); ?> diff --git a/module/project/view/team.html.php b/module/project/view/team.html.php index 96fae08b99..f8e7464106 100644 --- a/module/project/view/team.html.php +++ b/module/project/view/team.html.php @@ -27,7 +27,7 @@ } else { - common::printLink('project', 'managemembers', "projectID=$project->id", $lang->project->manageMembers, '', "class='btn btn-primary manage-team-btn'"); + if($app->user->limitedUser === 'no') common::printLink('project', 'managemembers', "projectID=$project->id", $lang->project->manageMembers, '', "class='btn btn-primary manage-team-btn'"); } ?>
@@ -41,6 +41,7 @@ team->days;?> team->hours;?> team->totalHours;?> + team->limitedUser;?> actions;?> @@ -60,9 +61,10 @@ days . $lang->project->day;?> hours . $lang->project->workHour;?> project->workHour;?> + team->limitedUserList[$member->limitedUser];?> createLink('project', 'unlinkMember', "projectID=$project->id&account=$member->account&confirm=yes"); echo html::a("javascript:ajaxDelete(\"$unlinkURL\",\"memberList\",confirmUnlinkMember)", '', '', "class='btn-icon' title='{$lang->project->unlinkMember}'"); @@ -74,7 +76,7 @@ - +
team->totalHours . ':' . "$totalHours{$lang->project->workHour}";?>
diff --git a/module/project/view/testtask.html.php b/module/project/view/testtask.html.php index e24aec46b0..d565654f6e 100644 --- a/module/project/view/testtask.html.php +++ b/module/project/view/testtask.html.php @@ -50,12 +50,12 @@ testtask->statusList[$task->status];?> id", '', 'list', 'sitemap'); - common::printIcon('testtask', 'linkCase', "taskID=$task->id", '', 'list', 'link'); - common::printIcon('testtask', 'edit', "taskID=$task->id", '', 'list'); - common::printIcon('testreport', 'create', "objectID=$task->id&objectType=testtask", '', 'list','flag'); + common::printIcon('testtask', 'cases', "taskID=$task->id", $task, 'list', 'sitemap'); + common::printIcon('testtask', 'linkCase', "taskID=$task->id", $task, 'list', 'link'); + common::printIcon('testtask', 'edit', "taskID=$task->id", $task, 'list'); + common::printIcon('testreport', 'create', "objectID=$task->id&objectType=testtask", $task, 'list','flag'); - if(common::hasPriv('testtask', 'delete')) + if(common::hasPriv('testtask', 'delete', $task)) { $deleteURL = $this->createLink('testtask', 'delete', "taskID=$task->id&confirm=yes"); echo html::a("javascript:ajaxDelete(\"$deleteURL\",\"taskList\",confirmDelete)", '', '', "class='btn-icon' title='{$lang->testtask->delete}'"); diff --git a/module/project/view/view.html.php b/module/project/view/view.html.php index fd98bd41df..388c7a333e 100644 --- a/module/project/view/view.html.php +++ b/module/project/view/view.html.php @@ -35,8 +35,8 @@ echo '
'; echo "
"; - common::printIcon('project', 'edit', $params); - common::printIcon('project', 'delete', $params, '', 'button', '', 'hiddenwin'); + common::printIcon('project', 'edit', $params, $project); + common::printIcon('project', 'delete', $params, $project, 'button', '', 'hiddenwin'); echo '
'; common::printRPN($browseLink); diff --git a/module/release/model.php b/module/release/model.php index d7fdf1153d..728a02ae97 100644 --- a/module/release/model.php +++ b/module/release/model.php @@ -319,4 +319,19 @@ class releaseModel extends model $this->dao->update(TABLE_RELEASE)->set('status')->eq($status)->where('id')->eq($releaseID)->exec(); return dao::isError(); } + + /** + * Judge an action is clickable or not. + *- + * @param object $product- + * @param string $action- + * @access public + * @return void + */ + public static function isClickable($release, $action) + { + if(!common::limitedUser($release)) return false; + + return true; + } } diff --git a/module/release/view/browse.html.php b/module/release/view/browse.html.php index 1e346bfd4f..4aa6700a97 100644 --- a/module/release/view/browse.html.php +++ b/module/release/view/browse.html.php @@ -53,13 +53,13 @@ id&type=story&link=true"), ' ', '', "class='btn-icon' title='{$lang->release->linkStory}'"); if(common::hasPriv('release', 'linkBug') and $this->config->global->flow != 'onlyStory') echo html::a(inlink('view', "releaseID=$release->id&type=bug&link=true"), ' ', '', "class='btn-icon' title='{$lang->release->linkBug}'"); - if(common::hasPriv('release', 'changeStatus')) + if(common::hasPriv('release', 'changeStatus', $release)) { $changedStatus = $release->status == 'normal' ? 'terminate' : 'normal'; echo html::a(inlink('changeStatus', "releaseID=$release->id&status=$changedStatus"), ' ', 'hiddenwin', "class='btn-icon' title='{$lang->release->changeStatusList[$changedStatus]}'"); } - common::printIcon('release', 'edit', "release=$release->id", '', 'list'); - if(common::hasPriv('release', 'delete')) + common::printIcon('release', 'edit', "release=$release->id", $release, 'list'); + if(common::hasPriv('release', 'delete', $release)) { $deleteURL = $this->createLink('release', 'delete', "releaseID=$release->id&confirm=yes"); echo html::a("javascript:ajaxDelete(\"$deleteURL\",\"releaseList\",confirmDelete)", '', '', "class='btn-icon' title='{$lang->release->delete}'"); diff --git a/module/release/view/view.html.php b/module/release/view/view.html.php index 55ce0def71..4a2359fabb 100644 --- a/module/release/view/view.html.php +++ b/module/release/view/view.html.php @@ -29,7 +29,7 @@ ob_start(); echo "
"; - if(common::hasPriv('release', 'changeStatus')) + if(common::hasPriv('release', 'changeStatus', $release)) { $changedStatus = $release->status == 'normal' ? 'terminate' : 'normal'; echo html::a(inlink('changeStatus', "releaseID=$release->id&type=$changedStatus"), ' ' . $lang->release->changeStatusList[$changedStatus], 'hiddenwin', "class='btn'"); @@ -39,8 +39,8 @@ echo '
'; echo "
"; - common::printIcon('release', 'edit', "releaseID=$release->id"); - common::printIcon('release', 'delete', "releaseID=$release->id", '', 'button', '', 'hiddenwin'); + common::printIcon('release', 'edit', "releaseID=$release->id", $release); + common::printIcon('release', 'delete', "releaseID=$release->id", $release, 'button', '', 'hiddenwin'); echo '
'; echo "
"; diff --git a/module/story/lang/en.php b/module/story/lang/en.php index 7c70ef37d0..0311f26085 100644 --- a/module/story/lang/en.php +++ b/module/story/lang/en.php @@ -90,6 +90,7 @@ $lang->story->keywords = 'Keywords'; $lang->story->newStory = 'Continue adding Story.'; $lang->story->colorTag = 'Color Tag'; $lang->story->files = 'Files'; +$lang->story->copy = "Duplicate a Story"; $lang->story->ditto = 'Ditto'; $lang->story->dittoNotice = 'This Story does not belong to the same Product as the last Story does!'; diff --git a/module/story/lang/zh-cn.php b/module/story/lang/zh-cn.php index 7410cc1dfb..e260cbdde6 100644 --- a/module/story/lang/zh-cn.php +++ b/module/story/lang/zh-cn.php @@ -90,6 +90,7 @@ $lang->story->keywords = '关键词'; $lang->story->newStory = '继续添加需求'; $lang->story->colorTag = '颜色标签'; $lang->story->files = '附件'; +$lang->story->copy = "复制需求"; $lang->story->ditto = '同上'; $lang->story->dittoNotice = '该需求与上一需求不属于同一产品!'; diff --git a/module/story/lang/zh-tw.php b/module/story/lang/zh-tw.php index e2bb29bed1..f439ea47f6 100644 --- a/module/story/lang/zh-tw.php +++ b/module/story/lang/zh-tw.php @@ -90,6 +90,7 @@ $lang->story->keywords = '關鍵詞'; $lang->story->newStory = '繼續添加需求'; $lang->story->colorTag = '顏色標籤'; $lang->story->files = '附件'; +$lang->story->copy = "復制需求"; $lang->story->ditto = '同上'; $lang->story->dittoNotice = '該需求與上一需求不屬於同一產品!'; diff --git a/module/story/model.php b/module/story/model.php index 601c73318d..645cbc5dd0 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -1456,19 +1456,19 @@ class storyModel extends model /** * Get stories through search. - * + * * @access public - * @param int $productID - * @param int $queryID - * @param string $orderBy - * @param object $pager - * @param string $projectID + * @param int $productID + * @param int $queryID + * @param string $orderBy + * @param object $pager + * @param string $projectID * @access public * @return array */ public function getBySearch($productID, $queryID, $orderBy, $pager = null, $projectID = '', $branch = 0) { - if($projectID != '') + if($projectID != '') { $products = $this->loadModel('project')->getProducts($projectID); } @@ -1668,11 +1668,11 @@ class storyModel extends model /** * Get stories list of a plan. - * - * @param int $planID - * @param string $status - * @param string $orderBy - * @param object $pager + * + * @param int $planID + * @param string $status + * @param string $orderBy + * @param object $pager * @access public * @return array */ @@ -1683,19 +1683,19 @@ class storyModel extends model ->beginIF($status and $status != 'all')->andWhere('status')->in($status)->fi() ->andWhere('deleted')->eq(0) ->orderBy($orderBy)->page($pager)->fetchAll('id'); - + $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'story'); - + return $stories; } /** * Get stories pairs of a plan. - * - * @param int $planID - * @param string $status - * @param string $orderBy - * @param object $pager + * + * @param int $planID + * @param string $status + * @param string $orderBy + * @param object $pager * @access public * @return array */ @@ -2186,6 +2186,8 @@ class storyModel extends model { $action = strtolower($action); + if(!common::limitedUser($story)) return false; + if($action == 'change') return $story->status != 'closed'; if($action == 'review') return $story->status == 'draft' or $story->status == 'changed'; if($action == 'close') return $story->status != 'closed'; diff --git a/module/story/view/view.html.php b/module/story/view/view.html.php index 99cccbf9ab..85d9b06c77 100644 --- a/module/story/view/view.html.php +++ b/module/story/view/view.html.php @@ -41,8 +41,8 @@ ob_start(); echo "
"; - common::printIcon('story', 'change', "storyID=$story->id", $story); - common::printIcon('story', 'review', "storyID=$story->id", $story); + common::printIcon('story', 'change', "storyID=$story->id", $story); + common::printIcon('story', 'review', "storyID=$story->id", $story); if($story->status != 'closed' and !isonlybody()) { @@ -51,8 +51,8 @@ if(common::hasPriv('story', 'batchCreate')) echo html::a($link, " " . $lang->story->subdivide, '', $misc); } - common::printIcon('story', 'close', "storyID=$story->id", $story, 'button', '', '', 'iframe text-danger', true); - common::printIcon('story', 'activate', "storyID=$story->id", $story, 'button', '', '', 'iframe text-success', true); + common::printIcon('story', 'close', "storyID=$story->id", $story, 'button', '', '', 'iframe text-danger', true); + common::printIcon('story', 'activate', "storyID=$story->id", $story, 'button', '', '', 'iframe text-success', true); if($this->config->global->flow != 'onlyStory' and !isonlybody() and (common::hasPriv('testcase', 'create') or common::hasPriv('testcase', 'batchCreate'))) { @@ -64,7 +64,7 @@ echo "
"; } - if($from == 'project') common::printIcon('task', 'create', "project=$param&storyID=$story->id&moduleID=$story->module", '', 'button', 'smile'); + if($from == 'project') common::printIcon('task', 'create', "project=$param&storyID=$story->id&moduleID=$story->module", $story, 'button', 'smile'); echo '
'; echo "
"; - common::printIcon('story', 'edit', "storyID=$story->id"); - common::printCommentIcon('story'); - common::printIcon('story', 'create', "productID=$story->product&branch=$story->branch&moduleID=$story->module&storyID=$story->id", '', 'button', 'copy'); - common::printIcon('story', 'delete', "storyID=$story->id", '', 'button', '', 'hiddenwin'); + common::printIcon('story', 'edit', "storyID=$story->id", $story); + common::printCommentIcon('story', $story); + common::printIcon('story', 'create', "productID=$story->product&branch=$story->branch&moduleID=$story->module&storyID=$story->id", $story, 'button', 'copy'); + common::printIcon('story', 'delete', "storyID=$story->id", $story, 'button', '', 'hiddenwin'); echo '
'; echo "
"; @@ -354,7 +354,7 @@
    linkStories) ; + $linkStories = explode(',', $story->linkStories) ; foreach($linkStories as $linkStoryID) { if(isset($story->extraStories[$linkStoryID])) echo '
  • ' . html::a(inlink('view', "storyID=$linkStoryID"), "#$linkStoryID " . $story->extraStories[$linkStoryID]) . '
  • '; @@ -368,7 +368,7 @@
      childStories) ; + $childStories = explode(',', $story->childStories) ; foreach($childStories as $childStoryID) { if(isset($story->extraStories[$childStoryID])) echo '
    • ' . html::a(inlink('view', "storyID=$childStoryID"), "#$childStoryID " . $story->extraStories[$childStoryID]) . '
    • '; diff --git a/module/task/model.php b/module/task/model.php index 3e4294abd6..d61af2cf2c 100644 --- a/module/task/model.php +++ b/module/task/model.php @@ -1593,6 +1593,8 @@ class taskModel extends model { $action = strtolower($action); + if(!common::limitedUser($task, 'task')) return false; + if($action == 'assignto') return $task->status != 'closed' and $task->status != 'cancel'; if($action == 'start') return $task->status == 'wait'; if($action == 'restart') return $task->status == 'pause'; diff --git a/module/task/view/view.html.php b/module/task/view/view.html.php index 1d47c06c8a..e7cec9645a 100644 --- a/module/task/view/view.html.php +++ b/module/task/view/view.html.php @@ -43,10 +43,10 @@ echo '
'; echo "
"; - common::printIcon('task', 'edit', "taskID=$task->id"); - common::printCommentIcon('task'); - common::printIcon('task', 'create', "productID=0&storyID=0&moduleID=0&taskID=$task->id", '', 'button', 'copy'); - common::printIcon('task', 'delete', "projectID=$task->project&taskID=$task->id", '', 'button', '', 'hiddenwin'); + common::printIcon('task', 'edit', "taskID=$task->id", $task); + common::printCommentIcon('task', $task); + common::printIcon('task', 'create', "productID=0&storyID=0&moduleID=0&taskID=$task->id", $task, 'button', 'copy'); + common::printIcon('task', 'delete', "projectID=$task->project&taskID=$task->id", $task, 'button', '', 'hiddenwin'); echo '
'; echo "
"; diff --git a/module/testcase/model.php b/module/testcase/model.php index d677682bb0..1912604acc 100644 --- a/module/testcase/model.php +++ b/module/testcase/model.php @@ -932,6 +932,8 @@ class testcaseModel extends model { $action = strtolower($action); + if(!common::limitedUser($case)) return false; + if($action == 'createbug') return $case->caseFails > 0; if($action == 'review') return $case->status == 'wait'; diff --git a/module/testcase/view/browsedata.html.php b/module/testcase/view/browsedata.html.php index 30c6d5733e..121fbd0548 100644 --- a/module/testcase/view/browsedata.html.php +++ b/module/testcase/view/browsedata.html.php @@ -77,13 +77,13 @@ stepNumber;?> id&version=$case->version", '', 'list', 'play', '', 'runCase iframe', false, "data-width='95%'"); - common::printIcon('testtask', 'results', "runID=0&caseID=$case->id", '', 'list', 'list-alt', '', 'results iframe', false, "data-width='95%'"); + common::printIcon('testtask', 'runCase', "runID=0&caseID=$case->id&version=$case->version", $case, 'list', 'play', '', 'runCase iframe', false, "data-width='95%'"); + common::printIcon('testtask', 'results', "runID=0&caseID=$case->id", $case, 'list', 'list-alt', '', 'results iframe', false, "data-width='95%'"); if($config->testcase->needReview or !empty($config->testcase->forceReview)) common::printIcon('testcase', 'review', "caseID=$case->id", $case, 'list', 'review', '', 'iframe'); common::printIcon('testcase', 'edit', "caseID=$case->id", $case, 'list'); common::printIcon('testcase', 'create', "productID=$case->product&branch=$case->branch&moduleID=$case->module&from=testcase¶m=$case->id", $case, 'list', 'copy'); - if(common::hasPriv('testcase', 'delete')) + if(common::hasPriv('testcase', 'delete', $case)) { $deleteURL = $this->createLink('testcase', 'delete', "caseID=$case->id&confirm=yes"); echo html::a("javascript:ajaxDelete(\"$deleteURL\",\"caseList\",confirmDelete)", '', '', "title='{$lang->testcase->delete}' class='btn-icon'"); diff --git a/module/testcase/view/view.html.php b/module/testcase/view/view.html.php index 9ab3491bbd..8dfc0b1984 100644 --- a/module/testcase/view/view.html.php +++ b/module/testcase/view/view.html.php @@ -45,22 +45,22 @@ echo "
"; if(!$isLibCase) { - common::printIcon('testtask', 'runCase', "runID=$runID&caseID=$case->id&version=$case->currentVersion", '', 'button', '', '', 'runCase', false, "data-width='95%'"); - common::printIcon('testtask', 'results', "runID=$runID&caseID=$case->id&version=$case->version", '', 'button', '', '', 'results', false, "data-width='95%'"); + common::printIcon('testtask', 'runCase', "runID=$runID&caseID=$case->id&version=$case->currentVersion", $case, 'button', '', '', 'runCase', false, "data-width='95%'"); + common::printIcon('testtask', 'results', "runID=$runID&caseID=$case->id&version=$case->version", $case, 'button', '', '', 'results', false, "data-width='95%'"); - if($caseFails > 0) common::printIcon('testcase', 'createBug', "product=$case->product&branch=$case->branch&extra=caseID=$case->id,version=$case->version,runID=$runID", '', 'button', 'bug', '', 'iframe', '', "data-width='90%'"); + if($caseFails > 0) common::printIcon('testcase', 'createBug', "product=$case->product&branch=$case->branch&extra=caseID=$case->id,version=$case->version,runID=$runID", $case, 'button', 'bug', '', 'iframe', '', "data-width='90%'"); } if($config->testcase->needReview or !empty($config->testcase->forceReview)) common::printIcon('testcase', 'review', "caseID=$case->id", $case, 'button', 'review', '', 'iframe'); echo '
'; echo "
"; - common::printIcon('testcase', 'edit',"caseID=$case->id"); - common::printCommentIcon('testcase'); - if(!$isLibCase) common::printIcon('testcase', 'create', "productID=$case->product&branch=$case->branch&moduleID=$case->module&from=testcase¶m=$case->id", '', 'button', 'copy'); - if($isLibCase and common::hasPriv('testsuite', 'createCase')) echo html::a($this->createLink('testsuite', 'createCase', "libID=$case->lib&moduleID=$case->module¶m=$case->id"), "", '', "class='btn' title='{$lang->testcase->copy}'"); - common::printIcon('testcase', 'delete', "caseID=$case->id", '', 'button', '', 'hiddenwin'); + common::printIcon('testcase', 'edit',"caseID=$case->id", $case); + common::printCommentIcon('testcase', $case); + if(!$isLibCase) common::printIcon('testcase', 'create', "productID=$case->product&branch=$case->branch&moduleID=$case->module&from=testcase¶m=$case->id", $case, 'button', 'copy'); + if($isLibCase and common::hasPriv('testsuite', 'createCase')) echo html::a($this->createLink('testsuite', 'createCase', "libID=$case->lib&moduleID=$case->module¶m=$case->id", $case), "", '', "class='btn' title='{$lang->testcase->copy}'"); + common::printIcon('testcase', 'delete', "caseID=$case->id", $case, 'button', '', 'hiddenwin'); echo '
'; - + echo "
"; common::printRPN($browseLink, $preAndNext, inlink('view', "caseID=%s&version=0&testtask=$from&taskID=$taskID")); echo '
'; diff --git a/module/testsuite/model.php b/module/testsuite/model.php index f2a1f288d7..090da3af16 100644 --- a/module/testsuite/model.php +++ b/module/testsuite/model.php @@ -804,4 +804,19 @@ class testsuiteModel extends model } } } + + /** + * Judge an action is clickable or not. + *- + * @param object $product- + * @param string $action- + * @access public + * @return void + */ + public static function isClickable($testsuite, $action) + { + if(!common::limitedUser($testsuite)) return false; + + return true; + } } diff --git a/module/testsuite/view/browse.html.php b/module/testsuite/view/browse.html.php index 5ee5104c39..5de87fc912 100644 --- a/module/testsuite/view/browse.html.php +++ b/module/testsuite/view/browse.html.php @@ -45,10 +45,10 @@ addedDate;?> id", '', 'list', 'link'); - common::printIcon('testsuite', 'edit', "suiteID=$suite->id", '', 'list'); + common::printIcon('testsuite', 'linkCase', "suiteID=$suite->id", $suite, 'list', 'link'); + common::printIcon('testsuite', 'edit', "suiteID=$suite->id", $suite, 'list'); - if(common::hasPriv('testsuite', 'delete')) + if(common::hasPriv('testsuite', 'delete', $suite)) { $deleteURL = $this->createLink('testsuite', 'delete', "suiteID=$suite->id&confirm=yes"); echo html::a("javascript:ajaxDelete(\"$deleteURL\",\"suiteList\",confirmDelete)", '', '', "title='{$lang->testsuite->delete}' class='btn-icon'"); diff --git a/module/testsuite/view/view.html.php b/module/testsuite/view/view.html.php index 03dba03eb8..64043ae6a5 100644 --- a/module/testsuite/view/view.html.php +++ b/module/testsuite/view/view.html.php @@ -105,13 +105,13 @@ stepNumber;?> createLink('testsuite', 'unlinkCase', "suiteID=$suite->id&caseID=$case->id&confirm=yes"); echo html::a("javascript:ajaxDelete(\"$unlinkURL\",\"caseList\",confirmUnlink)", '', '', "title='{$lang->testsuite->unlinkCase}' class='btn-icon'"); } - common::printIcon('testtask', 'runCase', "runID=0&caseID=$case->id&version=$case->version", '', 'list', 'play', '', 'runCase iframe', false, "data-width='95%'"); - common::printIcon('testtask', 'results', "runID=0&caseID=$case->id", '', 'list', 'list-alt', '', 'results iframe', false, "data-width='95%'"); + common::printIcon('testtask', 'runCase', "runID=0&caseID=$case->id&version=$case->version", $suite, 'list', 'play', '', 'runCase iframe', false, "data-width='95%'"); + common::printIcon('testtask', 'results', "runID=0&caseID=$case->id", $suite, 'list', 'list-alt', '', 'results iframe', false, "data-width='95%'"); ?> diff --git a/module/testtask/model.php b/module/testtask/model.php index 104de76185..61ff1bb631 100644 --- a/module/testtask/model.php +++ b/module/testtask/model.php @@ -1099,6 +1099,8 @@ class testtaskModel extends model { $action = strtolower($action); + if(!common::limitedUser($testtask)) return false; + if($action == 'start') return $testtask->status == 'wait'; if($action == 'block') return ($testtask->status == 'doing' || $testtask->status == 'wait'); if($action == 'activate') return ($testtask->status == 'blocked' || $testtask->status == 'done'); diff --git a/module/testtask/view/browse.html.php b/module/testtask/view/browse.html.php index 0bdeeb7a3f..4df556fd65 100644 --- a/module/testtask/view/browse.html.php +++ b/module/testtask/view/browse.html.php @@ -86,13 +86,13 @@ $status = $this->session->testTaskVersionStatus; testtask->statusList[$task->status];?> id", 'play', 'list', 'sitemap'); + common::printIcon('testtask', 'cases', "taskID=$task->id", $task, 'list', 'sitemap'); common::printIcon('testtask', 'view', "taskID=$task->id", '', 'list', 'file','','iframe',true); - common::printIcon('testtask', 'linkCase', "taskID=$task->id", '', 'list', 'link'); - common::printIcon('testtask', 'edit', "taskID=$task->id", '', 'list','','','iframe',true); - common::printIcon('testreport', 'browse', "objectID=$task->product&objectType=product&extra=$task->id", '', 'list','flag'); + common::printIcon('testtask', 'linkCase', "taskID=$task->id", $task, 'list', 'link'); + common::printIcon('testtask', 'edit', "taskID=$task->id", $task, 'list','','','iframe',true); + common::printIcon('testreport', 'browse', "objectID=$task->product&objectType=product&extra=$task->id", $task, 'list','flag'); - if(common::hasPriv('testtask', 'delete')) + if(common::hasPriv('testtask', 'delete', $task)) { $deleteURL = $this->createLink('testtask', 'delete', "taskID=$task->id&confirm=yes"); echo html::a("javascript:ajaxDelete(\"$deleteURL\",\"taskList\",confirmDelete)", '', '', "title='{$lang->testtask->delete}' class='btn-icon'"); diff --git a/module/testtask/view/casesdata.html.php b/module/testtask/view/casesdata.html.php index 4ece30abcb..a172a05b70 100644 --- a/module/testtask/view/casesdata.html.php +++ b/module/testtask/view/casesdata.html.php @@ -61,10 +61,10 @@ stepNumber;?> id", '', 'list', '', '', 'runCase iframe', false, "data-width='95%'"); - common::printIcon('testtask', 'results', "id=$run->id", '', 'list', '', '', 'iframe', '', "data-width='90%'"); + common::printIcon('testtask', 'runCase', "id=$run->id", $run, 'list', '', '', 'runCase iframe', false, "data-width='95%'"); + common::printIcon('testtask', 'results', "id=$run->id", $run, 'list', '', '', 'iframe', '', "data-width='90%'"); - if(common::hasPriv('testtask', 'unlinkCase')) + if(common::hasPriv('testtask', 'unlinkCase', $run)) { $unlinkURL = $this->createLink('testtask', 'unlinkCase', "caseID=$run->id&confirm=yes"); echo html::a("javascript:ajaxDelete(\"$unlinkURL\",\"caseList\",confirmUnlink)", '', '', "title='{$lang->testtask->unlinkCase}' class='btn-icon'"); diff --git a/module/testtask/view/view.html.php b/module/testtask/view/view.html.php index 1e40dfd314..5cce7d152b 100644 --- a/module/testtask/view/view.html.php +++ b/module/testtask/view/view.html.php @@ -38,8 +38,8 @@ echo '
'; echo "
"; - common::printIcon('testtask', 'edit', "taskID=$task->id"); - common::printIcon('testtask', 'delete', "taskID=$task->id", '', 'button', '', 'hiddenwin'); + common::printIcon('testtask', 'edit', "taskID=$task->id", $task); + common::printIcon('testtask', 'delete', "taskID=$task->id", $task, 'button', '', 'hiddenwin'); echo '
'; echo "
"; diff --git a/module/user/config.php b/module/user/config.php index b4211a351f..47ab768e3e 100644 --- a/module/user/config.php +++ b/module/user/config.php @@ -6,8 +6,8 @@ $config->user->edit = new stdclass(); $config->user->create->requiredFields = 'account,realname,password,password1,password2'; $config->user->edit->requiredFields = 'account,realname'; -$config->user->customBatchCreateFields = 'dept,email,gender,commiter,join,skype,qq,yahoo,gtalk,wangwang,mobile,phone,address,zipcode'; -$config->user->customBatchEditFields = 'dept,email,commiter,join,skype,qq,yahoo,gtalk,wangwang,mobile,phone,address,zipcode'; +$config->user->customBatchCreateFields = 'dept,email,gender,commiter,join,skype,qq,yahoo,gtalk,wangwang,mobile,phone,address,zipcode,limitedUser'; +$config->user->customBatchEditFields = 'dept,email,commiter,join,skype,qq,yahoo,gtalk,wangwang,mobile,phone,address,zipcode,limitedUser'; $config->user->custom = new stdclass(); $config->user->custom->batchCreateFields = 'dept,email,gender'; diff --git a/module/user/lang/zh-cn.php b/module/user/lang/zh-cn.php index 6c0fee5f61..f9a04cff6e 100644 --- a/module/user/lang/zh-cn.php +++ b/module/user/lang/zh-cn.php @@ -97,6 +97,10 @@ $lang->user->lockWarning = "您还有%s次尝试机会。"; $lang->user->loginLocked = "密码尝试次数太多,请联系管理员解锁,或%s分钟后重试。"; $lang->user->weakPassword = "您的密码强度小于系统设定。"; +$lang->user->limitedUser = '受限用户'; +$lang->user->limitedUserList['no'] = '否'; +$lang->user->limitedUserList['yes'] = '是'; + $lang->user->roleList[''] = ''; $lang->user->roleList['dev'] = '研发'; $lang->user->roleList['qa'] = '测试'; @@ -128,12 +132,13 @@ $lang->user->tpl->content = '内容'; $lang->user->tpl->public = '是否公开'; $lang->user->placeholder = new stdclass(); -$lang->user->placeholder->account = '英文、数字和下划线的组合,三位以上'; -$lang->user->placeholder->password1 = '六位以上'; -$lang->user->placeholder->role = '职位影响内容和用户列表的顺序。'; -$lang->user->placeholder->group = '分组决定用户的权限列表。'; -$lang->user->placeholder->commiter = '版本控制系统(subversion)中的帐号'; -$lang->user->placeholder->verify = '需要输入你的密码加以验证'; +$lang->user->placeholder->account = '英文、数字和下划线的组合,三位以上'; +$lang->user->placeholder->password1 = '六位以上'; +$lang->user->placeholder->role = '职位影响内容和用户列表的顺序。'; +$lang->user->placeholder->group = '分组决定用户的权限列表。'; +$lang->user->placeholder->commiter = '版本控制系统(subversion)中的帐号'; +$lang->user->placeholder->verify = '需要输入你的密码加以验证'; +$lang->user->placeholder->limitedUser = '只能编辑与自己相关的内容。'; $lang->user->placeholder->passwordStrength[1] = '6位以上,包含大小写字母,数字。'; $lang->user->placeholder->passwordStrength[2] = '10位以上,包含大小写字母,数字,特殊字符。'; diff --git a/module/user/model.php b/module/user/model.php index 8e2f464ebb..1f2ed14d4a 100644 --- a/module/user/model.php +++ b/module/user/model.php @@ -200,7 +200,7 @@ class userModel extends model /** * Create a user. - * + * * @access public * @return void */ @@ -298,6 +298,8 @@ class userModel extends model $data[$i]->address = $users->address[$i]; $data[$i]->zipcode = $users->zipcode[$i]; + $data[$i]->limitedUser = $users->limitedUser[$i]; + /* Change for append field, such as feedback.*/ if(!empty($this->config->user->batchAppendFields)) { @@ -465,6 +467,7 @@ class userModel extends model $users[$id]['phone'] = $data->phone[$id]; $users[$id]['address'] = $data->address[$id]; $users[$id]['zipcode'] = $data->zipcode[$id]; + $users[$id]['limitedUser'] = $data->limitedUser[$id]; $users[$id]['dept'] = $data->dept[$id] == 'ditto' ? (isset($prev['dept']) ? $prev['dept'] : 0) : $data->dept[$id]; $users[$id]['role'] = $data->role[$id] == 'ditto' ? (isset($prev['role']) ? $prev['role'] : 0) : $data->role[$id]; @@ -518,7 +521,7 @@ class userModel extends model public function updatePassword($userID) { if(!$this->checkPassword()) return; - + $user = fixer::input('post') ->setIF($this->post->password1 != false, 'password', md5($this->post->password1)) ->remove('account, password1, password2, originalPassword') @@ -581,7 +584,7 @@ class userModel extends model } return !dao::isError(); } - + /** * Identify a user. * @@ -593,7 +596,7 @@ class userModel extends model public function identify($account, $password) { if(!$account or !$password) return false; - + /* Get the user first. If $password length is 32, don't add the password condition. */ $record = $this->dao->select('*')->from(TABLE_USER) ->where('account')->eq($account) diff --git a/module/user/view/batchcreate.html.php b/module/user/view/batchcreate.html.php index 9989a3a032..1a06e6e8ca 100644 --- a/module/user/view/batchcreate.html.php +++ b/module/user/view/batchcreate.html.php @@ -55,6 +55,7 @@ $minWidth = (count($visibleFields) > 5) ? 'w-150px' : ''; '> user->phone;?> '> user->address;?> '> user->zipcode;?> + '> user->limitedUser;?> $lang->user->ditto)?> @@ -89,7 +90,8 @@ $minWidth = (count($visibleFields) > 5) ? 'w-150px' : ''; '> '> '> - + > user->limitedUserList, 'no');?> + user->verifyPassword?> diff --git a/module/user/view/batchedit.html.php b/module/user/view/batchedit.html.php index ee2624613e..c3a89db2ed 100644 --- a/module/user/view/batchedit.html.php +++ b/module/user/view/batchedit.html.php @@ -51,6 +51,7 @@ $minWidth = (count($visibleFields) > 7) ? 'w-120px' : ''; '> user->phone;?> '> user->address;?> '> user->zipcode;?> + '> user->limitedUser;?> $lang->user->ditto) + $depts;?> @@ -80,6 +81,7 @@ $minWidth = (count($visibleFields) > 7) ? 'w-120px' : ''; '> id]", $user->phone, "class='form-control' autocomplete='off'");?> '> id]", $user->address, "class='form-control' autocomplete='off'");?> '> id]", $user->zipcode, "class='form-control' autocomplete='off'");?> + > id]", $lang->user->limitedUserList, $user->limitedUser);?> diff --git a/module/user/view/create.html.php b/module/user/view/create.html.php index 95d34dd32f..db58bf376d 100644 --- a/module/user/view/create.html.php +++ b/module/user/view/create.html.php @@ -61,6 +61,11 @@ user->placeholder->group?> + + user->limitedUser;?> + user->limitedUserList, 'no');?> + user->placeholder->limitedUser?> + user->email;?> diff --git a/module/user/view/edit.html.php b/module/user/view/edit.html.php index 4a03320217..30f6be8ccd 100644 --- a/module/user/view/edit.html.php +++ b/module/user/view/edit.html.php @@ -71,6 +71,8 @@ user->commiter;?> commiter, "class='form-control' autocomplete='off'");?> + user->limitedUser;?> + user->limitedUserList, $user->limitedUser);?> @@ -80,13 +82,13 @@ - + - +
skype, "class='form-control' autocomplete='off'");?> user->qq;?> qq, "class='form-control' autocomplete='off'");?>
user->yahoo;?> yahoo, "class='form-control' autocomplete='off'");?> user->gtalk;?> gtalk, "class='form-control' autocomplete='off'");?>
user->wangwang;?> wangwang, "class='form-control' autocomplete='off'");?>