From 7683db7228fcd476ac722cdfeb6d2dd325540b2d Mon Sep 17 00:00:00 2001 From: chenfeiCF Date: Tue, 23 Feb 2016 21:46:26 +0800 Subject: [PATCH] * finish task #2459. --- module/dept/model.php | 18 ++++++++++++++++-- module/group/control.php | 6 ++++-- module/group/model.php | 16 ++++++++++++++++ module/group/view/managemember.html.php | 10 +++++++++- 4 files changed, 45 insertions(+), 5 deletions(-) diff --git a/module/dept/model.php b/module/dept/model.php index 005e2aaff5..bac6850a85 100644 --- a/module/dept/model.php +++ b/module/dept/model.php @@ -115,16 +115,17 @@ class deptModel extends model * * @param int $rootDeptID * @param string $userFunc + * @param int $groupID * @access public * @return string */ - public function getTreeMenu($rootDeptID = 0, $userFunc) + public function getTreeMenu($rootDeptID = 0, $userFunc, $groupID = 0) { $deptMenu = array(); $stmt = $this->dbh->query($this->buildMenuQuery($rootDeptID)); while($dept = $stmt->fetch()) { - $linkHtml = call_user_func($userFunc, $dept); + $linkHtml = call_user_func($userFunc, $dept, $groupID); if(isset($deptMenu[$dept->id]) and !empty($deptMenu[$dept->id])) { @@ -202,6 +203,19 @@ class deptModel extends model return $linkHtml; } + /** + * Create the group Link. + * + * @param int $dept + * @param int $groupID + * @access public + * @return string + */ + public function createGroupLink($dept, $groupID) + { + return html::a(helper::createLink('group', 'managemember', "groupID=$groupID&deptID={$dept->id}"), $dept->name, '_self', "id='dept{$dept->id}'"); + } + /** * Get sons of a department. * diff --git a/module/group/control.php b/module/group/control.php index 2b7f818890..7e8b720e9c 100644 --- a/module/group/control.php +++ b/module/group/control.php @@ -221,10 +221,11 @@ class group extends control * Manage members of a group. * * @param int $groupID + * @param int $deptID * @access public * @return void */ - public function manageMember($groupID) + public function manageMember($groupID, $deptID = 0) { if(!empty($_POST)) { @@ -234,7 +235,7 @@ class group extends control } $group = $this->group->getById($groupID); $groupUsers = $this->group->getUserPairs($groupID); - $allUsers = $this->user->getPairs('nodeleted|noclosed|noempty|noletter'); + $allUsers = $this->group->getDeptUserPairs($deptID); $otherUsers = array_diff_assoc($allUsers, $groupUsers); $title = $this->lang->company->common . $this->lang->colon . $group->name . $this->lang->colon . $this->lang->group->manageMember; @@ -244,6 +245,7 @@ class group extends control $this->view->title = $title; $this->view->position = $position; $this->view->group = $group; + $this->view->deptTree = $this->loadModel('dept')->getTreeMenu($rooteDeptID = 0, array('deptModel', 'createGroupLink'), $groupID); $this->view->groupUsers = $groupUsers; $this->view->otherUsers = $otherUsers; diff --git a/module/group/model.php b/module/group/model.php index 582dbd7956..9c9a61fbc5 100644 --- a/module/group/model.php +++ b/module/group/model.php @@ -178,6 +178,22 @@ class groupModel extends model ->fetchPairs(); } + /** + * Get user pairs of a dept. + * + * @param int $deptID + * @access public + * @return array + */ + public function getDeptUserPairs($deptID = 0) + { + return $this->dao->select('account, realname')->from(TABLE_USER) + ->where('deleted')->eq(0) + ->beginIF($deptID)->andWhere('dept')->eq((int)$deptID) + ->orderBy('account') + ->fetchPairs(); + } + /** * Delete a group. * diff --git a/module/group/view/managemember.html.php b/module/group/view/managemember.html.php index 710bf34d3c..6444189693 100644 --- a/module/group/view/managemember.html.php +++ b/module/group/view/managemember.html.php @@ -18,7 +18,15 @@ group->manageMember;?> icons['manage']);?> - +
+ +
+
+
icons['company']);?> dept->common;?>
+
+
+
+