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.
|
|
|
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
require_once 'includes/functions.php';
|
|
|
|
require_once 'includes/class/class.LSsession.php';
|
|
|
|
|
|
|
|
$GLOBALS['LSsession'] = new LSsession();
|
|
|
|
|
|
|
|
if($LSsession -> startLSsession()) {
|
2008-02-26 18:40:05 +01:00
|
|
|
if (isset($_REQUEST['LSobject'])) {
|
|
|
|
$LSobject = $_REQUEST['LSobject'];
|
2008-02-12 18:59:44 +01:00
|
|
|
|
|
|
|
if ( $LSobject == 'SELF' ) {
|
2008-02-26 18:40:05 +01:00
|
|
|
$_REQUEST['LSobject'] = $GLOBALS['LSsession']-> LSuserObject -> getType();
|
|
|
|
$_REQUEST['dn'] = $GLOBALS['LSsession']-> LSuserObject -> getValue('dn');
|
|
|
|
}
|
|
|
|
if ( $GLOBALS['LSsession'] -> loadLSobject($_REQUEST['LSobject']) ) {
|
|
|
|
if ( isset($_REQUEST['dn']) ) {
|
|
|
|
if ($GLOBALS['LSsession'] -> canAccess($_REQUEST['LSobject'],$_REQUEST['dn'])) {
|
|
|
|
if ( $GLOBALS['LSsession'] -> canEdit($_REQUEST['LSobject'],$_REQUEST['dn']) ) {
|
|
|
|
$LSview_actions[] = array(
|
|
|
|
'label' => _('Modifier'),
|
|
|
|
'url' =>'modify.php?LSobject='.$_REQUEST['LSobject'].'&dn='.$_REQUEST['dn'],
|
|
|
|
'action' => 'modify'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($GLOBALS['LSsession'] -> canCreate($_REQUEST['LSobject'])) {
|
|
|
|
$LSview_actions[] = array(
|
|
|
|
'label' => _('Copier'),
|
|
|
|
'url' =>'create.php?LSobject='.$_REQUEST['LSobject'].'&load='.$_REQUEST['dn'],
|
|
|
|
'action' => 'copy'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($GLOBALS['LSsession'] -> canRemove($_REQUEST['LSobject'],$_REQUEST['dn'])) {
|
|
|
|
$LSview_actions[] = array(
|
|
|
|
'label' => _('Supprimer'),
|
|
|
|
'url' => 'remove.php?LSobject='.$_REQUEST['LSobject'].'&dn='.$_REQUEST['dn'],
|
|
|
|
'action' => 'delete'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($GLOBALS['LSsession']-> LSuserObject -> getValue('dn') != $_REQUEST['dn']) {
|
|
|
|
$object = new $_REQUEST['LSobject']();
|
|
|
|
$object -> loadData($_REQUEST['dn']);
|
|
|
|
$GLOBALS['Smarty'] -> assign('pagetitle',$object -> getDisplayValue());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$object = &$GLOBALS['LSsession']-> LSuserObject;
|
|
|
|
$GLOBALS['Smarty'] -> assign('pagetitle',_('Mon compte'));
|
|
|
|
}
|
|
|
|
|
|
|
|
$view = $object -> getView();
|
|
|
|
$view -> displayView();
|
|
|
|
|
|
|
|
// Relations
|
|
|
|
if (is_array($object -> config['relations'])) {
|
|
|
|
$LSrelations=array();
|
|
|
|
foreach($object -> config['relations'] as $relationName => $relationConf) {
|
|
|
|
if ($GLOBALS['LSsession'] -> relationCanAccess($object -> getValue('dn'),$relationName)) {
|
|
|
|
$return=array('label' => $relationConf['label']);
|
|
|
|
|
|
|
|
$id=rand();
|
|
|
|
$return['id']=$id;
|
|
|
|
$_SESSION['LSrelation'][$id] = array(
|
|
|
|
'relationName' => $relationName,
|
|
|
|
'objectType' => $object -> getType(),
|
|
|
|
'objectDn' => $object -> getDn(),
|
|
|
|
);
|
|
|
|
if ($GLOBALS['LSsession'] -> relationCanEdit($object -> getValue('dn'),$relationName)) {
|
|
|
|
$return['actions'][] = array(
|
|
|
|
'label' => _('Modifier'),
|
|
|
|
'url' => 'select.php?LSobject='.$relationConf['LSobject'],
|
|
|
|
'action' => 'modify'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$GLOBALS['LSsession'] -> addJSscript('LSselect.js');
|
|
|
|
$GLOBALS['LSsession'] -> addJSscript('LSsmoothbox.js');
|
|
|
|
$GLOBALS['LSsession'] -> addCssFile('LSsmoothbox.css');
|
|
|
|
$GLOBALS['LSsession'] -> addJSscript('LSrelation.js');
|
2008-04-25 15:48:12 +02:00
|
|
|
if($GLOBALS['LSsession'] -> loadLSobject($relationConf['LSobject'])) {
|
|
|
|
if (method_exists($relationConf['LSobject'],$relationConf['list_function'])) {
|
|
|
|
$objRel = new $relationConf['LSobject']();
|
|
|
|
$list = $objRel -> $relationConf['list_function']($object);
|
|
|
|
if (is_array($list)) {
|
|
|
|
foreach($list as $o) {
|
|
|
|
$return['objectList'][] = $o -> getDisplayValue();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$return['objectList']=array();
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2008-04-25 15:48:12 +02:00
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(1013,$relationName);
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
2008-04-25 15:48:12 +02:00
|
|
|
$LSrelations[]=$return;
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
|
|
|
else {
|
2008-04-25 15:48:12 +02:00
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(1016,array('relation' => $relationName,'LSobject' => $relationConf['LSobject']));
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$GLOBALS['Smarty'] -> assign('LSrelations',$LSrelations);
|
|
|
|
}
|
|
|
|
|
|
|
|
$GLOBALS['Smarty'] -> assign('LSview_actions',$LSview_actions);
|
|
|
|
$GLOBALS['LSsession'] -> addJSscript('LSsmoothbox.js');
|
|
|
|
$GLOBALS['LSsession'] -> addCssFile('LSsmoothbox.css');
|
|
|
|
$GLOBALS['LSsession'] -> setTemplate('view.tpl');
|
2008-02-08 18:39:24 +01:00
|
|
|
}
|
2008-02-26 18:40:05 +01:00
|
|
|
else {
|
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(1011);
|
2008-02-08 18:39:24 +01:00
|
|
|
}
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
$objectList=array();
|
|
|
|
$object = new $_REQUEST['LSobject']();
|
|
|
|
$GLOBALS['Smarty']->assign('pagetitle',$object -> getLabel());
|
|
|
|
$GLOBALS['Smarty']->assign('LSobject_list_objectname',$object -> getLabel());
|
2008-02-12 18:59:44 +01:00
|
|
|
|
2008-02-26 18:40:05 +01:00
|
|
|
if ($GLOBALS['LSsession'] -> canCreate($_REQUEST['LSobject'])) {
|
2008-02-12 18:59:44 +01:00
|
|
|
$LSview_actions[] = array (
|
2008-02-26 18:40:05 +01:00
|
|
|
'label' => _('Nouveau'),
|
|
|
|
'url' => 'create.php?LSobject='.$_REQUEST['LSobject'],
|
|
|
|
'action' => 'create'
|
2008-02-12 18:59:44 +01:00
|
|
|
);
|
2008-02-26 18:40:05 +01:00
|
|
|
$canCopy=true;
|
2008-02-12 18:59:44 +01:00
|
|
|
}
|
|
|
|
|
2008-02-26 18:40:05 +01:00
|
|
|
if ( $_REQUEST['LSview_pattern']!='' ) {
|
|
|
|
$filter='(|';
|
|
|
|
if ( isset($_REQUEST['LSview_approx']) ) {
|
|
|
|
foreach ($object -> attrs as $attr_name => $attr_val) {
|
|
|
|
$filter.='('.$attr_name.'~='.$_REQUEST['LSview_pattern'].')';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
foreach ($object -> attrs as $attr_name => $attr_val) {
|
|
|
|
$filter.='('.$attr_name.'=*'.$_REQUEST['LSview_pattern'].'*)';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$filter.=')';
|
|
|
|
$GLOBALS['Smarty']->assign('LSobject_list_filter','filter='.urlencode($filter));
|
|
|
|
}
|
|
|
|
else if ($_REQUEST['filter']) {
|
|
|
|
$filter=urldecode($_REQUEST['filter']);
|
|
|
|
$GLOBALS['Smarty']->assign('LSobject_list_filter','filter='.$_REQUEST['filter']);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$filter=NULL;
|
|
|
|
$GLOBALS['Smarty']->assign('LSobject_list_filter','');
|
|
|
|
}
|
2008-04-25 15:48:12 +02:00
|
|
|
|
|
|
|
$topDn = $object -> config['container_dn'].','.$GLOBALS['LSsession'] -> topDn;
|
|
|
|
|
|
|
|
$list=$object -> listObjects($filter,$topDn);
|
2008-02-26 18:40:05 +01:00
|
|
|
$nbObjects=count($list);
|
|
|
|
$GLOBALS['Smarty']->assign('LSobject_list_nbresult',$nbObjects);
|
|
|
|
if ($nbObjects > NB_LSOBJECT_LIST) {
|
|
|
|
if (isset($_REQUEST['page'])) {
|
|
|
|
$list = array_slice($list, ($_REQUEST['page']) * NB_LSOBJECT_LIST, NB_LSOBJECT_LIST);
|
|
|
|
$GLOBALS['Smarty']->assign('LSobject_list_currentpage',$_REQUEST['page']);
|
|
|
|
$GLOBALS['Smarty']->assign('LSobject_list_nbpage',ceil($nbObjects / NB_LSOBJECT_LIST));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$list = array_slice($list, 0, NB_LSOBJECT_LIST);
|
|
|
|
$GLOBALS['Smarty']->assign('LSobject_list_currentpage',0);
|
|
|
|
$GLOBALS['Smarty']->assign('LSobject_list_nbpage',ceil($nbObjects / NB_LSOBJECT_LIST));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$c=0;
|
|
|
|
foreach($list as $thisObject) {
|
|
|
|
$c++;
|
|
|
|
unset($actions);
|
|
|
|
if ($GLOBALS['LSsession'] -> canAccess($_REQUEST['LSobject'],$thisObject->getValue('dn'))) {
|
|
|
|
$actions[] = array(
|
|
|
|
'label' => _('Voir'),
|
|
|
|
'url' =>'view.php?LSobject='.$_REQUEST['LSobject'].'&dn='.$thisObject -> getValue('dn'),
|
|
|
|
'action' => 'view'
|
|
|
|
);
|
|
|
|
|
|
|
|
if ($GLOBALS['LSsession'] -> canEdit($_REQUEST['LSobject'],$thisObject->getValue('dn'))) {
|
|
|
|
$actions[]=array(
|
2008-02-12 18:59:44 +01:00
|
|
|
'label' => _('Modifier'),
|
2008-02-26 18:40:05 +01:00
|
|
|
'url' => 'modify.php?LSobject='.$_REQUEST['LSobject'].'&dn='.$thisObject->getValue('dn'),
|
2008-02-12 18:59:44 +01:00
|
|
|
'action' => 'modify'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2008-02-26 18:40:05 +01:00
|
|
|
if ($canCopy) {
|
|
|
|
$actions[] = array(
|
2008-02-12 18:59:44 +01:00
|
|
|
'label' => _('Copier'),
|
2008-02-26 18:40:05 +01:00
|
|
|
'url' =>'create.php?LSobject='.$_REQUEST['LSobject'].'&load='.$thisObject -> getValue('dn'),
|
2008-02-12 18:59:44 +01:00
|
|
|
'action' => 'copy'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2008-04-25 15:48:12 +02:00
|
|
|
if ($GLOBALS['LSsession'] -> canRemove($thisObject -> getType(),$thisObject -> getValue('dn'))) {
|
2008-02-26 18:40:05 +01:00
|
|
|
$actions[] = array (
|
2008-02-12 18:59:44 +01:00
|
|
|
'label' => _('Supprimer'),
|
2008-02-26 18:40:05 +01:00
|
|
|
'url' => 'remove.php?LSobject='.$_REQUEST['LSobject'].'&dn='.$thisObject -> getValue('dn'),
|
2008-02-12 18:59:44 +01:00
|
|
|
'action' => 'delete'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2008-02-26 18:40:05 +01:00
|
|
|
if ($c%2==0) {
|
|
|
|
$tr='bis';
|
2008-02-12 18:59:44 +01:00
|
|
|
}
|
|
|
|
else {
|
2008-02-26 18:40:05 +01:00
|
|
|
$tr='';
|
2008-02-12 18:59:44 +01:00
|
|
|
}
|
2008-02-26 18:40:05 +01:00
|
|
|
|
|
|
|
$objectList[]=array(
|
|
|
|
'dn' => $thisObject->getValue('dn'),
|
|
|
|
'displayValue' => $thisObject->getDisplayValue(),
|
|
|
|
'actions' => $actions,
|
|
|
|
'tr' => $tr
|
|
|
|
);
|
2008-02-12 18:59:44 +01:00
|
|
|
}
|
2008-02-26 18:40:05 +01:00
|
|
|
else {
|
|
|
|
debug($thisObject->getValue('dn'));
|
2008-02-08 18:39:24 +01:00
|
|
|
}
|
|
|
|
}
|
2008-02-26 18:40:05 +01:00
|
|
|
$GLOBALS['LSsession'] -> addJSscript('LSview.js');
|
|
|
|
|
|
|
|
|
|
|
|
$GLOBALS['Smarty']->assign('LSview_search',array(
|
|
|
|
'action' => $_SERVER['PHP_SELF'],
|
|
|
|
'submit' => _('Rechercher'),
|
|
|
|
'LSobject' => $_REQUEST['LSobject']
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
|
|
$GLOBALS['Smarty']->assign('_Actions',_('Actions'));
|
|
|
|
$GLOBALS['Smarty']->assign('_Modifier',_('Modifier'));
|
|
|
|
$GLOBALS['Smarty']->assign('LSobject_list',$objectList);
|
|
|
|
$GLOBALS['Smarty']->assign('LSobject_list_objecttype',$_REQUEST['LSobject']);
|
|
|
|
$GLOBALS['Smarty'] -> assign('LSview_actions',$LSview_actions);
|
|
|
|
$GLOBALS['LSsession'] -> setTemplate('viewList.tpl');
|
2008-02-12 18:59:44 +01:00
|
|
|
}
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(1004,$_REQUEST['LSobject']);
|
2008-02-08 18:39:24 +01:00
|
|
|
}
|
2008-02-12 18:59:44 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(1012);
|
2008-02-08 18:39:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$GLOBALS['LSsession'] -> setTemplate('login.tpl');
|
|
|
|
}
|
|
|
|
|
|
|
|
// Affichage des retours d'erreurs
|
|
|
|
$GLOBALS['LSsession'] -> displayTemplate();
|
|
|
|
?>
|