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/class/class.LSsession.php';
|
|
|
|
|
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'];
|
2008-06-18 14:27:35 +02:00
|
|
|
$dn = $_REQUEST['dn'];
|
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'),
|
2008-06-21 18:16:15 +02:00
|
|
|
'url' =>'modify.php?LSobject='.$LSobject.'&dn='.$dn,
|
|
|
|
'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'),
|
2008-06-21 18:16:15 +02:00
|
|
|
'url' =>'create.php?LSobject='.$LSobject.'&load='.$dn,
|
|
|
|
'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'),
|
2008-06-21 18:16:15 +02:00
|
|
|
'url' => 'remove.php?LSobject='.$LSobject.'&dn='.$dn,
|
|
|
|
'action' => 'delete'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
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);
|
2009-01-07 20:24:14 +01:00
|
|
|
$GLOBALS['Smarty'] -> assign('pagetitle',$object -> getDisplayName());
|
2008-06-21 18:16:15 +02:00
|
|
|
}
|
|
|
|
else {
|
2009-01-24 18:45:14 +01:00
|
|
|
$object = LSsession :: getLSuserObject();
|
2009-02-12 13:38:56 +01:00
|
|
|
$GLOBALS['Smarty'] -> 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
|
|
|
|
if (is_array($object -> config['LSrelation'])) {
|
2008-06-21 18:16:15 +02:00
|
|
|
$LSrelations=array();
|
2008-10-08 17:34:36 +02:00
|
|
|
$LSrelations_JSparams=array();
|
2009-01-08 00:06:05 +01:00
|
|
|
foreach($object -> config['LSrelation'] as $relationName => $relationConf) {
|
2009-01-24 18:45:14 +01:00
|
|
|
if (LSsession :: relationCanAccess($object -> getValue('dn'),$LSobject,$relationName)) {
|
2008-07-31 11:16:25 +02:00
|
|
|
$return=array(
|
|
|
|
'label' => $relationConf['label'],
|
|
|
|
'LSobject' => $relationConf['LSobject']
|
|
|
|
);
|
2008-06-21 18:16:15 +02:00
|
|
|
|
2008-10-08 17:34:36 +02:00
|
|
|
if (isset($relationConf['emptyText'])) {
|
|
|
|
$return['emptyText'] = $relationConf['emptyText'];
|
|
|
|
}
|
|
|
|
else {
|
2009-02-12 13:38:56 +01:00
|
|
|
$return['emptyText'] = _('No object.');
|
2008-10-08 17:34:36 +02:00
|
|
|
}
|
|
|
|
|
2008-06-21 18:16:15 +02:00
|
|
|
$id=rand();
|
|
|
|
$return['id']=$id;
|
2008-10-08 17:34:36 +02:00
|
|
|
$LSrelations_JSparams[$id]=array(
|
|
|
|
'emptyText' => $return['emptyText']
|
|
|
|
);
|
2008-06-21 18:16:15 +02:00
|
|
|
$_SESSION['LSrelation'][$id] = array(
|
|
|
|
'relationName' => $relationName,
|
|
|
|
'objectType' => $object -> getType(),
|
|
|
|
'objectDn' => $object -> getDn(),
|
2008-02-26 18:40:05 +01:00
|
|
|
);
|
2009-01-24 18:45:14 +01:00
|
|
|
if (LSsession :: relationCanEdit($object -> getValue('dn'),$LSobject,$relationName)) {
|
2008-06-21 18:16:15 +02:00
|
|
|
$return['actions'][] = array(
|
2009-02-12 13:38:56 +01:00
|
|
|
'label' => _('Modify'),
|
2008-09-28 13:05:02 +02:00
|
|
|
'url' => 'select.php?LSobject='.$relationConf['LSobject'].'&multiple=1',
|
2008-06-21 18:16:15 +02:00
|
|
|
'action' => 'modify'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2009-01-24 18:45:14 +01:00
|
|
|
LSsession :: addJSscript('LSselect.js');
|
|
|
|
LSsession :: addCssFile('LSselect.css');
|
|
|
|
LSsession :: addJSscript('LSsmoothbox.js');
|
|
|
|
LSsession :: addCssFile('LSsmoothbox.css');
|
|
|
|
LSsession :: addJSscript('LSrelation.js');
|
|
|
|
LSsession :: addCssFile('LSrelation.css');
|
|
|
|
LSsession :: addJSscript('LSconfirmBox.js');
|
|
|
|
LSsession :: addCssFile('LSconfirmBox.css');
|
|
|
|
LSsession :: addJSscript('LSview.js');
|
2008-07-05 22:28:49 +02:00
|
|
|
|
2009-01-24 18:45:14 +01:00
|
|
|
if(LSsession :: loadLSobject($relationConf['LSobject'])) {
|
2008-06-21 18:16:15 +02:00
|
|
|
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) {
|
2008-07-05 22:28:49 +02:00
|
|
|
$o_infos = array(
|
2009-01-07 20:24:14 +01:00
|
|
|
'text' => $o -> getDisplayName(NULL,true),
|
2008-07-05 22:28:49 +02:00
|
|
|
'dn' => $o -> getDn()
|
|
|
|
);
|
|
|
|
$return['objectList'][] = $o_infos;
|
2008-06-21 18:16:15 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$return['objectList']=array();
|
2008-04-25 15:48:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2009-01-24 18:45:14 +01:00
|
|
|
LSerror :: addErrorCode('LSrelations_01',$relationName);
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
2008-06-21 18:16:15 +02:00
|
|
|
$LSrelations[]=$return;
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
|
|
|
else {
|
2009-01-24 18:45:14 +01:00
|
|
|
LSerror :: addErrorCode('LSrelations_04',array('relation' => $relationName,'LSobject' => $relationConf['LSobject']));
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-10-08 17:34:36 +02:00
|
|
|
|
2009-01-24 18:45:14 +01:00
|
|
|
LSsession :: addJSscript('LSconfirmBox.js');
|
|
|
|
LSsession :: addCssFile('LSconfirmBox.css');
|
2008-06-21 18:16:15 +02:00
|
|
|
$GLOBALS['Smarty'] -> assign('LSrelations',$LSrelations);
|
2009-01-24 18:45:14 +01:00
|
|
|
LSsession :: addJSconfigParam('LSrelations',$LSrelations_JSparams);
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
2008-06-21 18:16:15 +02:00
|
|
|
|
|
|
|
$GLOBALS['Smarty'] -> assign('LSview_actions',$LSview_actions);
|
2009-01-24 18:45:14 +01:00
|
|
|
LSsession :: addJSscript('LSsmoothbox.js');
|
|
|
|
LSsession :: addCssFile('LSsmoothbox.css');
|
|
|
|
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
|
2008-02-26 18:40:05 +01:00
|
|
|
else {
|
2008-06-21 18:16:15 +02:00
|
|
|
$objectList=array();
|
|
|
|
$object = new $LSobject();
|
2008-06-18 14:27:35 +02:00
|
|
|
|
2008-06-21 18:16:15 +02:00
|
|
|
$GLOBALS['Smarty']->assign('pagetitle',$object -> getLabel());
|
|
|
|
$GLOBALS['Smarty']->assign('LSobject_list_objectname',$object -> getLabel());
|
|
|
|
|
|
|
|
if (isset($_SESSION['LSsession']['LSsearch'][$LSobject])) {
|
|
|
|
$filter = $_SESSION['LSsession']['LSsearch'][$LSobject]['filter'];
|
|
|
|
$params = $_SESSION['LSsession']['LSsearch'][$LSobject]['params'];
|
|
|
|
$pattern = $_SESSION['LSsession']['LSsearch'][$LSobject]['pattern'];
|
|
|
|
$recur = $_SESSION['LSsession']['LSsearch'][$LSobject]['recur'];
|
|
|
|
if ($recur) {
|
2009-01-24 18:45:14 +01:00
|
|
|
$topDn = LSsession :: getTopDn();
|
2008-06-18 14:27:35 +02:00
|
|
|
}
|
|
|
|
else {
|
2009-01-24 18:45:14 +01:00
|
|
|
$topDn = $object -> config['container_dn'].','.LSsession :: getTopDn();
|
2008-06-18 14:27:35 +02:00
|
|
|
}
|
2008-06-21 18:16:15 +02:00
|
|
|
$approx = $_SESSION['LSsession']['LSsearch'][$LSobject]['approx'];
|
|
|
|
$orderby = $_SESSION['LSsession']['LSsearch'][$LSobject]['orderby'];
|
|
|
|
$ordersense = $_SESSION['LSsession']['LSsearch'][$LSobject]['ordersense'];
|
|
|
|
$doSubDn = $_SESSION['LSsession']['LSsearch'][$LSobject]['doSubDn'];
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
|
|
|
else {
|
2008-06-18 14:27:35 +02:00
|
|
|
$filter = NULL;
|
2009-01-24 18:45:14 +01:00
|
|
|
$topDn = $object -> config['container_dn'].','.LSsession :: getTopDn();
|
2008-06-21 18:16:15 +02:00
|
|
|
$params = array('scope' => 'one');
|
|
|
|
$pattern = false;
|
|
|
|
$recur = false;
|
|
|
|
$approx = false;
|
|
|
|
$orderby = false;
|
2008-10-27 12:20:51 +01:00
|
|
|
$_REQUEST['orderby']=$GLOBALS['LSobjects'][$LSobject]['orderby'];
|
2008-06-21 18:16:15 +02:00
|
|
|
$ordersense = 'ASC';
|
2009-01-24 18:45:14 +01:00
|
|
|
$subDnLdapServer = LSsession :: getSubDnLdapServer();
|
|
|
|
$doSubDn = (($subDnLdapServer)&&(!LSsession :: isSubDnLSobject($LSobject)));
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
2008-06-21 18:16:15 +02:00
|
|
|
|
|
|
|
if (isset($_REQUEST['LSview_search_submit'])) {
|
|
|
|
if (isset($_REQUEST['LSview_pattern']) && ($_REQUEST['LSview_pattern']!=$pattern)) {
|
|
|
|
$pattern = $_REQUEST['LSview_pattern'];
|
|
|
|
}
|
|
|
|
|
|
|
|
$approx = (isset($_REQUEST['LSview_approx']));
|
|
|
|
|
|
|
|
if ($pattern && $pattern!='') {
|
2009-01-25 18:43:30 +01:00
|
|
|
$filter=$object -> getPatternFilter($pattern,$approx);
|
2008-06-20 17:52:15 +02:00
|
|
|
}
|
|
|
|
else {
|
2008-06-21 18:16:15 +02:00
|
|
|
$filter = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($_REQUEST['LSview_recur'])) {
|
|
|
|
$recur = true;
|
|
|
|
$params['scope'] = 'sub';
|
2009-01-24 18:45:14 +01:00
|
|
|
$topDn = LSsession :: getTopDn();
|
2008-06-21 18:16:15 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
$recur = false;
|
|
|
|
$params['scope'] = 'one';
|
2009-01-24 18:45:14 +01:00
|
|
|
$topDn = $object -> config['container_dn'].','.LSsession :: getTopDn();
|
2008-06-20 17:52:15 +02:00
|
|
|
}
|
|
|
|
}
|
2008-06-21 18:16:15 +02:00
|
|
|
|
|
|
|
$sort=false;
|
|
|
|
if ((isset($_REQUEST['orderby']))) {
|
2009-01-07 20:58:08 +01:00
|
|
|
$possible_values= array('displayName','subDn');
|
2008-06-21 18:16:15 +02:00
|
|
|
if (in_array($_REQUEST['orderby'],$possible_values)) {
|
|
|
|
$sort=true;
|
|
|
|
if ($orderby==$_REQUEST['orderby']) {
|
|
|
|
$ordersense = ($ordersense=='ASC')?'DESC':'ASC';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$ordersense = 'ASC';
|
|
|
|
}
|
|
|
|
$orderby=$_REQUEST['orderby'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$GLOBALS['Smarty']->assign('LSobject_list_subDn',$doSubDn);
|
|
|
|
|
|
|
|
// Sauvegarde en Session
|
|
|
|
$_SESSION['LSsession']['LSsearch'][$LSobject] = array(
|
|
|
|
'filter' => $filter,
|
|
|
|
'topDn' => $topDn,
|
|
|
|
'params' => $params,
|
|
|
|
'pattern' => $pattern,
|
|
|
|
'recur' => $recur,
|
|
|
|
'approx' => $approx,
|
|
|
|
'orderby' => $orderby,
|
|
|
|
'ordersense' => $ordersense,
|
|
|
|
'doSubDn' => $doSubDn
|
|
|
|
);
|
2008-06-18 14:27:35 +02:00
|
|
|
|
2008-06-21 18:16:15 +02:00
|
|
|
$GLOBALS['Smarty']->assign('LSview_search_pattern',$pattern);
|
2008-06-18 14:27:35 +02:00
|
|
|
|
2008-06-21 18:16:15 +02:00
|
|
|
if ($recur) {
|
|
|
|
$GLOBALS['Smarty']->assign('LSview_search_recur',true);
|
2008-06-18 14:27:35 +02:00
|
|
|
}
|
2008-06-21 18:16:15 +02:00
|
|
|
if ($approx) {
|
|
|
|
$GLOBALS['Smarty']->assign('LSview_search_approx',true);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Hidden fields
|
|
|
|
$GLOBALS['Smarty']->assign('LSview_search_hidden_fields',array(
|
|
|
|
'LSobject' => $LSobject,
|
|
|
|
'LSview_search_submit' => 1
|
|
|
|
));
|
|
|
|
|
|
|
|
// Hash de la recherche déterminer à partir des paramètres de la recherche
|
|
|
|
$hash = mhash (MHASH_MD5,
|
|
|
|
print_r(
|
|
|
|
array(
|
|
|
|
'LSobject' => $LSobject,
|
|
|
|
'filter' => $filter,
|
|
|
|
'topDn' => $topDn,
|
|
|
|
'params' => $params
|
|
|
|
),
|
|
|
|
true
|
|
|
|
)
|
2008-06-18 14:27:35 +02:00
|
|
|
);
|
|
|
|
|
2009-01-24 18:45:14 +01:00
|
|
|
if ((LSsession :: cacheSearch()) && isset($_SESSION['LSsession']['LSsearch'][$hash]) && (!isset($_REQUEST['refresh']))) {
|
2008-06-21 18:16:15 +02:00
|
|
|
// On affiche à partir du cache
|
|
|
|
$searchData=$_SESSION['LSsession']['LSsearch'][$hash];
|
2009-02-12 13:38:56 +01:00
|
|
|
LSdebug('Find : From cache');
|
2008-12-15 13:44:04 +01:00
|
|
|
if(!isset($searchData['LSview_actions']['create'])) {
|
|
|
|
LSdebug('Recherche : Check Create()');
|
2009-01-24 18:45:14 +01:00
|
|
|
if (LSsession :: canCreate($LSobject)) {
|
2008-12-15 13:44:04 +01:00
|
|
|
$searchData['LSview_actions']['create'] = array (
|
2009-02-12 13:38:56 +01:00
|
|
|
'label' => _('New'),
|
2008-12-15 13:44:04 +01:00
|
|
|
'url' => 'create.php?LSobject='.$LSobject,
|
|
|
|
'action' => 'create'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$searchData['LSview_actions']['create'] = false;
|
|
|
|
}
|
|
|
|
$_SESSION['LSsession']['LSsearch'][$hash]=$searchData;
|
|
|
|
}
|
2008-06-21 18:16:15 +02:00
|
|
|
}
|
2008-12-15 13:44:04 +01:00
|
|
|
else { // Load
|
2009-02-12 13:38:56 +01:00
|
|
|
LSdebug('Find : Load');
|
2009-01-24 18:45:14 +01:00
|
|
|
if (LSsession :: canCreate($LSobject)) {
|
2008-12-15 13:44:04 +01:00
|
|
|
$LSview_actions['create'] = array (
|
2009-02-12 13:38:56 +01:00
|
|
|
'label' => _('New'),
|
2008-06-21 18:16:15 +02:00
|
|
|
'url' => 'create.php?LSobject='.$LSobject,
|
|
|
|
'action' => 'create'
|
|
|
|
);
|
|
|
|
$canCopy=true;
|
|
|
|
}
|
2008-12-15 13:44:04 +01:00
|
|
|
else {
|
|
|
|
$LSview_actions['create'] = false;
|
|
|
|
}
|
|
|
|
$LSview_actions['refresh'] = array (
|
2009-02-12 13:38:56 +01:00
|
|
|
'label' => _('Refresh'),
|
2008-06-21 18:16:15 +02:00
|
|
|
'url' => 'view.php?LSobject='.$LSobject.'&refresh',
|
|
|
|
'action' => 'refresh'
|
|
|
|
);
|
|
|
|
|
2008-11-09 01:57:50 +01:00
|
|
|
$list=$object -> listObjectsName($filter,$topDn,$params);
|
2008-06-18 14:27:35 +02:00
|
|
|
|
2008-06-21 18:16:15 +02:00
|
|
|
$nbObjects=0;
|
2008-11-09 01:57:50 +01:00
|
|
|
foreach($list as $objDn => $objName) {
|
2009-01-24 18:45:14 +01:00
|
|
|
if (LSsession :: canAccess($LSobject,$objDn)) {
|
2008-06-21 18:16:15 +02:00
|
|
|
$subDn_name=false;
|
|
|
|
if ($doSubDn) {
|
2008-11-09 01:57:50 +01:00
|
|
|
$subDn_name = $object -> getSubDnName($objDn);
|
2008-06-18 14:27:35 +02:00
|
|
|
}
|
2008-06-21 18:16:15 +02:00
|
|
|
$nbObjects++;
|
2008-07-05 22:28:49 +02:00
|
|
|
|
2008-06-21 18:16:15 +02:00
|
|
|
|
|
|
|
$objectList[]=array(
|
2008-11-09 01:57:50 +01:00
|
|
|
'dn' => $objDn,
|
2009-01-07 20:58:08 +01:00
|
|
|
'displayName' => $objName,
|
2008-06-21 18:16:15 +02:00
|
|
|
'subDn' => $subDn_name
|
2008-06-18 14:27:35 +02:00
|
|
|
);
|
|
|
|
}
|
2008-06-21 18:16:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$searchData['LSobject_list_nbresult']=$nbObjects;
|
|
|
|
|
|
|
|
$searchData['objectList']=$objectList;
|
|
|
|
$searchData['LSview_actions'] = $LSview_actions;
|
2008-07-15 18:24:35 +02:00
|
|
|
if ($orderby) {
|
|
|
|
$sort=true;
|
|
|
|
}
|
2008-12-15 13:44:04 +01:00
|
|
|
} // Fin Load
|
2008-07-05 22:28:49 +02:00
|
|
|
|
|
|
|
if ((!isset($searchData['objectList'][0]['actions']))&&(!empty($searchData['objectList']))) {
|
2008-09-26 20:03:56 +02:00
|
|
|
LSdebug('Load actions');
|
2008-07-05 22:28:49 +02:00
|
|
|
for($i=0;$i<$searchData['LSobject_list_nbresult'];$i++) {
|
|
|
|
$actions=array();
|
|
|
|
|
|
|
|
$actions[] = array(
|
2009-02-17 14:14:46 +01:00
|
|
|
'label' => _('View'),
|
2008-07-05 22:28:49 +02:00
|
|
|
'url' =>'view.php?LSobject='.$LSobject.'&dn='.$searchData['objectList'][$i]['dn'],
|
|
|
|
'action' => 'view'
|
|
|
|
);
|
|
|
|
|
2009-01-24 18:45:14 +01:00
|
|
|
if (LSsession :: canEdit($LSobject,$searchData['objectList'][$i]['dn'])) {
|
2008-07-05 22:28:49 +02:00
|
|
|
$actions[]=array(
|
2009-02-12 13:38:56 +01:00
|
|
|
'label' => _('Modify'),
|
2008-07-05 22:28:49 +02:00
|
|
|
'url' => 'modify.php?LSobject='.$LSobject.'&dn='.$searchData['objectList'][$i]['dn'],
|
|
|
|
'action' => 'modify'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($canCopy) {
|
|
|
|
$actions[] = array(
|
2009-02-12 13:38:56 +01:00
|
|
|
'label' => _('Copy'),
|
2008-07-05 22:28:49 +02:00
|
|
|
'url' =>'create.php?LSobject='.$LSobject.'&load='.$searchData['objectList'][$i]['dn'],
|
|
|
|
'action' => 'copy'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2009-01-24 18:45:14 +01:00
|
|
|
if (LSsession :: canRemove($LSobject,$searchData['objectList'][$i]['dn'])) {
|
2008-07-05 22:28:49 +02:00
|
|
|
$actions[] = array (
|
2009-02-12 13:38:56 +01:00
|
|
|
'label' => _('Delete'),
|
2008-07-05 22:28:49 +02:00
|
|
|
'url' => 'remove.php?LSobject='.$LSobject.'&dn='.$searchData['objectList'][$i]['dn'],
|
|
|
|
'action' => 'delete'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
$searchData['objectList'][$i]['actions']=$actions;
|
2008-06-21 18:16:15 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$GLOBALS['Smarty']->assign('LSobject_list_nbresult',$searchData['LSobject_list_nbresult']);
|
|
|
|
|
|
|
|
// Order by if $sort
|
|
|
|
if ($sort) {
|
|
|
|
function sortBy($a,$b) {
|
|
|
|
global $ordersense;
|
|
|
|
global $orderby;
|
2008-06-18 14:27:35 +02:00
|
|
|
|
2008-06-21 18:16:15 +02:00
|
|
|
if ($ordersense=='ASC') {
|
|
|
|
$sense = -1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$sense = 1;
|
2008-06-18 14:27:35 +02:00
|
|
|
}
|
|
|
|
|
2008-06-21 18:16:15 +02:00
|
|
|
if ($a == $b) return 0;
|
|
|
|
$sort = array($a[$orderby],$b[$orderby]);
|
|
|
|
sort($sort);
|
|
|
|
if ($sort[0]==$a[$orderby])
|
|
|
|
return 1*$sense;
|
|
|
|
return -1*$sense;
|
2008-02-12 18:59:44 +01:00
|
|
|
}
|
2008-06-21 18:16:15 +02:00
|
|
|
if (!uasort($searchData['objectList'],'sortBy')) {
|
2009-02-12 13:38:56 +01:00
|
|
|
LSdebug('Error while sorting.');
|
2008-02-12 18:59:44 +01:00
|
|
|
}
|
2008-12-15 13:44:04 +01:00
|
|
|
} // Fin Order by
|
2008-06-21 18:16:15 +02:00
|
|
|
$GLOBALS['Smarty']->assign('LSobject_list_orderby',$orderby);
|
|
|
|
$GLOBALS['Smarty']->assign('LSobject_list_ordersense',$ordersense);
|
|
|
|
|
2008-12-15 13:44:04 +01:00
|
|
|
// Mise en cache
|
2009-01-24 18:45:14 +01:00
|
|
|
if (LSsession :: cacheSearch()) {
|
2008-07-05 22:28:49 +02:00
|
|
|
$_SESSION['LSsession']['LSsearch'][$hash]=$searchData;
|
|
|
|
}
|
|
|
|
|
2008-06-21 18:16:15 +02:00
|
|
|
// Pagination
|
|
|
|
if ($searchData['LSobject_list_nbresult'] > NB_LSOBJECT_LIST) {
|
|
|
|
if (isset($_REQUEST['page'])) {
|
|
|
|
$searchData['objectList'] = array_slice($searchData['objectList'], ($_REQUEST['page']) * NB_LSOBJECT_LIST, NB_LSOBJECT_LIST);
|
|
|
|
$GLOBALS['Smarty']->assign('LSobject_list_currentpage',$_REQUEST['page']);
|
|
|
|
|
2008-06-20 17:52:15 +02:00
|
|
|
}
|
|
|
|
else {
|
2008-06-21 18:16:15 +02:00
|
|
|
$searchData['objectList'] = array_slice($searchData['objectList'], 0, NB_LSOBJECT_LIST);
|
|
|
|
$GLOBALS['Smarty']->assign('LSobject_list_currentpage',0);
|
2008-06-20 17:52:15 +02:00
|
|
|
}
|
2008-06-21 18:16:15 +02:00
|
|
|
$searchData['LSobject_list_nbpage']=ceil($searchData['LSobject_list_nbresult'] / NB_LSOBJECT_LIST);
|
|
|
|
$GLOBALS['Smarty']->assign('LSobject_list_nbpage',$searchData['LSobject_list_nbpage']);
|
2008-12-15 13:44:04 +01:00
|
|
|
} // Fin Pagination
|
2008-06-21 18:16:15 +02:00
|
|
|
|
2009-01-24 18:45:14 +01:00
|
|
|
LSsession :: addJSscript('LSconfirmBox.js');
|
|
|
|
LSsession :: addCssFile('LSconfirmBox.css');
|
|
|
|
LSsession :: addJSscript('LSview.js');
|
2008-06-21 18:16:15 +02:00
|
|
|
|
|
|
|
$GLOBALS['Smarty']->assign('LSview_search',array(
|
|
|
|
'action' => $_SERVER['PHP_SELF'],
|
|
|
|
'submit' => _('Rechercher'),
|
|
|
|
'LSobject' => $LSobject
|
|
|
|
));
|
|
|
|
|
2009-02-12 13:38:56 +01:00
|
|
|
$GLOBALS['Smarty']->assign('LSview_search_recur_label',_('Recursive search'));
|
|
|
|
$GLOBALS['Smarty']->assign('LSview_search_approx_label',_('Aproximative search'));
|
2008-06-18 14:27:35 +02:00
|
|
|
|
2009-02-12 13:38:56 +01:00
|
|
|
$GLOBALS['Smarty']->assign('LSobject_list_without_result_label',_("This search doesn't give any result."));
|
2008-06-21 18:16:15 +02:00
|
|
|
$GLOBALS['Smarty']->assign('_Actions',_('Actions'));
|
2009-02-12 13:38:56 +01:00
|
|
|
$GLOBALS['Smarty']->assign('_Modifier',_('Modify'));
|
2008-06-21 18:16:15 +02:00
|
|
|
$GLOBALS['Smarty']->assign('LSobject_list',$searchData['objectList']);
|
|
|
|
$GLOBALS['Smarty']->assign('LSobject_list_objecttype',$LSobject);
|
|
|
|
$GLOBALS['Smarty'] -> assign('LSview_actions',$searchData['LSview_actions']);
|
2009-01-24 18:45:14 +01:00
|
|
|
LSsession :: setTemplate('viewList.tpl');
|
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();
|
2008-02-08 18:39:24 +01:00
|
|
|
?>
|