From 4c841a2f23a63a38a06bbcdc92e2c2110b6621e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=80=A1=E6=A0=8B?= Date: Fri, 20 Aug 2021 13:58:50 +0800 Subject: [PATCH] * finish task #41529. --- module/action/model.php | 2 +- module/dept/model.php | 10 ++++++---- module/execution/control.php | 2 +- module/project/control.php | 2 +- module/report/control.php | 2 +- module/user/control.php | 22 +++++++++++----------- 6 files changed, 21 insertions(+), 19 deletions(-) diff --git a/module/action/model.php b/module/action/model.php index 471854534c..a4906e86ae 100755 --- a/module/action/model.php +++ b/module/action/model.php @@ -1044,7 +1044,7 @@ class actionModel extends model $objectNames['user'][0] = 'guest'; // Add guest account. /* Get the same dept department. */ - $deptUsers = $this->loadModel('dept')->getDeptUserPairs($this->app->user->dept, 'useid'); + $deptUsers = $this->loadModel('dept')->getDeptUserPairs($this->app->user->dept, 'id'); foreach($actions as $i => $action) { /* Add name field to the actions. */ diff --git a/module/dept/model.php b/module/dept/model.php index fd3e8b4654..95af218dd0 100644 --- a/module/dept/model.php +++ b/module/dept/model.php @@ -392,15 +392,17 @@ class deptModel extends model * Get user pairs of a department. * * @param int $deptID - * @param string $params userid|outside|all + * @param string $key id|account + * @param string $type inside|outside + * @param string $params all * @access public * @return array */ - public function getDeptUserPairs($deptID = 0, $params = '') + public function getDeptUserPairs($deptID = 0, $key = 'account', $type = 'inside', $params = '') { $childDepts = $this->getAllChildID($deptID); - $keyField = strpos($params, 'useid') !== false ? 'id' : 'account'; - $type = (strpos($params, 'outside') !== false) ? 'outside' : 'inside'; + $keyField = $key == 'id' ? 'id' : 'account'; + $type = $type == 'outside' ? 'outside' : 'inside'; return $this->dao->select("$keyField, realname")->from(TABLE_USER) ->where('deleted')->eq(0) diff --git a/module/execution/control.php b/module/execution/control.php index 6182b84f59..adaa6da8d5 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -1186,7 +1186,7 @@ class execution extends control $this->view->title = $title; $this->view->position = $position; - $this->view->deptUsers = $this->loadModel('dept')->getDeptUserPairs($this->app->user->dept, 'useid'); + $this->view->deptUsers = $this->loadModel('dept')->getDeptUserPairs($this->app->user->dept, 'id'); $this->view->canBeChanged = common::canModify('execution', $execution); // Determines whether an object is editable. $this->display(); diff --git a/module/project/control.php b/module/project/control.php index 3c561f7fd4..a0501d2832 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -1168,7 +1168,7 @@ class project extends control $this->view->title = $project->name . $this->lang->colon . $this->lang->project->team; $this->view->projectID = $projectID; $this->view->teamMembers = $this->project->getTeamMembers($projectID); - $this->view->deptUsers = $this->loadModel('dept')->getDeptUserPairs($this->app->user->dept, 'useid'); + $this->view->deptUsers = $this->loadModel('dept')->getDeptUserPairs($this->app->user->dept, 'id'); $this->view->canBeChanged = common::canModify('project', $project); $this->display(); diff --git a/module/report/control.php b/module/report/control.php index cdcfb3b4d8..22b9a431d9 100644 --- a/module/report/control.php +++ b/module/report/control.php @@ -324,7 +324,7 @@ class report extends control if($dept) { - $users = $this->loadModel('dept')->getDeptUserPairs($dept, 'useid'); + $users = $this->loadModel('dept')->getDeptUserPairs($dept, 'id'); $users = array('' => $this->lang->report->annualData->allUser) + $users; } diff --git a/module/user/control.php b/module/user/control.php index 1211e8a348..0a458ba7ab 100644 --- a/module/user/control.php +++ b/module/user/control.php @@ -80,7 +80,7 @@ class user extends control $account = $user->account; $todos = $this->todo->getList($type, $account, $status, 0, $pager, $sort); $date = (int)$type == 0 ? helper::today() : $type; - $users = $this->loadModel('dept')->getDeptUserPairs($this->app->user->dept, 'useid'); + $users = $this->loadModel('dept')->getDeptUserPairs($this->app->user->dept, 'id'); if(!isset($users[$userID])) die(js::error($this->lang->user->error->noAccess) . js::locate('back')); /* set menus. */ @@ -123,7 +123,7 @@ class user extends control $user = $this->user->getById($userID, 'id'); $account = $user->account; - $users = $this->loadModel('dept')->getDeptUserPairs($this->app->user->dept, 'useid'); + $users = $this->loadModel('dept')->getDeptUserPairs($this->app->user->dept, 'id'); /* Modify story title. */ $this->loadModel('story'); @@ -166,7 +166,7 @@ class user extends control $user = $this->user->getById($userID, 'id'); $account = $user->account; - $users = $this->loadModel('dept')->getDeptUserPairs($this->app->user->dept, 'useid'); + $users = $this->loadModel('dept')->getDeptUserPairs($this->app->user->dept, 'id'); /* Set the menu. */ $this->view->userList = $this->user->setUserList($users, $userID); @@ -207,7 +207,7 @@ class user extends control $user = $this->user->getById($userID, 'id'); $account = $user->account; - $users = $this->loadModel('dept')->getDeptUserPairs($this->app->user->dept, 'useid'); + $users = $this->loadModel('dept')->getDeptUserPairs($this->app->user->dept, 'id'); /* Set menu. */ $this->view->userList = $this->user->setUserList($users, $userID); @@ -247,7 +247,7 @@ class user extends control $user = $this->user->getById($userID, 'id'); $account = $user->account; - $users = $this->loadModel('dept')->getDeptUserPairs($this->app->user->dept, 'useid'); + $users = $this->loadModel('dept')->getDeptUserPairs($this->app->user->dept, 'id'); /* Set menu. */ $this->view->userList = $this->user->setUserList($users, $userID); @@ -298,7 +298,7 @@ class user extends control $user = $this->user->getById($userID, 'id'); $account = $user->account; - $users = $this->loadModel('dept')->getDeptUserPairs($this->app->user->dept, 'useid'); + $users = $this->loadModel('dept')->getDeptUserPairs($this->app->user->dept, 'id'); /* Append id for secend sort. */ $sort = $this->loadModel('common')->appendOrder($orderBy); @@ -349,7 +349,7 @@ class user extends control $user = $this->user->getById($userID, 'id'); $account = $user->account; - $users = $this->loadModel('dept')->getDeptUserPairs($this->app->user->dept, 'useid'); + $users = $this->loadModel('dept')->getDeptUserPairs($this->app->user->dept, 'id'); /* Load pager. */ $this->app->loadClass('pager', $static = true); @@ -389,7 +389,7 @@ class user extends control $user = $this->user->getById($userID, 'id'); $account = $user->account; - $users = $this->loadModel('dept')->getDeptUserPairs($this->app->user->dept, 'useid'); + $users = $this->loadModel('dept')->getDeptUserPairs($this->app->user->dept, 'id'); /* Load pager. */ $this->app->loadClass('pager', $static = true); @@ -429,7 +429,7 @@ class user extends control $user = $this->user->getById($userID, 'id'); $account = $user->account; - $users = $this->loadModel('dept')->getDeptUserPairs($this->app->user->dept, 'useid'); + $users = $this->loadModel('dept')->getDeptUserPairs($this->app->user->dept, 'id'); /* Load pager. */ $this->app->loadClass('pager', $static = true); @@ -462,7 +462,7 @@ class user extends control $user = $this->user->getById($userID, 'id'); $account = $user->account; - $users = $this->loadModel('dept')->getDeptUserPairs($this->app->user->dept, 'useid'); + $users = $this->loadModel('dept')->getDeptUserPairs($this->app->user->dept, 'id'); $this->view->title = "USER #$user->id $user->account/" . $this->lang->user->profile; $this->view->position[] = $this->lang->user->common; @@ -1080,7 +1080,7 @@ class user extends control { $user = $this->user->getById($userID, 'id'); $account = $user->account; - $users = $this->loadModel('dept')->getDeptUserPairs($this->app->user->dept, 'useid'); + $users = $this->loadModel('dept')->getDeptUserPairs($this->app->user->dept, 'id'); /* set menus. */ $this->view->userList = $this->user->setUserList($users, $userID);