addressbook extension:

Admin can now define multiple addressbooks each with an own edit / view template and an own icon.
Atm. all Addressbooks are stored in one backend, but this will change soon^tm
This commit is contained in:
Cornelius Weiß 2006-03-14 14:26:55 +00:00
parent 300b9b1070
commit 4e9c822ed8
10 changed files with 110 additions and 36 deletions

View File

@ -92,7 +92,7 @@
// are we called via xmlrpc?
$this->xmlrpc = is_object($GLOBALS['server']) && $GLOBALS['server']->last_method;
/* _debug_array($_POST); */
//_debug_array($_POST);
$_start = get_var('start',array('POST','GET'));
$_query = get_var('query',array('POST','GET'),'_UNSET_');
$_cquery = get_var('cquery', array('GET','POST'),'_UNSET_');
@ -126,11 +126,14 @@
{
$this->typeid = $_typeid;
}
if(!@in_array($this->typeid,array('n','c')))
{
$this->typeid = 'n';
}
/*
if(!@in_array($this->typeid,array('n','c')))
{
$this->typeid = 'n';
}
*/
if(isset($_POST['fcat_id']) || isset($_POST['fcat_id']))
{
$this->cat_id = $_fcat_id;

View File

@ -185,9 +185,6 @@ class bocontacts extends socontacts
if($contact['id'] == 0)
{
$contact['owner'] = $this->user;
// we create a normal contact
$contact['tid'] = 'n';
$isUpdate = false;
}
@ -207,7 +204,7 @@ class bocontacts extends socontacts
$contact['#ophone'] = $contact['ophone']; unset($contact['ophone']);
$contact['#address2'] = $contact['address2']; unset($contact['address2']);
$contact['#address3'] = $contact['address3']; unset($contact['address3']);
$error_nr = parent::save($contact);
if(!$error_nr)
@ -223,7 +220,7 @@ class bocontacts extends socontacts
$contact['ophone'] = $contact['#ophone']; unset($contact['#ophone']);
$contact['address2'] = $contact['#address2']; unset($contact['#address2']);
$contact['address3'] = $contact['#address3']; unset($contact['#address3']);
$contact['msg'] = $error_nr ?
lang('Something went wrong by saving this contact. Errorcode %1',$error_nr) :
lang('Contact saved');
@ -260,6 +257,7 @@ class bocontacts extends socontacts
return $data;
}
/**
* searches contacts for rows matching searchcriteria
*

View File

@ -69,11 +69,10 @@ class socontacts
$custom =& CreateObject('admin.customfields',$contact_app);
$this->customfields = $custom->get_customfields();
if ($this->customfields && !is_array($this->customfields))
{
$this->customfields = unserialize($this->customfields);
}
if ($this->customfields && !is_array($this->customfields)) $this->customfields = unserialize($this->customfields);
if (!$this->customfields) $this->customfields = array();
$this->content_types = $custom->get_content_types();
if ($this->content_types && !is_array($this->content_types)) $this->content_types = unserialize($this->content_types);
}
/**
@ -135,11 +134,12 @@ class socontacts
$this->somain->data = $this->data2db($contact);
$error_nr = $this->somain->save();
$contact['id'] = $this->somain->data['id'];
if($error_nr) return $error_nr_main;
if($error_nr) return $error_nr;
// save customfields
foreach ((array)$this->customfields + array('ophone' => '', 'address2' => '' , 'address3' => '') as $field => $options)
{
if(!array_key_exists('#'.$field,$contact)) continue;
$value = $contact['#'.$field];
$data = array(
$this->extra_id => $contact['id'],

View File

@ -381,6 +381,22 @@
}
$this->bo->save_preferences($prefs,'',$columns_to_display,'');
}
$typeicon = '<td height="21">&nbsp;</td>';
$cols = $typeicon . $cols;
$custom =& CreateObject('admin.customfields',$contact_app);
$this->html =& CreateObject('phpgwapi.html');
$this->content_types = $custom->get_content_types();
if ($this->content_types && !is_array($this->content_types)) $this->content_types = unserialize($this->content_types);
foreach($this->content_types as $type => $data)
{
$this->contact_types[$type] = $data['name'];
$icon = !empty($data['options']['icon']) ? $this->html->image('addressbook',$data['options']['icon'],$data['name'], ' width="16px" height="16px"') : $data['name'];
$add_buttons .= "<td ><a href=\"\" onClick= \"window.open('". $GLOBALS['egw']->link('/index.php', array('menuaction'=>'addressbook.uicontacts.edit','typeid'=>$type)). "','_blank','dependent=yes,width=850,height=440,location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes'); return false;\" >".$icon." </a></td>";
}
$GLOBALS['egw']->template->set_var('add_buttons',$add_buttons);
$GLOBALS['egw']->template->set_var('addressbuch_type',lang('Addressbook').'-'.lang('type'));
if(!$this->start)
{
@ -415,7 +431,7 @@
Set qfilter to display entries where tid=n (normal contact entry),
else they may be accounts, etc.
*/
$qfilter = 'tid=' . (string)$this->typeid;
$qfilter = 'tid='.($this->typeid ? (string)$this->typeid : '!');
switch($this->filter)
{
case 'blank':
@ -490,20 +506,19 @@
$GLOBALS['egw']->template->set_var('searchreturn',$noprefs . ' ' . $searchreturn);
$GLOBALS['egw']->template->set_var('lang_showing',$lang_showing);
$GLOBALS['egw']->template->set_var('search_filter',$search_filter);
/*
$GLOBALS['egw']->template->set_var('lang_show',lang('Show') . ':');
$GLOBALS['egw']->template->set_var('contact_type_list',$this->formatted_list('typeid',$this->contact_types,$this->typeid,False,True));
$GLOBALS['egw']->template->set_var('contact_type_list',$this->formatted_list('typeid',array('' => 'all') + $this->contact_types,$this->typeid,False,True));
$GLOBALS['egw']->template->set_var('self_url',$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uiaddressbook.index'));
*/
$GLOBALS['egw']->template->set_var('lang_show','');
$GLOBALS['egw']->template->set_var('contact_type_list','');
$GLOBALS['egw']->template->set_var('self_url','');
// $GLOBALS['egw']->template->set_var('lang_show','');
// $GLOBALS['egw']->template->set_var('contact_type_list','');
// $GLOBALS['egw']->template->set_var('self_url','');
$GLOBALS['egw']->template->set_var('cats',lang('Category'));
$GLOBALS['egw']->template->set_var('cats_url',$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uiaddressbook.index'));
/* $GLOBALS['egw']->template->set_var('cats_link',$this->cat_option($this->cat_id)); */
$GLOBALS['egw']->template->set_var('lang_cats',lang('Select'));
// $GLOBALS['egw']->template->set_var('lang_addressbook',lang('Address book'));
//$GLOBALS['egw']->template->set_var('lang_addressbook',lang('Address book'));
$GLOBALS['egw']->template->set_var('th_bg',$GLOBALS['egw_info']['theme']['th_bg']);
$GLOBALS['egw']->template->set_var('th_font',$GLOBALS['egw_info']['theme']['font']);
$GLOBALS['egw']->template->set_var('th_text',$GLOBALS['egw_info']['theme']['th_text']);
@ -521,7 +536,7 @@
$GLOBALS['egw']->template->set_var('lang_export',lang('Export Contacts'));
$GLOBALS['egw']->template->set_var('export_url',$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uiXport.export'));
$GLOBALS['egw']->template->set_var('lang_delete',lang('Delete'));
$GLOBALS['egw']->template->set_var('column_count',count($columns_to_display));
$GLOBALS['egw']->template->set_var('column_count',count($columns_to_display) + 1);
$GLOBALS['egw']->template->set_var('lang_sure',lang('Are you sure you want to delete these entries ?'));
$GLOBALS['egw']->template->set_var('start',$this->start);
@ -532,6 +547,7 @@
$GLOBALS['egw']->template->set_var('cat_id',$this->cat_id);
$GLOBALS['egw']->template->set_var('qfield',$qfield);
$GLOBALS['egw']->template->set_var('cols',$cols);
$GLOBALS['egw']->template->pparse('out','addressbook_header');
@ -546,6 +562,17 @@
$myid = $entries[$i]['id'];
$myowner = $entries[$i]['owner'];
if(!empty($this->content_types[$entries[$i]['tid']]['options']['icon']))
{
$icon = $this->html->image('addressbook',$this->content_types[$entries[$i]['tid']]['options']['icon'],$this->content_types[$entries[$i]['tid']]['name'], 'width="16px" height="16px"');
}
else
{
$icon = $this->content_types[$entries[$i]['tid']]['name'];
}
$GLOBALS['egw']->template->set_var('col_data',$icon);
$GLOBALS['egw']->template->parse('columns','column',True);
/* each entry column */
foreach($columns_to_display as $column => $nul)
{
@ -574,6 +601,7 @@
{
$ref = ''; $data = $coldata;
}
$GLOBALS['egw']->template->set_var('col_data',$ref.$data);
$GLOBALS['egw']->template->parse('columns','column',True);
}

View File

@ -70,7 +70,7 @@ class uicontacts extends bocontacts
}
if (is_array($content))
{
list($button) = each($content['button']);
list($button) = @each($content['button']);
switch($button)
{
case 'save':
@ -105,6 +105,7 @@ class uicontacts extends bocontacts
}
break;
}
// type change
}
else
{
@ -118,6 +119,8 @@ class uicontacts extends bocontacts
}
else // look if we have presets for a new contact
{
$new_type = array_keys($this->content_types);
$content['tid'] = $_GET['typeid'] ? $_GET['typeid'] : $new_type[0];
foreach($this->get_contact_conlumns() as $field => $data)
{
if ($_GET['presets'][$field]) $content[$field] = $_GET['presets'][$field];
@ -146,7 +149,6 @@ class uicontacts extends bocontacts
$preserv = array(
'id' => $content['id'],
'lid' => $content['lid'],
'tid' => $content['tid'],
'owner' => $content['owner'],
'fn' => $content['fn'],
'geo' => $content['geo'],
@ -156,13 +158,17 @@ class uicontacts extends bocontacts
for($i = -23; $i<=23; $i++) $tz[$i] = ($i > 0 ? '+' : '').$i;
$sel_options['tz'] = $tz;
$content['tz'] = $content['tz'] ? $content['tz'] : 0;
foreach($this->content_types as $type => $data) $sel_options['tid'][$type] = $data['name'];
foreach($GLOBALS['egw']->acl->get_all_location_rights($GLOBALS['egw']->acl->account_id,'addressbook',true) as $id => $right)
{
if($id < 0) $sel_options['published_groups'][$id] = $GLOBALS['egw']->accounts->id2name($id);
}
$content['typegfx'] = $GLOBALS['egw']->html->image('addressbook',$this->content_types[$content['tid']]['options']['icon'],'',' width="16px" height="16px"');
$content['link_to'] = array(
'to_app' => 'addressbook',
'to_id' => $content['link_to']['to_id'],
);
$this->tmpl->read('addressbook.edit');
$this->tmpl->read($this->content_types[$content['tid']]['options']['template']);
return $this->tmpl->exec('addressbook.uicontacts.edit',$content,$sel_options,$readonlys,$preserv, 2);
}
@ -197,7 +203,7 @@ class uicontacts extends bocontacts
$content = $this->read($contact_id);
}
foreach($content as $key => $val)
foreach((array)$content as $key => $val)
{
$readonlys[$key] = true;
if (in_array($key,array('tel_home','tel_work','tel_cell')))
@ -220,7 +226,16 @@ class uicontacts extends bocontacts
$sel_options['tz'] = $tz;
$content['tz'] = $content['tz'] ? $content['tz'] : 0;
$this->tmpl->read('addressbook.edit');
for($i = -23; $i<=23; $i++) $tz[$i] = ($i > 0 ? '+' : '').$i;
$sel_options['tz'] = $tz;
$content['tz'] = $content['tz'] ? $content['tz'] : 0;
foreach($this->content_types as $type => $data) $sel_options['tid'][$type] = $data['name'];
foreach(explode(',',$content['published_groups']) as $id)
{
$sel_options['published_groups'][$id] = $GLOBALS['egw']->accounts->id2name($id);
}
$content['typegfx'] = $GLOBALS['egw']->html->image('addressbook',$this->content_types[$content['tid']]['options']['icon'],'',' width="16px" height="16px"');
$this->tmpl->read($this->content_types[$content['tid']]['options']['template']);
foreach(array('email','email_home','url') as $name)
{
if ($content[$name] )
@ -354,7 +369,8 @@ class uicontacts extends bocontacts
for($i = -23; $i<=23; $i++) $tz[$i] = ($i > 0 ? '+' : '').$i;
$sel_options['tz'] = $tz + array('' => lang('doesn\'t matter'));
$sel_options['tid'][] = lang('all');
//foreach($this->content_types as $type => $data) $sel_options['tid'][$type] = $data['name'];
$this->tmpl->read('addressbook.search');
return $this->tmpl->exec('addressbook.uicontacts.search',$content,$sel_options,$readonlys,$preserv);
}

File diff suppressed because one or more lines are too long

View File

@ -51,6 +51,7 @@ contact settings admin de Kontakt Einstellungen
copied by %1, from record #%2. addressbook de Kopiert von %1, vom Datensatz Nr. %2.
country common de Land
create new links addressbook de Neue Verknüpfung erstellen
credit addressbook de Darlehen
csv-fieldname addressbook de CSV-Feldname
csv-filename addressbook de CSV-Dateiname
custom addressbook de Benutzerdefiniert
@ -108,6 +109,7 @@ import from outlook addressbook de Aus Outlook importieren
import multiple vcard addressbook de Import mehrere VCards
import next set addressbook de Nächsten Satz importieren
import_instructions addressbook de In Netscape, öffnen Sie das Adressbuch und wählen Sie <b>Exportieren</b> aus dem Datei Menü aus. Die Dateien werden im LDIF Formaz exportiert.<p> In Outlook wählen Sie den Ordner Kontakte aus, wählen Sie <b>Importieren und Exportieren...</p> aus dem <b>Datei</b> Menü aus und Exportieren Sie die Kontakte als eine CSV Datei.<p> In Palm Desktop 4.0 oder größer, öffnen Sie Ihr Adressbuch und wählen Sie <b>Export</b> aus dem Datei-Menü aus. Die Datei wird im VCard-Format exportiert.
income addressbook de Einkommen
international addressbook de International
isdn phone addressbook de ISDN-Tel.
label addressbook de Adressetikett

View File

@ -51,6 +51,7 @@ contact settings admin en Contact Settings
copied by %1, from record #%2. addressbook en Copied by %1, from record #%2.
country common en Country
create new links addressbook en Create new links
credit addressbook en Credit
csv-fieldname addressbook en CSV-Fieldname
csv-filename addressbook en CSV-Filename
custom addressbook en Custom
@ -108,6 +109,7 @@ import from outlook addressbook en Import from Outlook
import multiple vcard addressbook en Import Multiple VCard
import next set addressbook en Import next set
import_instructions addressbook en In Netscape, open the Addressbook and select <b>Export</b> from the <b>File</b> menu. The file exported will be in LDIF format.<p>Or, in Outlook, select your Contacts folder, select <b>Import and Export...</b> from the <b>File</b> menu and export your contacts into a comma separated text (CSV) file. <p>Or, in Palm Desktop 4.0 or greater, visit your addressbook and select <b>Export</b> from the <b>File</b> menu. The file exported will be in VCard format.
income addressbook en Income
international addressbook en International
isdn phone addressbook en ISDN Phone
label addressbook en Label

View File

@ -36,3 +36,6 @@
.emailGroup table{
height: 87px;
}
.space{
width: 80px;
}

View File

@ -37,7 +37,23 @@ function check_all(which)
}
</style>
<div align="center">
{lang_showing}
<!-- Type-selection -->
<table width="95%" border="0">
<tr>
<td width="33%">&nbsp;</td>
<td width="33%">{lang_showing}</td>
<td width="33%">
<table width="100%">
<tr>
<form action="{self_url}" method="post"><td>{addressbuch_type}:</td><td> {contact_type_list}</td></form>
<td>{lang_add}: </td>{add_buttons}
</tr>
</table>
</td>
</tr>
</table>
<br>{searchreturn}
{search_filter}