* user: refactor the task method.
This commit is contained in:
+16
-15
@@ -134,43 +134,44 @@ class user extends control
|
||||
}
|
||||
|
||||
/**
|
||||
* Tasks of a user.
|
||||
* 查看某个用户的任务。
|
||||
* View user's tasks.
|
||||
*
|
||||
* @param int $userID
|
||||
* @param string $type
|
||||
* @param string $orderBy
|
||||
* @param int $recTotal
|
||||
* @param int $recPerPage
|
||||
* @param int $pageID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function task($userID, $type = 'assignedTo', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
|
||||
public function task(int $userID, string $type = 'assignedTo', string $orderBy = 'id_desc', int $recTotal = 0, int $recPerPage = 20, int $pageID = 1)
|
||||
{
|
||||
/* Save the session. */
|
||||
$this->session->set('taskList', $this->app->getURI(true), 'execution');
|
||||
|
||||
/* Load pager. */
|
||||
$this->app->loadClass('pager', $static = true);
|
||||
$this->app->loadClass('pager', true);
|
||||
$pager = pager::init($recTotal, $recPerPage, $pageID);
|
||||
|
||||
$user = $this->user->getById($userID, 'id');
|
||||
$account = $user->account;
|
||||
$deptID = $this->app->user->admin ? 0 : $this->app->user->dept;
|
||||
$users = $this->loadModel('dept')->getDeptUserPairs($deptID, 'id');
|
||||
$user = $this->user->getById($userID, 'id');
|
||||
$deptID = $this->app->user->admin ? 0 : $this->app->user->dept;
|
||||
$users = $this->loadModel('dept')->getDeptUserPairs($deptID, 'id');
|
||||
if(!isset($users[$userID])) $users[$userID] = $user->realname;
|
||||
|
||||
/* Append id for second sort. */
|
||||
$sort = common::appendOrder($orderBy);
|
||||
if(strpos($sort, 'Label') !== false) $sort = str_replace('Label', '', $sort);
|
||||
|
||||
/* Assign. */
|
||||
$this->view->userList = $this->user->setUserList($users, $userID);
|
||||
$this->view->title = $this->lang->user->common . $this->lang->colon . $this->lang->user->task;
|
||||
$this->view->tabID = 'task';
|
||||
$this->view->tasks = $this->loadModel('task')->getUserTasks($account, $type, 0, $pager, $sort);
|
||||
$this->view->type = $type;
|
||||
$this->view->orderBy = $orderBy;
|
||||
$this->view->user = $user;
|
||||
$this->view->pager = $pager;
|
||||
$this->view->title = $this->lang->user->common . $this->lang->colon . $this->lang->user->task;
|
||||
$this->view->tasks = $this->loadModel('task')->getUserTasks($user->account, $type, 0, $pager, $sort);
|
||||
$this->view->deptUsers = $users;
|
||||
$this->view->user = $user;
|
||||
$this->view->type = $type;
|
||||
$this->view->orderBy = $orderBy;
|
||||
$this->view->pager = $pager;
|
||||
$this->display();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user