sitemgr contact-form that stores direct into the addressbook

This commit is contained in:
Ralf Becker 2007-06-05 23:22:24 +00:00
parent 46049623bc
commit df73036d2b
5 changed files with 416 additions and 0 deletions

View File

@ -0,0 +1,115 @@
<?php
/**
* Addressbook - Sitemgr contact form
*
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @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$
*/
require_once(EGW_INCLUDE_ROOT.'/etemplate/inc/class.uietemplate.inc.php');
/**
* SiteMgr contact form for the addressbook
*
*/
class addressbook_contactform
{
/**
* Shows the contactform and stores the submitted data
*
* @param array $content=null submitted eTemplate content
* @param int $addressbook
* @param array $fields
* @param string $msg
* @return string html content
*/
function display($content=null,$addressbook=null,$fields=null,$msg=null)
{
//echo "<p>addressbook_contactform::display($content,$addressbook,".print_r($fields,true).",$msg)</p>\n";
$tpl = new etemplate('addressbook.contactform');
if (is_array($content))
{
if ($content['captcha'] != $content['captcha_result'])
{
$tpl->set_validation_error('captcha',lang('Wrong - try again ...'));
}
elseif ($content['submitit'])
{
if ($content['owner']) // save the contact in the addressbook
{
$content['addressbook'] = $addressbook;
require_once(EGW_INCLUDE_ROOT.'/addressbook/inc/class.bocontacts.inc.php');
$contact = new bocontacts();
if ($contact->save($content))
{
return '<p align="center">'.$content['msg'].'</p>';
}
else
{
return '<p align="center">'.lang('There was an error saving your data :-(').'<br />'.
lang('The anonymous user has probably no add rights for this addressbook.').'</p>';
}
}
else // todo email
{
return 'email not yet implemented!';
}
}
}
else
{
$preserv['owner'] = $addressbook;
$preserv['msg'] = $msg;
if (!$fields) $fields = array('org_name','n_fn','email','tel_work','url','note','captcha');
$custom = 1;
foreach($fields as $name)
{
if ($name{0} == '#') // custom field
{
static $contact;
if (is_null($contact))
{
require_once(EGW_INCLUDE_ROOT.'/addressbook/inc/class.bocontacts.inc.php');
$contact = new bocontacts();
}
$content['show']['custom'.$custom] = true;
$content['customfield'][$custom] = $name;
$content['customlabel'][$custom] = $contact->customfields[substr($name,1)]['label'];
++$custom;
}
elseif($name == 'adr_one_locality')
{
if (!($content['show'][$name] = $GLOBALS['egw_info']['user']['preferences']['addressbook']['addr_format']))
{
$content['show'][$name] = 'postcode_city';
}
}
else
{
$content['show'][$name] = true;
}
}
}
$content['addr_format'] = $GLOBALS['egw_info']['user']['preferences']['addressbook']['addr_format'];
if ($addressbook) $preserv['owner'] = $addressbook;
if ($msg) $preserv['msg'] = $msg;
// a simple calculation captcha
$num1 = rand(1,99);
$num2 = rand(1,99);
if ($num2 > $num1) // keep the result positive
{
$n = $num1; $num1 = $num2; $num2 = $n;
}
$content['captcha_task'] = sprintf('%d - %d =',$num1,$num2);
$preserv['captcha_result'] = $num1-$num2;
return $tpl->exec('addressbook.addressbook_contactform.display',$content,$sel_options,$readonlys,$preserv);
}
}

View File

