diff --git a/trunk/INSTALL b/trunk/INSTALL
new file mode 100644
index 00000000..25292daa
--- /dev/null
+++ b/trunk/INSTALL
@@ -0,0 +1,6 @@
+Pré-requis :
+ - Php 5 : magic_quotes_gpc = off
+ - php5-mhash
+ - Net_LDAP2 (http://pear.php.net/package/Net_LDAP2)
+ - Smarty (http://www.smarty.net/)
+ - tmp/ et template_c/ en ecriture
diff --git a/trunk/conf/config.LSobjects.php b/trunk/conf/config.LSobjects.php
deleted file mode 100644
index 7de6bea3..00000000
--- a/trunk/conf/config.LSobjects.php
+++ /dev/null
@@ -1,31 +0,0 @@
-
diff --git a/trunk/conf/config.error_code.php b/trunk/conf/config.error_code.php
index cba009f3..d119ffc0 100644
--- a/trunk/conf/config.error_code.php
+++ b/trunk/conf/config.error_code.php
@@ -258,7 +258,14 @@ $GLOBALS['LSerror_code'] = array (
1015 => array (
'msg' => _("LSrelations : Une erreur s'est produite durant la mise a jour de la relation %{relation}."),
'level' => 'c'
+ ),
+ 1016 => array (
+ 'msg' => _("LSrelations : L'objet %{LSobject} de la relation %{relation} est inconnu."),
+ 'level' => 'w'
+ ),
+ 1017 => array (
+ 'msg' => _("LSsession : Impossible de créer correctement la liste des niveaux. Vérifier la configuration."),
+ 'level' => 'c'
)
-
);
?>
diff --git a/trunk/conf/config.inc.php b/trunk/conf/config.inc.php
index 31d81fe3..62311517 100644
--- a/trunk/conf/config.inc.php
+++ b/trunk/conf/config.inc.php
@@ -22,10 +22,10 @@
// Configuration LDAP Saisie :
$GLOBALS['LSconfig'] = array(
- 'NetLDAP' => '/usr/share/php/Net/LDAP.php',
+ 'NetLDAP2' => '/usr/share/php/Net/LDAP2.php',
'Smarty' => '/var/www/tmp/Smarty-2.6.18/libs/Smarty.class.php',
'lang' => 'fr_FR.UTF8',
- 'cacheLSrights' => true,
+ 'cacheLSrights' => false,
'ldap_servers' => array (
array (
'name' => 'LSexample',
@@ -54,25 +54,12 @@ $GLOBALS['LSconfig'] = array(
),
'cacheLSrights' => false,
'authobject' => 'LSeepeople',
- 'authobject_pwdattr' => 'userPassword'
- ),
- array (
- 'name' => 'Ldap 2',
- 'ldap_config'=> array(
- 'host' => '127.0.0.1',
- 'port' => 389,
- 'version' => 3,
- 'starttls' => false,
- 'binddn' => 'uid=toto,ou=people,o=com',
- 'bindpw' => 'toto',
- 'basedn' => 'o=com',
- 'options' => array(),
- 'filter' => '(objectClass=*)',
- 'scope' => 'sub'
- ),
- 'subdnobject' => 'LSeecompany',
- 'authobject' => 'LSeepeople',
- 'authobject_pwdattr' => 'userPassword'
+ 'authobject_pwdattr' => 'userPassword',
+ 'LSobjects' => array (
+ 'LSeepeople',
+ 'LSeegroup',
+ 'LSeecompany'
+ )
)
)
);
@@ -80,7 +67,8 @@ $GLOBALS['LSconfig'] = array(
//Debug
$GLOBALS['LSdebug']['active'] = true;
-define('NB_LSOBJECT_LIST',2);
+define('NB_LSOBJECT_LIST',20);
+define('NB_LSOBJECT_LIST_SELECT',11);
define('MAX_SEND_FILE_SIZE',2000000);
@@ -92,6 +80,7 @@ setlocale(LC_ALL, $GLOBALS['LSconfig']['lang']);
// 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/');
diff --git a/trunk/includes/class/class.LSattr_html_select_list.php b/trunk/includes/class/class.LSattr_html_select_list.php
index a4a1f1e2..92d8bd97 100644
--- a/trunk/includes/class/class.LSattr_html_select_list.php
+++ b/trunk/includes/class/class.LSattr_html_select_list.php
@@ -84,6 +84,10 @@ class LSattr_html_select_list extends LSattr_html{
$GLOBALS['LSerror'] -> addErrorCode(102,$this -> name);
break;
}
+ if (!$GLOBALS['LSsession'] -> loadLSobject($val['object_type'])) {
+ $GLOBALS['LSerror'] -> addErrorCode(1004,$val['object_type']);
+ return;
+ }
$obj = new $val['object_type']();
if($val['scope']) {
$param=array('scope' => $this -> config['possible_values']['scope']);
diff --git a/trunk/includes/class/class.LSattribute.php b/trunk/includes/class/class.LSattribute.php
index b7b8aed1..b5731704 100644
--- a/trunk/includes/class/class.LSattribute.php
+++ b/trunk/includes/class/class.LSattribute.php
@@ -261,12 +261,12 @@ class LSattribute {
break;
case 'self':
if (($this -> config['rights']['self'] == 'w') || ($this -> config['rights']['self'] == 'r')) {
- $return=$this -> config['self'];
+ $return=$this -> config['rights']['self'];
}
break;
default: //user
if (($this -> config['rights']['user'] == 'w') || ($this -> config['rights']['user'] == 'r')) {
- $return=$this -> config['user'];
+ $return=$this -> config['rights']['user'];
}
break;
}
@@ -314,8 +314,8 @@ class LSattribute {
* @retval boolean true si la valeur a été rafraichie ou que ce n'est pas nécessaire, false sinon
*/
function refreshForm(&$form,$idForm) {
- if(isset($this -> config['form'][$idForm])) {
- $form_element = &$form -> getElement($this -> name);
+ if(isset($this -> config['form'][$idForm]) && ($this -> myRights()=='w')) {
+ $form_element = $form -> getElement($this -> name);
$values = $this -> html -> refreshForm($this -> getFormVal());
return $form_element -> setValue($values);
}
@@ -420,7 +420,7 @@ class LSattribute {
$value=call_user_func($this -> config['generate_function'],$this -> ldapObject);
if (!empty($value)) {
//$this -> setValue($value); // pas nécéssaire ??
- $this -> updateData=$value;
+ $this -> updateData=array($value);
return true;
}
return;
diff --git a/trunk/includes/class/class.LSformElement_select_object.php b/trunk/includes/class/class.LSformElement_select_object.php
index f4954f9d..e7a6f471 100644
--- a/trunk/includes/class/class.LSformElement_select_object.php
+++ b/trunk/includes/class/class.LSformElement_select_object.php
@@ -65,7 +65,7 @@ class LSformElement_select_object extends LSformElement {
$return['html']="
\n";
if (!$this -> isFreeze()) {
diff --git a/trunk/includes/class/class.LSldap.php b/trunk/includes/class/class.LSldap.php
index 5d6b92c9..7abf86e8 100644
--- a/trunk/includes/class/class.LSldap.php
+++ b/trunk/includes/class/class.LSldap.php
@@ -23,7 +23,7 @@
/**
* Gestion de l'accès à l'annaire Ldap
*
- * Cette classe gère l'accès à l'annuaire ldap en s'appuyant sur PEAR :: Net_LDAP
+ * Cette classe gère l'accès à l'annuaire ldap en s'appuyant sur PEAR :: Net_LDAP2
*
* @author Benjamin Renard
*/
@@ -40,11 +40,11 @@ class LSldap {
*
* @author Benjamin Renard
*
- * @param[in] $config array Tableau de configuration au formar Net_LDAP
+ * @param[in] $config array Tableau de configuration au formar Net_LDAP2
*
* @retval void
*
- * @see Net_LDAP::connect()
+ * @see Net_LDAP2::connect()
*/
function LSldap ($config) {
$this -> config = $config;
@@ -61,8 +61,8 @@ class LSldap {
* @retval boolean true si la connection est établie, false sinon
*/
function connect() {
- $this -> cnx = Net_LDAP::connect($this -> config);
- if (Net_LDAP::isError($this -> cnx)) {
+ $this -> cnx = Net_LDAP2::connect($this -> config);
+ if (Net_LDAP2::isError($this -> cnx)) {
$GLOBALS['LSerror'] -> addErrorCode(1,$this -> cnx -> getMessage());
$this -> cnx = NULL;
return;
@@ -93,9 +93,9 @@ class LSldap {
*
* @param[in] $filter [required] string Filtre de recherche Ldap
* @param[in] $basedn string DN de base pour la recherche
- * @param[in] $params array Paramètres de recherche au format Net_LDAP::search()
+ * @param[in] $params array Paramètres de recherche au format Net_LDAP2::search()
*
- * @see Net_LDAP::search()
+ * @see Net_LDAP2::search()
*
* @retval array Retourne un tableau associatif contenant :
* - ['dn'] : le DN de l'entré
@@ -104,7 +104,7 @@ class LSldap {
*/
function search ($filter,$basedn=NULL,$params = array()) {
$ret = $this -> cnx -> search($basedn,$filter,$params);
- if (Net_LDAP::isError($ret)) {
+ if (Net_LDAP2::isError($ret)) {
$GLOBALS['LSerror'] -> addErrorCode(2,$ret -> getMessage());
return;
}
@@ -125,9 +125,9 @@ class LSldap {
*
* @param[in] $filter [required] string Filtre de recherche Ldap
* @param[in] $basedn string DN de base pour la recherche
- * @param[in] $params array Paramètres de recherche au format Net_LDAP::search()
+ * @param[in] $params array Paramètres de recherche au format Net_LDAP2::search()
*
- * @see Net_LDAP::search()
+ * @see Net_LDAP2::search()
*
* @retval numeric Le nombre d'entré trouvées
*/
@@ -135,7 +135,7 @@ class LSldap {
if (empty($filter))
$filter=NULL;
$ret = $this -> cnx -> search($basedn,$filter,$params);
- if (Net_LDAP::isError($ret)) {
+ if (Net_LDAP2::isError($ret)) {
$GLOBALS['LSerror'] -> addErrorCode(2,$ret -> getMessage());
return;
}
@@ -175,14 +175,14 @@ class LSldap {
* @param[in] $object_type string Type de l'objet Ldap
* @param[in] $dn string DN de l'entré Ldap
*
- * @retval ldapentry Un objet ldapentry (PEAR::Net_LDAP)
+ * @retval ldapentry Un objet ldapentry (PEAR::Net_LDAP2)
*/
function getEntry($object_type,$dn) {
if(isset($GLOBALS['LSobjects'][$object_type])){
$obj_conf=$GLOBALS['LSobjects'][$object_type];
$entry = $this -> cnx -> getEntry($dn);
- if (Net_Ldap::isError($entry)) {
- $newentry = new Net_Ldap_Entry(&$this -> cnx);
+ if (Net_LDAP2::isError($entry)) {
+ $newentry = new Net_LDAP2_Entry(&$this -> cnx);
$newentry -> dn($dn);
$newentry -> add(array('objectclass' => $obj_conf['objectclass']));
foreach($obj_conf['attrs'] as $attr_name => $attr_conf) {
@@ -227,6 +227,12 @@ class LSldap {
}
}
}
+ else {
+ if (!empty($attrVal)) {
+ $drop = false;
+ $changeData[$attrName][]=$attrVal;
+ }
+ }
if($drop) {
$dropAttr[] = $attrName;
}
@@ -234,13 +240,14 @@ class LSldap {
$entry -> replace($changeData);
debug('change : '.print_r($changeData,true));
debug('drop : '.print_r($dropAttr,true));
+
+ $ret = $entry -> update();
if (!empty($dropAttr)) {
foreach($dropAttr as $attr) {
$entry -> delete($attr);
}
}
- $ret = $entry -> update();
- if (Net_Ldap::isError($ret)) {
+ if (Net_LDAP2::isError($ret)) {
$GLOBALS['LSerror'] -> addErrorCode(5,$dn);
debug('NetLdap-Error : '.$ret->getMessage());
}
@@ -268,8 +275,8 @@ class LSldap {
$config = $this -> config;
$config['binddn'] = $dn;
$config['bindpw'] = $pwd;
- $cnx = Net_LDAP::connect($config);
- if (Net_LDAP::isError($cnx)) {
+ $cnx = Net_LDAP2::connect($config);
+ if (Net_LDAP2::isError($cnx)) {
return;
}
return true;
diff --git a/trunk/includes/class/class.LSldapObject.php b/trunk/includes/class/class.LSldapObject.php
index 1b8d7a78..5e4fd85c 100644
--- a/trunk/includes/class/class.LSldapObject.php
+++ b/trunk/includes/class/class.LSldapObject.php
@@ -31,9 +31,9 @@ $GLOBALS['LSsession'] -> loadLSclass('LSattribute');
*/
class LSldapObject {
- var $config;
+ var $config = array();
var $type_name;
- var $attrs;
+ var $attrs = array();
var $forms;
var $view;
var $dn=false;
@@ -572,7 +572,7 @@ class LSldapObject {
*
* @param[in] $filter array (ou string) Filtre de recherche Ldap / Tableau de filtres de recherche
* @param[in] $basedn string DN de base pour la recherche
- * @param[in] $params array Paramètres de recherche au format Net_LDAP::search()
+ * @param[in] $params array Paramètres de recherche au format Net_LDAP2::search()
*
* @retval array Tableau d'objet correspondant au resultat de la recherche
*/
@@ -806,36 +806,19 @@ class LSldapObject {
return ' ';
}
}
-
- /**
- * Retourn une liste d'option pour un select d'un objet du même type
- *
- * @author Benjamin Renard
- *
- * @retval string HTML code
- */
- function getSelectOptions() {
- $list = $this -> listObjects();
- $display='';
- foreach($list as $object) {
- $display.="\n";
- }
- return $display;
- }
/**
* Retourn un tableau pour un select d'un objet du même type
*
* @author Benjamin Renard
*
- * @retval array['dn','display']
+ * @retval array('dn' => 'display')
*/
- function getSelectArray() {
- $list = $this -> listObjects();
+ function getSelectArray($topDn=NULL) {
+ $list = $this -> listObjects(NULL,$topDn);
$return=array();
foreach($list as $object) {
- $return['dn'][] = $object -> getDn();
- $return['display'][] = $object -> getDisplayValue();
+ $return[$object -> getDn()] = $object -> getDisplayValue();
}
return $return;
}
diff --git a/trunk/includes/class/class.LSsession.php b/trunk/includes/class/class.LSsession.php
index 965a4a2c..2a968618 100644
--- a/trunk/includes/class/class.LSsession.php
+++ b/trunk/includes/class/class.LSsession.php
@@ -75,12 +75,12 @@ class LSsession {
*/
function loadConfig() {
if (loadDir($this -> confDir, '^config\..*\.php$')) {
- if ( @include_once $GLOBALS['LSconfig']['Smarty'] ) {
+ if ( include_once $GLOBALS['LSconfig']['Smarty'] ) {
$GLOBALS['Smarty'] = new Smarty();
return true;
}
else {
- $GLOBALS['LSerror'] -> addErrorCode(1008);
+ die($GLOBALS['LSerror_code'][1008]['msg']);
return;
}
return true;
@@ -121,7 +121,7 @@ class LSsession {
return true;
if($type!='')
$type=$type.'.';
- return @include_once LS_CLASS_DIR .'class.'.$type.$class.'.php';
+ return include_once LS_CLASS_DIR .'class.'.$type.$class.'.php';
}
/*
@@ -132,10 +132,13 @@ class LSsession {
* @retval boolean true si le chargement a réussi, false sinon.
*/
function loadLSobject($object) {
- if (!$this -> loadLSclass($object,'LSobjects'))
+ $this -> loadLSclass('LSldapObject');
+ if (!$this -> loadLSclass($object,'LSobjects')) {
return;
- if (!require_once( LS_OBJECTS_DIR . 'config.LSobjects.'.$object.'.php' ))
+ }
+ if (!require_once( LS_OBJECTS_DIR . 'config.LSobjects.'.$object.'.php' )) {
return;
+ }
return true;
}
@@ -143,7 +146,7 @@ class LSsession {
* Chargement des objects LdapSaisie
*
* Chargement des LSobjects contenue dans la variable
- * $GLOBALS['LSobjects_loads']
+ * $this -> ldapServer['LSobjects']
*
* @retval boolean true si le chargement a réussi, false sinon.
*/
@@ -151,12 +154,12 @@ class LSsession {
$this -> loadLSclass('LSldapObject');
- if(!is_array($GLOBALS['LSobjects_loads'])) {
+ if(!is_array($this -> ldapServer['LSobjects'])) {
$GLOBALS['LSerror'] -> addErrorCode(1001,"LSobjects['loads']");
return;
}
- foreach ($GLOBALS['LSobjects_loads'] as $object) {
+ foreach ($this -> ldapServer['LSobjects'] as $object) {
if ( !$this -> loadLSobject($object) )
return;
}
@@ -211,7 +214,6 @@ class LSsession {
* @retval boolean True si l'initialisation à réussi (utilisateur authentifié), false sinon.
*/
function startLSsession() {
- $this -> loadLSobjects();
$this -> loadLSaddons();
session_start();
@@ -235,23 +237,35 @@ class LSsession {
$this -> rdn = $_SESSION['LSsession']['rdn'];
$this -> ldapServerId = $_SESSION['LSsession']['ldapServerId'];
$this -> tmp_file = $_SESSION['LSsession']['tmp_file'];
+
if ( ($GLOBALS['LSconfig']['cacheLSrights']) || ($this -> ldapServer['cacheLSrights']) ) {
$this -> ldapServer = $_SESSION['LSsession']['ldapServer'];
$this -> LSrights = $_SESSION['LSsession']['LSrights'];
$this -> LSaccess = $_SESSION['LSsession']['LSaccess'];
if (!$this -> LSldapConnect())
return;
+ $this -> loadLSobjects();
}
else {
$this -> setLdapServer($this -> ldapServerId);
if (!$this -> LSldapConnect())
return;
+ $this -> loadLSobjects();
$this -> loadLSrights();
}
+ $this -> loadLSobject($this -> ldapServer['authobject']);
$this -> LSuserObject = new $this -> ldapServer['authobject']();
$this -> LSuserObject -> loadData($this -> dn);
$this -> loadLSaccess();
$GLOBALS['Smarty'] -> assign('LSsession_username',$this -> LSuserObject -> getDisplayValue());
+
+ if ($_POST['LSsession_topDn']) {
+ if ($this -> validSubDnLdapServer($_POST['LSsession_topDn'])) {
+ $this -> topDn = $_POST['LSsession_topDn'];
+ $_SESSION['LSsession']['topDn'] = $_POST['LSsession_topDn'];
+ } // end if
+ } // end if
+
return true;
}
@@ -268,6 +282,7 @@ class LSsession {
// Connexion au serveur LDAP
if ($this -> LSldapConnect()) {
+
// topDn
if ( $_POST['LSsession_topDn'] != '' ){
$this -> topDn = $_POST['LSsession_topDn'];
@@ -275,6 +290,7 @@ class LSsession {
else {
$this -> topDn = $this -> ldapServer['ldap_config']['basedn'];
}
+ $_SESSION['LSsession_topDn']=$this -> topDn;
if ( $this -> loadLSobject($this -> ldapServer['authobject']) ) {
$authobject = new $this -> ldapServer['authobject']();
@@ -315,6 +331,10 @@ class LSsession {
$GLOBALS['LSerror'] -> addErrorCode(1009);
}
}
+ if ($this -> ldapServerId) {
+ $GLOBALS['Smarty'] -> assign('ldapServerId',$this -> ldapServerId);
+ }
+ $GLOBALS['Smarty'] -> assign('topDn',$this -> topDn);
$this -> displayLoginForm();
return;
}
@@ -348,7 +368,7 @@ class LSsession {
*/
function LSldapConnect() {
if ($this -> ldapServer) {
- include_once($GLOBALS['LSconfig']['NetLDAP']);
+ include_once($GLOBALS['LSconfig']['NetLDAP2']);
if (!$this -> loadLSclass('LSldap'))
return;
$GLOBALS['LSldap'] = new LSldap($this -> ldapServer['ldap_config']);
@@ -370,19 +390,46 @@ class LSsession {
* @retval mixed Tableau des subDn, false si une erreur est survenue.
*/
function getSubDnLdapServer() {
- if ( isset($this ->ldapServer['subdnobject']) ) {
- if( $this -> loadLSobject($this ->ldapServer['subdnobject']) ) {
- if ($subdnobject = new $this ->ldapServer['subdnobject']()) {
- return $subdnobject -> getSelectArray();
+ if ( is_array($this ->ldapServer['subDn']) ) {
+ $return=array();
+ foreach($this ->ldapServer['subDn'] as $subDn_name => $subDn_config) {
+ if ($subDn_name == 'LSobject') {
+ if (is_array($subDn_config)) {
+ foreach($subDn_config as $LSobject_name => $LSoject_topDn) {
+ if ($LSoject_topDn) {
+ $topDn = $LSoject_topDn;
+ }
+ else {
+ $topDn = NULL;
+ }
+ if( $this -> loadLSobject($LSobject_name) ) {
+ if ($subdnobject = new $LSobject_name()) {
+ $tbl_return = $subdnobject -> getSelectArray($topDn);
+ if (is_array($tbl_return)) {
+ $return=array_merge($return,$tbl_return);
+ }
+ else {
+ $GLOBALS['LSerror'] -> addErrorCode(1017);
+ }
+ }
+ else {
+ $GLOBALS['LSerror'] -> addErrorCode(1017);
+ }
+ }
+ else {
+ $GLOBALS['LSerror'] -> addErrorCode(1004,$LSobject_name);
+ }
+ }
+ }
+ else {
+ $GLOBALS['LSerror'] -> addErrorCode(1017);
+ }
}
else {
- return;
+ $return[$subDn_config] = $subDn_name;
}
}
- else {
- $GLOBALS['LSerror'] -> addErrorCode(1004,$this ->ldapServer['subdnobject']);
- return;
- }
+ return $return;
}
else {
return;
@@ -393,29 +440,38 @@ class LSsession {
* Retourne les options d'une liste déroulante pour le choix du topDn
* de connexion au serveur Ldap
*
- * Liste les subdnobject ($this ->ldapServer['subdnobject'])
+ * Liste les subdn ($this ->ldapServer['subDn'])
*
* @retval string Les options (\n";
}
- else {
- $GLOBALS['LSerror'] -> addErrorCode(1004,$this ->ldapServer['subdnobject']);
- return;
- }
- }
- else {
- return;
+ return $display;
}
+ return;
+ }
+
+ function validSubDnLdapServer($subDn) {
+ $listTopDn = $this -> getSubDnLdapServer();
+ if(is_array($listTopDn)) {
+ foreach($listTopDn as $dn => $txt) {
+ if ($subDn==$dn) {
+ return true;
+ } // end if
+ } // end foreach
+ } // end if
+ return;
}
/*
@@ -455,15 +511,6 @@ class LSsession {
$GLOBALS['Smarty'] -> assign('loginform_ldapservers_name',$ldapservers_name);
$GLOBALS['Smarty'] -> assign('loginform_ldapservers_index',$ldapservers_index);
- $this -> setLdapServer(0);
- if ( $this -> LSldapConnect() ) {
- $topDn_array = $this -> getSubDnLdapServer();
- if ( $topDn_array ) {
- $GLOBALS['Smarty'] -> assign('loginform_topdn_name',$topDn_array['display']);
- $GLOBALS['Smarty'] -> assign('loginform_topdn_index',$topDn_array['dn']);
- }
- }
-
$GLOBALS['Smarty'] -> assign('loginform_label_level',_('Niveau'));
$GLOBALS['Smarty'] -> assign('loginform_label_user',_('Identifiant'));
$GLOBALS['Smarty'] -> assign('loginform_label_pwd',_('Mot de passe'));
@@ -550,7 +597,22 @@ class LSsession {
$GLOBALS['Smarty'] -> assign('LSsession_css',$Css_txt);
$GLOBALS['Smarty'] -> assign('LSaccess',$this -> LSaccess);
-
+
+ // Niveau
+ $listTopDn = $this -> getSubDnLdapServer();
+ if (is_array($listTopDn)) {
+ $GLOBALS['Smarty'] -> assign('label_level',_('Niveau'));
+ $LSsession_topDn_index = array();
+ $LSsession_topDn_name = array();
+ foreach($listTopDn as $index => $name) {
+ $LSsession_topDn_index[] = $index;
+ $LSsession_topDn_name[] = $name;
+ }
+ $GLOBALS['Smarty'] -> assign('LSsession_topDn_index',$LSsession_topDn_index);
+ $GLOBALS['Smarty'] -> assign('LSsession_topDn_name',$LSsession_topDn_name);
+ $GLOBALS['Smarty'] -> assign('LSsession_topDn',$this -> topDn);
+ }
+
$GLOBALS['LSerror'] -> display();
debug_print();
if (!$this -> template)
@@ -791,7 +853,7 @@ class LSsession {
if (!isset($GLOBALS['LSobjects'][$LSobject]['relations'][$relationName]))
return;
$whoami = $this -> whoami($dn);
-
+
if (($right=='w') || ($right=='r')) {
if ($GLOBALS['LSobjects'][$LSobject]['relations'][$relationName]['rights'][$whoami] == $right) {
return true;
diff --git a/trunk/includes/functions.php b/trunk/includes/functions.php
index c424f008..c4060d05 100644
--- a/trunk/includes/functions.php
+++ b/trunk/includes/functions.php
@@ -122,7 +122,7 @@ function debug($data,$get=true) {
return true;
}
-function debug_print() {
+function debug_print($return=false) {
if (( $GLOBALS['LSdebug']['fields'] ) && ( $GLOBALS['LSdebug']['active'] )) {
$txt='';
foreach($GLOBALS['LSdebug']['fields'] as $debug) {
@@ -135,7 +135,11 @@ function debug_print() {
}
$txt.='
';
$GLOBALS['Smarty'] -> assign('LSdebug',$txt);
+ if ($return) {
+ return $txt;
+ }
}
+ return;
}
/**
diff --git a/trunk/includes/js/LSdefault.js b/trunk/includes/js/LSdefault.js
index 96e68aa6..0cb34ecc 100644
--- a/trunk/includes/js/LSdefault.js
+++ b/trunk/includes/js/LSdefault.js
@@ -18,6 +18,15 @@ var LSdefault = new Class({
this.loading_img=[];
LSdebug(this.loading_img);
this.loading_img_id=-1;
+
+ this.LSsession_topDn = $('LSsession_topDn');
+ if (this.LSsession_topDn) {
+ this.LSsession_topDn.addEvent('change',this.onLSsession_topDnChange.bind(this));
+ }
+ },
+
+ onLSsession_topDnChange: function() {
+ $('LSsession_topDn_form').submit();
},
onLSdebugHiddenClick: function(event){
@@ -36,6 +45,12 @@ var LSdefault = new Class({
this.displayLSerror();
},
+ displayDebug: function(html) {
+ this.LSdebug.empty();
+ this.LSdebug.setHTML(html);
+ this.displayDebugBox();
+ },
+
displayLSerror: function() {
this.LSerror.setStyle('top',getScrollTop()+10);
new Fx.Style(this.LSerror,'opacity',{duration:500}).start(0,0.8);
diff --git a/trunk/includes/js/LSselect.js b/trunk/includes/js/LSselect.js
index e89e571a..3d443e61 100644
--- a/trunk/includes/js/LSselect.js
+++ b/trunk/includes/js/LSselect.js
@@ -10,6 +10,8 @@ var LSselect = new Class({
el.addEvent('submit',this.onSubmitSearchForm.bindWithEvent(this,el));
}, this);
+ this.LSselect_topDn = $('LSselect_topDn');
+ this.LSselect_topDn.addEvent('change',this.onChangeLSselect_topDn.bind(this));
},
initializeContent: function() {
@@ -66,8 +68,17 @@ var LSselect = new Class({
this.initializeContent();
},
+ onChangeLSselect_topDn: function() {
+ form = this.LSselect_topDn.getParent().getParent();
+ this.submitSearchForm(form);
+ },
+
onSubmitSearchForm: function(event, form) {
new Event(event).stop();
+ this.submitSearchForm(form);
+ },
+
+ submitSearchForm: function(form) {
var imgload = varLSdefault.loadingImgDisplay($('title'),'inside');
form.send({
update: $('content'),
diff --git a/trunk/includes/js/LSsession_login.js b/trunk/includes/js/LSsession_login.js
index 22fe52d9..02359d95 100644
--- a/trunk/includes/js/LSsession_login.js
+++ b/trunk/includes/js/LSsession_login.js
@@ -4,6 +4,7 @@ var LSsession_login = new Class({
if ( ! this.select_ldapserver )
return;
this.select_ldapserver.addEvent('change',this.onLdapServerChanged.bind(this));
+ this.onLdapServerChanged();
},
onLdapServerChanged: function(){
@@ -23,11 +24,14 @@ var LSsession_login = new Class({
var data = Json.evaluate(responseText);
LSdebug(data);
if ( data ) {
+ if (data.LSdebug) {
+ varLSdefault.displayDebug(data.LSdebug);
+ }
if (data.LSerror) {
varLSdefault.displayError(data.LSerror);
return;
}
- else {
+ if (data.list_topDn) {
$('LSsession_topDn').getParent().setHTML(data.list_topDn);
LSdebug($('LSsession_topDn').innerHTML);
$$('.loginform-level').each(function(el) {
diff --git a/trunk/index_ajax.php b/trunk/index_ajax.php
index a055adb8..2aef553c 100644
--- a/trunk/index_ajax.php
+++ b/trunk/index_ajax.php
@@ -4,7 +4,6 @@ require_once 'includes/functions.php';
require_once 'includes/class/class.LSsession.php';
$GLOBALS['LSsession'] = new LSsession();
-$GLOBALS['LSsession'] -> loadLSobjects();
if ($_REQUEST['template'] != 'login') {
if ( !$GLOBALS['LSsession'] -> startLSsession() ) {
@@ -19,7 +18,9 @@ switch($_REQUEST['template']) {
if ( isset($_REQUEST['server']) ) {
$GLOBALS['LSsession'] -> setLdapServer($_REQUEST['server']);
if ( $GLOBALS['LSsession'] -> LSldapConnect() ) {
- $list = $GLOBALS['LSsession'] -> getSubDnLdapServerOptions();
+ session_start();
+ $GLOBALS['LSsession'] -> loadLSobjects();
+ $list = $GLOBALS['LSsession'] -> getSubDnLdapServerOptions($_SESSION['LSsession_topDn']);
if (is_string($list)) {
$list="";
$data = array('list_topDn' => $list, 'imgload' => $_REQUEST['imgload']);
@@ -300,5 +301,10 @@ if ($GLOBALS['LSerror']->errorsDefined()) {
$data['LSerror'] = $GLOBALS['LSerror']->getErrors();
}
+$debug_txt = debug_print(true);
+if ($debug_txt != "") {
+ $data['LSdebug'] = $debug_txt;
+}
+
echo json_encode($data);
?>
diff --git a/trunk/select.php b/trunk/select.php
index 592bd4b5..d885b333 100644
--- a/trunk/select.php
+++ b/trunk/select.php
@@ -57,20 +57,27 @@ if($LSsession -> startLSsession()) {
$filter=NULL;
$GLOBALS['Smarty']->assign('LSobject_list_filter','');
}
-
- $list=$object -> listObjects($filter);
+
+ $topDn = $object -> config['container_dn'].','.$GLOBALS['LSsession'] -> topDn;
+ if(isset($_REQUEST['LSselect_topDn'])) {
+ if ($GLOBALS['LSsession'] -> validSubDnLdapServer($_REQUEST['LSselect_topDn'])) {
+ $topDn = $object -> config['container_dn'].','.$_REQUEST['LSselect_topDn'];
+ }
+ }
+
+ $list=$object -> listObjects($filter,$topDn);
$nbObjects=count($list);
- if ($nbObjects > NB_LSOBJECT_LIST) {
+ if ($nbObjects > NB_LSOBJECT_LIST_SELECT) {
if (isset($_GET['page'])) {
- $list = array_slice($list, ($_GET['page']) * NB_LSOBJECT_LIST, NB_LSOBJECT_LIST);
+ $list = array_slice($list, ($_GET['page']) * NB_LSOBJECT_LIST_SELECT, NB_LSOBJECT_LIST_SELECT);
$GLOBALS['Smarty']->assign('LSobject_list_currentpage',$_GET['page']);
- $GLOBALS['Smarty']->assign('LSobject_list_nbpage',ceil($nbObjects / NB_LSOBJECT_LIST));
+ $GLOBALS['Smarty']->assign('LSobject_list_nbpage',ceil($nbObjects / NB_LSOBJECT_LIST_SELECT));
}
else {
- $list = array_slice($list, 0, NB_LSOBJECT_LIST);
+ $list = array_slice($list, 0, NB_LSOBJECT_LIST_SELECT);
$GLOBALS['Smarty']->assign('LSobject_list_currentpage',0);
- $GLOBALS['Smarty']->assign('LSobject_list_nbpage',ceil($nbObjects / NB_LSOBJECT_LIST));
+ $GLOBALS['Smarty']->assign('LSobject_list_nbpage',ceil($nbObjects / NB_LSOBJECT_LIST_SELECT));
}
}
$c=0;
diff --git a/trunk/templates/css/LSdefault.css b/trunk/templates/css/LSdefault.css
index 36496fcc..7b4d2661 100644
--- a/trunk/templates/css/LSdefault.css
+++ b/trunk/templates/css/LSdefault.css
@@ -1,28 +1,28 @@
#LSerror {
- width: 50%;
- position: absolute;
- top: 10px;
- left: 10px;
- background-color: #f00;
- visibility: hidden;
- color: #fff;
- z-index: 100;
+ width: 50%;
+ position: absolute;
+ top: 10px;
+ left: 10px;
+ background-color: #f00;
+ visibility: hidden;
+ color: #fff;
+ z-index: 100;
}
#LSdebug {
- width: 50%;
- position: absolute;
- top: 10px;
- left: 50%;
- background-color: #84ff6a;
- visibility: hidden;
- color: #fff;
- z-index: 100;
+ width: 50%;
+ position: absolute;
+ top: 10px;
+ left: 50%;
+ background-color: #84ff6a;
+ visibility: hidden;
+ color: #fff;
+ z-index: 100;
}
#LSdebug_hidden {
- float: right;
- color: #fff;
- text-decoration: none;
- font-weight: bold;
+ float: right;
+ color: #fff;
+ text-decoration: none;
+ font-weight: bold;
}
diff --git a/trunk/templates/css/LSform.css b/trunk/templates/css/LSform.css
index 69374d13..29ea7674 100644
--- a/trunk/templates/css/LSform.css
+++ b/trunk/templates/css/LSform.css
@@ -38,6 +38,10 @@ ul.LSform {
margin: 0;
}
+li.LSform {
+ overflow: auto;
+}
+
.LSform-errors {
color: #fff;
background-color: #f59a67;
diff --git a/trunk/templates/css/LSsmoothbox.css b/trunk/templates/css/LSsmoothbox.css
index 15487c81..afd0d61a 100644
--- a/trunk/templates/css/LSsmoothbox.css
+++ b/trunk/templates/css/LSsmoothbox.css
@@ -26,3 +26,7 @@
margin-bottom: 0;
font-size: 100%;
}
+
+#frame-LSsmoothbox {
+ overflow: auto;
+}
diff --git a/trunk/templates/css/base.css b/trunk/templates/css/base.css
index 52f9f406..cbc08b7e 100644
--- a/trunk/templates/css/base.css
+++ b/trunk/templates/css/base.css
@@ -65,6 +65,18 @@ hr {
padding: 0.3em;
}
+
+#LSsession_topDn {
+ height: 1.5em;
+}
+
+#LSsession_topDn_form {
+ float: left;
+ font-size: 0.7em;
+ color: #fff;
+
+}
+
#user_name {
font-weight: bold;
}
@@ -213,6 +225,14 @@ form.LSview_search {
margin-right: 2em;
}
+form.LSselect_search {
+ float: none;
+}
+
+div.LSselect_search {
+ float: right;
+}
+
label.LSview_search {
font-size: 0.6em;
display: block;
@@ -242,6 +262,13 @@ div.LSobject-select {
width: 10px;
}
+#LSselect_topDn_label {
+ float: left;
+ font-size: 0.8em;
+ margin-left: 1em;
+ margin-top: 0.5em;
+}
+
form.LSselect_search {
margin-top: 0.5em;
}
diff --git a/trunk/templates/login.tpl b/trunk/templates/login.tpl
index 69df4942..4a85c33f 100644
--- a/trunk/templates/login.tpl
+++ b/trunk/templates/login.tpl
@@ -21,10 +21,10 @@
- {$loginform_label_ldapserver}
-
-
+
- {$loginform_label_level}
-
+
- {$loginform_label_user}
- {$loginform_label_pwd}
diff --git a/trunk/templates/select.tpl b/trunk/templates/select.tpl
index c231ddb7..66879e3a 100644
--- a/trunk/templates/select.tpl
+++ b/trunk/templates/select.tpl
@@ -1,13 +1,23 @@
-
{$pagetitle}
+
{include file='select_table.tpl'}
diff --git a/trunk/templates/top.tpl b/trunk/templates/top.tpl
index 88eb1c69..b6513de6 100644
--- a/trunk/templates/top.tpl
+++ b/trunk/templates/top.tpl
@@ -27,4 +27,17 @@
-
Connecté en tant que {$LSsession_username}
+
+
+ {if $LSsession_topDn!=""}
+
+ {/if}
+
+ Connecté en tant que {$LSsession_username}
+
diff --git a/trunk/view.php b/trunk/view.php
index 076f6db8..bafdefbc 100644
--- a/trunk/view.php
+++ b/trunk/view.php
@@ -99,23 +99,27 @@ if($LSsession -> startLSsession()) {
$GLOBALS['LSsession'] -> addJSscript('LSsmoothbox.js');
$GLOBALS['LSsession'] -> addCssFile('LSsmoothbox.css');
$GLOBALS['LSsession'] -> addJSscript('LSrelation.js');
-
- 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();
+ 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();
}
}
else {
- $return['objectList']=array();
+ $GLOBALS['LSerror'] -> addErrorCode(1013,$relationName);
}
+ $LSrelations[]=$return;
}
else {
- $GLOBALS['LSerror'] -> addErrorCode(1013,$relationName);
+ $GLOBALS['LSerror'] -> addErrorCode(1016,array('relation' => $relationName,'LSobject' => $relationConf['LSobject']));
}
- $LSrelations[]=$return;
}
}
$GLOBALS['Smarty'] -> assign('LSrelations',$LSrelations);
@@ -168,8 +172,10 @@ if($LSsession -> startLSsession()) {
$filter=NULL;
$GLOBALS['Smarty']->assign('LSobject_list_filter','');
}
-
- $list=$object -> listObjects($filter);
+
+ $topDn = $object -> config['container_dn'].','.$GLOBALS['LSsession'] -> topDn;
+
+ $list=$object -> listObjects($filter,$topDn);
$nbObjects=count($list);
$GLOBALS['Smarty']->assign('LSobject_list_nbresult',$nbObjects);
if ($nbObjects > NB_LSOBJECT_LIST) {
@@ -211,7 +217,7 @@ if($LSsession -> startLSsession()) {
);
}
- if ($GLOBALS['LSsession'] -> canRemove($thisObject -> getType(),$GLOBALS['LSsession']-> LSuserObject -> getValue('dn'))) {
+ if ($GLOBALS['LSsession'] -> canRemove($thisObject -> getType(),$thisObject -> getValue('dn'))) {
$actions[] = array (
'label' => _('Supprimer'),
'url' => 'remove.php?LSobject='.$_REQUEST['LSobject'].'&dn='.$thisObject -> getValue('dn'),