adding the feature of viewing the distributionlists of a contact in list and singleview

enabling longer orgnames and emailaddresses
This commit is contained in:
Klaus Leithoff 2008-01-31 12:52:43 +00:00
parent 4fd4d8fb6a
commit 55eb8ece48
6 changed files with 100 additions and 10 deletions

View File

@ -117,7 +117,6 @@
}
if ($_POST['next']) $_POST['action'] = 'next';
switch($_POST['action'])
{
case '': // Start, ask Filename
@ -375,7 +374,6 @@
$log .= "\t\t<td>$val</td>\n";
}
$empty = !count($values);
// convert the category name to an id
if ($values['cat_id'])
{
@ -416,7 +414,7 @@
}
if(!$_POST['debug'] && !$empty) // dont import empty contacts
{
$GLOBALS['egw']->contacts->save($values);
$rvalue=$GLOBALS['egw']->contacts->save($values);
//echo "<p>adding: ".print_r($values,true)."</p>\n";
}
}

View File

@ -133,7 +133,6 @@ class bocontacts extends socontacts
$this->now_su = time() + $this->tz_offset_s;
$this->prefs =& $GLOBALS['egw_info']['user']['preferences']['addressbook'];
// get the default addressbook from the users prefs
$this->default_addressbook = $GLOBALS['egw_info']['user']['preferences']['addressbook']['add_default'] ?
(int)$GLOBALS['egw_info']['user']['preferences']['addressbook']['add_default'] : $this->user;

View File