@ -5,6 +5,7 @@
%1 records imported addressbook de %1 Datensätze importiert
%1 records read (not yet imported, you may go %2back%3 and uncheck test import) addressbook de %1 Datensätze gelesen (noch nicht importiert, sie können %2zurück%3 gehen und Test-Import auschalten)
%1 starts with '%2' addressbook de %1 beginnt mit '%2'
%s please calculate the result addressbook de %s Bitte berechnen Sie das Ergebnis
(e.g. 1969) addressbook de (z.B. 1966)
<b>no conversion type &lt;none&gt; could be located.</b> please choose a conversion type from the list addressbook de <b>Kein Übersetzungstyp <none> konnte gefunden werden.</b> Bitte wählen Sie einen Übersetzungstyp aus der Liste
@-eval() is only availible to admins!!! addressbook de @-eval() ist nur verfügbar für Administratoren!!!
@ -77,10 +78,12 @@ contact common de Kontakt
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 id addressbook de Kontakt ID
contact repository admin de Speicherort Kontakte
contact saved addressbook de Kontakt gespeichert
contact settings admin de Kontakt Einstellungen
contactform addressbook de Kontaktformular
contacts and account contact-data to ldap admin de Kontakte und Kontaktdaten der Benutzer nach LDAP
contacts to ldap admin de Kontakte nach LDAP
contacts to ldap, account contact-data to sql admin de Kontakte nach LDAP, Kontaktdaten der Benutzer nach SQL
@ -197,6 +200,7 @@ link title for contacts show addressbook de Titel der Verkn
links addressbook de Verknüpfungen
list all categories addressbook de Liste alle Kategorien
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 vcard addressbook de VCard laden
@ -204,6 +208,7 @@ locations addressbook de Standorte
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
message after submitting the form addressbook de Nachricht nach dem Abschicken des Formulars
message phone addressbook de Anrufbeantworter
middle name addressbook de Zweiter Vorname
migration finished addressbook de Migration beendet
@ -250,6 +255,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
required fields * addressbook de unbedingt auszufüllende Felder *
role addressbook de Funktion
room addressbook de Raum
search for '%1' addressbook de Suche nach '%1'
@ -280,7 +286,12 @@ suffix addressbook de Zusatz
tel home addressbook de Telefon privat
telephony integration admin de Telefonie Integration
test import (show importable records <u>only</u> in browser) addressbook de Test-Import (zeigt importierbare Datensätze <u>nur</u> im Browser an)
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!
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.
this person's last name was not in the address book. addressbook de Der Nachname dieser Person ist nicht im Adressbuch.
timezone addressbook de Zeitzone
@ -299,6 +310,7 @@ used for links and for the own sorting of the list addressbook de wird f
vcard common de VCard
vcards require a first name entry. addressbook de VCards benötigen einen Vornamen.
vcards require a last name entry. addressbook de VCards benötigen einen Nachnamen.
verification addressbook de Verifikation
view linked infolog entries addressbook de Verknüpfte InfoLog Einträge anzeigen
warning!! ldap is valid only if you are not using contacts for accounts storage! admin de WARNUNG!! LDAP darf nur verwendet werden, wenn sie die Benutzerkonten nicht im Adressbuch speichern!
warning: all contacts found will be deleted! addressbook de WARNUNG: Alle gefundenen Kontakte werden gelöscht!
@ -310,6 +322,7 @@ which fields should be exported. all means every field stored in the addressbook
whole query addressbook de gesamte Abfrage
work phone addressbook de Tel dienstl.
write (update or add) a single entry by passing the fields. addressbook de Schreibt (aktualiseren oder zufügen) eines einzelnen Eintrags durch Übergabe der Felder
wrong - try again ... addressbook de Falsch - nochmal versuchen ...
yes, for the next three days addressbook de Ja, für die nächsten drei Tage
yes, for the next two weeks addressbook de Ja, für die nächsten zwei Wochen
yes, for the next week addressbook de Ja, für die nächste Woche

View File

