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='.$dn,
49 if (LSsession :: canCreate($LSobject)) {
50 $LSview_actions[] = array(
52 'url' =>'create.php?LSobject='.$LSobject.'&load='.$dn,
57 if (LSsession :: canRemove($LSobject,$dn)) {
58 $LSview_actions[] = array(
59 'label' => _('Delete'),
60 'url' => 'remove.php?LSobject='.$LSobject.'&dn='.$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 'url' => 'custom_action.php?LSobject='.$LSobject.'&dn='.$dn.'&customAction='.$name,
73 'action' => ((isset($config['icon']))?$config['icon']:'generate'),
74 'class' => 'LScustomActions'.(($config['noConfirmation'])?' LScustomActions_noConfirmation':'')
80 if (LSsession :: getLSuserObjectDn() != $dn) {
81 $object = new $LSobject();
82 $object -> loadData($dn);
83 $GLOBALS['Smarty'] -> assign('pagetitle',$object -> getDisplayName());
86 $object = LSsession :: getLSuserObject();
87 $GLOBALS['Smarty'] -> assign('pagetitle',_('My account'));
90 $view = $object -> getView();
91 $view -> displayView();
94 if (LSsession :: loadLSclass('LSrelation')) {
95 LSrelation :: displayInLSview($object);
98 $GLOBALS['Smarty'] -> assign('LSview_actions',$LSview_actions);
99 LSsession :: setTemplate('view.tpl');
102 LSerror :: addErrorCode('LSsession_11');
105 // Affichage d'une liste d'un type d'objet
106 elseif (LSsession :: loadLSclass('LSsearch')) {
107 $object = new $LSobject();
108 $GLOBALS['Smarty']->assign('pagetitle',$object -> getLabel());
110 $LSsearch = new LSsearch($LSobject,'LSview');
111 $LSsearch -> setParamsFormPostData();
113 $searchForm = array (
114 'action' => $_SERVER['PHP_SELF'],
115 'recursive' => (! LSsession :: isSubDnLSobject($LSobject) && LSsession :: subDnIsEnabled() ),
117 'submit' => _('Search'),
118 'approx' => _('Approximative search'),
119 'recursive' => _('Recursive search')
122 'pattern' => $LSsearch->getParam('pattern'),
123 'approx' => $LSsearch->getParam('approx'),
124 'recursive' => $LSsearch->getParam('recursive')
127 'submit' => 'LSsearch_submit'
129 'hiddenFields' => $LSsearch -> getHiddenFieldForm(),
130 'predefinedFilter' => $LSsearch->getParam('predefinedFilter')
132 $GLOBALS['Smarty']->assign('searchForm',$searchForm);
134 $LSview_actions=array();
135 if(LSsession :: canCreate($LSobject)) {
136 $LSview_actions['create'] = array (
138 'url' => 'create.php?LSobject='.$LSobject,
142 $LSview_actions['refresh'] = array (
143 'label' => 'Refresh',
144 'url' => 'view.php?LSobject='.$LSobject.'&refresh',
145 'action' => 'refresh'
147 /*$LSview_actions['purge'] = array (
148 'label' => 'Purge the cache',
149 'url' => 'view.php?LSobject='.$LSobject.'&LSsearchPurgeSession',
152 $GLOBALS['Smarty']->assign('LSview_actions',$LSview_actions);
156 $LSsearch -> redirectWhenOnlyOneResult();
158 $page=(isset($_REQUEST['page'])?(int)$_REQUEST['page']:0);
159 $page = $LSsearch -> getPage($page);
160 $GLOBALS['Smarty']->assign('page',$page);
161 $GLOBALS['Smarty']->assign('LSsearch',$LSsearch);
163 if (LSsession :: loadLSclass('LSform')) {
164 LSform :: loadDependenciesDisplayView();
167 LSsession :: setTemplate('viewSearch.tpl');
170 LSsession :: addErrorCode('LSsession_05','LSsearch');
175 LSerror :: addErrorCode('LSsession_11');
179 LSerror :: addErrorCode('LSsession_12');
183 LSsession :: setTemplate('login.tpl');
185 // Affichage des retours d'erreurs
186 LSsession :: displayTemplate();
188 if (isset($LSsearch)) {
189 $LSsearch->afterUsingResult();