diff --git a/module/common/lang/zh-cn.php b/module/common/lang/zh-cn.php index b70937f025..f43a769535 100755 --- a/module/common/lang/zh-cn.php +++ b/module/common/lang/zh-cn.php @@ -148,7 +148,7 @@ $lang->program->viewMenu->stakeholder = array('link' => "干系人|program|pgmst $lang->personnel = new stdClass(); $lang->personnel->menu = new stdClass(); $lang->personnel->menu->accessible = array('link' => "可访问人员|personnel|accessible|program=%s"); -$lang->personnel->menu->whitelist = array('link' => "白名单|personnel|whitelist|program=%s"); +$lang->personnel->menu->whitelist = array('link' => "白名单|personnel|whitelist|program=%s", 'alias' => 'addwhitelist'); $lang->personnel->menu->putinto = array('link' => "投入人员|personnel|putinto|program=%s"); /* Scrum menu. */ diff --git a/module/common/model.php b/module/common/model.php index 1ec612c979..c95b78885a 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -622,6 +622,7 @@ class commonModel extends model $label = $menuItem->text; $subMenu = ''; + /* Print sub menus. */ if(isset($menuItem->subMenu)) { diff --git a/module/personnel/control.php b/module/personnel/control.php index 9bdd964a9d..79ff40ebf8 100644 --- a/module/personnel/control.php +++ b/module/personnel/control.php @@ -133,10 +133,10 @@ class personnel extends control public function addWhitelist($objectID = 0, $deptID = 0) { $this->loadModel('program'); - $this->app->loadLang('project'); $this->lang->navGroup->program = 'program'; $this->lang->program->switcherMenu = $this->program->getPGMCommonAction() . $this->program->getPGMSwitcher($objectID); $this->program->setPGMViewMenu($objectID); + $this->app->loadLang('project'); if($_POST) { diff --git a/module/personnel/model.php b/module/personnel/model.php index 0768ba8aac..dbeb73f348 100644 --- a/module/personnel/model.php +++ b/module/personnel/model.php @@ -215,6 +215,18 @@ class personnelModel extends model ->fetchAll(); } + /** + * Get whitelisted accounts. + * + * @param int $objectID + * @access public + * @return array + */ + public function getWhitelistAccount($objectID = 0) + { + return $this->dao->select('account')->from(TABLE_ACL)->where('objectID')->eq($objectID)->fetchPairs('account'); + } + /** * Adding users to access control lists. * @@ -222,7 +234,7 @@ class personnelModel extends model * @param string $objectType program|project|product|sprint * @param int $objectID * @param string $type whitelist|blacklist - * @param string $source upgrade|add + * @param string $source upgrade|add|sync * @param string $desc * @access public * @return void @@ -235,7 +247,7 @@ class personnelModel extends model $users = array_unique($users); if(empty($users)) return false; - $whitelist = ''; + $accounts = ''; foreach($users as $account) { $acl = new stdClass(); @@ -246,11 +258,30 @@ class personnelModel extends model $acl->source = $source; $acl->desc = $desc; $this->dao->insert(TABLE_ACL)->data($acl)->autoCheck()->exec(); - $whitelist .= ',' . $account; + $accounts[$account] = $account; } $objectTable = $objectType == 'product' ? TABLE_PRODUCT : TABLE_PROJECT; + $whitelist = ',' . implode(',', $accounts); $this->dao->update($objectTable)->set('whitelist')->eq($whitelist)->where('id')->eq($objectID)->exec(); + + /* Synchronization of people from the product whitelist to the program set. */ + if($objectType == 'product') + { + $product = $this->loadModel('product')->getById($objectID); + $programWhitelist = $this->getWhitelistAccount($product->program); + $newWhitelist = array_merge($programWhitelist, $accounts); + $this->updateWhitelist($newWhitelist, 'program', $product->program, 'whitelist', 'sync', 'From product synchronization to program set.'); + } + + /* Synchronization of people from the sprint white list to the project. */ + if($objectType == 'sprint') + { + $project = $this->dao->select('project')->from(TABLE_PROJECT)->where('id')->eq($objectID)->fetch('project', ''); + $projectWhitelist = $this->getWhitelistAccount($project); + $newWhitelist = array_merge($projectWhitelist, $accounts); + $this->updateWhitelist($newWhitelist, 'project', $project, 'whitelist', 'sync', 'From sprint synchronization to project.'); + } } /** diff --git a/module/program/model.php b/module/program/model.php index 47055e2df2..164bf3bc5e 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -223,7 +223,8 @@ class programModel extends model foreach($this->lang->personnel->menu as $label => $menu) { - $this->lang->personnel->menu->$label = is_array($menu) ? sprintf($menu['link'], $programID) : sprintf($menu, $programID); + $menu['link'] = is_array($menu) ? sprintf($menu['link'], $programID) : sprintf($menu, $programID); + $this->lang->personnel->menu->$label = $menu; } $this->lang->program->menu = $this->lang->program->viewMenu;