@ -5,6 +5,7 @@
%1 records imported addressbook en %1 records imported
%1 records read (not yet imported, you may go %2back%3 and uncheck test import) addressbook en %1 records read (not yet imported, you may go %2back%3 and uncheck Test Import)
%1 starts with '%2' addressbook en %1 starts with '%2'
%s please calculate the result addressbook en %s please calculate the result
(e.g. 1969) addressbook en (e.g. 1969)
<b>no conversion type &lt;none&gt; could be located.</b> please choose a conversion type from the list addressbook en <b>No conversion type &lt;none&gt; could be located.</b> Please choose a conversion type from the list
@-eval() is only availible to admins!!! addressbook en @-eval() is only availible to admins!!!
@ -77,10 +78,12 @@ contact common en Contact
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 id addressbook en Contact ID
contact repository admin en Contact repository
contact saved addressbook en Contact saved
contact settings admin en Contact Settings
contactform addressbook en Contactform
contacts and account contact-data to ldap admin en contacts and account contact-data to LDAP
contacts to ldap admin en contacts to LDAP
contacts to ldap, account contact-data to sql admin en contacts to LDAP, account contact-data to SQL
@ -205,6 +208,7 @@ locations addressbook en locations
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
message after submitting the form addressbook en Message after submitting the form
message phone addressbook en Message Phone
middle name addressbook en Middle Name
migration finished addressbook en Migration finished
@ -251,6 +255,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
required fields * addressbook en required fields *
role addressbook en Role
room addressbook en Room
search for '%1' addressbook en Search for '%1'
@ -281,7 +286,12 @@ suffix addressbook en Suffix
tel home addressbook en tel home
telephony integration admin en Telephony integration
test import (show importable records <u>only</u> in browser) addressbook en Test Import (show importable records <u>only</u> in browser)
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!
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.
this person's last name was not in the address book. addressbook en This person's last name was not in the address book.
timezone addressbook en Timezone
@ -300,6 +310,7 @@ used for links and for the own sorting of the list addressbook en used for links
vcard common en VCard
vcards require a first name entry. addressbook en VCards require a first name entry.
vcards require a last name entry. addressbook en Vcards require a last name entry.
verification addressbook en Verification
view linked infolog entries addressbook en View linked InfoLog entries
warning!! ldap is valid only if you are not using contacts for accounts storage! admin en WARNING!! LDAP is valid only if you are NOT using contacts for accounts storage!
warning: all contacts found will be deleted! addressbook en WARNING: All contacts found will be deleted!
@ -311,6 +322,7 @@ which fields should be exported. all means every field stored in the addressbook
whole query addressbook en whole query
work phone addressbook en Work Phone
write (update or add) a single entry by passing the fields. addressbook en Write (update or add) a single entry by passing the fields.
wrong - try again ... addressbook en Wrong - try again ...
yes, for the next three days addressbook en Yes, for the next three days
yes, for the next two weeks addressbook en Yes, for the next two weeks
yes, for the next week addressbook en Yes, for the next week

View File

