* userModel: refactor the getContactLists method.

This commit is contained in:
liugang
2023-11-29 10:46:59 +08:00
parent 10956f3163
commit bd8505fa47
7 changed files with 15 additions and 17 deletions
+2 -2
View File
@@ -1147,7 +1147,7 @@ class bugZen extends bug
$this->view->releasedBuilds = $this->loadModel('release')->getReleasedBuilds($bug->productID, $bug->branch);
$this->view->resultFiles = (!empty($resultID) and !empty($stepIdList)) ? $this->loadModel('file')->getByObject('stepResult', $resultID, str_replace('_', ',', $stepIdList)) : array();
$this->view->product = $currentProduct;
$this->view->contactList = $this->loadModel('user')->getContactLists($this->app->user->account, 'withnote');
$this->view->contactList = $this->loadModel('user')->getContactLists();
$this->view->projectID = isset($projectID) ? $projectID : $bug->projectID;
$this->view->executionID = isset($executionID) ? $executionID : (!empty($bug->execution->id) ? $bug->execution->id : '');
}
@@ -1262,7 +1262,7 @@ class bugZen extends bug
$this->view->cases = $this->loadModel('testcase')->getPairsByProduct($bug->product, array(0, $bug->branch));
$this->view->users = $this->user->getPairs('noclosed', "$bug->assignedTo,$bug->resolvedBy,$bug->closedBy,$bug->openedBy");
$this->view->actions = $this->loadModel('action')->getList('bug', $bug->id);
$this->view->contactList = $this->loadModel('user')->getContactLists($this->app->user->account, 'withnote');
$this->view->contactList = $this->loadModel('user')->getContactLists();
$this->view->assignedToList = $assignedToList;
$this->view->execution = $this->loadModel('execution')->getByID($bug->execution);
}
+2 -2
View File
@@ -1324,7 +1324,7 @@ EOF;
$users = $this->user->getPairs($userParams, $mode == 'new' ? '' : $userList, $this->config->maxCount);
$this->view->title = $this->lang->my->common . $this->lang->colon . $label;
$this->view->lists = $this->user->getContactLists($this->app->user->account, '', 'list');
$this->view->lists = $this->user->getContactLists($this->app->user->account, 'list');
$this->view->users = $users;
$this->view->mode = $mode;
$this->view->label = $label;
@@ -1357,7 +1357,7 @@ EOF;
*/
public function buildContactLists(string $dropdownName = 'mailto', string $attr = '')
{
$this->view->contactLists = $this->user->getContactLists($this->app->user->account, 'withnote');
$this->view->contactLists = $this->user->getContactLists();
$this->view->dropdownName = $dropdownName;
$this->view->attr = $attr;
$this->display();
+1 -1
View File
@@ -279,7 +279,7 @@ class taskZen extends task
$this->view->showAllModule = isset($this->config->execution->task->allModule) ? $this->config->execution->task->allModule : '';
$this->view->modules = $this->tree->getTaskOptionMenu($task->execution, 0, $this->view->showAllModule ? 'allModule' : '');
$this->view->executions = $executions;
$this->view->contactLists = $this->loadModel('user')->getContactLists($this->app->user->account, 'withnote');
$this->view->contactLists = $this->loadModel('user')->getContactLists();
$this->display();
}
+1 -1
View File
@@ -624,7 +624,7 @@ class testtask extends control
$this->view->title = $testtask->name . $this->lang->colon . $this->lang->close;
$this->view->actions = $this->loadModel('action')->getList('testtask', $taskID);
$this->view->users = $this->loadModel('user')->getPairs('noclosed|nodeleted|qdfirst');
$this->view->contactLists = $this->user->getContactLists($this->app->user->account, 'withnote');
$this->view->contactLists = $this->user->getContactLists();
$this->view->testtask = $testtask;
$this->display();
}
+1 -1
View File
@@ -393,7 +393,7 @@ class testtaskZen extends testtask
$this->view->builds = empty($productID) ? array() : $this->loadModel('build')->getBuildPairs(array($productID), 'all', 'noempty,notrunk,withexecution', $executionID ? $executionID : $task->project, $executionID ? 'execution' : 'project', $task->build, false);
$this->view->testreports = $this->loadModel('testreport')->getPairs($task->product, $task->testreport);
$this->view->users = $this->loadModel('user')->getPairs('nodeleted|noclosed', $task->owner);
$this->view->contactLists = $this->user->getContactLists($this->app->user->account, 'withnote');
$this->view->contactLists = $this->user->getContactLists();
}
/**
+1 -1
View File
@@ -1037,7 +1037,7 @@ class user extends control
*/
public function ajaxGetContactList()
{
$contactList = $this->user->getContactLists($this->app->user->account, 'withnote');
$contactList = $this->user->getContactLists();
$items = array();
foreach($contactList as $contactID => $contactName) $items[] = array('text' => $contactName, 'value' => $contactID);
+7 -9
View File
@@ -1258,28 +1258,26 @@ class userModel extends model
}
/**
* Get contact list of a user.
* 获取某个用户可以查看的联系人列表。
* Get the contact list of a user.
*
* @param string $account
* @param string $params withempty|withnote
* @param string $mode pairs|list
* @access public
* @return array
*/
public function getContactLists(string $account, string $params = '', string $mode = 'pairs'): array
public function getContactLists(string $account = '', string $mode = 'pairs'): array
{
if(!$account) $account = $this->app->user->account;
$this->dao->select('*')->from(TABLE_USERCONTACT)
->where('account')->eq($account)
->orWhere('public')->eq(1)
->orderBy('public, id_desc');
$contacts = $mode == 'pairs' ? $this->dao->fetchPairs('id', 'listName') : $this->dao->fetchAll();
if(empty($contacts)) return array();
if($mode == 'pairs') return $this->dao->fetchPairs('id', 'listName');
if(strpos($params, 'withempty') !== false) $contacts = array('' => '') + $contacts;
if(strpos($params, 'withnote') !== false) $contacts = array('' => $this->lang->user->contacts->common) + $contacts;
return $contacts;
return $this->dao->fetchAll();
}
/**