* Add sync whitelist.
This commit is contained in:
@@ -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. */
|
||||
|
||||
@@ -622,6 +622,7 @@ class commonModel extends model
|
||||
|
||||
$label = $menuItem->text;
|
||||
$subMenu = '';
|
||||
|
||||
/* Print sub menus. */
|
||||
if(isset($menuItem->subMenu))
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user