mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-12-18 14:33:49 +01:00
- Ajout d'un fichier core.php s'occupant des inclusions minimum pour le lancement de toutes les mécaniques
-> Déplacement des définitions des constantes de chemins et de gettext dans ce fichier -> Déplacement des ini_set() dans ce fichier - LSdebug : -> La variable d'activation devient la constante LSdebug -> Le tableau de stockages des messages s'appel maintenant LSdebug_fieds - LSconfig : Ajout d'une classe gérant la configuration du projet qui servira d'abstraction à la configuration - LSsession : -> Suppresion de la méthode loadConfig() et ajout de la méthode startLSconfig() -> Ajout de la méthode startLStemplate() -> Ajout du commentaire à la méthode getTopDn() -> La méthode vérifie l'existance de la classe portant le nom du type d'objet avant de lancer le chargement -> Utilisation LSconfig pour l'accès à la configuration
This commit is contained in:
parent
713cccedb1
commit
3bcfd6e39f
12 changed files with 246 additions and 103 deletions
|
@ -172,7 +172,7 @@ define('LS_IMAGES_DIR', 'images/'.LS_THEME);
|
|||
define('LS_CSS_DIR', 'css/'.LS_THEME);
|
||||
|
||||
//Debug
|
||||
$GLOBALS['LSdebug']['active'] = true;
|
||||
define('LSdebug',true);
|
||||
|
||||
// Logs
|
||||
$GLOBALS['LSlog']['filename'] = 'tmp/LS.log';
|
||||
|
@ -183,16 +183,6 @@ define('NB_LSOBJECT_LIST_SELECT',11);
|
|||
|
||||
define('MAX_SEND_FILE_SIZE',2000000);
|
||||
|
||||
// Définitions des dossiers d'inclusions
|
||||
define('LS_CONF_DIR','conf/');
|
||||
define('LS_OBJECTS_DIR', LS_CONF_DIR . 'LSobjects/');
|
||||
define('LS_INCLUDE_DIR','includes/');
|
||||
define('LS_CLASS_DIR', LS_INCLUDE_DIR .'class/');
|
||||
define('LS_LIB_DIR', LS_INCLUDE_DIR .'libs/');
|
||||
define('LS_ADDONS_DIR', LS_INCLUDE_DIR .'addons/');
|
||||
define('LS_JS_DIR', LS_INCLUDE_DIR .'js/');
|
||||
define('LS_TMP_DIR', 'tmp/');
|
||||
|
||||
|
||||
// Javascript
|
||||
$GLOBALS['defaultJSscipts']=array(
|
||||
|
@ -202,13 +192,4 @@ $GLOBALS['defaultJSscipts']=array(
|
|||
'LSdefault.js'
|
||||
);
|
||||
|
||||
// PHP values
|
||||
ini_set( 'magic_quotes_gpc', 'off' );
|
||||
ini_set( 'magic_quotes_sybase', 'off' );
|
||||
ini_set( 'magic_quotes_runtime', 'off' );
|
||||
|
||||
// Locale
|
||||
define('LS_TEXT_DOMAIN', 'ldapsaisie');
|
||||
define('LS_I18N_DIR', 'lang');
|
||||
|
||||
?>
|
||||
|
|
46
trunk/core.php
Normal file
46
trunk/core.php
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
// PHP values
|
||||
ini_set( 'magic_quotes_gpc', 'off' );
|
||||
ini_set( 'magic_quotes_sybase', 'off' );
|
||||
ini_set( 'magic_quotes_runtime', 'off' );
|
||||
|
||||
// Définitions des dossiers d'inclusions
|
||||
define('LS_CONF_DIR','conf/');
|
||||
define('LS_OBJECTS_DIR', LS_CONF_DIR . 'LSobjects/');
|
||||
define('LS_INCLUDE_DIR','includes/');
|
||||
define('LS_CLASS_DIR', LS_INCLUDE_DIR .'class/');
|
||||
define('LS_LIB_DIR', LS_INCLUDE_DIR .'libs/');
|
||||
define('LS_ADDONS_DIR', LS_INCLUDE_DIR .'addons/');
|
||||
define('LS_JS_DIR', LS_INCLUDE_DIR .'js/');
|
||||
define('LS_TMP_DIR', 'tmp/');
|
||||
|
||||
// Locale
|
||||
define('LS_TEXT_DOMAIN', 'ldapsaisie');
|
||||
define('LS_I18N_DIR', 'lang');
|
||||
|
||||
require_once LS_INCLUDE_DIR.'functions.php';
|
||||
|
||||
require_once LS_CLASS_DIR.'class.LSsession.php';
|
||||
|
||||
?>
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
******************************************************************************/
|
||||
|
||||
require_once 'includes/class/class.LSsession.php';
|
||||
require_once 'core.php';
|
||||
|
||||
if(LSsession :: startLSsession()) {
|
||||
|
||||
|
|
95
trunk/includes/class/class.LSconfig.php
Normal file
95
trunk/includes/class/class.LSconfig.php
Normal file
|
@ -0,0 +1,95 @@
|
|||
<?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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* Object LSconfig
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
class LSconfig {
|
||||
|
||||
// Configuration Data
|
||||
private static $data=array();
|
||||
|
||||
/**
|
||||
* Lancement de LSconfig
|
||||
*
|
||||
* Chargement initiale des données de configuration à partir des fichiers en
|
||||
* config.*.php du dossier LS_CONF_DIR
|
||||
*
|
||||
* @retval boolean True si tout s'est bien passé, False sinon
|
||||
**/
|
||||
public static function start() {
|
||||
if (loadDir(LS_CONF_DIR, '^config\..*\.php$')) {
|
||||
if (is_array($GLOBALS['LSconfig'])) {
|
||||
self :: $data = $GLOBALS['LSconfig'];
|
||||
self :: $data['LSaddons'] = $GLOBALS['LSaddons'];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupération d'une valeur
|
||||
*
|
||||
* @param[in] $var string Le nom de valeur à récupérer (Exemple : cacheSearch)
|
||||
*
|
||||
* @retval mixed La valeur de la variable, ou false si son nom n'est parsable
|
||||
**/
|
||||
public static function get($var) {
|
||||
$vars=explode('.',$var);
|
||||
if(is_array($vars)) {
|
||||
$data=self :: $data;
|
||||
foreach ($vars as $v) {
|
||||
$data=$data[$v];
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Définition d'une valeur
|
||||
*
|
||||
* @param[in] $var string Le nom de valeur à définir
|
||||
* @param[in] $val mixed La valeur de la variable
|
||||
*
|
||||
* @retval boolean True si tout s'est bien passé, False sinon
|
||||
**/
|
||||
public static function set($var,$val) {
|
||||
$vars=explode('.',$var);
|
||||
if(is_array($vars)) {
|
||||
$code='self :: $data';
|
||||
foreach ($vars as $v) {
|
||||
$code.='["'.$v.'"]';
|
||||
}
|
||||
$code.='=$val;';
|
||||
return (eval($code)===NULL);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
|
@ -20,9 +20,6 @@
|
|||
|
||||
******************************************************************************/
|
||||
|
||||
define('LS_DEFAULT_CONF_DIR','conf');
|
||||
require_once 'includes/functions.php';
|
||||
|
||||
/**
|
||||
* Gestion des sessions
|
||||
*
|
||||
|
@ -95,7 +92,7 @@ class LSsession {
|
|||
if (!file_exists($file)) {
|
||||
return;
|
||||
}
|
||||
if ($GLOBALS['LSdebug']['active']) {
|
||||
if (LSdebug) {
|
||||
return include_once($file);
|
||||
}
|
||||
else {
|
||||
|
@ -105,48 +102,60 @@ class LSsession {
|
|||
}
|
||||
|
||||
/**
|
||||
* Chargement de la configuration
|
||||
*
|
||||
* Chargement des fichiers de configuration et création de l'objet Smarty.
|
||||
* Lancement de LSconfig
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval true si tout c'est bien passé, false sinon
|
||||
*/
|
||||
private static function loadConfig() {
|
||||
if (loadDir(LS_DEFAULT_CONF_DIR, '^config\..*\.php$')) {
|
||||
if ( self :: includeFile($GLOBALS['LSconfig']['Smarty']) ) {
|
||||
$GLOBALS['Smarty'] = new Smarty();
|
||||
$GLOBALS['Smarty'] -> template_dir = LS_TEMPLATES_DIR;
|
||||
$GLOBALS['Smarty'] -> compile_dir = LS_TMP_DIR;
|
||||
|
||||
if ($GLOBALS['LSdebug']['active']) {
|
||||
$GLOBALS['Smarty'] -> caching = 0;
|
||||
// cache files are always regenerated
|
||||
$GLOBALS['Smarty'] -> force_compile = TRUE;
|
||||
// recompile template if it is changed
|
||||
$GLOBALS['Smarty'] -> compile_check = TRUE;
|
||||
}
|
||||
|
||||
$GLOBALS['Smarty'] -> assign('LS_CSS_DIR',LS_CSS_DIR);
|
||||
$GLOBALS['Smarty'] -> assign('LS_IMAGES_DIR',LS_IMAGES_DIR);
|
||||
|
||||
self :: addJSconfigParam('LS_IMAGES_DIR',LS_IMAGES_DIR);
|
||||
private static function startLSconfig() {
|
||||
if (self :: loadLSclass('LSconfig')) {
|
||||
if (LSconfig :: start()) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
die("ERROR : Can't load Smarty.");
|
||||
return;
|
||||
}
|
||||
die("ERROR : Can't load configuration files.");
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lancement et initialisation de Smarty
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval true si tout c'est bien passé, false sinon
|
||||
*/
|
||||
private static function startLStemplate() {
|
||||
if ( self :: includeFile(LSconfig :: get('Smarty')) ) {
|
||||
$GLOBALS['Smarty'] = new Smarty();
|
||||
$GLOBALS['Smarty'] -> template_dir = LS_TEMPLATES_DIR;
|
||||
$GLOBALS['Smarty'] -> compile_dir = LS_TMP_DIR;
|
||||
|
||||
if (LSdebug) {
|
||||
$GLOBALS['Smarty'] -> caching = 0;
|
||||
// cache files are always regenerated
|
||||
$GLOBALS['Smarty'] -> force_compile = TRUE;
|
||||
// recompile template if it is changed
|
||||
$GLOBALS['Smarty'] -> compile_check = TRUE;
|
||||
}
|
||||
|
||||
$GLOBALS['Smarty'] -> assign('LS_CSS_DIR',LS_CSS_DIR);
|
||||
$GLOBALS['Smarty'] -> assign('LS_IMAGES_DIR',LS_IMAGES_DIR);
|
||||
|
||||
self :: addJSconfigParam('LS_IMAGES_DIR',LS_IMAGES_DIR);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
die("ERROR : Can't load configuration files.");
|
||||
return;
|
||||
}
|
||||
|
||||
die("ERROR : Can't load Smarty.");
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne le topDn de la session
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval string le topDn de la session
|
||||
*/
|
||||
public static function getTopDn() {
|
||||
return self :: $topDn;
|
||||
}
|
||||
|
@ -194,6 +203,9 @@ class LSsession {
|
|||
* @retval boolean true si le chargement a réussi, false sinon.
|
||||
*/
|
||||
public static function loadLSobject($object) {
|
||||
if(class_exists($object)) {
|
||||
return true;
|
||||
}
|
||||
$error = 0;
|
||||
self :: loadLSclass('LSldapObject');
|
||||
if (!self :: loadLSclass($object,'LSobjects')) {
|
||||
|
@ -202,6 +214,11 @@ class LSsession {
|
|||
if (!self :: includeFile( LS_OBJECTS_DIR . 'config.LSobjects.'.$object.'.php' )) {
|
||||
$error = 1;
|
||||
}
|
||||
else {
|
||||
if (!LSconfig :: set("LSobjects.$object",$GLOBALS['LSobjects'][$object])) {
|
||||
$error = 1;
|
||||
}
|
||||
}
|
||||
if ($error) {
|
||||
LSerror :: addErrorCode('LSsession_04',$object);
|
||||
return;
|
||||
|
@ -239,12 +256,13 @@ class LSsession {
|
|||
* @retval boolean true si le chargement a réussi, false sinon.
|
||||
*/
|
||||
public static function loadLSaddons() {
|
||||
if(!is_array($GLOBALS['LSaddons']['loads'])) {
|
||||
$conf=LSconfig :: get('LSaddons.loads');
|
||||
if(!is_array($conf)) {
|
||||
LSerror :: addErrorCode('LSsession_01',"LSaddons['loads']");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($GLOBALS['LSaddons']['loads'] as $addon) {
|
||||
foreach ($conf as $addon) {
|
||||
self :: loadLSaddon($addon);
|
||||
}
|
||||
return true;
|
||||
|
@ -266,7 +284,7 @@ class LSsession {
|
|||
$lang = self :: $ldapServer['lang'];
|
||||
}
|
||||
else {
|
||||
$lang = $GLOBALS['LSconfig']['lang'];
|
||||
$lang = LSconfig :: get('lang');
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['encoding'])) {
|
||||
|
@ -279,7 +297,7 @@ class LSsession {
|
|||
$encoding = self :: $ldapServer['encoding'];
|
||||
}
|
||||
else {
|
||||
$encoding = $GLOBALS['LSconfig']['encoding'];
|
||||
$encoding = LSconfig :: get('encoding');
|
||||
}
|
||||
|
||||
$_SESSION['LSlang']=$lang;
|
||||
|
@ -360,9 +378,12 @@ class LSsession {
|
|||
* @retval boolean True si l'initialisation à réussi, false sinon.
|
||||
*/
|
||||
public static function initialize() {
|
||||
if (!self :: loadConfig()) {
|
||||
if (!self :: startLSconfig()) {
|
||||
return;
|
||||
}
|
||||
|
||||
self :: startLStemplate();
|
||||
|
||||
session_start();
|
||||
|
||||
self :: setLocale();
|
||||
|
@ -773,9 +794,10 @@ class LSsession {
|
|||
* @retval boolean True sinon false.
|
||||
*/
|
||||
public static function setLdapServer($id) {
|
||||
if ( isset($GLOBALS['LSconfig']['ldap_servers'][$id]) ) {
|
||||
$conf = LSconfig :: get("ldap_servers.$id");
|
||||
if ( is_array($conf) ) {
|
||||
self :: $ldapServerId = $id;
|
||||
self :: $ldapServer=$GLOBALS['LSconfig']['ldap_servers'][$id];
|
||||
self :: $ldapServer = $conf;
|
||||
self :: setLocale();
|
||||
return true;
|
||||
}
|
||||
|
@ -791,7 +813,7 @@ class LSsession {
|
|||
*/
|
||||
public static function LSldapConnect() {
|
||||
if (self :: $ldapServer) {
|
||||
self :: includeFile($GLOBALS['LSconfig']['NetLDAP2']);
|
||||
self :: includeFile(LSconfig :: get('NetLDAP2'));
|
||||
if (!self :: loadLSclass('LSldap')) {
|
||||
return;
|
||||
}
|
||||
|
@ -964,13 +986,13 @@ class LSsession {
|
|||
else {
|
||||
$GLOBALS['Smarty'] -> assign('loginform_action',$_SERVER['REQUEST_URI']);
|
||||
}
|
||||
if (count($GLOBALS['LSconfig']['ldap_servers'])==1) {
|
||||
if (count(LSconfig :: get('ldap_servers'))==1) {
|
||||
$GLOBALS['Smarty'] -> assign('loginform_ldapserver_style','style="display: none"');
|
||||
}
|
||||
$GLOBALS['Smarty'] -> assign('loginform_label_ldapserver',_('LDAP server'));
|
||||
$ldapservers_name=array();
|
||||
$ldapservers_index=array();
|
||||
foreach($GLOBALS['LSconfig']['ldap_servers'] as $id => $infos) {
|
||||
foreach(LSconfig :: get('ldap_servers') as $id => $infos) {
|
||||
$ldapservers_index[]=$id;
|
||||
$ldapservers_name[]=__($infos['name']);
|
||||
}
|
||||
|
@ -1002,14 +1024,14 @@ class LSsession {
|
|||
$GLOBALS['Smarty'] -> assign('pagetitle',_('Recovery of your credentials'));
|
||||
$GLOBALS['Smarty'] -> assign('recoverpasswordform_action','index.php?LSsession_recoverPassword');
|
||||
|
||||
if (count($GLOBALS['LSconfig']['ldap_servers'])==1) {
|
||||
if (count(LSconfig :: get('ldap_servers'))==1) {
|
||||
$GLOBALS['Smarty'] -> assign('recoverpasswordform_ldapserver_style','style="display: none"');
|
||||
}
|
||||
|
||||
$GLOBALS['Smarty'] -> assign('recoverpasswordform_label_ldapserver',_('LDAP server'));
|
||||
$ldapservers_name=array();
|
||||
$ldapservers_index=array();
|
||||
foreach($GLOBALS['LSconfig']['ldap_servers'] as $id => $infos) {
|
||||
foreach(LSconfig :: get('ldap_servers') as $id => $infos) {
|
||||
$ldapservers_index[]=$id;
|
||||
$ldapservers_name[]=$infos['name'];
|
||||
}
|
||||
|
@ -1127,15 +1149,12 @@ class LSsession {
|
|||
$JSscript_txt.="<script src='".$script['path'].$script['file']."' type='text/javascript'></script>\n";
|
||||
}
|
||||
|
||||
$KAconf = LSconfig :: get('keepLSsessionActive');
|
||||
if (
|
||||
(
|
||||
(!isset(self :: $ldapServer['keepLSsessionActive']))
|
||||
&&
|
||||
(
|
||||
(!isset($GLOBALS['LSconfig']['keepLSsessionActive']))
|
||||
||
|
||||
($GLOBALS['LSconfig']['keepLSsessionActive'])
|
||||
)
|
||||
(!($KAconf === false))
|
||||
)
|
||||
||
|
||||
(self :: $ldapServer['keepLSsessionActive'])
|
||||
|
@ -1145,7 +1164,7 @@ class LSsession {
|
|||
|
||||
$GLOBALS['Smarty'] -> assign('LSjsConfig',json_encode(self :: $_JSconfigParams));
|
||||
|
||||
if ($GLOBALS['LSdebug']['active']) {
|
||||
if (LSdebug) {
|
||||
$JSscript_txt.="<script type='text/javascript'>LSdebug_active = 1;</script>\n";
|
||||
}
|
||||
else {
|
||||
|
@ -1397,7 +1416,7 @@ class LSsession {
|
|||
foreach($objectConf['LSobjects'] as $type) {
|
||||
if (self :: loadLSobject($type)) {
|
||||
if (self :: canAccess($type)) {
|
||||
$access[$type] = $GLOBALS['LSobjects'][$type]['label'];
|
||||
$access[$type] = LSconfig :: get('LSobjects.'.$type.'.label');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1418,7 +1437,7 @@ class LSsession {
|
|||
foreach($config['LSobjects'] as $objectType) {
|
||||
if (self :: loadLSobject($objectType)) {
|
||||
if (self :: canAccess($objectType)) {
|
||||
$access[$objectType] = $GLOBALS['LSobjects'][$objectType]['label'];
|
||||
$access[$objectType] = LSconfig :: get('LSobjects.'.$objectType.'.label');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1434,7 +1453,7 @@ class LSsession {
|
|||
foreach(self :: $ldapServer['LSaccess'] as $objectType) {
|
||||
if (self :: loadLSobject($objectType)) {
|
||||
if (self :: canAccess($objectType)) {
|
||||
$access[$objectType] = $GLOBALS['LSobjects'][$objectType]['label'];
|
||||
$access[$objectType] = LSconfig :: get('LSobjects.'.$objectType.'.label');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1529,22 +1548,22 @@ class LSsession {
|
|||
}
|
||||
}
|
||||
else {
|
||||
$objectdn=$GLOBALS['LSobjects'][$LSobject]['container_dn'].','.self :: $topDn;
|
||||
$objectdn=LSconfig :: get('LSobjects.'.$LSobject.'.container_dn').','.self :: $topDn;
|
||||
$whoami = self :: whoami($objectdn);
|
||||
}
|
||||
|
||||
// Pour un attribut particulier
|
||||
if ($attr) {
|
||||
if ($attr=='rdn') {
|
||||
$attr=$GLOBALS['LSobjects'][$LSobject]['rdn'];
|
||||
$attr=LSconfig :: get('LSobjects.'.$LSobject.'.rdn');
|
||||
}
|
||||
if (!isset($GLOBALS['LSobjects'][$LSobject]['attrs'][$attr])) {
|
||||
if (!is_array(LSconfig :: get('LSobjects.'.$LSobject.'.attrs.'.$attr))) {
|
||||
return;
|
||||
}
|
||||
|
||||
$r = 'n';
|
||||
foreach($whoami as $who) {
|
||||
$nr = $GLOBALS['LSobjects'][$LSobject]['attrs'][$attr]['rights'][$who];
|
||||
$nr = LSconfig :: get('LSobjects.'.$LSobject.'.attrs.'.$attr.'.rights.'.$who);
|
||||
if($nr == 'w') {
|
||||
$r = 'w';
|
||||
}
|
||||
|
@ -1570,10 +1589,11 @@ class LSsession {
|
|||
}
|
||||
|
||||
// Pour un attribut quelconque
|
||||
if (is_array($GLOBALS['LSobjects'][$LSobject]['attrs'])) {
|
||||
$attrs_conf=LSconfig :: get('LSobjects.'.$LSobject.'.attrs');
|
||||
if (is_array($attrs_conf)) {
|
||||
if (($right=='r')||($right=='w')) {
|
||||
foreach($whoami as $who) {
|
||||
foreach ($GLOBALS['LSobjects'][$LSobject]['attrs'] as $attr_name => $attr_config) {
|
||||
foreach ($attrs_conf as $attr_name => $attr_config) {
|
||||
if ($attr_config['rights'][$who]==$right) {
|
||||
return true;
|
||||
}
|
||||
|
@ -1582,7 +1602,7 @@ class LSsession {
|
|||
}
|
||||
else {
|
||||
foreach($whoami as $who) {
|
||||
foreach ($GLOBALS['LSobjects'][$LSobject]['attrs'] as $attr_name => $attr_config) {
|
||||
foreach ($attrs_conf as $attr_name => $attr_config) {
|
||||
if ( ($attr_config['rights'][$who]=='r') || ($attr_config['rights'][$who]=='w') ) {
|
||||
return true;
|
||||
}
|
||||
|
@ -1640,14 +1660,15 @@ class LSsession {
|
|||
* @retval boolean True si l'utilisateur a accès, false sinon
|
||||
*/
|
||||
public static function relationCanAccess($dn,$LSobject,$relationName,$right=NULL) {
|
||||
if (!isset($GLOBALS['LSobjects'][$LSobject]['LSrelation'][$relationName]))
|
||||
$relConf=LSconfig :: get('LSobjects.'.$LSobject.'.LSrelation.'.$relationName);
|
||||
if (!is_array($relConf))
|
||||
return;
|
||||
$whoami = self :: whoami($dn);
|
||||
|
||||
if (($right=='w') || ($right=='r')) {
|
||||
$r = 'n';
|
||||
foreach($whoami as $who) {
|
||||
$nr = $GLOBALS['LSobjects'][$LSobject]['LSrelation'][$relationName]['rights'][$who];
|
||||
$nr = $relConf['rights'][$who];
|
||||
if($nr == 'w') {
|
||||
$r = 'w';
|
||||
}
|
||||
|
@ -1664,7 +1685,7 @@ class LSsession {
|
|||
}
|
||||
else {
|
||||
foreach($whoami as $who) {
|
||||
if (($GLOBALS['LSobjects'][$LSobject]['LSrelation'][$relationName]['rights'][$who] == 'w') || ($GLOBALS['LSobjects'][$LSobject]['LSrelation'][$relationName]['rights'][$who] == 'r')) {
|
||||
if (($relConf['rights'][$who] == 'w') || ($relConf['rights'][$who] == 'r')) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1774,7 +1795,7 @@ class LSsession {
|
|||
* @retval boolean True si le cache des droits est activé, false sinon.
|
||||
*/
|
||||
public static function cacheLSprofiles() {
|
||||
return ( ($GLOBALS['LSconfig']['cacheLSprofiles']) || (self :: $ldapServer['cacheLSprofiles']) );
|
||||
return ( (LSconfig :: get('cacheLSprofiles')) || (self :: $ldapServer['cacheLSprofiles']) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1785,7 +1806,7 @@ class LSsession {
|
|||
* @retval boolean True si le cache des subDn est activé, false sinon.
|
||||
*/
|
||||
public static function cacheSudDn() {
|
||||
return (($GLOBALS['LSconfig']['cacheSubDn']) || (self :: $ldapServer['cacheSubDn']));
|
||||
return ( (LSconfig :: get('cacheSubDn')) || (self :: $ldapServer['cacheSubDn']));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1796,7 +1817,7 @@ class LSsession {
|
|||
* @retval boolean True si le cache des recherches est activé, false sinon.
|
||||
*/
|
||||
public static function cacheSearch() {
|
||||
return (($GLOBALS['LSconfig']['cacheSearch']) || (self :: $ldapServer['cacheSearch']));
|
||||
return ( (LSconfig :: get('cacheSearch')) || (self :: $ldapServer['cacheSearch']));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -188,29 +188,29 @@ function return_data($data) {
|
|||
return $data;
|
||||
}
|
||||
|
||||
$GLOBALS['LSdebug']['fields']=array();
|
||||
$GLOBALS['LSdebug_fields']=array();
|
||||
function LSdebug($data,$dump=false) {
|
||||
if ($dump) {
|
||||
ob_start();
|
||||
var_dump($data);
|
||||
$GLOBALS['LSdebug']['fields'][]=ob_get_contents();
|
||||
$GLOBALS['LSdebug_fields'][]=ob_get_contents();
|
||||
ob_end_clean();
|
||||
}
|
||||
else {
|
||||
if (is_array($data)||is_object($data)) {
|
||||
$GLOBALS['LSdebug']['fields'][]=$data;
|
||||
$GLOBALS['LSdebug_fields'][]=$data;
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSdebug']['fields'][]="[$data]";
|
||||
$GLOBALS['LSdebug_fields'][]="[$data]";
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function LSdebug_print($return=false) {
|
||||
if (( $GLOBALS['LSdebug']['fields'] ) && ( $GLOBALS['LSdebug']['active'] )) {
|
||||
if (( $GLOBALS['LSdebug_fields'] ) && (LSdebug)) {
|
||||
$txt='<ul>';
|
||||
foreach($GLOBALS['LSdebug']['fields'] as $debug) {
|
||||
foreach($GLOBALS['LSdebug_fields'] as $debug) {
|
||||
if (is_array($debug)||is_object($debug)) {
|
||||
$txt.='<li><pre>'.print_r($debug,true).'</pre></li>';
|
||||
}
|
||||
|
@ -228,9 +228,9 @@ function LSdebug_print($return=false) {
|
|||
}
|
||||
|
||||
function LSdebugDefined() {
|
||||
if (!$GLOBALS['LSdebug']['active'])
|
||||
if (!LSdebug)
|
||||
return;
|
||||
return (!empty($GLOBALS['LSdebug']['fields']));
|
||||
return (!empty($GLOBALS['LSdebug_fields']));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
******************************************************************************/
|
||||
|
||||
require_once 'includes/class/class.LSsession.php';
|
||||
require_once 'core.php';
|
||||
|
||||
if(LSsession :: startLSsession()) {
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
require_once 'includes/class/class.LSsession.php';
|
||||
require_once 'core.php';
|
||||
|
||||
if (!isset($_REQUEST['noLSsession'])) {
|
||||
if ( !LSsession :: startLSsession() ) {
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
******************************************************************************/
|
||||
|
||||
require_once 'includes/class/class.LSsession.php';
|
||||
require_once 'core.php';
|
||||
|
||||
if(LSsession :: startLSsession()) {
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
******************************************************************************/
|
||||
|
||||
require_once 'includes/class/class.LSsession.php';
|
||||
require_once 'core.php';
|
||||
|
||||
if(LSsession :: startLSsession()) {
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
******************************************************************************/
|
||||
|
||||
require_once 'includes/class/class.LSsession.php';
|
||||
require_once 'core.php';
|
||||
|
||||
if(LSsession :: startLSsession()) {
|
||||
if (isset($_REQUEST['LSobject'])) {
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
******************************************************************************/
|
||||
|
||||
require_once 'includes/class/class.LSsession.php';
|
||||
require_once 'core.php';
|
||||
|
||||
if(LSsession :: startLSsession()) {
|
||||
if (isset($_REQUEST['LSobject'])) {
|
||||
|
|
Loading…
Reference in a new issue