diff --git a/module/common/model.php b/module/common/model.php index 512cf8032d..0cdc5a8e33 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -544,7 +544,14 @@ class commonModel extends model echo '

  • '; echo '
  • ' . $lang->recent . '
  • '; - $extraWhere = empty($app->user->admin) && !empty($app->user->view->projects) ? ' and parent in (' . $app->user->view->projects . ') ' : ''; + $extraWhere = empty($app->user->admin) ? ' and id in (' . $app->user->view->sprints . ') and project in (' . $app->user->view->projects . ') ' : ''; + + if(empty($app->user->admin) && (empty($app->user->view->sprints) || empty($app->user->view->projects))) + { + echo "\n"; + return false; + } + $recentProjects = $dbh->query('select * from ' . TABLE_PROJECT . " where type in ('stage','sprint') $extraWhere and status != 'close' and deleted = '0' order by 'id' desc limit 6")->fetchAll(); if(!empty($recentProjects)) diff --git a/module/personnel/control.php b/module/personnel/control.php index 1ffd7e48bd..1941deecbe 100644 --- a/module/personnel/control.php +++ b/module/personnel/control.php @@ -94,15 +94,22 @@ class personnel extends control * @access public * @return void */ - public function whitelist($objectID = 0, $module = 'personnel', $browseType = 'all', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) + public function whitelist($objectID = 0, $module = 'personnel', $objectType = 'program', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) { if($module == 'personnel') $this->setProgramNavMenu($objectID); $this->app->loadLang('user'); + $this->app->session->set('whitelistBrowse', $this->app->getURI(true)); $this->app->loadClass('pager', true); $pager = pager::init($recTotal, $recPerPage, $pageID); - $whitelist = $this->personnel->getWhitelist($objectID, $browseType, $orderBy, $pager); + $whitelist = $this->personnel->getWhitelist($objectID, $objectType, $orderBy, $pager); + + if($module == 'program') + { + $goback = $this->session->PRJBrowse ? $this->session->PRJBrowse : $this->createLink('program', 'PRJBrowse'); + $this->view->goback = $goback; + } $this->view->title = $this->lang->personnel->whitelist; $this->view->position[] = $this->lang->personnel->whitelist; @@ -137,8 +144,8 @@ class personnel extends control $response['message'] = $this->getError(); $this->send($response); } - - $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->createLink($module, 'whitelist', "objectID=$objectID"))); + $moduleMethod = $module == 'program' ? 'PRJWhitelist' : 'addWhitelist'; + $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->createLink($module, $moduleMethod, "objectID=$objectID"))); } $this->loadModel('dept'); @@ -152,7 +159,7 @@ class personnel extends control $this->view->module = $module; $this->view->deptID = $deptID; $this->view->deptUsers = $deptUsers; - $this->view->whitelist = $this->personnel->getWhitelist($objectID); + $this->view->whitelist = $this->personnel->getWhitelist($objectID, $objectType); $this->view->depts = $this->dept->getOptionMenu(); $this->view->users = $this->loadModel('user')->getPairs('noclosed|nodeleted'); $this->view->dept = $this->dept->getByID($deptID); diff --git a/module/personnel/js/addwhitelist.js b/module/personnel/js/addwhitelist.js index 63fc24e4fa..18d3fe2cb3 100644 --- a/module/personnel/js/addwhitelist.js +++ b/module/personnel/js/addwhitelist.js @@ -7,7 +7,7 @@ function setDeptUsers(dept) { var deptID = $(dept).val(); - var link = createLink(module, 'addWhitelist', 'objectID=' + objectID + '&deptID=' + deptID + '&objectType=' + objectType + '&module=' + module); + var link = createLink(module, moduleMethod, 'objectID=' + objectID + '&deptID=' + deptID + '&objectType=' + objectType + '&module=' + module); location.href = link; } diff --git a/module/personnel/lang/de.php b/module/personnel/lang/de.php index 3aced58727..ba36cf9579 100644 --- a/module/personnel/lang/de.php +++ b/module/personnel/lang/de.php @@ -1,5 +1,5 @@ personnel->common = 'Personnel'; +$lang->personnel->common = 'Program Personnel'; $lang->personnel->accessible = 'Acess List'; $lang->personnel->putInto = 'Input Resource'; $lang->personnel->department = 'Department'; diff --git a/module/personnel/lang/en.php b/module/personnel/lang/en.php index 3aced58727..ba36cf9579 100644 --- a/module/personnel/lang/en.php +++ b/module/personnel/lang/en.php @@ -1,5 +1,5 @@ personnel->common = 'Personnel'; +$lang->personnel->common = 'Program Personnel'; $lang->personnel->accessible = 'Acess List'; $lang->personnel->putInto = 'Input Resource'; $lang->personnel->department = 'Department'; diff --git a/module/personnel/lang/fr.php b/module/personnel/lang/fr.php index 3aced58727..ba36cf9579 100644 --- a/module/personnel/lang/fr.php +++ b/module/personnel/lang/fr.php @@ -1,5 +1,5 @@ personnel->common = 'Personnel'; +$lang->personnel->common = 'Program Personnel'; $lang->personnel->accessible = 'Acess List'; $lang->personnel->putInto = 'Input Resource'; $lang->personnel->department = 'Department'; diff --git a/module/personnel/lang/vi.php b/module/personnel/lang/vi.php index 3aced58727..ba36cf9579 100644 --- a/module/personnel/lang/vi.php +++ b/module/personnel/lang/vi.php @@ -1,5 +1,5 @@ personnel->common = 'Personnel'; +$lang->personnel->common = 'Program Personnel'; $lang->personnel->accessible = 'Acess List'; $lang->personnel->putInto = 'Input Resource'; $lang->personnel->department = 'Department'; diff --git a/module/personnel/lang/zh-cn.php b/module/personnel/lang/zh-cn.php index aecd46969e..74627c9482 100644 --- a/module/personnel/lang/zh-cn.php +++ b/module/personnel/lang/zh-cn.php @@ -1,5 +1,5 @@ personnel->common = '人员'; +$lang->personnel->common = '项目集人员'; $lang->personnel->accessible = '可访问人员列表'; $lang->personnel->putInto = '投入人员列表'; $lang->personnel->department = '部门'; diff --git a/module/personnel/lang/zh-tw.php b/module/personnel/lang/zh-tw.php index af1b741934..110d5d0472 100644 --- a/module/personnel/lang/zh-tw.php +++ b/module/personnel/lang/zh-tw.php @@ -1,5 +1,5 @@ personnel->common = '人員'; +$lang->personnel->common = '項目集人員'; $lang->personnel->accessible = '可訪問人員列表'; $lang->personnel->putInto = '投入人員列表'; $lang->personnel->department = '部門'; diff --git a/module/personnel/model.php b/module/personnel/model.php index dbeb73f348..805fd24167 100644 --- a/module/personnel/model.php +++ b/module/personnel/model.php @@ -198,18 +198,19 @@ class personnelModel extends model * Access to program set input staff. * * @param int $objectID - * @param string $browseType + * @param string $objectType program|project|product|sprint * @param string $orderBy * @param object $pager * @access public * @return array */ - public function getWhitelist($objectID = 0, $browseType = 'all', $orderBy = 'id_desc', $pager = '') + public function getWhitelist($objectID = 0, $objectType = '', $orderBy = 'id_desc', $pager = '') { return $this->dao->select('t1.id,t1.account,t2.realname,t2.role,t2.phone,t2.qq,t2.weixin,t2.email')->from(TABLE_ACL)->alias('t1') ->leftjoin(TABLE_USER)->alias('t2')->on('t1.account = t2.account') ->where('t1.objectID')->eq($objectID) ->andWhere('t1.type')->eq('whitelist') + ->andWhere('t1.objectType')->eq($objectType) ->orderBy($orderBy) ->beginIF(!empty($pager))->page($pager)->fi() ->fetchAll(); @@ -219,12 +220,13 @@ class personnelModel extends model * Get whitelisted accounts. * * @param int $objectID + * @param string $objectType * @access public * @return array */ - public function getWhitelistAccount($objectID = 0) + public function getWhitelistAccount($objectID = 0, $objectType = '') { - return $this->dao->select('account')->from(TABLE_ACL)->where('objectID')->eq($objectID)->fetchPairs('account'); + return $this->dao->select('account')->from(TABLE_ACL)->where('objectID')->eq($objectID)->andWhere('objectType')->eq($objectType)->fetchPairs('account'); } /** @@ -241,7 +243,7 @@ class personnelModel extends model */ public function updateWhitelist($users = array(), $objectType = '', $objectID = 0, $type = 'whitelist', $source = 'add', $desc = '') { - $this->dao->delete()->from(TABLE_ACL)->where('objectID')->eq($objectID)->exec(); + $this->dao->delete()->from(TABLE_ACL)->where('objectID')->eq($objectID)->andWhere('objectType')->eq($objectType)->exec(); $users = array_filter($users); $users = array_unique($users); @@ -269,7 +271,7 @@ class personnelModel extends model if($objectType == 'product') { $product = $this->loadModel('product')->getById($objectID); - $programWhitelist = $this->getWhitelistAccount($product->program); + $programWhitelist = $this->getWhitelistAccount($product->program, 'program'); $newWhitelist = array_merge($programWhitelist, $accounts); $this->updateWhitelist($newWhitelist, 'program', $product->program, 'whitelist', 'sync', 'From product synchronization to program set.'); } @@ -278,7 +280,7 @@ class personnelModel extends model if($objectType == 'sprint') { $project = $this->dao->select('project')->from(TABLE_PROJECT)->where('id')->eq($objectID)->fetch('project', ''); - $projectWhitelist = $this->getWhitelistAccount($project); + $projectWhitelist = $this->getWhitelistAccount($project, 'project'); $newWhitelist = array_merge($projectWhitelist, $accounts); $this->updateWhitelist($newWhitelist, 'project', $project, 'whitelist', 'sync', 'From sprint synchronization to project.'); } diff --git a/module/personnel/view/addwhitelist.html.php b/module/personnel/view/addwhitelist.html.php index 2ad7f83051..7f4d1bf97c 100644 --- a/module/personnel/view/addwhitelist.html.php +++ b/module/personnel/view/addwhitelist.html.php @@ -16,7 +16,8 @@