ability to insert contacts into documents, one can specify a document dir and a default document in the addressbook prefs. Addressbook then offers actions to insert (at the moment only single) contacts into that document. The default document is also shown as in extra icon for each contact in the list. Documents have to be text document including rtf, which allows to be saved as open office or word documents.

This commit is contained in:
Ralf Becker 2007-06-17 13:55:43 +00:00
parent 3de717157c
commit e34e046fd7
7 changed files with 164 additions and 11 deletions

View File

@ -4,7 +4,7 @@
*
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package tracker
* @package addressbook
* @copyright (c) 2007 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
@ -218,8 +218,14 @@ class addressbook_tracking extends bo_tracking
{
foreach($this->contacts->customfields as $name => $custom)
{
if (!$data['#'.$name]) continue;
if (!$header_done)
{
$details['custom'] = array(
'value' => lang('Custom fields').':',
'type' => 'reply',
);
$header_done = true;
}
$details['#'.$name] = array(
'label' => $custom['label'],
'value' => $data['#'.$name],

View File

@ -224,7 +224,33 @@ class contacts_admin_prefs
'xmlrpc' => True,
'admin' => false,
);
if ($GLOBALS['egw_info']['user']['apps']['filemanager'])
{
$link = $GLOBALS['egw']->link('/index.php','menuaction=addressbook.addressbook_merge.show_replacements');
$GLOBALS['settings']['default_document'] = array(
'type' => 'input',
'size' => 60,
'label' => 'Default document to insert contacts',
'name' => 'default_document',
'help' => lang('If you specify a document (full vfs path) here, addressbook displays an extra document icon for each address. That icon allows to download the specified document with the contact data inserted.').' '.
lang('The document can contain placeholder like $$n_fn$$, to be replaced with the contact data (%1full list of placeholder names%2).','<a href="'.$link.'" target="_blank">','</a>').' '.
lang('At the moment the following document-types are supported:').'*.rtf, *.txt',
'xmlrpc' => True,
'admin' => False,
);
$GLOBALS['settings']['document_dir'] = array(
'type' => 'input',
'size' => 60,
'label' => 'Directory with documents to insert contacts',
'name' => 'document_dir',
'help' => lang('If you specify a directory (full vfs path) here, addressbook displays an action for each document. That action allows to download the specified document with the contact data inserted.').' '.
lang('The document can contain placeholder like $$n_fn$$, to be replaced with the contact data (%1full list of placeholder names%2).','<a href="'.$link.'" target="_blank">','</a>').' '.
lang('At the moment the following document-types are supported:').'*.rtf, *.txt',
'xmlrpc' => True,
'admin' => False,
);
}
return true; // otherwise prefs say it cant find the file ;-)
}

View File

@ -107,6 +107,12 @@ class uicontacts extends bocontacts
$content['action'] = 'delete';
$content['nm']['rows']['checked'] = array($id);
}
if (isset($content['nm']['rows']['document'])) // handle insert in default document button like an action
{
list($id) = @each($content['nm']['rows']['document']);
$content['action'] = 'document';
$content['nm']['rows']['checked'] = array($id);
}
if ($content['action'] !== '')
{
if (!count($content['nm']['rows']['checked']) && !$content['use_all'] && $content['action'] != 'delete_list')
@ -264,7 +270,10 @@ class uicontacts extends bocontacts
$sel_options['action']['remove_from_list'] = lang('Remove selected contacts from distribution list');
$sel_options['action']['delete_list'] = lang('Delete selected distribution list!');
}
if ($this->prefs['document_dir'])
{
$sel_options['action'] += $this->get_document_actions();
}
if (!array_key_exists('importexport',$GLOBALS['egw_info']['user']['apps'])) unset($sel_options['action']['export']);
// dont show tid-selection if we have only one content_type
@ -469,6 +478,11 @@ class uicontacts extends bocontacts
$to_list = (int)substr($action,8);
$action = 'to_list';
}
if (substr($action,0,9) == 'document-')
{
$document = substr($action,10);
$action = 'document';
}
// Security: stop non-admins to export more then the configured number of contacts
if (in_array($action,array('csv','vcard')) && (int)$this->config['contact_export_limit'] &&
!isset($GLOBALS['egw_info']['user']['apps']['admin']) && count($checked) > $this->config['contact_export_limit'])
@ -542,6 +556,10 @@ class uicontacts extends bocontacts
$GLOBALS['egw']->session->appsession($session_name,'addressbook',$query);
}
return false;
case 'document':
$msg = $this->download_document($checked,$document);
return false;
}
foreach($checked as $id)
{
@ -933,6 +951,8 @@ class uicontacts extends bocontacts
}
}
}
$readonlys["document[$row[id]]"] = !$this->prefs['default_document'];
// hide region for address format 'postcode_city'
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']);
@ -1831,6 +1851,71 @@ $readonlys['button[vcard]'] = true;
}
$GLOBALS['egw']->common->egw_footer();
}
/**
* Download a document with inserted contact(s)
*
* @param array $ids contact-ids
* @param string $document vfs-path of document
* @return string error-message or error, otherwise the function does NOT return!
*/
function download_document($ids,$document='')
{
if (!$document) $document = $this->prefs['default_document'];
require_once(EGW_API_INC.'/class.vfs.inc.php');
$vfs =& new vfs();
if (!$document || $document != $this->prefs['default_document'] &&
substr($document,0,1+strlen($this->prefs['document_dir'])) != $this->prefs['document_dir'].'/' ||
!$vfs->acl_check(array(
'string' => $document,
'relatives' => RELATIVE_ROOT,
'operation' => EGW_ACL_READ,
'must_exist' => true,
)))
{
return lang("Document '%1' does not exist or is not readable for you!");
}
require_once(EGW_INCLUDE_ROOT.'/addressbook/inc/class.addressbook_merge.inc.php');
$document_merge =& new addressbook_merge();
return $document_merge->download($document,$ids);
}
/**
* Returning document actions / files from the document_dir
*
* @return array
*/
function get_document_actions()
{
if (!$this->prefs['document_dir']) return array();
if (!is_array($actions = $GLOBALS['egw']->session->appsession('document_actions','addressbook')))
{
require_once(EGW_API_INC.'/class.vfs.inc.php');
$vfs =& new vfs;
$actions = array();
if (($files = $vfs->ls(array(
'string' => $this->prefs['document_dir'],
'relatives' => RELATIVE_ROOT,
))))
{
foreach($files as $file)
{
// return only the mime-types we support
if ($file['mime_type'] != 'application/rtf' && substr($file['mime_type'],0,5) != 'text/') continue;
// As browsers not always return the right mime_type, you could use a negative list instead
//if ($file['mime_type'] == 'Directory' || substr($file['mime_type'],0,6) == 'image/') continue;
$actions['document-'.$file['directory'].'/'.$file['name']] = lang('Insert in document').': '.$file['name'];
}
}
$GLOBALS['egw']->session->appsession('document_actions','addressbook',$actions);
}
return $actions;
}
}
if (!function_exists('array_intersect_key')) // php5.1 function

