2 /*******************************************************************************
3 * Copyright (C) 2007 Easter-eggs
4 * http://ldapsaisie.labs.libre-entreprise.org
6 * Author: See AUTHORS file in top-level directory.
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version 2
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 ******************************************************************************/
23 require_once 'core.php';
25 if(LSsession :: startLSsession()) {
26 if (isset($_REQUEST['LSobject'])) {
27 $LSobject = $_REQUEST['LSobject'];
28 $dn = isset($_REQUEST['dn'])?urldecode($_REQUEST['dn']):null;
30 if (LSsession :: in_menu($LSobject)) {
32 if ( $LSobject == 'SELF' ) {
33 $LSobject = LSsession :: getLSuserObject() -> getType();
34 $dn = LSsession :: getLSuserObjectDn();
37 if ( LSsession :: loadLSobject($LSobject) ) {
38 // Affichage d'un objet
40 if (LSsession :: canAccess($LSobject,$dn)) {
41 if ( LSsession :: canEdit($LSobject,$dn) ) {
42 $LSview_actions[] = array(
43 'label' => _('Modify'),
44 'url' =>'modify.php?LSobject='.$LSobject.'&dn='.urlencode($dn),
49 if (LSsession :: canCreate($LSobject)) {
50 $LSview_actions[] = array(
52 'url' =>'create.php?LSobject='.$LSobject.'&load='.urlencode($dn),
57 if (LSsession :: canRemove($LSobject,$dn)) {
58 $LSview_actions[] = array(
59 'label' => _('Delete'),
60 'url' => 'remove.php?LSobject='.$LSobject.'&dn='.urlencode($dn),
66 $customActionsConfig = LSconfig :: get('LSobjects.'.$LSobject.'.customActions');
67 if (is_array($customActionsConfig)) {
68 foreach($customActionsConfig as $name => $config) {
69 if (LSsession :: canExecuteCustomAction($dn,$LSobject,$name)) {
70 $LSview_actions[] = array (
71 'label' => ((isset($config['label']))?__($config['label']):__($name)),
72 'hideLabel' => ((isset($config['hideLabel']))?$config['hideLabel']:False),
73 'url' => 'custom_action.php?LSobject='.$LSobject.'&dn='.urlencode($dn).'&customAction='.$name,
74 'action' => ((isset($config['icon']))?$config['icon']:'generate'),
75 'class' => 'LScustomActions'.(($config['noConfirmation'])?' LScustomActions_noConfirmation':'')
81 if (LSsession :: getLSuserObjectDn() != $dn) {
82 $object = new $LSobject();
83 $object -> loadData($dn);
84 LStemplate :: assign('pagetitle',$object -> getDisplayName());
87 $object = LSsession :: getLSuserObject();
88 LStemplate :: assign('pagetitle',_('My account'));
91 $view = $object -> getView();
92 $view -> displayView();
95 if (LSsession :: loadLSclass('LSrelation')) {
96 LSrelation :: displayInLSview($object);
99 LStemplate :: assign('LSview_actions',$LSview_actions);
100 LSsession :: setTemplate('view.tpl');
103 LSerror :: addErrorCode('LSsession_11');
106 // Affichage d'une liste d'un type d'objet
107 elseif (LSsession :: loadLSclass('LSsearch')) {
108 $object = new $LSobject();
109 LStemplate :: assign('pagetitle',$object -> getLabel());
111 $LSsearch = new LSsearch($LSobject,'LSview');
112 $LSsearch -> setParam('extraDisplayedColumns',True);
113 $LSsearch -> setParamsFormPostData();
115 $searchForm = array (
116 'action' => $_SERVER['PHP_SELF'],
117 'recursive' => (! LSsession :: isSubDnLSobject($LSobject) && LSsession :: subDnIsEnabled() ),
119 'submit' => _('Search'),
120 'approx' => _('Approximative search'),
121 'recursive' => _('Recursive search')
124 'pattern' => $LSsearch->getParam('pattern'),
125 'approx' => $LSsearch->getParam('approx'),
126 'recursive' => $LSsearch->getParam('recursive')
129 'submit' => 'LSsearch_submit'
131 'hiddenFields' => $LSsearch -> getHiddenFieldForm(),
132 'predefinedFilter' => $LSsearch->getParam('predefinedFilter')
134 LStemplate :: assign('searchForm',$searchForm);
136 $LSview_actions=array();
137 if(LSsession :: canCreate($LSobject)) {
138 $LSview_actions['create'] = array (
140 'url' => 'create.php?LSobject='.$LSobject,
143 $LSview_actions['import'] = array (
145 'url' => 'import.php?LSobject='.$LSobject,
149 $LSview_actions['refresh'] = array (
150 'label' => 'Refresh',
151 'url' => 'view.php?LSobject='.$LSobject.'&refresh',
152 'action' => 'refresh'
154 /*$LSview_actions['purge'] = array (
155 'label' => 'Purge the cache',
156 'url' => 'view.php?LSobject='.$LSobject.'&LSsearchPurgeSession',
161 $customActionsConfig = LSconfig :: get('LSobjects.'.$LSobject.'.LSsearch.customActions');
162 if (is_array($customActionsConfig)) {
163 foreach($customActionsConfig as $name => $config) {
164 if (LSsession :: canExecuteLSsearchCustomAction($LSsearch,$name)) {
165 $LSview_actions[] = array (
166 'label' => ((isset($config['label']))?__($config['label']):__($name)),
167 'hideLabel' => ((isset($config['hideLabel']))?$config['hideLabel']:False),
168 'url' => 'custom_search_action.php?LSobject='.$LSobject.'&customAction='.$name,
169 'action' => ((isset($config['icon']))?$config['icon']:'generate'),
170 'class' => 'LScustomActions'.(($config['noConfirmation'])?' LScustomActions_noConfirmation':'')
176 LStemplate :: assign('LSview_actions',$LSview_actions);
180 $LSsearch -> redirectWhenOnlyOneResult();
182 $page=(isset($_REQUEST['page'])?(int)$_REQUEST['page']:0);
183 $page = $LSsearch -> getPage($page);
184 LStemplate :: assign('page',$page);
185 LStemplate :: assign('LSsearch',$LSsearch);
187 if (LSsession :: loadLSclass('LSform')) {
188 LSform :: loadDependenciesDisplayView();
191 LSsession :: setTemplate('viewSearch.tpl');
194 LSsession :: addErrorCode('LSsession_05','LSsearch');
199 LSerror :: addErrorCode('LSsession_11');
203 LSerror :: addErrorCode('LSsession_12');
207 LSsession :: setTemplate('login.tpl');
209 // Affichage des retours d'erreurs
210 LSsession :: displayTemplate();
212 if (isset($LSsearch)) {
213 $LSsearch->afterUsingResult();