diff --git a/addressbook/inc/class.addressbook_merge.inc.php b/addressbook/inc/class.addressbook_merge.inc.php
index b43d955053..1425ab7116 100644
--- a/addressbook/inc/class.addressbook_merge.inc.php
+++ b/addressbook/inc/class.addressbook_merge.inc.php
@@ -251,6 +251,13 @@ class addressbook_merge // extends bo_merge
{
$content = preg_replace('/\$\$calendar\/[0-9]+\/[a-z_]+\$\$/','',$content);
}
+
+ $this->replacements = $replacements;
+ if (strpos($content,'$$IF'))
+ { //Example use to use: $$IF n_prefix~Herr~Sehr geehrter~Sehr geehrte$$
+ $content = preg_replace_callback('/\$\$IF ([0-9a-z_-]+)~(.*)~(.*)~(.*)\$\$/imU',Array($this,'replace_callback'),$content);
+ }
+
if ($contentrepeat) $contentrep[$id] = $content;
}
if ($contentrepeat)
@@ -267,6 +274,13 @@ class addressbook_merge // extends bo_merge
return $content;
}
+
+ function replace_callback($param)
+ {
+ $replace = preg_match('/'.$param[2].'/',$this->replacements['$$'.$param[1].'$$']) ? $param[3] : $param[4];
+ return $replace;
+ }
+
/**
* Download document merged with contact(s)
*
@@ -324,8 +338,9 @@ class addressbook_merge // extends bo_merge
'date' => lang('Date'),
'user/n_fn' => lang('Name of current user, all other contact fields are valid too'),
'user/account_lid' => lang('Username'),
- 'pagerepeat' => lang('For serial letter use this tag. Put the content, you want to repeat between two Tags.')
- ) as $name => $label)
+ 'pagerepeat' => lang('For serial letter use this tag. Put the content, you want to repeat between two Tags.'),
+ 'IF fieldname' => lang('Example $$IF n_prefix~Mr~Hello Mr.~Hello Ms.$$ - search the field "n_prefix", for "Mr", if found, write Hello Mr., else write Hello Ms.'),
+ ) as $name => $label)
{
echo '
$$'.$name.'$$ | '.$label." |
\n";
}
diff --git a/addressbook/setup/egw_de.lang b/addressbook/setup/egw_de.lang
index 17d730794d..795ef0407d 100644
--- a/addressbook/setup/egw_de.lang
+++ b/addressbook/setup/egw_de.lang
@@ -156,6 +156,7 @@ end addressbook de Ende
enter the path to the exported file here addressbook de Bitte geben Sie den Pfad für die exportierte Datei an
error deleting the contact !!! addressbook de Fehler beim Löschen des Kontakts !!!
error saving the contact !!! addressbook de Fehler beim Speichern des Kontakts !!!
+example $$if n_prefix~mr~hello mr.~hello ms.$$ - search the field "n_prefix", for "mr", if found, write hello mr., else write hello ms. addressbook de Beispiel: "$$IF n_prefix~Herr~Sehr geehrter~Sehr geehrte$$" - suche in dem Feld "n_prefix" nach "Herr", wenn gefunden, schreibe "Sehr geehrter", wenn nicht gefunden schreibe "Sehr geehrte"
existing links addressbook de Bestehende Verknüpfungen
export addressbook de Export
export as csv addressbook de Exportieren als CSV
diff --git a/addressbook/setup/egw_en.lang b/addressbook/setup/egw_en.lang
index 4a91eb014a..65debc9310 100644
--- a/addressbook/setup/egw_en.lang
+++ b/addressbook/setup/egw_en.lang
@@ -156,6 +156,7 @@ end addressbook en End
enter the path to the exported file here addressbook en Enter the path to the exported file here
error deleting the contact !!! addressbook en Error deleting the contact !!!
error saving the contact !!! addressbook en Error saving the contact !!!
+example $$if n_prefix~mr~hello mr.~hello ms.$$ - search the field "n_prefix", for "mr", if found, write hello mr., else write hello ms. addressbook en Example $$IF n_prefix~Mr~Hello Mr.~Hello Ms.$$ - search the field "n_prefix", for "Mr", if found, write Hello Mr., else write Hello Ms.
existing links addressbook en Existing links
export addressbook en export
export as csv addressbook en Export as CSV