@ -0,0 +1,99 @@
<?php
/**
* Addressbook - Sitemgr contact form
*
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @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$
*/
require_once(EGW_INCLUDE_ROOT.'/etemplate/inc/class.sitemgr_module.inc.php');
/**
* SiteMgr contact form for the addressbook
*
*/
class module_addressbook_contactform extends sitemgr_module
{
/**
* Constructor
*
* @return module_addressbook_contactform
*/
function module_addressbook_contactform()
{
$this->arguments = array(); // get's set in get_user_interface
$this->title = lang('Contactform');
$this->description = lang('This module displays a contactform, that stores direct into the addressbook.');
$this->etemplate_method = 'addressbook.addressbook_contactform.display';
}
/**
* Reimplemented to add the addressbook translations and fetch the addressbooks only if needed for the user-interface
*
* @return array
*/
function get_user_interface()
{
$GLOBALS['egw']->translation->add_app('addressbook');
require_once(EGW_INCLUDE_ROOT.'/addressbook/inc/class.uicontacts.inc.php');
$uicontacts = new uicontacts();
$default = $fields = array(
'org_name' => lang('Company'),
'org_unit' => lang('Department'),
'n_fn' => lang('Prefix').', '.lang('Firstname').' + '.lang('Lastname'),
'sep1' => '----------------------------',
'email' => lang('email'),
'tel_work' => lang('work phone'),
'tel_cell' => lang('mobile phone'),
'tel_fax' => lang('fax'),
'tel_home' => lang('home phone'),
'url' => lang('url'),
'sep2' => '----------------------------',
'adr_one_street' => lang('street'),
'adr_one_street2' => lang('address line 2'),
'adr_one_locality' => lang('city').' + '.lang('zip code'),
'sep3' => '----------------------------',
);
foreach($uicontacts->customfields as $name => $data)
{
$fields['#'.$name] = $data['label'];
}
$fields += array(
'sep4' => '----------------------------',
'note' => lang('message'),
'sep5' => '----------------------------',
'captcha' => lang('Verification'),
);
$this->arguments = array(
'arg1' => array(
'type' => 'select',
'label' => lang('Addressbook the contact should be saved to').' ('.lang('The anonymous user needs add rights for it!').')',
'options' => array(
'' => lang('None'),
)+$uicontacts->get_addressbooks(EGW_ACL_ADD) // add to not show the accounts!
),
'arg2' => array(
'type' => 'select',
'label' => lang('Contact fields to show'),
'multiple' => true,
'options' => $fields,
'default' => $default,
'params' => array('size' => 15),
),
'arg3' => array(
'type' => 'textfield',
'label' => lang('Message after submitting the form'),
'params' => array('size' => 80),
'default' => lang('Thank you for contacting us.'),
),
);
return parent::get_user_interface();
}
}

View File

