* Task #3465
This commit is contained in:
+33
-6
@@ -915,15 +915,29 @@ class userModel extends model
|
||||
/**
|
||||
* Get contact list of a user.
|
||||
*
|
||||
* @param string $account
|
||||
* @param string $params withempty|withnote
|
||||
* @param string $account
|
||||
* @param string $params withempty|withnote
|
||||
*
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function getContactLists($account, $params= '')
|
||||
{
|
||||
$contacts = $this->dao->select('id, listName')->from(TABLE_USERCONTACT)->where('account')->eq($account)->fetchPairs();
|
||||
if(!$contacts) return array();
|
||||
$contacts = $this->getListByAccount($account);
|
||||
$globalIDs = isset($this->config->my->global->globalContacts) ? $this->config->my->global->globalContacts : '';
|
||||
|
||||
if(!empty($globalIDs))
|
||||
{
|
||||
$globalIDs = explode(',', $globalIDs);
|
||||
$globalContacts = $this->dao->select('id, listName')->from(TABLE_USERCONTACT)->where('id')->in($globalIDs)->fetchPairs();
|
||||
foreach($globalContacts as $id => $contact)
|
||||
{
|
||||
if(in_array($id, array_keys($contacts))) unset($globalContacts[$id]);
|
||||
}
|
||||
if(!empty($globalContacts)) $contacts = $globalContacts + $contacts;
|
||||
}
|
||||
|
||||
if(empty($contacts)) return array();
|
||||
|
||||
if(strpos($params, 'withempty') !== false) $contacts = array('' => '') + $contacts;
|
||||
if(strpos($params, 'withnote') !== false) $contacts = array('' => $this->lang->user->contacts->common) + $contacts;
|
||||
@@ -931,6 +945,19 @@ class userModel extends model
|
||||
return $contacts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Contact List by account.
|
||||
*
|
||||
* @param string $account
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getListByAccount($account)
|
||||
{
|
||||
return $this->dao->select('id, listName')->from(TABLE_USERCONTACT)->where('account')->eq($account)->fetchPairs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a contact list by id.
|
||||
*
|
||||
@@ -1022,7 +1049,7 @@ class userModel extends model
|
||||
*/
|
||||
public function setGlobalContacts($listID, $isPush = true)
|
||||
{
|
||||
$contacts = $this->loadModel('setting')->getItem("owner=system&module=my§ion=global&key=globalContact");
|
||||
$contacts = $this->loadModel('setting')->getItem("owner=system&module=my§ion=global&key=globalContacts");
|
||||
$contactsIDs = empty($contacts) ? array() : explode(',', $contacts);
|
||||
if($isPush)
|
||||
{
|
||||
@@ -1033,7 +1060,7 @@ class userModel extends model
|
||||
$key = array_search($listID, $contactsIDs);
|
||||
if($key !== false) array_splice($contactsIDs, $key, 1);
|
||||
}
|
||||
$this->loadModel('setting')->setItem('system.my.global.globalContact', join(',', $contactsIDs));
|
||||
$this->loadModel('setting')->setItem('system.my.global.globalContacts', join(',', $contactsIDs));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user