* Addressbook: fix bug setting Hide User Account in preferences into Show all accounts breaks show accounts

This commit is contained in:
Hadi Nategh 2017-12-01 14:58:44 +01:00
parent 227a5b28da
commit 90a5e91fc7
10 changed files with 17 additions and 17 deletions

View File

@ -68,7 +68,7 @@ class addressbook_export_contacts_csv implements importexport_iface_export_plugi
$this->ui->get_rows($query,$selection,$readonlys, true); // only return the ids $this->ui->get_rows($query,$selection,$readonlys, true); // only return the ids
} }
elseif ( $options['selection'] == 'all' ) { elseif ( $options['selection'] == 'all' ) {
if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) { if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] === '1') {
$col_filter['account_id'] = null; $col_filter['account_id'] = null;
} }
$selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '','',false,'AND',false,$col_filter); $selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '','',false,'AND',false,$col_filter);

View File

@ -51,7 +51,7 @@ class addressbook_export_vcard implements importexport_iface_export_plugin {
$this->uicontacts->get_rows($query,$this->selection,$readonlys, true); // only return the ids $this->uicontacts->get_rows($query,$this->selection,$readonlys, true); // only return the ids
} }
elseif ( $options['selection'] == 'all' ) { elseif ( $options['selection'] == 'all' ) {
if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) { if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] === '1') {
$col_filter['account_id'] = null; $col_filter['account_id'] = null;
} }
$this->selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '','',false,'AND',false,$col_filter); $this->selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '','',false,'AND',false,$col_filter);

View File

