diff --git a/module/personnel/control.php b/module/personnel/control.php index 27e6a8a072..9bdd964a9d 100644 --- a/module/personnel/control.php +++ b/module/personnel/control.php @@ -138,13 +138,30 @@ class personnel extends control $this->lang->program->switcherMenu = $this->program->getPGMCommonAction() . $this->program->getPGMSwitcher($objectID); $this->program->setPGMViewMenu($objectID); + if($_POST) + { + $this->personnel->addWhitelist('program', $objectID); + if(dao::isError()) + { + $response['result'] = 'fail'; + $response['message'] = $this->getError(); + $this->send($response); + } + + $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inLink('whitelist', "programID=$objectID"))); + } + + $this->loadModel('dept'); + $deptUsers = empty($deptID) ? array() : $this->dept->getDeptUserPairs($deptID); + $this->view->title = $this->lang->personnel->addWhitelist; $this->view->position[] = $this->lang->personnel->addWhitelist; $this->view->objectID = $objectID; $this->view->deptID = $deptID; + $this->view->deptUsers = $deptUsers; $this->view->whitelist = $this->personnel->getWhitelist($objectID); - $this->view->depts = $this->loadModel('dept')->getOptionMenu(); + $this->view->depts = $this->dept->getOptionMenu(); $this->view->users = $this->loadModel('user')->getPairs('noclosed|nodeleted'); $this->view->dept = $this->dept->getByID($deptID); @@ -159,7 +176,7 @@ class personnel extends control * @access public * @return void */ - public function unlinkACL($id = 0, $confirm = 'no') + public function unbindWhielist($id = 0, $confirm = 'no') { if($confirm == 'no') { diff --git a/module/personnel/lang/de.php b/module/personnel/lang/de.php index eb06941909..3aced58727 100644 --- a/module/personnel/lang/de.php +++ b/module/personnel/lang/de.php @@ -15,3 +15,7 @@ $lang->personnel->search = 'Search'; $lang->personnel->program = 'Program'; $lang->personnel->emptyTip = 'No data'; $lang->personnel->childrenStage = 'Child stage'; + +$lang->personnel->whitelist = 'Whitelist'; +$lang->personnel->addWhitelist = 'Add Whitelist'; +$lang->personnel->confirmDelete = 'Confirm removal of the user from the whitelist?'; diff --git a/module/personnel/lang/en.php b/module/personnel/lang/en.php index eb06941909..3aced58727 100644 --- a/module/personnel/lang/en.php +++ b/module/personnel/lang/en.php @@ -15,3 +15,7 @@ $lang->personnel->search = 'Search'; $lang->personnel->program = 'Program'; $lang->personnel->emptyTip = 'No data'; $lang->personnel->childrenStage = 'Child stage'; + +$lang->personnel->whitelist = 'Whitelist'; +$lang->personnel->addWhitelist = 'Add Whitelist'; +$lang->personnel->confirmDelete = 'Confirm removal of the user from the whitelist?'; diff --git a/module/personnel/lang/fr.php b/module/personnel/lang/fr.php index eb06941909..3aced58727 100644 --- a/module/personnel/lang/fr.php +++ b/module/personnel/lang/fr.php @@ -15,3 +15,7 @@ $lang->personnel->search = 'Search'; $lang->personnel->program = 'Program'; $lang->personnel->emptyTip = 'No data'; $lang->personnel->childrenStage = 'Child stage'; + +$lang->personnel->whitelist = 'Whitelist'; +$lang->personnel->addWhitelist = 'Add Whitelist'; +$lang->personnel->confirmDelete = 'Confirm removal of the user from the whitelist?'; diff --git a/module/personnel/lang/vi.php b/module/personnel/lang/vi.php index eb06941909..3aced58727 100644 --- a/module/personnel/lang/vi.php +++ b/module/personnel/lang/vi.php @@ -15,3 +15,7 @@ $lang->personnel->search = 'Search'; $lang->personnel->program = 'Program'; $lang->personnel->emptyTip = 'No data'; $lang->personnel->childrenStage = 'Child stage'; + +$lang->personnel->whitelist = 'Whitelist'; +$lang->personnel->addWhitelist = 'Add Whitelist'; +$lang->personnel->confirmDelete = 'Confirm removal of the user from the whitelist?'; diff --git a/module/personnel/lang/zh-tw.php b/module/personnel/lang/zh-tw.php index 102873c2d8..af1b741934 100644 --- a/module/personnel/lang/zh-tw.php +++ b/module/personnel/lang/zh-tw.php @@ -15,3 +15,7 @@ $lang->personnel->search = '搜索'; $lang->personnel->program = '項目集'; $lang->personnel->emptyTip = '暫無'; $lang->personnel->childrenStage = '子階段'; + +$lang->personnel->whitelist = '白名單列表'; +$lang->personnel->addWhitelist = '添加白名單'; +$lang->personnel->confirmDelete = '確認將該用戶移除白名單?'; diff --git a/module/personnel/model.php b/module/personnel/model.php index 24fb0c537c..0768ba8aac 100644 --- a/module/personnel/model.php +++ b/module/personnel/model.php @@ -215,6 +215,58 @@ class personnelModel extends model ->fetchAll(); } + /** + * Adding users to access control lists. + * + * @param array $users + * @param string $objectType program|project|product|sprint + * @param int $objectID + * @param string $type whitelist|blacklist + * @param string $source upgrade|add + * @param string $desc + * @access public + * @return void + */ + public function updateWhitelist($users = array(), $objectType = '', $objectID = 0, $type = 'whitelist', $source = 'add', $desc = '') + { + $this->dao->delete()->from(TABLE_ACL)->where('objectID')->eq($objectID)->exec(); + + $users = array_filter($users); + $users = array_unique($users); + if(empty($users)) return false; + + $whitelist = ''; + foreach($users as $account) + { + $acl = new stdClass(); + $acl->account = $account; + $acl->objectType = $objectType; + $acl->objectID = $objectID; + $acl->type = $type; + $acl->source = $source; + $acl->desc = $desc; + $this->dao->insert(TABLE_ACL)->data($acl)->autoCheck()->exec(); + $whitelist .= ',' . $account; + } + + $objectTable = $objectType == 'product' ? TABLE_PRODUCT : TABLE_PROJECT; + $this->dao->update($objectTable)->set('whitelist')->eq($whitelist)->where('id')->eq($objectID)->exec(); + } + + /** + * Adding users to access control lists. + * + * @param string $objectType program|project|product|sprint + * @param int $objectID + * @access public + * @return void + */ + public function addWhitelist($objectType = '', $objectID = 0) + { + $users = $this->post->accounts; + $this->updateWhitelist($users, $objectType, $objectID); + } + /** * Create access links by department. * diff --git a/module/personnel/view/addwhitelist.html.php b/module/personnel/view/addwhitelist.html.php index 5d7b54e242..cf6f9bc56f 100644 --- a/module/personnel/view/addwhitelist.html.php +++ b/module/personnel/view/addwhitelist.html.php @@ -24,7 +24,7 @@