* Addressbook - fix SQL error with accounts hidden + Organisation by location / department

- Fix accounts missing if no preference for hide accounts set
This commit is contained in:
nathangray 2017-11-29 09:11:46 -07:00
parent 8705ca2589
commit e88afc07d0
3 changed files with 7 additions and 2 deletions

View File

@ -148,6 +148,7 @@ class addressbook_hooks
'help' => 'Hides accounts completly from the adressbook.', 'help' => 'Hides accounts completly from the adressbook.',
'xmlrpc' => True, 'xmlrpc' => True,
'admin' => false, 'admin' => false,
'default'=> '0'
); );
$contacts = new Api\Contacts(); $contacts = new Api\Contacts();
$fileas_options = $contacts->fileas_options(); $fileas_options = $contacts->fileas_options();

View File

@ -185,6 +185,10 @@ class Contacts extends Contacts\Storage
$this->now_su = DateTime::to('now','ts'); $this->now_su = DateTime::to('now','ts');
$this->prefs =& $GLOBALS['egw_info']['user']['preferences']['addressbook']; $this->prefs =& $GLOBALS['egw_info']['user']['preferences']['addressbook'];
if(!isset($this->prefs['hide_accounts']))
{
$this->prefs['hide_accounts'] = '0';
}
// get the default addressbook from the users prefs // get the default addressbook from the users prefs
$this->default_addressbook = $GLOBALS['egw_info']['user']['preferences']['addressbook']['add_default'] ? $this->default_addressbook = $GLOBALS['egw_info']['user']['preferences']['addressbook']['add_default'] ?
(int)$GLOBALS['egw_info']['user']['preferences']['addressbook']['add_default'] : $this->user; (int)$GLOBALS['egw_info']['user']['preferences']['addressbook']['add_default'] : $this->user;

View File

@ -194,7 +194,7 @@ class Sql extends Api\Storage
'COUNT(DISTINCT egw_addressbook.contact_id) AS org_count', 'COUNT(DISTINCT egw_addressbook.contact_id) AS org_count',
"COUNT(DISTINCT CASE WHEN org_unit IS NULL THEN '' ELSE org_unit END) AS org_unit_count", "COUNT(DISTINCT CASE WHEN org_unit IS NULL THEN '' ELSE org_unit END) AS org_unit_count",
"COUNT(DISTINCT CASE WHEN adr_one_locality IS NULL THEN '' ELSE adr_one_locality END) AS adr_one_locality_count", "COUNT(DISTINCT CASE WHEN adr_one_locality IS NULL THEN '' ELSE adr_one_locality END) AS adr_one_locality_count",
),$wildcard,false,$op/*'OR'*/,'UNION',$filter); ),$wildcard,false,$op/*'OR'*/,'UNION',$filter,$join);
// org by location // org by location
parent::search($param['search'],array('org_name'), parent::search($param['search'],array('org_name'),
"GROUP BY org_name,$by ORDER BY org_name $sort,$by $sort", array( "GROUP BY org_name,$by ORDER BY org_name $sort,$by $sort", array(
@ -203,7 +203,7 @@ class Sql extends Api\Storage
'COUNT(DISTINCT egw_addressbook.contact_id) AS org_count', 'COUNT(DISTINCT egw_addressbook.contact_id) AS org_count',
"COUNT(DISTINCT CASE WHEN org_unit IS NULL THEN '' ELSE org_unit END) AS org_unit_count", "COUNT(DISTINCT CASE WHEN org_unit IS NULL THEN '' ELSE org_unit END) AS org_unit_count",
"COUNT(DISTINCT CASE WHEN adr_one_locality IS NULL THEN '' ELSE adr_one_locality END) AS adr_one_locality_count", "COUNT(DISTINCT CASE WHEN adr_one_locality IS NULL THEN '' ELSE adr_one_locality END) AS adr_one_locality_count",
),$wildcard,false,$op/*'OR'*/,'UNION',$filter); ),$wildcard,false,$op/*'OR'*/,'UNION',$filter,$join);
$append = "ORDER BY org_name $sort,is_main DESC,$by $sort"; $append = "ORDER BY org_name $sort,is_main DESC,$by $sort";
} }
$rows = parent::search($param['search'],array('org_name'),$append,$extra,$wildcard,false,$op/*'OR'*/, $rows = parent::search($param['search'],array('org_name'),$append,$extra,$wildcard,false,$op/*'OR'*/,