diff --git a/trunk/includes/class/class.LSsearch.php b/trunk/includes/class/class.LSsearch.php index 57f83868..adf7da27 100644 --- a/trunk/includes/class/class.LSsearch.php +++ b/trunk/includes/class/class.LSsearch.php @@ -57,6 +57,7 @@ class LSsearch { 'displayFormat' => NULL, 'nbObjectsByPage' => NB_LSOBJECT_LIST, 'nbPageLinkByPage' => 10, + 'customInfos' => array(), 'withoutCache' => false ); @@ -441,6 +442,24 @@ class LSsearch { if (is_string($params['displayFormat'])) { $this -> params['displayFormat'] = $params['displayFormat']; } + + // Custom Infos + if (is_array($params['customInfos'])) { + foreach($params['customInfos'] as $name => $data) { + if(is_array($data['function']) && is_string($data['function'][0])) { + LSsession::loadLSclass($data['function'][0]); + } + if (is_callable($data['function'])) { + $this -> params['customInfos'][$name] = array ( + 'function' => &$data['function'], + 'args' => $data['args'] + ); + } + else { + LSerror :: addErrorCode('LSsearch_14',$name); + } + } + } $this -> saveParamsInSession(); return $OK; @@ -1126,5 +1145,8 @@ _("LSsearch : Error during the search.") LSerror :: defineError('LSsearch_13', _("LSsearch : Error sorting the search.") ); +LSerror :: defineError('LSsearch_14', +_("LSsearch : The function of the custum information %{name} is not callable.") +); ?> diff --git a/trunk/includes/class/class.LSsearchEntry.php b/trunk/includes/class/class.LSsearchEntry.php index 65e0edb3..13101e24 100644 --- a/trunk/includes/class/class.LSsearchEntry.php +++ b/trunk/includes/class/class.LSsearchEntry.php @@ -113,6 +113,9 @@ class LSsearchEntry { $this -> cache['displayName'] = $this -> getFData($this -> params['displayFormat']); return $this -> cache['displayName']; } + elseif ($key=='LSobject'||$key=='type_name'||$key=='type') { + return $this -> LSobject; + } elseif ($key=='dn') { return $this -> dn; } @@ -174,7 +177,20 @@ class LSsearchEntry { elseif (in_array($key,array_keys($this -> attrs))) { return $this -> attrs[$key]; } + elseif (array_key_exists($key,$this->params['customInfos'])) { + if(isset($this -> cache['customInfos'][$key])) { + return $this -> cache['customInfos'][$key]; + } + if(is_array($this->params['customInfos'][$key]['function']) && is_string($this->params['customInfos'][$key]['function'][0])) { + LSsession::loadLSclass($this->params['customInfos'][$key]['function'][0]); + } + if(is_callable($this->params['customInfos'][$key]['function'])) { + $this -> cache['customInfos'][$key]=call_user_func($this->params['customInfos'][$key]['function'],$this,$this->params['customInfos'][$key]['args']); + return $this -> cache['customInfos'][$key]; + } + } else { + LSlog('LSsearchEntry : '.$this -> dn.' => Unknown property '.$key.' !'); return __("Unknown property !"); } }