diff --git a/public_html/includes/class/class.LSrelation.php b/public_html/includes/class/class.LSrelation.php index 6c8acf8e..464f0153 100644 --- a/public_html/includes/class/class.LSrelation.php +++ b/public_html/includes/class/class.LSrelation.php @@ -258,7 +258,7 @@ class LSrelation { if ($relation -> canEdit()) { $return['actions'][] = array( 'label' => _('Modify'), - 'url' => 'select.php?LSobject='.$relationConf['LSobject'].'&multiple=1'.($relation -> getRelatedEditableAttribute()?'&editableAttr='.$relation -> getRelatedEditableAttribute():''), + 'url' => 'object/'.$relationConf['LSobject'].'/select?multiple=1'.($relation -> getRelatedEditableAttribute()?'&editableAttr='.$relation -> getRelatedEditableAttribute():''), 'action' => 'modify' ); } diff --git a/public_html/includes/js/LSformElement_select_object_field.js b/public_html/includes/js/LSformElement_select_object_field.js index 3ca2b6fb..261d4017 100644 --- a/public_html/includes/js/LSformElement_select_object_field.js +++ b/public_html/includes/js/LSformElement_select_object_field.js @@ -148,7 +148,18 @@ var LSformElement_select_object_field = new Class({ varLSsmoothbox.asNew(); varLSsmoothbox.addEvent('valid',this.onLSsmoothboxValid.bind(this)); varLSsmoothbox.displayValidBtn(); - varLSsmoothbox.openURL('select.php?LSobject='+this.params['object_type']+((this.params['multiple'])?'&multiple=1':'')+((this.params['filter64'])?'&filter64='+this.params['filter64']:''),{width: 635}); + var url='object/'+this.params['object_type']+'/select'; + var params = []; + if (this.params['multiple']) { + params.push('multiple=1'); + } + if (this.params['filter64']) { + params.push('filter64='+this.params['filter64']); + } + if (params) { + url=url+'?'+params.join('&'); + } + varLSsmoothbox.openURL(url, {width: 635}); } }, diff --git a/public_html/includes/routes.php b/public_html/includes/routes.php index 841e094a..098f4e0c 100644 --- a/public_html/includes/routes.php +++ b/public_html/includes/routes.php @@ -469,6 +469,139 @@ function handle_old_custom_search_action_php($request) { } LSurl :: add_handler('#^custom_search_action.php#', 'handle_old_custom_search_action_php'); +/* + * Handle LSobject select request + * + * @param[in] $request LSurlRequest The request + * + * @retval void +**/ +function handle_LSobject_select($request) { + $object = get_LSobject_from_request($request, true); + if (!$object) + return; + + $LSobject = $object -> getType(); + + if (!LSsession :: loadLSclass('LSsearch')) { + LSsession :: addErrorCode('LSsession_05', 'LSsearch'); + LSsession :: displayTemplate(); + return false; + } + + // Instanciate LSsearch + $LSsearch = new LSsearch($LSobject,'LSselect'); + $LSsearch -> setParamsFormPostData(); + $LSsearch -> setParam('nbObjectsByPage', NB_LSOBJECT_LIST_SELECT); + + // Handle parameters + $selectablly = (isset($_REQUEST['selectablly'])?$_REQUEST['selectablly']:0); + + if (is_string($_REQUEST['editableAttr'])) { + $LSsearch -> setParam( + 'customInfos', + array ( + 'selectablly' => array ( + 'function' => array('LSselect', 'selectablly'), + 'args' => $_REQUEST['editableAttr'] + ) + ) + ); + $selectablly=1; + } + + if (!empty($_REQUEST['filter64'])) { + $filter = base64_decode($_REQUEST['filter64'], 1); + if ($filter) { + $LSsearch -> setParam('filter', $filter); + } + } + $multiple = (isset($_REQUEST['multiple'])?1:0); + $page = (isset($_REQUEST['page'])?(int)$_REQUEST['page']:0); + + // Run search + $LSsearch -> run(); + + // Set template variables + LStemplate :: assign('pagetitle', $object -> getLabel()); + LStemplate :: assign('LSview_actions', + array( + array ( + 'label' => 'Refresh', + 'url' => "object/$LSobject/select?refresh", + 'action' => 'refresh' + ) + ) + ); + LStemplate :: assign('searchForm', + array ( + 'action' => "object/$LSobject/select", + 'recursive' => (! LSsession :: isSubDnLSobject($LSobject) && LSsession :: subDnIsEnabled() ), + 'multiple' => $multiple, + 'selectablly' => $selectablly, + 'labels' => array ( + 'submit' => _('Search'), + 'approx' => _('Approximative search'), + 'recursive' => _('Recursive search'), + 'level' => _('Level') + ), + 'values' => array ( + 'pattern' => $LSsearch->getParam('pattern'), + 'approx' => $LSsearch->getParam('approx'), + 'recursive' => $LSsearch->getParam('recursive'), + 'basedn' => $LSsearch->getParam('basedn') + ), + 'names' => array ( + 'submit' => 'LSsearch_submit' + ), + 'hiddenFields' => array_merge( + $LSsearch -> getHiddenFieldForm(), + array( + 'ajax' => 1, + 'filter64' => $_REQUEST['filter64'], + 'selectablly' => $selectablly, + 'multiple' => $multiple + ) + ) + ) + ); + LStemplate :: assign('page', $LSsearch -> getPage($page)); + LStemplate :: assign('LSsearch', $LSsearch); + LStemplate :: assign('LSobject_list_objectname', $object -> getLabel()); + + // Set & display template + LSsession :: setTemplate(isset($_REQUEST['ajax'])?'select_table.tpl':'select.tpl'); + LSsession :: setAjaxDisplay(); + LSsession :: displayTemplate(); + $LSsearch->afterUsingResult(); +} +LSurl :: add_handler('#^object/(?P[^/]+)/select?$#', 'handle_LSobject_select'); + +/* + * Handle old select.php request for retro-compatibility + * + * @param[in] $request LSurlRequest The request + * + * @retval void + **/ +function handle_old_select_php($request) { + if (!isset($_GET['LSobject'])) + $url = null; + else { + $url = "object/".$_GET['pattern']."/select"; + // Preserve GET parameters + $params = array(); + foreach (array('filter64', 'multiple', 'selectablly', 'editableAttr', 'page', 'ajax', 'refresh') as $param) + if (isset($_GET[$param])) + $params[] = $param.'='.$_GET[$param]; + if ($params) + $url .= '?'.implode('&', $params); + } + LSerror :: addErrorCode('LSsession_26', 'select.php'); + LSurl :: redirect($url); +} +LSurl :: add_handler('#^select\.php#', 'handle_old_select_php'); + /* * Handle LSobject import request * diff --git a/public_html/select.php b/public_html/select.php deleted file mode 100644 index 8fa48577..00000000 --- a/public_html/select.php +++ /dev/null @@ -1,137 +0,0 @@ - getLabel()); - - $LSsearch = new LSsearch($LSobject,'LSselect'); - $LSsearch -> setParamsFormPostData(); - $LSsearch -> setParam('nbObjectsByPage',NB_LSOBJECT_LIST_SELECT); - - $selectablly=((isset($_REQUEST['selectablly']))?$_REQUEST['selectablly']:0); - - if (is_string($_REQUEST['editableAttr'])) { - $LSsearch -> setParam( - 'customInfos', - array ( - 'selectablly' => array ( - 'function' => array('LSselect','selectablly'), - 'args' => $_REQUEST['editableAttr'] - ) - ) - ); - $selectablly=1; - } - - if (!empty($_REQUEST['filter64'])) { - $filter=base64_decode($_REQUEST['filter64'],1); - if ($filter) { - $LSsearch -> setParam('filter',$filter); - } - } - $multiple = ((isset($_REQUEST['multiple']))?1:0); - - $searchForm = array ( - 'action' => $_SERVER['PHP_SELF'], - 'recursive' => (! LSsession :: isSubDnLSobject($LSobject) && LSsession :: subDnIsEnabled() ), - 'multiple' => $multiple, - 'selectablly' => $selectablly, - 'labels' => array ( - 'submit' => _('Search'), - 'approx' => _('Approximative search'), - 'recursive' => _('Recursive search'), - 'level' => _('Level') - ), - 'values' => array ( - 'pattern' => $LSsearch->getParam('pattern'), - 'approx' => $LSsearch->getParam('approx'), - 'recursive' => $LSsearch->getParam('recursive'), - 'basedn' => $LSsearch->getParam('basedn') - ), - 'names' => array ( - 'submit' => 'LSsearch_submit' - ), - 'hiddenFields' => array_merge( - $LSsearch -> getHiddenFieldForm(), - array( - 'ajax' => 1, - 'filter64' => $_REQUEST['filter64'], - 'selectablly' => $selectablly, - 'multiple' => $multiple - ) - ) - ); - LStemplate :: assign('searchForm',$searchForm); - - $LSview_actions=array( - array ( - 'label' => 'Refresh', - 'url' => "object/$LSobject?refresh", - 'action' => 'refresh' - ) - ); - LStemplate :: assign('LSview_actions',$LSview_actions); - - $LSsearch -> run(); - $page=(isset($_REQUEST['page'])?(int)$_REQUEST['page']:0); - $page = $LSsearch -> getPage($page); - LStemplate :: assign('page',$page); - LStemplate :: assign('LSsearch',$LSsearch); - - LStemplate :: assign('LSobject_list_objectname',$object -> getLabel()); - - if (isset($_REQUEST['ajax'])) { - LSsession :: setTemplate('select_table.tpl'); - } - else { - LSsession :: setTemplate('select.tpl'); - } - - LSsession :: setAjaxDisplay(); - } - else { - LSsession :: addErrorCode('LSsession_05','LSsearch'); - } - } - } - else { - LSerror :: addErrorCode('LSsession_12'); - } -} -else { - LSsession :: setTemplate('login.tpl'); -} - -// Affichage des retours d'erreurs -LSsession :: displayTemplate(); - -if (isset($LSsearch)) { - $LSsearch->afterUsingResult(); -} diff --git a/public_html/templates/default/select_table.tpl b/public_html/templates/default/select_table.tpl index 58fb1e05..3dd4b4a2 100644 --- a/public_html/templates/default/select_table.tpl +++ b/public_html/templates/default/select_table.tpl @@ -35,7 +35,7 @@ {foreachelse} {$LSsearch->label_no_result|escape:"htmlall"} - + {/foreach} @@ -52,21 +52,21 @@ {else} {assign var=start value=0} {/if} - < + < {foreach from=0|range:10 item=i} {if $page.nb==$start+$i} - {$page.nb+1} + {$page.nb+1} {else} - {$i+$start+1} + {$i+$start+1} {/if} {/foreach} - > + > {else} {section name=listpage loop=$page.nbPages step=1} {if $page.nb == $smarty.section.listpage.index} - {$page.nb+1} + {$page.nb+1} {else} - {$smarty.section.listpage.index+1} + {$smarty.section.listpage.index+1} {/if} {/section} {/if}