2008-02-08 18:39:24 +01:00
|
|
|
<?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.
|
|
|
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
2009-03-25 13:26:32 +01:00
|
|
|
require_once 'core.php';
|
2008-02-08 18:39:24 +01:00
|
|
|
|
2009-01-24 18:45:14 +01:00
|
|
|
if(LSsession :: startLSsession()) {
|
2008-02-26 18:40:05 +01:00
|
|
|
if (isset($_REQUEST['LSobject'])) {
|
|
|
|
$LSobject = $_REQUEST['LSobject'];
|
2012-05-03 12:34:22 +02:00
|
|
|
$dn = isset($_REQUEST['dn'])?urldecode($_REQUEST['dn']):null;
|
2008-02-12 18:59:44 +01:00
|
|
|
|
2009-01-24 18:45:14 +01:00
|
|
|
if (LSsession :: in_menu($LSobject)) {
|
2008-06-18 14:27:35 +02:00
|
|
|
|
2008-06-21 18:16:15 +02:00
|
|
|
if ( $LSobject == 'SELF' ) {
|
2009-01-24 18:45:14 +01:00
|
|
|
$LSobject = LSsession :: getLSuserObject() -> getType();
|
|
|
|
$dn = LSsession :: getLSuserObjectDn();
|
2008-06-21 18:16:15 +02:00
|
|
|
}
|
|
|
|
|
2009-01-24 18:45:14 +01:00
|
|
|
if ( LSsession :: loadLSobject($LSobject) ) {
|
2008-06-21 18:16:15 +02:00
|
|
|
// Affichage d'un objet
|
|
|
|
if ( $dn!='' ) {
|
2009-01-24 18:45:14 +01:00
|
|
|
if (LSsession :: canAccess($LSobject,$dn)) {
|
|
|
|
if ( LSsession :: canEdit($LSobject,$dn) ) {
|
2008-06-21 18:16:15 +02:00
|
|
|
$LSview_actions[] = array(
|
2009-02-12 13:38:56 +01:00
|
|
|
'label' => _('Modify'),
|
2012-05-03 12:45:46 +02:00
|
|
|
'url' =>'modify.php?LSobject='.$LSobject.'&dn='.urlencode($dn),
|
2008-06-21 18:16:15 +02:00
|
|
|
'action' => 'modify'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2009-01-24 18:45:14 +01:00
|
|
|
if (LSsession :: canCreate($LSobject)) {
|
2008-06-21 18:16:15 +02:00
|
|
|
$LSview_actions[] = array(
|
2009-02-12 13:38:56 +01:00
|
|
|
'label' => _('Copy'),
|
2012-05-03 14:43:46 +02:00
|
|
|
'url' =>'create.php?LSobject='.$LSobject.'&load='.urlencode($dn),
|
2008-06-21 18:16:15 +02:00
|
|
|
'action' => 'copy'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2009-01-24 18:45:14 +01:00
|
|
|
if (LSsession :: canRemove($LSobject,$dn)) {
|
2008-06-21 18:16:15 +02:00
|
|
|
$LSview_actions[] = array(
|
2009-02-12 13:38:56 +01:00
|
|
|
'label' => _('Delete'),
|
2012-05-03 14:43:46 +02:00
|
|
|
'url' => 'remove.php?LSobject='.$LSobject.'&dn='.urlencode($dn),
|
2008-06-21 18:16:15 +02:00
|
|
|
'action' => 'delete'
|
|
|
|
);
|
|
|
|
}
|
2011-03-25 18:05:26 +01:00
|
|
|
|
|
|
|
// Custum Actions
|
|
|
|
$customActionsConfig = LSconfig :: get('LSobjects.'.$LSobject.'.customActions');
|
|
|
|
if (is_array($customActionsConfig)) {
|
|
|
|
foreach($customActionsConfig as $name => $config) {
|
|
|
|
if (LSsession :: canExecuteCustomAction($dn,$LSobject,$name)) {
|
|
|
|
$LSview_actions[] = array (
|
|
|
|
'label' => ((isset($config['label']))?__($config['label']):__($name)),
|
2012-10-04 14:49:30 +02:00
|
|
|
'hideLabel' => ((isset($config['hideLabel']))?$config['hideLabel']:False),
|
2012-05-03 14:52:32 +02:00
|
|
|
'url' => 'custom_action.php?LSobject='.$LSobject.'&dn='.urlencode($dn).'&customAction='.$name,
|
2011-05-20 15:56:19 +02:00
|
|
|
'action' => ((isset($config['icon']))?$config['icon']:'generate'),
|
2011-07-06 15:53:51 +02:00
|
|
|
'class' => 'LScustomActions'.(($config['noConfirmation'])?' LScustomActions_noConfirmation':'')
|
2011-03-25 18:05:26 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-06-21 18:16:15 +02:00
|
|
|
|
2009-01-24 18:45:14 +01:00
|
|
|
if (LSsession :: getLSuserObjectDn() != $dn) {
|
2008-06-21 18:16:15 +02:00
|
|
|
$object = new $LSobject();
|
|
|
|
$object -> loadData($dn);
|
2013-06-17 23:39:22 +02:00
|
|
|
LStemplate :: assign('pagetitle',$object -> getDisplayName());
|
2008-06-21 18:16:15 +02:00
|
|
|
}
|
|
|
|
else {
|
2009-01-24 18:45:14 +01:00
|
|
|
$object = LSsession :: getLSuserObject();
|
2013-06-17 23:39:22 +02:00
|
|
|
LStemplate :: assign('pagetitle',_('My account'));
|
2008-06-21 18:16:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$view = $object -> getView();
|
|
|
|
$view -> displayView();
|
|
|
|
|
2009-01-08 00:06:05 +01:00
|
|
|
// LSrelations
|
2009-02-20 15:05:22 +01:00
|
|
|
if (LSsession :: loadLSclass('LSrelation')) {
|
|
|
|
LSrelation :: displayInLSview($object);
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
2008-06-21 18:16:15 +02:00
|
|
|
|
2013-06-17 23:39:22 +02:00
|
|
|
LStemplate :: assign('LSview_actions',$LSview_actions);
|
2009-01-24 18:45:14 +01:00
|
|
|
LSsession :: setTemplate('view.tpl');
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
|
|
|
else {
|
2009-01-24 18:45:14 +01:00
|
|
|
LSerror :: addErrorCode('LSsession_11');
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
|
|
|
}
|
2008-06-21 18:16:15 +02:00
|
|
|
// Affichage d'une liste d'un type d'objet
|
2009-10-30 01:03:17 +01:00
|
|
|
elseif (LSsession :: loadLSclass('LSsearch')) {
|
2008-06-21 18:16:15 +02:00
|
|
|
$object = new $LSobject();
|
2013-06-17 23:39:22 +02:00
|
|
|
LStemplate :: assign('pagetitle',$object -> getLabel());
|
2008-06-21 18:16:15 +02:00
|
|
|
|
2009-10-30 01:03:17 +01:00
|
|
|
$LSsearch = new LSsearch($LSobject,'LSview');
|
2014-06-17 16:08:41 +02:00
|
|
|
$LSsearch -> setParam('extraDisplayedColumns',True);
|
2009-10-30 01:03:17 +01:00
|
|
|
$LSsearch -> setParamsFormPostData();
|
2008-06-21 18:16:15 +02:00
|
|
|
|
2009-10-30 01:03:17 +01:00
|
|
|
$searchForm = array (
|
|
|
|
'action' => $_SERVER['PHP_SELF'],
|
2009-10-31 03:21:12 +01:00
|
|
|
'recursive' => (! LSsession :: isSubDnLSobject($LSobject) && LSsession :: subDnIsEnabled() ),
|
2009-10-30 01:03:17 +01:00
|
|
|
'labels' => array (
|
|
|
|
'submit' => _('Search'),
|
|
|
|
'approx' => _('Approximative search'),
|
|
|
|
'recursive' => _('Recursive search')
|
|
|
|
),
|
|
|
|
'values' => array (
|
|
|
|
'pattern' => $LSsearch->getParam('pattern'),
|
|
|
|
'approx' => $LSsearch->getParam('approx'),
|
|
|
|
'recursive' => $LSsearch->getParam('recursive')
|
|
|
|
),
|
|
|
|
'names' => array (
|
|
|
|
'submit' => 'LSsearch_submit'
|
|
|
|
),
|
2010-02-03 02:10:04 +01:00
|
|
|
'hiddenFields' => $LSsearch -> getHiddenFieldForm(),
|
|
|
|
'predefinedFilter' => $LSsearch->getParam('predefinedFilter')
|
2008-06-18 14:27:35 +02:00
|
|
|
);
|
2013-06-17 23:39:22 +02:00
|
|
|
LStemplate :: assign('searchForm',$searchForm);
|
2009-10-30 01:03:17 +01:00
|
|
|
|
|
|
|
$LSview_actions=array();
|
|
|
|
if(LSsession :: canCreate($LSobject)) {
|
|
|
|
$LSview_actions['create'] = array (
|
|
|
|
'label' => 'New',
|
|
|
|
'url' => 'create.php?LSobject='.$LSobject,
|
|
|
|
'action' => 'create'
|
2008-06-21 18:16:15 +02:00
|
|
|
);
|
|
|
|
}
|
2009-10-30 01:03:17 +01:00
|
|
|
$LSview_actions['refresh'] = array (
|
|
|
|
'label' => 'Refresh',
|
|
|
|
'url' => 'view.php?LSobject='.$LSobject.'&refresh',
|
|
|
|
'action' => 'refresh'
|
|
|
|
);
|
|
|
|
/*$LSview_actions['purge'] = array (
|
|
|
|
'label' => 'Purge the cache',
|
|
|
|
'url' => 'view.php?LSobject='.$LSobject.'&LSsearchPurgeSession',
|
|
|
|
'action' => 'delete'
|
|
|
|
);*/
|
2014-10-08 17:24:30 +02:00
|
|
|
|
|
|
|
// Custum Actions
|
|
|
|
$customActionsConfig = LSconfig :: get('LSobjects.'.$LSobject.'.LSsearch.customActions');
|
|
|
|
if (is_array($customActionsConfig)) {
|
|
|
|
foreach($customActionsConfig as $name => $config) {
|
|
|
|
if (LSsession :: canExecuteLSsearchCustomAction($LSsearch,$name)) {
|
|
|
|
$LSview_actions[] = array (
|
|
|
|
'label' => ((isset($config['label']))?__($config['label']):__($name)),
|
|
|
|
'hideLabel' => ((isset($config['hideLabel']))?$config['hideLabel']:False),
|
|
|
|
'url' => 'custom_search_action.php?LSobject='.$LSobject.'&customAction='.$name,
|
|
|
|
'action' => ((isset($config['icon']))?$config['icon']:'generate'),
|
|
|
|
'class' => 'LScustomActions'.(($config['noConfirmation'])?' LScustomActions_noConfirmation':'')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-17 23:39:22 +02:00
|
|
|
LStemplate :: assign('LSview_actions',$LSview_actions);
|
2009-10-30 01:03:17 +01:00
|
|
|
|
|
|
|
$LSsearch -> run();
|
2010-02-14 18:45:39 +01:00
|
|
|
|
|
|
|
$LSsearch -> redirectWhenOnlyOneResult();
|
|
|
|
|
2010-11-16 19:22:56 +01:00
|
|
|
$page=(isset($_REQUEST['page'])?(int)$_REQUEST['page']:0);
|
2009-10-30 01:03:17 +01:00
|
|
|
$page = $LSsearch -> getPage($page);
|
2013-06-17 23:39:22 +02:00
|
|
|
LStemplate :: assign('page',$page);
|
|
|
|
LStemplate :: assign('LSsearch',$LSsearch);
|
2008-06-21 18:16:15 +02:00
|
|
|
|
2009-02-20 15:05:22 +01:00
|
|
|
if (LSsession :: loadLSclass('LSform')) {
|
|
|
|
LSform :: loadDependenciesDisplayView();
|
|
|
|
}
|
2008-06-21 18:16:15 +02:00
|
|
|
|
2009-10-30 01:03:17 +01:00
|
|
|
LSsession :: setTemplate('viewSearch.tpl');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
LSsession :: addErrorCode('LSsession_05','LSsearch');
|
2008-06-21 18:16:15 +02:00
|
|
|
}
|
|
|
|
}
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
|
|
|
else {
|
2009-01-24 18:45:14 +01:00
|
|
|
LSerror :: addErrorCode('LSsession_11');
|
2008-02-08 18:39:24 +01:00
|
|
|
}
|
2008-02-12 18:59:44 +01:00
|
|
|
}
|
|
|
|
else {
|
2009-01-24 18:45:14 +01:00
|
|
|
LSerror :: addErrorCode('LSsession_12');
|
2008-02-08 18:39:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2009-01-24 18:45:14 +01:00
|
|
|
LSsession :: setTemplate('login.tpl');
|
2008-02-08 18:39:24 +01:00
|
|
|
}
|
|
|
|
// Affichage des retours d'erreurs
|
2009-01-24 18:45:14 +01:00
|
|
|
LSsession :: displayTemplate();
|
2009-10-30 01:03:17 +01:00
|
|
|
|
|
|
|
if (isset($LSsearch)) {
|
|
|
|
$LSsearch->afterUsingResult();
|
|
|
|
}
|
|
|
|
|
2008-02-08 18:39:24 +01:00
|
|
|
?>
|