mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-12-19 06:53:53 +01:00
Replace select.php by a LSurl route
This commit is contained in:
parent
d6848a3d71
commit
03485bd486
5 changed files with 153 additions and 146 deletions
|
@ -258,7 +258,7 @@ class LSrelation {
|
||||||
if ($relation -> canEdit()) {
|
if ($relation -> canEdit()) {
|
||||||
$return['actions'][] = array(
|
$return['actions'][] = array(
|
||||||
'label' => _('Modify'),
|
'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'
|
'action' => 'modify'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,7 +148,18 @@ var LSformElement_select_object_field = new Class({
|
||||||
varLSsmoothbox.asNew();
|
varLSsmoothbox.asNew();
|
||||||
varLSsmoothbox.addEvent('valid',this.onLSsmoothboxValid.bind(this));
|
varLSsmoothbox.addEvent('valid',this.onLSsmoothboxValid.bind(this));
|
||||||
varLSsmoothbox.displayValidBtn();
|
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});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -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');
|
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<LSobject>[^/]+)/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
|
* Handle LSobject import request
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,137 +0,0 @@
|
||||||
<?php
|
|
||||||
/*******************************************************************************
|
|
||||||
* Copyright (C) 2007 Easter-eggs
|
|
||||||
* http://ldapsaisie.labs.libre-entreprise.org
|
|
||||||
*
|
|
||||||
* Author: See AUTHORS file in top-level directory.
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License version 2
|
|
||||||
* as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
|
|
||||||
******************************************************************************/
|
|
||||||
|
|
||||||
require_once 'core.php';
|
|
||||||
|
|
||||||
if(LSsession :: startLSsession()) {
|
|
||||||
if (isset($_REQUEST['LSobject'])) {
|
|
||||||
$LSobject = $_REQUEST['LSobject'];
|
|
||||||
|
|
||||||
if ( LSsession ::loadLSobject($LSobject) ) {
|
|
||||||
if (LSsession :: loadLSclass('LSsearch')) {
|
|
||||||
$object = new $LSobject();
|
|
||||||
LStemplate :: assign('pagetitle',$object -> 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();
|
|
||||||
}
|
|
|
@ -52,21 +52,21 @@
|
||||||
{else}
|
{else}
|
||||||
{assign var=start value=0}
|
{assign var=start value=0}
|
||||||
{/if}
|
{/if}
|
||||||
<a href='select.php?LSobject={$LSsearch->LSobject|escape:"url"}&page=0&multiple={$searchForm.multiple}' class='LSobject-list-page'><</a>
|
<a href='object/{$LSsearch->LSobject|escape:"url"}/select?page=0&multiple={$searchForm.multiple}' class='LSobject-list-page'><</a>
|
||||||
{foreach from=0|range:10 item=i}
|
{foreach from=0|range:10 item=i}
|
||||||
{if $page.nb==$start+$i}
|
{if $page.nb==$start+$i}
|
||||||
<strong class='LSobject-list-page'>{$page.nb+1}</strong>
|
<strong class='LSobject-list-page'>{$page.nb+1}</strong>
|
||||||
{else}
|
{else}
|
||||||
<a href='select.php?LSobject={$LSsearch->LSobject|escape:"url"}&page={$i+$start}&multiple={$searchForm.multiple}' class='LSobject-list-page'>{$i+$start+1}</a>
|
<a href='object/{$LSsearch->LSobject|escape:"url"}/select?page={$i+$start}&multiple={$searchForm.multiple}' class='LSobject-list-page'>{$i+$start+1}</a>
|
||||||
{/if}
|
{/if}
|
||||||
{/foreach}
|
{/foreach}
|
||||||
<a href='select.php?LSobject={$LSsearch->LSobject|escape:"url"}&page={$page.nbPages-1}&multiple={$searchForm.multiple}' class='LSobject-list-page'>></a>
|
<a href='object/{$LSsearch->LSobject|escape:"url"}/select?page={$page.nbPages-1}&multiple={$searchForm.multiple}' class='LSobject-list-page'>></a>
|
||||||
{else}
|
{else}
|
||||||
{section name=listpage loop=$page.nbPages step=1}
|
{section name=listpage loop=$page.nbPages step=1}
|
||||||
{if $page.nb == $smarty.section.listpage.index}
|
{if $page.nb == $smarty.section.listpage.index}
|
||||||
<strong class='LSobject-list-page'>{$page.nb+1}</strong>
|
<strong class='LSobject-list-page'>{$page.nb+1}</strong>
|
||||||
{else}
|
{else}
|
||||||
<a href='select.php?LSobject={$LSsearch->LSobject|escape:"url"}&page={$smarty.section.listpage.index}&multiple={$searchForm.multiple}' class='LSobject-list-page'>{$smarty.section.listpage.index+1}</a>
|
<a href='object/{$LSsearch->LSobject|escape:"url"}/select?page={$smarty.section.listpage.index}&multiple={$searchForm.multiple}' class='LSobject-list-page'>{$smarty.section.listpage.index+1}</a>
|
||||||
{/if}
|
{/if}
|
||||||
{/section}
|
{/section}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
Loading…
Reference in a new issue