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 @@