mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-12-23 00:43:48 +01:00
- LSsearch :
- Added formIsSubmited() method and use it in setParamsFormPostData() method - Added redirectWhenOnlyOneResult() method - View : - Used LSsearch::redirectWhenOnlyOneResult() to redirect the user on object view page when the search return only on result
This commit is contained in:
parent
c0c7323040
commit
6a78b6bde4
2 changed files with 25 additions and 1 deletions
|
@ -495,6 +495,15 @@ class LSsearch {
|
|||
return $OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
*
|
||||
|
@ -503,7 +512,7 @@ class LSsearch {
|
|||
public function setParamsFormPostData() {
|
||||
$data = $_REQUEST;
|
||||
|
||||
if (isset($data['LSsearch_submit'])) {
|
||||
if (self::formIsSubmited()) {
|
||||
// Recursive
|
||||
if (is_null($data['recursive'])) {
|
||||
$data['recursive']=false;
|
||||
|
@ -1019,6 +1028,18 @@ class LSsearch {
|
|||
$this -> addResultToCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
|
|
|
@ -137,6 +137,9 @@ if(LSsession :: startLSsession()) {
|
|||
$GLOBALS['Smarty']->assign('LSview_actions',$LSview_actions);
|
||||
|
||||
$LSsearch -> run();
|
||||
|
||||
$LSsearch -> redirectWhenOnlyOneResult();
|
||||
|
||||
$page=(int)$_REQUEST['page'];
|
||||
$page = $LSsearch -> getPage($page);
|
||||
$GLOBALS['Smarty']->assign('page',$page);
|
||||
|
|
Loading…
Reference in a new issue