diff --git a/docs/index.rst b/docs/index.rst index 2272f05..813b598 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -26,3 +26,4 @@ LDAP Tool Box White Pages documentation vcardexport.rst updateinfos.rst tooltips.rst + patterns.rst diff --git a/docs/patterns.rst b/docs/patterns.rst new file mode 100644 index 0000000..e9358e6 --- /dev/null +++ b/docs/patterns.rst @@ -0,0 +1,20 @@ +Patterns +======== + +You can define a pattern to control edition of any attribute. + +By default no patterns are defined. You can create one by adding a property in attributes map and a message in the custom lang file by setting the ``pattern_item`` message. + +For example to add a pattern on phone item: + +* Edit or create ``/etc/service-desk/config.local.inc.php``: + +.. code-block:: php + + $attributes_map['phone']['pattern'] = "\+33 [0-9] [0-9]{2} [0-9]{2} [0-9]{2} [0-9]{2}"; + +* Edit or create ``/etc/service-desk/fr.inc.php``: + +.. code-block:: php + + $messages['pattern_phone'] = "+33 1 23 45 67 89"; diff --git a/templates/updateinfos.tpl b/templates/updateinfos.tpl index e815a72..c4180bc 100644 --- a/templates/updateinfos.tpl +++ b/templates/updateinfos.tpl @@ -38,6 +38,7 @@ {$type=$attributes_map.{$item}.type} {$faclass=$attributes_map.{$item}.faclass} {$multivalued=$attributes_map.{$item}.multivalued} + {$pattern=$attributes_map.{$item}.pattern} {$required=0} {if ($attributes_map.{$item}.mandatory|is_array)} {if in_array('all',$attributes_map.{$item}.mandatory) or in_array('update',$attributes_map.{$item}.mandatory)} @@ -60,10 +61,10 @@ {if $item|in_array:$update_items} {if !({$entry.$attribute.0})} - {include 'value_editor.tpl' item=$item itemindex=0 value="" type=$type list=$item_list.$item multivalued=$multivalued required=$required truncate_value_after=10000} + {include 'value_editor.tpl' item=$item itemindex=0 value="" type=$type list=$item_list.$item multivalued=$multivalued pattern=$pattern required=$required truncate_value_after=10000} {else} {foreach from=$entry.{$attribute} item=$value name=updatevalue} - {include 'value_editor.tpl' item=$item itemindex=$smarty.foreach.updatevalue.index multivalued=$multivalued required=$required value=$value type=$type list=$item_list.$item truncate_value_after=10000} + {include 'value_editor.tpl' item=$item itemindex=$smarty.foreach.updatevalue.index multivalued=$multivalued pattern=$pattern required=$required value=$value type=$type list=$item_list.$item truncate_value_after=10000} {/foreach} {/if} {else} diff --git a/templates/value_editor.tpl b/templates/value_editor.tpl index 784a9cf..58e07ad 100644 --- a/templates/value_editor.tpl +++ b/templates/value_editor.tpl @@ -1,11 +1,11 @@
{if $type eq 'text'} - + {else if $type eq 'mailto'} - + {else if $type eq 'tel'} - + {else if $type eq 'boolean'}
@@ -30,7 +30,7 @@
{else} - + {/if}