From c05741a489fb72228ef28678eea1c4b5dc657e15 Mon Sep 17 00:00:00 2001 From: bn8 Date: Wed, 6 Jan 2010 15:21:37 +0100 Subject: [PATCH] LSattribute / generate_value : the default_value is now used to generate the value of the attribute if the generate function or LSformat is not defined. --- .../includes/class/class.LSattribute.php | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/public_html/includes/class/class.LSattribute.php b/public_html/includes/class/class.LSattribute.php index 0001b9fd..303301ac 100644 --- a/public_html/includes/class/class.LSattribute.php +++ b/public_html/includes/class/class.LSattribute.php @@ -451,15 +451,17 @@ class LSattribute { * @retval boolean true si la valeur de l'attribut peut être générée, false sinon */ function canBeGenerated() { - if (function_exists($this -> config['generate_function'])) { - return true; - } - else if (isset($this -> config['generate_value_format'])) { - return true; - } - else { - return ; - } + return ( + (function_exists($this -> config['generate_function'])) + || + (isset($this -> config['generate_value_format'])) + || + ( + (is_string($this -> config['default_value'])) + && + (strlen($this -> config['default_value'])>0) + ) + ); } /** @@ -476,6 +478,9 @@ class LSattribute { else if (isset($this -> config['generate_value_format'])) { $value = $this -> ldapObject -> getFData($this -> config['generate_value_format']); } + else if (is_string($this -> config['default_value']) && strlen($this -> config['default_value'])>0) { + $value = $this -> config['default_value']; + } if (!empty($value)) { //$this -> setValue($value); // pas nécéssaire ?? $this -> updateData=array($value);