@ -123,7 +123,7 @@ class addressbook_groupdav extends Api\CalDAV\Handler
$filter['owner'] = $user; $filter['owner'] = $user;
} }
// should we hide the accounts addressbook // should we hide the accounts addressbook
if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) $filter['account_id'] = null; if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] === '1') $filter['account_id'] = null;
// process REPORT filters or multiget href's // process REPORT filters or multiget href's
$nresults = null; $nresults = null;
@ -1076,7 +1076,7 @@ class addressbook_groupdav extends Api\CalDAV\Handler
} }
foreach(array_keys($this->bo->get_addressbooks(Acl::READ)) as $id) foreach(array_keys($this->bo->get_addressbooks(Acl::READ)) as $id)
{ {
if (($id || !$GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) && if (($id || $GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] !== '1') &&
$GLOBALS['egw_info']['user']['account_id'] != $id && // no current user and no accounts, if disabled in ab prefs $GLOBALS['egw_info']['user']['account_id'] != $id && // no current user and no accounts, if disabled in ab prefs
(in_array('A',$this->home_set_pref) || in_array((string)$id,$this->home_set_pref)) && (in_array('A',$this->home_set_pref) || in_array((string)$id,$this->home_set_pref)) &&
is_numeric($id) && ($owner = $id ? $this->accounts->id2name($id) : 'accounts')) is_numeric($id) && ($owner = $id ? $this->accounts->id2name($id) : 'accounts'))
@ -1101,7 +1101,7 @@ class addressbook_groupdav extends Api\CalDAV\Handler
Api\CalDAV::mkprop('href',$data['caldav']->base_uri.'/'.$GLOBALS['egw_info']['user']['account_lid'].'/'))); Api\CalDAV::mkprop('href',$data['caldav']->base_uri.'/'.$GLOBALS['egw_info']['user']['account_lid'].'/')));
$data['props']['principal-address'] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'principal-address', $data['props']['principal-address'] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'principal-address',
$GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] ? '' : array( $GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] === '1' ? '' : array(
Api\CalDAV::mkprop('href',$data['caldav']->base_uri.'/addressbook-accounts/'.$GLOBALS['egw_info']['user']['person_id'].'.vcf'))); Api\CalDAV::mkprop('href',$data['caldav']->base_uri.'/addressbook-accounts/'.$GLOBALS['egw_info']['user']['person_id'].'.vcf')));
$data['props']['directory-gateway'] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'directory-gateway', array( $data['props']['directory-gateway'] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'directory-gateway', array(
@ -1141,7 +1141,7 @@ class addressbook_groupdav extends Api\CalDAV\Handler
// rewriting owner=0 to 'U', as 0 get's always selected by prefs // rewriting owner=0 to 'U', as 0 get's always selected by prefs
// not removing it for default or forced prefs based on current users pref // not removing it for default or forced prefs based on current users pref
if (!isset($addressbooks[0]) && (in_array($hook_data['type'], array('user', 'group')) || if (!isset($addressbooks[0]) && (in_array($hook_data['type'], array('user', 'group')) ||
$GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'])) $GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] === '1'))
{ {
unset($addressbooks['U']); unset($addressbooks['U']);
} }

View File

@ -869,7 +869,7 @@ class addressbook_zpush implements activesync_plugin_write, activesync_plugin_se
// rewriting owner=0 to 'U', as 0 get's always selected by prefs // rewriting owner=0 to 'U', as 0 get's always selected by prefs
// not removing it for default or forced prefs based on current users pref // not removing it for default or forced prefs based on current users pref
if (!isset($addressbooks[0]) && (in_array($hook_data['type'], array('user', 'group')) || if (!isset($addressbooks[0]) && (in_array($hook_data['type'], array('user', 'group')) ||
$GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'])) $GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] === '1'))
{ {
unset($addressbooks['U']); unset($addressbooks['U']);
} }

View File

@ -675,7 +675,7 @@ class CalDAV extends HTTP_WebDAV_Server
// only add global /addressbook-accounts/ as the one in home-set is added (and controled) by add_shared // only add global /addressbook-accounts/ as the one in home-set is added (and controled) by add_shared
if ($path == '/' && $app == 'addressbook' && if ($path == '/' && $app == 'addressbook' &&
!$GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) $GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] !== '1')
{ {
$file = $this->add_app($app,false,0,$path.$app.'-accounts/'); $file = $this->add_app($app,false,0,$path.$app.'-accounts/');
$file['props']['resourcetype']['val'][] = self::mkprop(self::CALENDARSERVER,'shared',''); $file['props']['resourcetype']['val'][] = self::mkprop(self::CALENDARSERVER,'shared','');
@ -851,7 +851,7 @@ class CalDAV extends HTTP_WebDAV_Server
$props['displayname'] = lang('All addressbooks'); $props['displayname'] = lang('All addressbooks');
break; break;
} }
elseif(!$user && !$GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) elseif(!$user && $GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] !== '1')
{ {
unset($props['owner']); unset($props['owner']);
$props['displayname'] = lang($app).' '.lang('Accounts'); $props['displayname'] = lang($app).' '.lang('Accounts');
@ -1972,7 +1972,7 @@ class CalDAV extends HTTP_WebDAV_Server
{ {
$user_prefix = '/'.$GLOBALS['egw_info']['user']['account_lid'].'/'.$app; $user_prefix = '/'.$GLOBALS['egw_info']['user']['account_lid'].'/'.$app;
list($app, $username) = explode('-', $app, 2); list($app, $username) = explode('-', $app, 2);
if ($username == 'accounts' && !$GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) if ($username == 'accounts' && $GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] !== '1')
{ {
$account_id = 0; $account_id = 0;
} }

View File

@ -983,7 +983,7 @@ class Principals extends Handler
// CardDAV // CardDAV
'addressbook-home-set' => Api\CalDAV::mkprop(Api\CalDAV::CARDDAV,'addressbook-home-set',$addressbooks), 'addressbook-home-set' => Api\CalDAV::mkprop(Api\CalDAV::CARDDAV,'addressbook-home-set',$addressbooks),
'principal-address' => Api\CalDAV::mkprop(Api\CalDAV::CARDDAV,'principal-address', 'principal-address' => Api\CalDAV::mkprop(Api\CalDAV::CARDDAV,'principal-address',
$GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] ? '' : array( $GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] === '1' ? '' : array(
Api\CalDAV::mkprop('href',$this->base_uri.'/addressbook-accounts/'.$account['person_id'].'.vcf'))), Api\CalDAV::mkprop('href',$this->base_uri.'/addressbook-accounts/'.$account['person_id'].'.vcf'))),
// CardDAV directory // CardDAV directory
'directory-gateway' => Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'directory-gateway',array( 'directory-gateway' => Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'directory-gateway',array(

View File

@ -1550,7 +1550,7 @@ class Contacts extends Contacts\Storage
$limit = array($options['start'], $options['num_rows']); $limit = array($options['start'], $options['num_rows']);
} }
$filter = (array)$options['filter']; $filter = (array)$options['filter'];
if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) $filter['account_id'] = null; if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] === '1') $filter['account_id'] = null;
if (($contacts =& parent::search($criteria,false,'org_name,n_family,n_given,cat_id,contact_email','','%',false,'OR', $limit, $filter))) if (($contacts =& parent::search($criteria,false,'org_name,n_family,n_given,cat_id,contact_email','','%',false,'OR', $limit, $filter)))
{ {
$ids = array(); $ids = array();
@ -2508,7 +2508,7 @@ class Contacts extends Contacts\Storage
if (!is_null($owner)) $filter['owner'] = $owner; if (!is_null($owner)) $filter['owner'] = $owner;
// should we hide the accounts addressbook // should we hide the accounts addressbook
if (!$owner && $GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) if (!$owner && $GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] === '1')
{ {
$filter['account_id'] = null; $filter['account_id'] = null;
} }

View File

@ -1165,7 +1165,7 @@ class Storage
} }
// add groups for all backends, if accounts addressbook is not hidden // add groups for all backends, if accounts addressbook is not hidden
if (empty($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'])) if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] !== '1')
{ {
foreach($GLOBALS['egw']->accounts->search(array( foreach($GLOBALS['egw']->accounts->search(array(
'type' => 'groups' 'type' => 'groups'

View File

@ -92,7 +92,7 @@ use EGroupware\Api\Etemplate;
$bdays =& $contacts->search(array('bday' => $month_start),array('id','n_family','n_given','bday'),'n_given,n_family','','%'); $bdays =& $contacts->search(array('bday' => $month_start),array('id','n_family','n_given','bday'),'n_given,n_family','','%');
// search accounts too, if not stored in accounts repository // search accounts too, if not stored in accounts repository
$extra_accounts_search = $contacts->account_repository == 'ldap' && !is_null($contacts->so_accounts) && $extra_accounts_search = $contacts->account_repository == 'ldap' && !is_null($contacts->so_accounts) &&
!$GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']; $GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] !== '1';
if ($extra_accounts_search && ($bdays2 = $contacts->search(array('bday' => $month_start),array('id','n_family','n_given','bday'), if ($extra_accounts_search && ($bdays2 = $contacts->search(array('bday' => $month_start),array('id','n_family','n_given','bday'),
'n_given,n_family','','%',false,'AND',false,array('owner' => 0)))) 'n_given,n_family','','%',false,'AND',false,array('owner' => 0))))
{ {

View File

@ -883,7 +883,7 @@ class mail_compose
{ {
$_searchCond = array('contact_id'=>$addressArray); $_searchCond = array('contact_id'=>$addressArray);
//error_log(__METHOD__.__LINE__.$_searchString); //error_log(__METHOD__.__LINE__.$_searchString);
if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) $showAccounts=false; $showAccounts= $GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] !== '1';
$filter = ($showAccounts?array():array('account_id' => null)); $filter = ($showAccounts?array():array('account_id' => null));
$filter['cols_to_search']=array('n_fn','email','email_home'); $filter['cols_to_search']=array('n_fn','email','email_home');
$contacts = $contacts_obj->search($_searchCond,array('n_fn','email','email_home'),'n_fn','','%',false,'OR',array(0,100),$filter); $contacts = $contacts_obj->search($_searchCond,array('n_fn','email','email_home'),'n_fn','','%',false,'OR',array(0,100),$filter);
@ -3483,7 +3483,7 @@ class mail_compose
if ($GLOBALS['egw_info']['user']['apps']['addressbook'] && strlen($_searchString)>=$_searchStringLength) if ($GLOBALS['egw_info']['user']['apps']['addressbook'] && strlen($_searchString)>=$_searchStringLength)
{ {
//error_log(__METHOD__.__LINE__.array2string($_searchString)); //error_log(__METHOD__.__LINE__.array2string($_searchString));
$showAccounts = empty($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']); $showAccounts = $GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] !== '1';
$search = explode(' ', $_searchString); $search = explode(' ', $_searchString);
foreach ($search as $k => $v) foreach ($search as $k => $v)
{ {