File diff suppressed because one or more lines are too long

View File

@ -46,6 +46,7 @@ are you shure you want to delete this contact? addressbook de Diesen Kontakt l
are you sure you want to delete this field? addressbook de Sind Sie sicher, dass Sie dieses Feld löschen wollen?
assistent addressbook de Assistent
assistent phone addressbook de Telefon Assistent
at the moment the following document-types are supported: addressbook de Im Moment werden die folgenden Dokumenttypen unterstützt:
birthday common de Geburtstag
birthdays common de Geburtstage
blank addressbook de Leer
@ -59,6 +60,7 @@ business phone addressbook de Tel. gesch
business state addressbook de Bundesland geschäftl.
business street addressbook de Straße geschäftl.
business zip code addressbook de PLZ geschäftl.
calendar fields: addressbook de Kalender Felder:
calendar uri addressbook de Kalender URI
can be changed via setup >> configuration admin de Kann über Setup >> Konfiguration geändert werden
car phone addressbook de Autotelefon
@ -69,6 +71,8 @@ charset for the csv export addressbook de Zeichensatz f
charset of file addressbook de Zeichensatz der Datei
check all addressbook de Alle auswählen
choose an icon for this contact type admin de Wählen Sie ein Icon für diesen Kontakt Typ
choose owner of imported data addressbook de Wählen Sie den Besitzer der importierten Daten
choose seperator and charset addressbook de Wählen Sie ein Trennzeichen und den Zeichensatz
chosse an etemplate for this contact type admin de Wählen Sie ein eTemplate für diesen Kontakt Typ
city common de Stadt
company common de Firma
@ -79,8 +83,10 @@ contact application admin de Kontakt Anwendung
contact copied addressbook de Kontakt kopiert
contact deleted addressbook de Kontakt gelöscht
contact fields to show addressbook de Kontaktfelder die angezeigt werden sollen
contact fields: addressbook de Kontaktfelder:
contact id addressbook de Kontakt ID
contact modified by %1 at %2 addressbook de Kontakt geändert von %1 am %2
contact not found! addressbook de Kontakt nicht gefunden!
contact repository admin de Speicherort Kontakte
contact saved addressbook de Kontakt gespeichert
contact settings admin de Kontakt Einstellungen
@ -117,6 +123,7 @@ distribution list deleted addressbook de Verteiler gel
distribution lists addressbook de Verteilerlisten
do you want a private addressbook, which can not be viewed by users, you grant access to your personal addressbook? addressbook de Wollen Sie ein privates Adressbuch, dass nicht von Benutzern einsehbar ist, denen Sie Zugriff auf Ihr persönliches Adressbuch gegeben haben?
do your really want to delete this contact? addressbook de Wollen sie diesen Kontakt wirklich löschen?
document '%1' does not exist or is not readable for you! addressbook de Dokument '%1' existiert nicht oder ist für Sie nicht lesbar!
doesn't matter addressbook de egal
domestic addressbook de Wohnung
don't hide empty columns addressbook de Leere Spalten nicht ausblenden
@ -160,6 +167,7 @@ for read only ldap admin de f
freebusy uri addressbook de Freebusy URI
full name addressbook de vollständiger Name
general addressbook de Allgemein
general fields: addressbook de Allgemeine Felder:
geo addressbook de GEO
global categories addressbook de Globale Kategorien
grant addressbook access common de Berechtigungen
@ -178,6 +186,8 @@ home zip code addressbook de PLZ privat
how many contacts should non-admins be able to export (empty = no limit) admin de Wieviele Kontakte sollen nicht-Adminstratoren exportieren können (leer = keine Begrenzung)
icon addressbook de Icon
if accounts are already in ldap admin de wenn die Benutzer bereits im LDAP sind
if you specify a directory (full vfs path) here, addressbook displays an action for each document. that action allows to download the specified document with the contact data inserted. addressbook de Wenn Sie hier ein Verzeichnis (kompletter VFS Pfad) angeben, zeigt das Adressbuch einen Befehl für jedes Dokument darin. Diese Befehler erlauben das angegebene Dokumnet mit Kontaktdaten eingefügt herunterzuladen.
if you specify a document (full vfs path) here, addressbook displays an extra document icon for each address. that icon allows to download the specified document with the contact data inserted. addressbook de Wenn Sie hier ein Dokument (kompletter VFS Pfad) angeben, zeigt das Adressbuch ein extranes Dokument Icon. Diese Icon erlaubt das Dokumnet mit Kontaktdaten eingefügt herunterzuladen.
import addressbook de Import
import contacts addressbook de Kontakte importieren
import csv-file into addressbook addressbook de Import CSV-Datei ins Adressbuch
@ -188,8 +198,10 @@ 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.
imports contacts into your addressbook from a csv file. csv means 'comma seperated values'. however in the options tab you can also choose other seperators. addressbook de Importiert Kontakte aus einer CSV Datei in Ihr Adressbuch. CSV bedeutet Komma getrennte Werte. Sie können in dem Reiter Einstellungen auch ein anderes Trennzeichen wählen.
in %1 days (%2) is %3's birthday. addressbook de In %1 Tagen (%2) ist der Geburtstag von %3.
income addressbook de Einkommen
insert in document addressbook de Einfügen in Dokument
insufficent rights to delete this list! addressbook de Keine Rechte diese Liste zu löschen!
international addressbook de International
label addressbook de Adressetikett
@ -207,8 +219,10 @@ list all customfields addressbook de Liste alle benutzerdefinierten Felder
list already exists! addressbook de Die Liste existiert bereits!
list created addressbook de Verteiler erzeugt
list creation failed, no rights! addressbook de Verteiler erzeugen fehlgeschlagen, keine Rechte!
load sample file addressbook de Beispieldatei laden
load vcard addressbook de VCard laden
locations addressbook de Standorte
manage mapping addressbook de Zuordnungen verwalten
mark records as private addressbook de Eintrag als Privat kennzeichnen
merge into first or account, deletes all other! addressbook de Vereinige im ersten oder Benutzerkonto, löscht alle anderen!
merged addressbook de vereinigt
@ -225,6 +239,7 @@ move to addressbook: addressbook de Verschiebe ins Adressbuch:
moved addressbook de verschoben
multiple vcard addressbook de Mehrere VCards
name for the distribution list addressbook de Name für die Verteilerliste
name of current user, all other contact fields are valid too addressbook de Name des aktuellen Benutzers, auch alle anderen Kontaktfelder sind erlaubt
name, address addressbook de Name, Adresse
new contact submitted by %1 at %2 addressbook de Neuer Kontakt eingetragen von %1 am %2
no vcard addressbook de Keine VCard
@ -261,6 +276,7 @@ record access addressbook de Zugriffsrechte
record owner addressbook de Datensatzeigentümer
remove selected contacts from distribution list addressbook de Ausgewählte Kontakte vom Verteiler löschen
removed from distribution list addressbook de vom Verteiler gelöscht
replacements for inserting contacts into documents addressbook de Platzhalter für das Einfügen von Kontakten in Dokumente
required fields * addressbook de unbedingt auszufüllende Felder *
role addressbook de Funktion
room addressbook de Raum
@ -297,6 +313,7 @@ thank you for contacting us. addressbook de Danke das Sie uns kontaktierten.
that field name has been used already ! addressbook de Dieser Feldname wird bereits benutzt!
the anonymous user has probably no add rights for this addressbook. addressbook de Der anonyme Benutzer hat vermutlich keine Hinzufügen Rechte für diese Adressbuch.
the anonymous user needs add rights for it! addressbook de Der anonyme Benutzer benötigt Hinzufügen Rechte dafür!
the document can contain placeholder like $$n_fn$$, to be replaced with the contact data (%1full list of placeholder names%2). addressbook de Das Dokument kann Platzhalter wie $$n_fn$$ enthalten, die mit den Kontaktdaten ersetzt werden (%1komplette Liste der Platzhalter%2).
there was an error saving your data :-( addressbook de Beim Speichern ihrer Daten ist ein Fehler aufgetreten :-(
this module displays a contactform, that stores direct into the addressbook. addressbook de Diese Module ist ein Kontaktformular, das direkt in das Adressbuch speichert.
this person's first name was not in the address book. addressbook de Der Vorname dieser Person ist nicht im Adressbuch.

View File

@ -46,6 +46,7 @@ are you shure you want to delete this contact? addressbook en Are you shure you
are you sure you want to delete this field? addressbook en Are you sure you want to delete this field?
assistent addressbook en Assistent
assistent phone addressbook en assistent phone
at the moment the following document-types are supported: addressbook en At the moment the following document-types are supported:
birthday common en Birthday
birthdays common en Birthdays
blank addressbook en Blank
@ -59,6 +60,7 @@ business phone addressbook en Business Phone
business state addressbook en Business State
business street addressbook en Business Street
business zip code addressbook en Business Postal Code
calendar fields: addressbook en Calendar fields:
calendar uri addressbook en Calendar URI
can be changed via setup >> configuration admin en Can be changed via Setup >> Configuration
car phone addressbook en Car Phone
@ -69,6 +71,8 @@ charset for the csv export addressbook en Charset for the CSV export
charset of file addressbook en Charset of file
check all addressbook en Check all
choose an icon for this contact type admin en Choose an icon for this contact type
choose owner of imported data addressbook en Choose owner of imported data
choose seperator and charset addressbook en Choose seperator and charset
chosse an etemplate for this contact type admin en Chosse an eTemplate for this contact type
city common en City
company common en Company
@ -79,8 +83,10 @@ contact application admin en Contact application
contact copied addressbook en Contact copied
contact deleted addressbook en Contact deleted
contact fields to show addressbook en Contact fields to show
contact fields: addressbook en Contact fields:
contact id addressbook en Contact ID
contact modified by %1 at %2 addressbook en Contact modified by %1 at %2
contact not found! addressbook en Contact not found!
contact repository admin en Contact repository
contact saved addressbook en Contact saved
contact settings admin en Contact Settings
@ -117,6 +123,7 @@ distribution list deleted addressbook en Distribution list deleted
distribution lists addressbook en Distribution lists
do you want a private addressbook, which can not be viewed by users, you grant access to your personal addressbook? addressbook en Do you want a private addressbook, which can not be viewed by users, you grant access to your personal addressbook?
do your really want to delete this contact? addressbook en Do your really want to delete this contact?
document '%1' does not exist or is not readable for you! addressbook en Document '%1' does not exist or is not readable for you!
doesn't matter addressbook en doesn't matter
domestic addressbook en Domestic
don't hide empty columns addressbook en Don't hide empty columns
@ -160,6 +167,7 @@ for read only ldap admin en for read only LDAP
freebusy uri addressbook en Freebusy URI
full name addressbook en Full Name
general addressbook en General
general fields: addressbook en General fields:
geo addressbook en GEO
global categories addressbook en Global Categories
grant addressbook access common en Grant Addressbook Access
@ -178,6 +186,8 @@ home zip code addressbook en Home ZIP Code
how many contacts should non-admins be able to export (empty = no limit) admin en How many contacts should non-admins be able to export (empty = no limit)
icon addressbook en Icon
if accounts are already in ldap admin en if accounts are already in LDAP
if you specify a directory (full vfs path) here, addressbook displays an action for each document. that action allows to download the specified document with the contact data inserted. addressbook en If you specify a directory (full vfs path) here, addressbook displays an action for each document. That action allows to download the specified document with the contact data inserted.
if you specify a document (full vfs path) here, addressbook displays an extra document icon for each address. that icon allows to download the specified document with the contact data inserted. addressbook en If you specify a document (full vfs path) here, addressbook displays an extra document icon for each address. That icon allows to download the specified document with the contact data inserted.
import addressbook en Import
import contacts addressbook en Import Contacts
import csv-file into addressbook addressbook en Import CSV-File into Addressbook
@ -188,8 +198,10 @@ 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.
imports contacts into your addressbook from a csv file. csv means 'comma seperated values'. however in the options tab you can also choose other seperators. addressbook en Imports contacts into your Addressbook from a CSV File. CSV means 'Comma Seperated Values'. However in the options Tab you can also choose other seperators.
in %1 days (%2) is %3's birthday. addressbook en In %1 days (%2) is %3's birthday.
income addressbook en Income
insert in document addressbook en Insert in document
insufficent rights to delete this list! addressbook en Insufficent rights to delete this list!
international addressbook en International
label addressbook en Label
@ -207,8 +219,10 @@ list all customfields addressbook en List all customfields
list already exists! addressbook en List already exists!
list created addressbook en List created
list creation failed, no rights! addressbook en List creation failed, no rights!
load sample file addressbook en Load Sample file
load vcard addressbook en Load VCard
locations addressbook en locations
manage mapping addressbook en Manage mapping
mark records as private addressbook en Mark records as private
merge into first or account, deletes all other! addressbook en Merge into first or account, deletes all other!
merged addressbook en merged
@ -225,6 +239,7 @@ move to addressbook: addressbook en Move to addressbook:
moved addressbook en moved
multiple vcard addressbook en Multiple VCard
name for the distribution list addressbook en Name for the distribution list
name of current user, all other contact fields are valid too addressbook en Name of current user, all other contact fields are valid too
name, address addressbook en Name, Address
new contact submitted by %1 at %2 addressbook en New contact submitted by %1 at %2
no vcard addressbook en No VCard
@ -261,6 +276,7 @@ record access addressbook en Record Access
record owner addressbook en Record owner
remove selected contacts from distribution list addressbook en Remove selected contacts from distribution list
removed from distribution list addressbook en removed from distribution list
replacements for inserting contacts into documents addressbook en Replacements for inserting contacts into documents
required fields * addressbook en required fields *
role addressbook en Role
room addressbook en Room
@ -297,6 +313,7 @@ thank you for contacting us. addressbook en Thank you for contacting us.
that field name has been used already ! addressbook en That field name has been used already !
the anonymous user has probably no add rights for this addressbook. addressbook en The anonymous user has probably no add rights for this addressbook.
the anonymous user needs add rights for it! addressbook en The anonymous user needs add rights for it!
the document can contain placeholder like $$n_fn$$, to be replaced with the contact data (%1full list of placeholder names%2). addressbook en The document can contain placeholder like $$n_fn$$, to be replaced with the contact data (%1full list of placeholder names%2).
there was an error saving your data :-( addressbook en There was an error saving your data :-(
this module displays a contactform, that stores direct into the addressbook. addressbook en This module displays a contactform, that stores direct into the addressbook.
this person's first name was not in the address book. addressbook en This person's first name was not in the address book.

View File

@ -10,12 +10,11 @@
<hbox>
<buttononly id="search" label="Advanced search" onclick="window.open(egw::link('/index.php','menuaction=addressbook.uicontacts.search'),'_blank','dependent=yes,width=850,height=440,scrollbars=yes,status=yes'); return false;"/>
<buttononly id="add" label="Add" statustext="Add a new contact" onclick="window.open(egw::link('/index.php','menuaction=addressbook.uicontacts.edit'),'_blank','dependent=yes,width=850,height=440,scrollbars=yes,status=yes'); return false;" class="rightPadAdd"/>
<description id="manual" class="rightPadAdd"/>
</hbox>
<styles>
.rightPadAdd { padding-right: 40px; }
</styles>
<styles>.rightPadAdd { width: 30px; }</styles>
</template>
<template id="addressbook.index.rows" template="" lang="" group="0" version="1.3.002">
<template id="addressbook.index.rows" template="" lang="" group="0" version="1.4.001">
<grid width="100%">
<columns>
<column/>
@ -167,6 +166,7 @@
</menulist>
</vbox>
<hbox options="0" class="noPrint" orient="0">
<button id="document[$row_cont[id]]" image="new" label="Insert in document"/>
<image options="addressbook.uicontacts.view&amp;contact_id=$row_cont[id]" label="View" src="view"/>
<button image="edit" label="Edit" onclick="window.open(egw::link('/index.php','menuaction=addressbook.uicontacts.edit&amp;contact_id=$row_cont[id]'),'_blank','dependent=yes,width=850,height=440,scrollbars=yes,status=yes'); return false;" id="edit[$row_cont[id]]"/>
<button id="delete[$row_cont[id]]" image="delete" label="Delete" statustext="Delete this contact" onclick="return confirm('Delete this contact');"/>