}
/**
+ * Return true only if the form is submited
+ *
+ * @retval boolean True only if the is submited
+ **/
+ private function formIsSubmited() {
+ return isset($_REQUEST['LSsearch_submit']);
+ }
+
+ /**
* Define search parameters by reading Post Data ($_REQUEST)
*
* @retval void
public function setParamsFormPostData() {
$data = $_REQUEST;
- if (isset($data['LSsearch_submit'])) {
+ if (self::formIsSubmited()) {
// Recursive
if (is_null($data['recursive'])) {
$data['recursive']=false;
}
/**
+ * Redirect user to object view if the search have only one result
+ *
+ * @retval boolean True only if user have been redirected
+ **/
+ function redirectWhenOnlyOneResult() {
+ if ($this -> total == 1 && $this -> result && self::formIsSubmited()) {
+ LSsession :: redirect('view.php?LSobject='.$this -> LSobject.'&dn='.$this -> result['list'][0]['dn']);
+ }
+ return;
+ }
+
+ /**
* Run the sort if it's enabled and if the result is not in the cache
*
* @retval boolean True on success or false
$GLOBALS['Smarty']->assign('LSview_actions',$LSview_actions);
$LSsearch -> run();
+
+ $LSsearch -> redirectWhenOnlyOneResult();
+
$page=(int)$_REQUEST['page'];
$page = $LSsearch -> getPage($page);
$GLOBALS['Smarty']->assign('page',$page);