forked from extern/egroupware
* Addressbook/Mail: allow to use groups as (readonly) distribution lists
This commit is contained in:
parent
0479408cfb
commit
523106c008
@ -1504,8 +1504,8 @@ window.egw_LAB.wait(function() {
|
|||||||
{
|
{
|
||||||
$query['col_filter']['account_id'] = null;
|
$query['col_filter']['account_id'] = null;
|
||||||
}
|
}
|
||||||
// enable/disable distribution lists depending on backend
|
// all backends allow now at least to use groups as distribution lists
|
||||||
$query['no_filter2'] = !$this->lists_available($query['filter']);
|
$query['no_filter2'] = false;
|
||||||
|
|
||||||
if (isset($this->org_views[(string) $query['org_view']]) && !$query['col_filter']['parent_id']) // we have an org view
|
if (isset($this->org_views[(string) $query['org_view']]) && !$query['col_filter']['parent_id']) // we have an org view
|
||||||
{
|
{
|
||||||
|
@ -223,4 +223,20 @@ class Ads extends Ldap
|
|||||||
|
|
||||||
parent::sanitize_update($ldapContact);
|
parent::sanitize_update($ldapContact);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a LDAP filter by group membership
|
||||||
|
*
|
||||||
|
* @param int $gid gidNumber (< 0 as used in EGroupware!)
|
||||||
|
* @return string filter or '' if $gid not < 0
|
||||||
|
*/
|
||||||
|
function membershipFilter($gid)
|
||||||
|
{
|
||||||
|
$filter = '';
|
||||||
|
if ($gid < 0 && ($dn = $GLOBALS['egw']->accounts->id2name($gid, 'account_dn')))
|
||||||
|
{
|
||||||
|
$filter .= '(memberOf='.$dn.')';
|
||||||
|
}
|
||||||
|
return $filter;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -973,6 +973,10 @@ class Ldap
|
|||||||
$filters .= $this->ids_filter($value);
|
$filters .= $this->ids_filter($value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'list':
|
||||||
|
$filter .= $this->membershipFilter($value);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$matches = null;
|
$matches = null;
|
||||||
if (!is_int($key))
|
if (!is_int($key))
|
||||||
@ -1009,6 +1013,28 @@ class Ldap
|
|||||||
return $filters;
|
return $filters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a LDAP filter by group membership
|
||||||
|
*
|
||||||
|
* @param int $gid gidNumber (< 0 as used in EGroupware!)
|
||||||
|
* @return string filter or '' if $gid not < 0
|
||||||
|
*/
|
||||||
|
function membershipFilter($gid)
|
||||||
|
{
|
||||||
|
$filter = '';
|
||||||
|
if ($gid < 0)
|
||||||
|
{
|
||||||
|
$filter .= '(|';
|
||||||
|
// unfortunately we have no group-membership attribute in LDAP, like in AD
|
||||||
|
foreach($GLOBALS['egw']->accounts->members($gid, true) as $account_id)
|
||||||
|
{
|
||||||
|
$filter .= '(uidNumber='.(int)$account_id.')';
|
||||||
|
}
|
||||||
|
$filter .= ')';
|
||||||
|
}
|
||||||
|
return $filter;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform the actual ldap-search, retrieve and convert all entries
|
* Perform the actual ldap-search, retrieve and convert all entries
|
||||||
*
|
*
|
||||||
|
@ -345,9 +345,17 @@ class Sql extends Api\Storage
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isset($filter['list']))
|
if (isset($filter['list']))
|
||||||
|
{
|
||||||
|
if ($filter['list'] < 0)
|
||||||
|
{
|
||||||
|
$join .= " JOIN egw_acl ON $this->table_name.account_id=acl_account AND acl_appname='phpgw_group' AND ".
|
||||||
|
$this->db->expression('egw_acl', array('acl_location' => $filter['list']));
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
$join .= " JOIN $this->ab2list_table ON $this->table_name.contact_id=$this->ab2list_table.contact_id AND ".
|
$join .= " JOIN $this->ab2list_table ON $this->table_name.contact_id=$this->ab2list_table.contact_id AND ".
|
||||||
$this->db->expression($this->ab2list_table, array('list_id' => $filter['list']));
|
$this->db->expression($this->ab2list_table, array('list_id' => $filter['list']));
|
||||||
|
}
|
||||||
unset($filter['list']);
|
unset($filter['list']);
|
||||||
}
|
}
|
||||||
// add join to show only active accounts (only if accounts are shown and in sql and we not already join the accounts table, eg. used by admin)
|
// add join to show only active accounts (only if accounts are shown and in sql and we not already join the accounts table, eg. used by admin)
|
||||||
@ -551,6 +559,28 @@ class Sql extends Api\Storage
|
|||||||
$lists[$row['list_id']]['members'][] = $row[$member_attr];
|
$lists[$row['list_id']]['members'][] = $row[$member_attr];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* groups as list are implemented currently in Contacts\Storage::get_lists() for all backends
|
||||||
|
if ($uid_column == 'list_owner' && in_array(0, (array)$uids) && (!$limit_in_ab || in_array(0, (array)$limit_in_ab)))
|
||||||
|
{
|
||||||
|
foreach($GLOBALS['egw']->accounts->search(array(
|
||||||
|
'type' => 'groups'
|
||||||
|
)) as $account_id => $group)
|
||||||
|
{
|
||||||
|
$list = array(
|
||||||
|
'list_id' => $account_id,
|
||||||
|
'list_name' => Api\Accounts::format_username($group['account_lid'], '', '', $account_id),
|
||||||
|
'list_owner' => 0,
|
||||||
|
'list_uid' => 'group'.$account_id,
|
||||||
|
'list_carddav_name' => 'group'.$account_id.'.vcf',
|
||||||
|
'list_etag' => md5(json_encode($GLOBALS['egw']->accounts->members($account_id, true)))
|
||||||
|
);
|
||||||
|
if ($member_attr)
|
||||||
|
{
|
||||||
|
$list['members'] = array(); // ToDo
|
||||||
|
}
|
||||||
|
$lists[(string)$account_id] = $list;
|
||||||
|
}
|
||||||
|
}*/
|
||||||
//error_log(__METHOD__.'('.array2string($uids).", '$uid_column', '$member_attr') returning ".array2string($lists));
|
//error_log(__METHOD__.'('.array2string($uids).", '$uid_column', '$member_attr') returning ".array2string($lists));
|
||||||
return $lists;
|
return $lists;
|
||||||
}
|
}
|
||||||
|
@ -1012,17 +1012,21 @@ class Storage
|
|||||||
*/
|
*/
|
||||||
function get_lists($required=Api\Acl::READ,$extra_labels=null)
|
function get_lists($required=Api\Acl::READ,$extra_labels=null)
|
||||||
{
|
{
|
||||||
if (!method_exists($this->somain,'get_lists')) return false;
|
$lists = is_array($extra_labels) ? $extra_labels : array();
|
||||||
|
|
||||||
|
if (method_exists($this->somain,'get_lists'))
|
||||||
|
{
|
||||||
$uids = array();
|
$uids = array();
|
||||||
foreach($this->grants as $uid => $rights)
|
foreach($this->grants as $uid => $rights)
|
||||||
{
|
{
|
||||||
|
// only requests groups / list in accounts addressbook for read
|
||||||
|
if (!$uid && $required != Api\Acl::READ) continue;
|
||||||
|
|
||||||
if (($rights & $required) == $required)
|
if (($rights & $required) == $required)
|
||||||
{
|
{
|
||||||
$uids[] = $uid;
|
$uids[] = $uid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$lists = is_array($extra_labels) ? $extra_labels : array();
|
|
||||||
|
|
||||||
foreach($this->somain->get_lists($uids) as $list_id => $data)
|
foreach($this->somain->get_lists($uids) as $list_id => $data)
|
||||||
{
|
{
|
||||||
@ -1032,6 +1036,16 @@ class Storage
|
|||||||
$lists[$list_id] .= ' ('.Api\Accounts::username($data['list_owner']).')';
|
$lists[$list_id] .= ' ('.Api\Accounts::username($data['list_owner']).')';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// add groups for all backends
|
||||||
|
foreach($GLOBALS['egw']->accounts->search(array(
|
||||||
|
'type' => 'groups'
|
||||||
|
)) as $account_id => $group)
|
||||||
|
{
|
||||||
|
$lists[(string)$account_id] = Api\Accounts::format_username($group['account_lid'], '', '', $account_id);
|
||||||
|
}
|
||||||
|
|
||||||
return $lists;
|
return $lists;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user