fix for bug #639: Distribution lists with user accounts in LDAP

This commit is contained in:
Ralf Becker 2007-05-01 09:17:23 +00:00
parent 09bfe009aa
commit 4ca46d10d0
2 changed files with 22 additions and 6 deletions

View File

@ -670,6 +670,8 @@ class socontacts
*/ */
function &get_backend($contact_id=null,$owner=null) function &get_backend($contact_id=null,$owner=null)
{ {
if ($owner === '') $owner = null;
if ($this->contact_repository != $this->account_repository && is_object($this->so_accounts) && if ($this->contact_repository != $this->account_repository && is_object($this->so_accounts) &&
(!is_null($owner) && !$owner || !is_null($contact_id) && (!is_null($owner) && !$owner || !is_null($contact_id) &&
($this->contact_repository == 'sql' && !is_numeric($contact_id) || ($this->contact_repository == 'sql' && !is_numeric($contact_id) ||
@ -888,4 +890,17 @@ class socontacts
return $this->somain->read_list($list); return $this->somain->read_list($list);
} }
/**
* Check if distribution lists are availible for a given addressbook
*
* @param int/string $owner '' means all lists, which uses the main addressbook
* @return boolean
*/
function lists_available($owner)
{
$backend =& $this->get_backend(null,$owner);
return method_exists($backend,'read_list');
}
} }

View File

@ -168,6 +168,7 @@ class uicontacts extends bocontacts
'filter' => '', // =All // IO filter, if not 'no_filter' => True 'filter' => '', // =All // IO filter, if not 'no_filter' => True
'filter_no_lang' => True, // I set no_lang for filter (=dont translate the options) 'filter_no_lang' => True, // I set no_lang for filter (=dont translate the options)
'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter)
'filter2_label' => lang('Distribution lists'), // IO filter2, if not 'no_filter2' => True
'filter2' => '', // IO filter2, if not 'no_filter2' => True 'filter2' => '', // IO filter2, if not 'no_filter2' => True
'filter2_no_lang'=> True, // I set no_lang for filter2 (=dont translate the options) 'filter2_no_lang'=> True, // I set no_lang for filter2 (=dont translate the options)
'lettersearch' => true, 'lettersearch' => true,
@ -176,13 +177,10 @@ class uicontacts extends bocontacts
'filter2_onchange' => "if(this.value=='add') { add_new_list(document.getElementById(form::name('filter')).value); this.value='';} else this.form.submit();", 'filter2_onchange' => "if(this.value=='add') { add_new_list(document.getElementById(form::name('filter')).value); this.value='';} else this.form.submit();",
); );
// if the backend supports distribution lists // if the backend supports distribution lists
if (($sel_options['filter2'] = $this->get_lists(EGW_ACL_READ,array( $sel_options['filter2'] = $this->get_lists(EGW_ACL_READ,array(
'' => lang('Distribution lists').'...', '' => lang('none'),
'add' => lang('Add a new list').'...', 'add' => lang('Add a new list').'...',
))) !== false) ));
{
$content['nm']['no_filter2'] = false;
}
// use the state of the last session stored in the user prefs // use the state of the last session stored in the user prefs
if (($state = @unserialize($this->prefs[$do_email ? 'email_state' : 'index_state']))) if (($state = @unserialize($this->prefs[$do_email ? 'email_state' : 'index_state'])))
{ {
@ -704,6 +702,9 @@ class uicontacts extends bocontacts
{ {
$query['col_filter']['account_id'] = null; $query['col_filter']['account_id'] = null;
} }
// enable/disable distribution lists depending on backend
$query['no_filter2'] = !$this->lists_available($query['filter']);
if (isset($this->org_views[(string) $query['org_view']])) // we have an org view if (isset($this->org_views[(string) $query['org_view']])) // we have an org view
{ {
unset($query['col_filter']['list']); // does not work together unset($query['col_filter']['list']); // does not work together