@ -43,7 +43,7 @@ class socontacts
* @var string
*/
var $extra_table = 'egw_addressbook_extra';
/**
* @var string
*/
@ -64,6 +64,33 @@ class socontacts
*/
var $extra_value = 'contact_value';
/**
* view for distributionlistsmembership
*
* @var string
*/
var $distributionlist_view ='(SELECT contact_id, egw_addressbook_lists.list_id as list_id, egw_addressbook_lists.list_name as list_name, egw_addressbook_lists.list_owner as list_owner FROM egw_addressbook_lists, egw_addressbook2list where egw_addressbook_lists.list_id=egw_addressbook2list.list_id) d_view ';
/**
* @var string
*/
var $distri_id = 'contact_id';
/**
* @var string
*/
var $distri_owner = 'list_owner';
/**
* @var string
*/
var $distri_key = 'list_id';
/**
* @var string
*/
var $distri_value = 'list_name';
/**
* Contact repository in 'sql' or 'ldap'
*
@ -172,9 +199,14 @@ class socontacts
* @var so_sql
*/
var $soextra;
var $sodistrib_list;
var $backend;
function socontacts($contact_app='addressbook')
{
$this->db = clone($GLOBALS['egw']->db);
$this->db->set_app('infolog');
$this->user = $GLOBALS['egw_info']['user']['account_id'];
$this->memberships = $GLOBALS['egw']->accounts->memberships($this->user,true);
@ -307,6 +339,38 @@ class socontacts
}
return $fields;
}
/**
* Read all distributionlists of the given id's
*
* @param int/array $ids
* @return array id => name => value
*/
function read_distributionlist($ids, $dl_allowed=array())
{
if ($this->contact_repository == 'ldap')
{
return array(); // ldap does not support distributionlists
}
foreach($ids as $key => $id)
{
if (!(int)$id) unset($ids[$key]);
}
if (!$ids) return array(); // nothing to do, eg. all these contacts are in ldap
$fields = array();
$filter[$this->distri_id]=$ids;
if (count($dl_allowed)) $filter[$this->distri_key]=$dl_allowed;
$this->db->select($this->distributionlist_view,'*',$filter,__LINE__,__FILE__);
while ($row = $this->db->row(true))
{
if ((isset($row[$this->distri_id])&&strlen($row[$this->distri_value])>0))
{
$fields[$row[$this->distri_id]][$row[$this->distri_key]] = $row[$this->distri_value].' ('.$GLOBALS['egw']->common->grab_owner_name($row[$this->distri_owner]).')';
}
}
return $fields;
}
/**
* changes the data from the db-format to your work-format
@ -469,6 +533,8 @@ class socontacts
$contact['#'.$field[$this->extra_key]] = $field[$this->extra_value];
}
}
$dl_list=$this->read_distributionlist(array($contact['id']));
if (count($dl_list)) $contact['distrib_lists']=implode("\n",$dl_list[$contact['id']]);
return $this->db2data($contact);
}

View File

@ -52,7 +52,7 @@ class uicontacts extends bocontacts
*
* @var string
*/
var $tabs = 'general|cats|home|details|links|custom|custom_private';
var $tabs = 'general|cats|home|details|links|distribution_list|custom_private';
function uicontacts($contact_app='addressbook')
{
@ -784,7 +784,7 @@ class uicontacts extends bocontacts
}
// 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
{
unset($query['col_filter']['list']); // does not work together
@ -863,12 +863,14 @@ class uicontacts extends bocontacts
// do we need to read the custom fields, depends on the column is enabled and customfields exist
$columselection = $this->prefs['nextmatch-addressbook.'.($do_email ? 'email' : 'index').'.rows'];
$available_distib_lists=$this->get_lists(EGW_ACL_EDIT);
if ($columselection) $columselection = explode(',',$columselection);
if (!$id_only && $rows)
{
$show_custom_fields = (!$columselection || in_array('customfields',$columselection)) && $this->customfields;
$show_calendar = !$columselection || in_array('calendar',$columselection);
if ($show_calendar || $show_custom_fields)
$show_distributionlist = !$columselection || in_array('distrib_lists',$columselection) ||count($available_distib_lists);
if ($show_calendar || $show_custom_fields || $show_distributionlist)
{
foreach($rows as $val)
{
@ -876,6 +878,9 @@ class uicontacts extends bocontacts
}
if ($show_custom_fields) $customfields = $this->read_customfields($ids);
if ($show_calendar) $calendar = $this->read_calendar($ids);
// distributionlist memership for the entrys
//_debug_array($this->get_lists(EGW_ACL_EDIT));
if ($show_distributionlist) $distributionlist = $this->read_distributionlist($ids,array_keys($available_distib_lists));
}
}
}
@ -970,6 +975,11 @@ class uicontacts extends bocontacts
$row['#'.$name] = $customfields[$row['id']][$name];
}
}
if (isset($distributionlist[$row['id']]))
{
$row['distrib_lists'] = implode("\n",array_values($distributionlist[$row['id']]));
//if ($show_distributionlist) $readonlys['distrib_lists'] =true;
}
if (isset($calendar[$row['id']]))
{
foreach($calendar[$row['id']] as $name => $data)
@ -991,6 +1001,11 @@ class uicontacts extends bocontacts
if (($row['addr_format'] = $this->addr_format_by_country($row['adr_one_countryname']))=='postcode_city') unset($row['adr_one_region']);
if (($row['addr_format2'] = $this->addr_format_by_country($row['adr_two_countryname']))=='postcode_city') unset($row['adr_two_region']);
}
if ($show_distributionlist) {
$readonlys['no_distrib_lists'] =true;
} else {
$readonlys['no_distrib_lists'] =false;
}
if (!$this->prefs['no_auto_hide'])
{
// disable photo column, if view contains no photo(s)

File diff suppressed because one or more lines are too long

View File

@ -10,7 +10,7 @@
/* Basic information about this app */
$setup_info['addressbook']['name'] = 'addressbook';
$setup_info['addressbook']['title'] = 'Addressbook';
$setup_info['addressbook']['version'] = '1.4';
$setup_info['addressbook']['version'] = '1.5';
$setup_info['addressbook']['app_order'] = 4;
$setup_info['addressbook']['enable'] = 1;