@ -0,0 +1,177 @@
<?xml version="1.0"?>
<!-- $Id$ -->
<overlay>
<template id="addressbook.contactform" template="" lang="" group="0" version="1.5.001">
<grid border="0">
<columns>
<column/>
<column/>
<column/>
<column/>
<column/>
<column/>
<column/>
</columns>
<rows>
<row disabled="!@show[org_name]">
<image src="home"/>
<description value="Company"/>
<textbox size="64" maxlength="64" id="org_name" span="4"/>
<description/>
</row>
<row disabled="!@show[org_unit]">
<description/>
<description value="Department"/>
<textbox size="64" maxlength="64" span="4" id="org_unit"/>
<description/>
</row>
<row valign="top" disabled="!@show[n_fn]">
<image src="accounts"/>
<description value="Contact"/>
<textbox size="10" maxlength="64" id="n_prefix" blur="Prefix"/>
<textbox id="n_given" size="20" maxlength="64" align="center"/>
<textbox id="n_family" align="right" size="22" maxlength="64" span="2" needed="1"/>
<description class="redItalic" value="*"/>
</row>
<row disabled="!@show[sep1]">
<hrule span="all"/>
</row>
<row disabled="!@show[email]">
<image src="email.png"/>
<description value="Email"/>
<textbox size="64" maxlength="64" validator="/^[a-z0-9.-_]+@[a-z0-9-]+(\.[a-z0-9-]+)+$/i" span="4" id="email" needed="1"/>
<description class="redItalic" value="*"/>
</row>
<row disabled="!@show[tel_work]">
<image src="phone"/>
<description value="Business phone"/>
<textbox size="64" maxlength="64" span="4" id="tel_work"/>
<description/>
</row>
<row disabled="!@show[tel_cell]">
<description/>
<description value="Mobile phone"/>
<textbox size="64" maxlength="64" span="4" id="tel_cell"/>
<description/>
</row>
<row disabled="!@show[tel_fax]">
<description/>
<description value="Fax"/>
<textbox size="64" maxlength="64" span="4" id="tel_fax"/>
<description/>
</row>
<row disabled="!@show[tel_home]">
<description/>
<description value="Home phone"/>
<textbox size="64" maxlength="64" span="4" id="tel_home"/>
<description/>
</row>
<row disabled="!@show[url]">
<image src="internet"/>
<description value="Internet"/>
<textbox size="64" maxlength="64" span="4" id="url"/>
<description/>
</row>
<row disabled="!@show[sep2]">
<hrule span="all"/>
</row>
<row disabled="!@show[adr_one_street]">
<image src="home"/>
<description value="Street"/>
<textbox size="64" maxlength="64" span="4" id="adr_one_street" needed="1"/>
<description class="redItalic" value="*"/>
</row>
<row disabled="!@show[adr_one_street2]">
<description/>
<description/>
<textbox size="64" maxlength="64" span="4" id="adr_one_street2"/>
<description/>
</row>
<row valign="top" disabled="!@show[adr_one_locality]=postcode_city">
<description/>
<description value="City"/>
<textbox size="10" maxlength="64" id="adr_one_postalcode" needed="1"/>
<textbox size="48" maxlength="64" span="3" id="adr_one_locality" align="right" needed="1"/>
<description class="redItalic" value="*"/>
</row>
<row valign="top" disabled="!@show[adr_one_locality]=city_state_postcode">
<description/>
<description value="Stadt"/>
<textbox size="36" maxlength="64" span="2" id="adr_one_locality" needed="1"/>
<textbox size="8" maxlength="64" id="adr_one_region" align="center"/>
<textbox size="8" maxlength="64" id="adr_one_postalcode" align="right" needed="1"/>
<description class="redItalic" value="*"/>
</row>
<row disabled="!@show[sep3]">
<hrule span="all"/>
</row>
<row disabled="!@show[custom1]">
<image src="gear"/>
<description value="@customlabel[1]"/>
<textbox id="@customfield[1]" span="4" needed="1" size="64"/>
<description class="redItalic" value="*"/>
</row>
<row disabled="!@show[custom2]">
<image src="gear"/>
<description value="@customlabel[2]"/>
<textbox id="@customfield[2]" span="4" needed="1" size="64"/>
<description class="redItalic" value="*"/>
</row>
<row disabled="!@show[custom3]">
<image src="gear"/>
<description value="@customlabel[3]"/>
<textbox id="@customfield[3]" span="4" needed="1" size="64"/>
<description class="redItalic" value="*"/>
</row>
<row disabled="!@show[custom4]">
<image src="gear"/>
<description value="@customlabel[4]"/>
<textbox id="@customfield[4]" span="4" needed="1" size="64"/>
<description />
</row>
<row disabled="!@show[custom5]">
<image src="gear"/>
<description value="@customlabel[5]"/>
<textbox id="@customfield[5]" span="4" needed="1" size="64"/>
<description />
</row>
<row disabled="!@show[custom6]">
<image src="gear"/>
<description value="@customlabel[6]"/>
<textbox id="@customfield[6]" span="4" needed="1" size="64"/>
<description class="redItalic" value="*"/>
</row>
<row disabled="!@show[sep4]">
<hrule span="all"/>
</row>
<row valign="top" disabled="!@show[note]">
<image src="edit.png"/>
<description value="Message"/>
<textbox multiline="true" rows="5" cols="45" span="4" class="width100" needed="1" id="note"/>
</row>
<row disabled="!@show[sep5]">
<hrule span="all"/>
</row>
<row disabled="!@show[captcha]">
<image src="private.png"/>
<description value="Verification"/>
<description value="@captcha_task"/>
<textbox label="%s please calculate the result" needed="1" span="3" id="captcha" size="3"/>
<description class="redItalic" value="*"/>
</row>
<row>
<description/>
<description/>
<button label="Submit" id="submitit"/>
<description span="all" class="redItalic" value="required fields *" align="right"/>
<description/>
<description/>
<description/>
</row>
</rows>
</grid>
<styles>
.width100 textarea { width: 99%; }
</styles>
</template>
</overlay>