- LSldapObject : Ajout des méthodes suivantes :

-> getSubDnValue()
  -> getSubDnName()
- LSview/LSselect : utilisation de la méthode getSubDnName() plutôt que le
  code en local
- config.inc.php :
  -> Modification du paramètre ldapServer['subDn']
  -> Ajout du paramètre LSaccess pour la composition du menu hors config subDn
  -> Suppression ldapServer['LSobjets'] : suppression du pré-chargement
     (cf.ci-dessous)
- LSsession :
  -> Rédéfinition de la méthode de construction du menu de l'interface
     (bug #1665)
  -> Mise en cache de LSaccess
  -> top.tpl : le bouton de rafraichissement subDn devient un bouton de
     rafraichissement génerale de LSsession (config / LSaccess / subDn)
  -> Suppression du pré-chargement des objets et donc de la méthode
     loadLSobjects()
  -> Ajout d'une méthode in_menu() utilisé entre par la méthode canAccess()
     pour valider les accès aux objets
- create.php : Correction d'un bug de chargement d'objet.
- config.error_code.php : Correction bug encodage
- index_ajax.php :
  -> Correction de bugs de chargement d'objets
  -> Suppression du code de gestion des retours d'erreur multiplié et inutile
This commit is contained in:
Benjamin Renard 2008-06-21 16:16:15 +00:00
parent a8931db30d
commit 7f82e8eb49
9 changed files with 657 additions and 557 deletions

View file

@ -248,7 +248,7 @@ $GLOBALS['LSerror_code'] = array (
'level' => 'c' 'level' => 'c'
), ),
1011 => array ( 1011 => array (
'msg' => _("LSsession : Vous n'êtes pas authorisé à effectuer cette action."), 'msg' => _("LSsession : Vous n'êtes pas authorisé à  effectuer cette action."),
'level' => 'c' 'level' => 'c'
), ),
1012 => array ( 1012 => array (

View file

@ -54,10 +54,15 @@ $GLOBALS['LSconfig'] = array(
) )
) )
), ),
'cacheLSrights' => false, 'cacheLSrights' => true,
'cacheSearch' => true, 'cacheSearch' => true,
'authobject' => 'LSeepeople', 'authobject' => 'LSeepeople',
'authobject_pwdattr' => 'userPassword', 'authobject_pwdattr' => 'userPassword',
'LSaccess' => array(
'LSeepeople',
'LSeegroup',
'LSeecompany'
),
'recoverPassword' => array( 'recoverPassword' => array(
'mailAttr' => 'mail', 'mailAttr' => 'mail',
'recoveryHashAttr' => 'lsRecoveryHash', 'recoveryHashAttr' => 'lsRecoveryHash',
@ -71,12 +76,7 @@ $GLOBALS['LSconfig'] = array(
'msg' => "Votre nouveau mot de passe : %{mdp}" 'msg' => "Votre nouveau mot de passe : %{mdp}"
) )
), ),
'emailSender' => 'noreply@lsexample.net', 'emailSender' => 'noreply@lsexample.net'
'LSobjects' => array (
'LSeepeople',
'LSeegroup',
'LSeecompany'
)
) )
) )
); );

View file

@ -36,7 +36,7 @@ if($LSsession -> startLSsession()) {
if (isset($LSobject)) { if (isset($LSobject)) {
// Création d'un LSobject // Création d'un LSobject
if (class_exists($LSobject)) { if ($GLOBALS['LSsession'] -> loadLSobject($LSobject)) {
if ( $GLOBALS['LSsession'] -> canCreate($LSobject) ) { if ( $GLOBALS['LSsession'] -> canCreate($LSobject) ) {
$object = new $LSobject(); $object = new $LSobject();

View file

@ -40,6 +40,7 @@ class LSldapObject {
var $other_values=array(); var $other_values=array();
var $submitError=true; var $submitError=true;
var $_whoami=NULL; var $_whoami=NULL;
var $_subDn_value=NULL;
/** /**
* Constructeur * Constructeur
@ -929,6 +930,38 @@ class LSldapObject {
function isNew() { function isNew() {
return (!$this -> dn); return (!$this -> dn);
} }
/**
* Retourne la valeur (DN) du subDn de l'objet
*
* @return string La valeur du subDn de l'object
*/
function getSubDnValue() {
if ($this -> _subDn_value) {
return $this -> _subDn_value;
}
$dn = $this -> getValue('dn');
$subDn_value='';
$subDnLdapServer = $GLOBALS['LSsession'] -> getSortSubDnLdapServer();
foreach ($subDnLdapServer as $subDn => $subDn_name) {
if (isCompatibleDNs($subDn,$dn)&&($subDn!=$dn)) {
$subDn_value=$subDn;
break;
}
}
$this -> _subDn_value = $subDn_value;
return $subDn_value;
}
/**
* Retourne la nom du subDn de l'objet
*
* @return string Le nom du subDn de l'object
*/
function getSubDnName() {
$subDnLdapServer = $GLOBALS['LSsession'] -> getSortSubDnLdapServer();
return $subDnLdapServer[$this -> getSubDnValue()];
}
} }
?> ?>

View file

@ -144,31 +144,6 @@ class LSsession {
return true; return true;
} }
/**
* Chargement des objects LdapSaisie
*
* Chargement des LSobjects contenue dans la variable
* $this -> ldapServer['LSobjects']
*
* @retval boolean true si le chargement a réussi, false sinon.
*/
function loadLSobjects() {
$this -> loadLSclass('LSldapObject');
if(!is_array($this -> ldapServer['LSobjects'])) {
$GLOBALS['LSerror'] -> addErrorCode(1001,"LSobjects['loads']");
return;
}
foreach ($this -> ldapServer['LSobjects'] as $object) {
if ( !$this -> loadLSobject($object) ) {
return;
}
}
return true;
}
/** /**
* Chargement d'un addons d'LdapSaisie * Chargement d'un addons d'LdapSaisie
* *
@ -245,30 +220,36 @@ class LSsession {
$this -> ldapServerId = $_SESSION['LSsession']['ldapServerId']; $this -> ldapServerId = $_SESSION['LSsession']['ldapServerId'];
$this -> tmp_file = $_SESSION['LSsession']['tmp_file']; $this -> tmp_file = $_SESSION['LSsession']['tmp_file'];
if ( $this -> cacheLSrights() ) { if ( $this -> cacheLSrights() && !isset($_REQUEST['LSsession_refresh']) ) {
$this -> ldapServer = $_SESSION['LSsession']['ldapServer']; $this -> ldapServer = $_SESSION['LSsession']['ldapServer'];
$this -> LSrights = $_SESSION['LSsession']['LSrights']; $this -> LSrights = $_SESSION['LSsession']['LSrights'];
$this -> LSaccess = $_SESSION['LSsession']['LSaccess']; $this -> LSaccess = $_SESSION['LSsession']['LSaccess'];
if (!$this -> LSldapConnect()) if (!$this -> LSldapConnect())
return; return;
$this -> loadLSobjects();
} }
else { else {
$this -> setLdapServer($this -> ldapServerId); $this -> setLdapServer($this -> ldapServerId);
if (!$this -> LSldapConnect()) if (!$this -> LSldapConnect())
return; return;
$this -> loadLSobjects();
$this -> loadLSrights(); $this -> loadLSrights();
} }
if ( $this -> cacheSudDn() && (!isset($_REQUEST['LSsession_topDn_refresh'])) ) { if ( $this -> cacheSudDn() && (!isset($_REQUEST['LSsession_refresh'])) ) {
$this -> _subDnLdapServer = $_SESSION['LSsession_subDnLdapServer']; $this -> _subDnLdapServer = $_SESSION['LSsession_subDnLdapServer'];
} }
$this -> loadLSobject($this -> ldapServer['authobject']); if (!$this -> loadLSobject($this -> ldapServer['authobject'])) {
$GLOBALS['LSerror'] -> addErrorCode(1004,$this -> ldapServer['authobject']);
return;
}
$this -> LSuserObject = new $this -> ldapServer['authobject'](); $this -> LSuserObject = new $this -> ldapServer['authobject']();
$this -> LSuserObject -> loadData($this -> dn); $this -> LSuserObject -> loadData($this -> dn);
if ( !$this -> cacheLSrights() || isset($_REQUEST['LSsession_refresh']) ) {
$this -> loadLSaccess(); $this -> loadLSaccess();
}
$GLOBALS['Smarty'] -> assign('LSsession_username',$this -> LSuserObject -> getDisplayValue()); $GLOBALS['Smarty'] -> assign('LSsession_username',$this -> LSuserObject -> getDisplayValue());
if ($_POST['LSsession_topDn']) { if ($_POST['LSsession_topDn']) {
@ -293,8 +274,6 @@ class LSsession {
$this -> setLdapServer(0); $this -> setLdapServer(0);
} }
$this -> loadLSobjects();
// Connexion au serveur LDAP // Connexion au serveur LDAP
if ($this -> LSldapConnect()) { if ($this -> LSldapConnect()) {
@ -564,9 +543,9 @@ class LSsession {
foreach($this ->ldapServer['subDn'] as $subDn_name => $subDn_config) { foreach($this ->ldapServer['subDn'] as $subDn_name => $subDn_config) {
if ($subDn_name == 'LSobject') { if ($subDn_name == 'LSobject') {
if (is_array($subDn_config)) { if (is_array($subDn_config)) {
foreach($subDn_config as $LSobject_name => $LSoject_topDn) { foreach($subDn_config as $LSobject_name => $LSoject_config) {
if ($LSoject_topDn) { if ($LSoject_config['topDn']) {
$topDn = $LSoject_topDn; $topDn = $LSoject_config['topDn'];
} }
else { else {
$topDn = NULL; $topDn = NULL;
@ -595,7 +574,9 @@ class LSsession {
} }
} }
else { else {
$return[$subDn_config] = $subDn_name; if ((isCompatibleDNs($subDn_config['dn'],$this -> ldapServer['ldap_config']['basedn']))&&($subDn_config['dn']!="")) {
$return[$subDn_config['dn']] = $subDn_name;
}
} }
} }
if ($this -> cacheSudDn()) { if ($this -> cacheSudDn()) {
@ -616,15 +597,11 @@ class LSsession {
* @return array() Tableau des subDn trié * @return array() Tableau des subDn trié
*/ */
function getSortSubDnLdapServer() { function getSortSubDnLdapServer() {
if(isset($_SESSION['LSsession']['LSview_subDnLdapServer']) && $this -> cacheSudDn()) {
return $_SESSION['LSsession']['LSview_subDnLdapServer'];
}
$subDnLdapServer = $this -> getSubDnLdapServer(); $subDnLdapServer = $this -> getSubDnLdapServer();
if (!$subDnLdapServer) { if (!$subDnLdapServer) {
return array(); return array();
} }
uksort($subDnLdapServer,"compareDn"); uksort($subDnLdapServer,"compareDn");
$_SESSION['LSsession']['LSview_subDnLdapServer']=$subDnLdapServer;
return $subDnLdapServer; return $subDnLdapServer;
} }
@ -851,7 +828,7 @@ class LSsession {
} }
$GLOBALS['Smarty'] -> assign('LSsession_css',$Css_txt); $GLOBALS['Smarty'] -> assign('LSsession_css',$Css_txt);
$GLOBALS['Smarty'] -> assign('LSaccess',$this -> LSaccess); $GLOBALS['Smarty'] -> assign('LSaccess',$this -> LSaccess[$this -> topDn]);
// Niveau // Niveau
$listTopDn = $this -> getSubDnLdapServer(); $listTopDn = $this -> getSubDnLdapServer();
@ -942,26 +919,91 @@ class LSsession {
* @retval void * @retval void
*/ */
function loadLSaccess() { function loadLSaccess() {
if ($this -> canAccess($this -> LSuserObject -> getType(),$this -> dn)) { $LSaccess=array();
$LSaccess = array( if (is_array($this -> ldapServer['subDn'])) {
'SELF' => array( foreach($this -> ldapServer['subDn'] as $name => $config) {
'label' => _('Mon compte'), if ($name=='LSobject') {
'DNs' => $this -> dn if (is_array($config)) {
)
); // Définition des subDns
foreach($config as $objectType => $objectConf) {
if ($this -> loadLSobject($objectType)) {
if ($subdnobject = new $objectType()) {
$tbl = $subdnobject -> getSelectArray();
if (is_array($tbl)) {
// Définition des accès
$access=array();
if (is_array($objectConf['LSobjects'])) {
foreach($objectConf['LSobjects'] as $type) {
if ($this -> loadLSobject($type)) {
if ($this -> canAccess($type)) {
$access[$type] = $GLOBALS['LSobjects'][$type]['label'];
}
} }
else { else {
$LSaccess = array(); $GLOBALS['LSerror'] -> addErrorCode(1004,$type);
} }
foreach ($GLOBALS['LSobjects'] as $objecttype => $objectconf) { }
if ($this -> canAccess($objecttype) ) { }
$LSaccess[$objecttype] = array ( foreach($tbl as $dn => $dn_name) {
'label' => $objectconf['label'], $LSaccess[$dn]=$access;
'Dns' => 'All' }
}
}
}
else {
$GLOBALS['LSerror'] -> addErrorCode(1004,$objectType);
}
}
}
}
else {
if ((isCompatibleDNs($this -> ldapServer['ldap_config']['basedn'],$config['dn']))&&($config['dn']!='')) {
$access=array();
if (is_array($config['LSobjects'])) {
foreach($config['LSobjects'] as $objectType) {
if ($this -> loadLSobject($objectType)) {
if ($this -> canAccess($objectType)) {
$access[$objectType] = $GLOBALS['LSobjects'][$objectType]['label'];
}
}
else {
$GLOBALS['LSerror'] -> addErrorCode(1004,$LSobject_name);
}
}
}
$LSaccess[$config['dn']]=$access;
}
}
}
}
else {
if(is_array($this -> ldapServer['LSaccess'])) {
$access=array();
foreach($this -> ldapServer['LSaccess'] as $objectType) {
if ($this -> loadLSobject($objectType)) {
if ($this -> canAccess($objectType)) {
$access[$objectType] = $GLOBALS['LSobjects'][$objectType]['label'];
}
}
else {
$GLOBALS['LSerror'] -> addErrorCode(1004,$LSobject_name);
}
}
$LSaccess[$this -> topDn] = $access;
}
}
foreach($LSaccess as $dn => $access) {
$LSaccess[$dn] = array_merge(
array(
'SELF' => _('Mon compte')
),
$access
); );
} }
}
$this -> LSaccess = $LSaccess; $this -> LSaccess = $LSaccess;
$_SESSION['LSsession']['LSaccess'] = $LSaccess;
} }
/** /**
@ -1013,10 +1055,24 @@ class LSsession {
* @retval boolean True si l'utilisateur a accès, false sinon * @retval boolean True si l'utilisateur a accès, false sinon
*/ */
function canAccess($LSobject,$dn=NULL,$right=NULL,$attr=NULL) { function canAccess($LSobject,$dn=NULL,$right=NULL,$attr=NULL) {
if (!$this -> loadLSobject($LSobject)) if (!$this -> loadLSobject($LSobject)) {
$GLOBALS['LSerror'] -> addErrorCode(1004,$LSobject);
return; return;
}
if ($dn) { if ($dn) {
$whoami = $this -> whoami($dn); $whoami = $this -> whoami($dn);
if ($dn==$this -> LSuserObject -> getValue('dn')) {
if (!$this -> in_menu('SELF')) {
return;
}
}
else {
$obj = new $LSobject();
$obj -> dn = $dn;
if (!$this -> in_menu($LSobject,$obj -> getSubDnValue())) {
return;
}
}
} }
else { else {
$objectdn=$GLOBALS['LSobjects'][$LSobject]['container_dn'].','.$this -> topDn; $objectdn=$GLOBALS['LSobjects'][$LSobject]['container_dn'].','.$this -> topDn;
@ -1272,7 +1328,7 @@ class LSsession {
* *
* @param[in] $subDn string subDn * @param[in] $subDn string subDn
* *
* @return string Le nom du subDn ou '' sinon * @retval string Le nom du subDn ou '' sinon
*/ */
function getSubDnName($subDn=false) { function getSubDnName($subDn=false) {
if (!$subDn) { if (!$subDn) {
@ -1291,10 +1347,9 @@ class LSsession {
* *
* @param[in] $type string Le type d'objet * @param[in] $type string Le type d'objet
* *
* @return boolean true si le type d'objet est un subDnObject, false sinon * @retval boolean true si le type d'objet est un subDnObject, false sinon
*/ */
function isSubDnLSobject($type) { function isSubDnLSobject($type) {
debug('seach : '.$type);
$result = false; $result = false;
if (is_array($this -> ldapServer['subDn']['LSobject'])) { if (is_array($this -> ldapServer['subDn']['LSobject'])) {
foreach($this -> ldapServer['subDn']['LSobject'] as $key => $value) { foreach($this -> ldapServer['subDn']['LSobject'] as $key => $value) {
@ -1305,6 +1360,18 @@ class LSsession {
} }
return $result; return $result;
} }
/**
* Retourne si un type d'objet est dans le menu courant
*
* @retval boolean true si le type d'objet est dans le menu, false sinon
*/
function in_menu($LSobject,$topDn=NULL) {
if (!$topDn) {
$topDn=$this -> topDn;
}
return isset($this -> LSaccess[$topDn][$LSobject]);
}
} }
?> ?>

View file

@ -20,7 +20,6 @@ if (!isset($_ERRORS)) {
$GLOBALS['LSsession'] -> setLdapServer($_REQUEST['server']); $GLOBALS['LSsession'] -> setLdapServer($_REQUEST['server']);
if ( $GLOBALS['LSsession'] -> LSldapConnect() ) { if ( $GLOBALS['LSsession'] -> LSldapConnect() ) {
session_start(); session_start();
$GLOBALS['LSsession'] -> loadLSobjects();
$list = $GLOBALS['LSsession'] -> getSubDnLdapServerOptions($_SESSION['LSsession_topDn']); $list = $GLOBALS['LSsession'] -> getSubDnLdapServerOptions($_SESSION['LSsession_topDn']);
if (is_string($list)) { if (is_string($list)) {
$list="<select name='LSsession_topDn' id='LSsession_topDn'>".$list."</select>"; $list="<select name='LSsession_topDn' id='LSsession_topDn'>".$list."</select>";
@ -29,15 +28,6 @@ if (!isset($_ERRORS)) {
'levelLabel' => $GLOBALS['LSsession'] -> getLevelLabel() 'levelLabel' => $GLOBALS['LSsession'] -> getLevelLabel()
); );
} }
else if (is_array($list)){
$data = array('LSerror' => $GLOBALS['LSerror']->getErrors());
}
else {
$data = null;
}
}
else {
$data = array('LSerror' => $GLOBALS['LSerror']->getErrors());
} }
} }
break; break;
@ -47,6 +37,7 @@ if (!isset($_ERRORS)) {
switch($_REQUEST['action']) { switch($_REQUEST['action']) {
case 'onAddFieldBtnClick': case 'onAddFieldBtnClick':
if ((isset($_REQUEST['attribute'])) && (isset($_REQUEST['objecttype'])) && (isset($_REQUEST['objectdn'])) && (isset($_REQUEST['idform'])) && (isset($_REQUEST['img'])) ) { if ((isset($_REQUEST['attribute'])) && (isset($_REQUEST['objecttype'])) && (isset($_REQUEST['objectdn'])) && (isset($_REQUEST['idform'])) && (isset($_REQUEST['img'])) ) {
if ($GLOBALS['LSsession'] -> loadLSobject($_REQUEST['objecttype'])) {
$object = new $_REQUEST['objecttype'](); $object = new $_REQUEST['objecttype']();
$object -> loadData($_REQUEST['objectdn']); $object -> loadData($_REQUEST['objectdn']);
$form = $object -> getForm($_REQUEST['idform']); $form = $object -> getForm($_REQUEST['idform']);
@ -57,15 +48,16 @@ if (!isset($_ERRORS)) {
'img' => $_REQUEST['img'], 'img' => $_REQUEST['img'],
); );
} }
}
else { else {
$data = array('LSerror' => $GLOBALS['LSerror']->getErrors()); $GLOBALS['LSerror'] -> addErrorCode(1004,$_REQUEST['objecttype']);
} }
} }
break; break;
case 'refreshField': case 'refreshField':
if ((isset($_REQUEST['attribute'])) && (isset($_REQUEST['objecttype'])) && (isset($_REQUEST['objectdn'])) && (isset($_REQUEST['idform'])) ) { if ((isset($_REQUEST['attribute'])) && (isset($_REQUEST['objecttype'])) && (isset($_REQUEST['objectdn'])) && (isset($_REQUEST['idform'])) ) {
if ($GLOBALS['LSsession'] -> loadLSobject($_REQUEST['objecttype'])) {
$object = new $_REQUEST['objecttype'](); $object = new $_REQUEST['objecttype']();
//$object -> loadData($_REQUEST['objectdn']);
$form = $object -> getForm($_REQUEST['idform']); $form = $object -> getForm($_REQUEST['idform']);
$field=$form -> getElement($_REQUEST['attribute']); $field=$form -> getElement($_REQUEST['attribute']);
$val = $field -> getDisplay(true); $val = $field -> getDisplay(true);
@ -74,15 +66,15 @@ if (!isset($_ERRORS)) {
'html' => $val['html'] 'html' => $val['html']
); );
} }
}
else { else {
$data = array( $GLOBALS['LSerror'] -> addErrorCode(1004,$_REQUEST['objecttype']);
'LSerror' => $GLOBALS['LSerror']->getErrors()
);
} }
} }
break; break;
case 'generatePassword': case 'generatePassword':
if ((isset($_REQUEST['attribute'])) && (isset($_REQUEST['objecttype'])) && (isset($_REQUEST['viewBtnId'])) && (isset($_REQUEST['fieldId'])) && (isset($_REQUEST['idform'])) ) { if ((isset($_REQUEST['attribute'])) && (isset($_REQUEST['objecttype'])) && (isset($_REQUEST['viewBtnId'])) && (isset($_REQUEST['fieldId'])) && (isset($_REQUEST['idform'])) ) {
if ($GLOBALS['LSsession'] -> loadLSobject($_REQUEST['objecttype'])) {
$object = new $_REQUEST['objecttype'](); $object = new $_REQUEST['objecttype']();
$form = $object -> getForm($_REQUEST['idform']); $form = $object -> getForm($_REQUEST['idform']);
$field=$form -> getElement($_REQUEST['attribute']); $field=$form -> getElement($_REQUEST['attribute']);
@ -94,15 +86,15 @@ if (!isset($_ERRORS)) {
'viewBtnId' => $_REQUEST['viewBtnId'] 'viewBtnId' => $_REQUEST['viewBtnId']
); );
} }
}
else { else {
$data = array( $GLOBALS['LSerror'] -> addErrorCode(1004,$_REQUEST['objecttype']);
'LSerror' => $GLOBALS['LSerror']->getErrors()
);
} }
} }
break; break;
case 'verifyPassword': case 'verifyPassword':
if ((isset($_REQUEST['attribute'])) && (isset($_REQUEST['objecttype'])) && (isset($_REQUEST['fieldId'])) && (isset($_REQUEST['fieldValue'])) && (isset($_REQUEST['idform'])) && (isset($_REQUEST['objectdn'])) ) { if ((isset($_REQUEST['attribute'])) && (isset($_REQUEST['objecttype'])) && (isset($_REQUEST['fieldId'])) && (isset($_REQUEST['fieldValue'])) && (isset($_REQUEST['idform'])) && (isset($_REQUEST['objectdn'])) ) {
if ($GLOBALS['LSsession'] -> loadLSobject($_REQUEST['objecttype'])) {
$object = new $_REQUEST['objecttype'](); $object = new $_REQUEST['objecttype']();
$form = $object -> getForm($_REQUEST['idform']); $form = $object -> getForm($_REQUEST['idform']);
$object -> loadData($_REQUEST['objectdn']); $object -> loadData($_REQUEST['objectdn']);
@ -113,6 +105,10 @@ if (!isset($_ERRORS)) {
'fieldId' => $_REQUEST['fieldId'] 'fieldId' => $_REQUEST['fieldId']
); );
} }
else {
$GLOBALS['LSerror'] -> addErrorCode(1004,$_REQUEST['objecttype']);
}
}
break; break;
} }
break; break;
@ -126,6 +122,7 @@ if (!isset($_ERRORS)) {
$object = new $conf['objectType'](); $object = new $conf['objectType']();
if (($object -> loadData($conf['objectDn'])) && (isset($object->config['relations'][$conf['relationName']]))) { if (($object -> loadData($conf['objectDn'])) && (isset($object->config['relations'][$conf['relationName']]))) {
$relationConf = $object->config['relations'][$conf['relationName']]; $relationConf = $object->config['relations'][$conf['relationName']];
if ($GLOBALS['LSsession'] -> loadLSobject($relationConf['LSobject'])) {
if ($GLOBALS['LSsession'] -> relationCanEdit($object -> getValue('dn'),$conf['relationName'])) { if ($GLOBALS['LSsession'] -> relationCanEdit($object -> getValue('dn'),$conf['relationName'])) {
if (method_exists($relationConf['LSobject'],$relationConf['list_function'])) { if (method_exists($relationConf['LSobject'],$relationConf['list_function'])) {
$objRel = new $relationConf['LSobject'](); $objRel = new $relationConf['LSobject']();
@ -149,6 +146,10 @@ if (!isset($_ERRORS)) {
$GLOBALS['LSerror'] -> addErrorCode(1011); $GLOBALS['LSerror'] -> addErrorCode(1011);
} }
} }
else {
$GLOBALS['LSerror'] -> addErrorCode(1004,$relationConf['LSobject']);
}
}
else { else {
$GLOBALS['LSerror'] -> addErrorCode(1012); $GLOBALS['LSerror'] -> addErrorCode(1012);
} }
@ -170,6 +171,7 @@ if (!isset($_ERRORS)) {
$object = new $conf['objectType'](); $object = new $conf['objectType']();
if (($object -> loadData($conf['objectDn'])) && (isset($object->config['relations'][$conf['relationName']]))) { if (($object -> loadData($conf['objectDn'])) && (isset($object->config['relations'][$conf['relationName']]))) {
$relationConf = $object->config['relations'][$conf['relationName']]; $relationConf = $object->config['relations'][$conf['relationName']];
if ($GLOBALS['LSsession'] -> loadLSobject($relationConf['LSobject'])) {
if ($GLOBALS['LSsession'] -> relationCanEdit($object -> getValue('dn'),$conf['relationName'])) { if ($GLOBALS['LSsession'] -> relationCanEdit($object -> getValue('dn'),$conf['relationName'])) {
if (is_array($_SESSION['LSselect'][$relationConf['LSobject']])) { if (is_array($_SESSION['LSselect'][$relationConf['LSobject']])) {
if (method_exists($relationConf['LSobject'],$relationConf['update_function'])) { if (method_exists($relationConf['LSobject'],$relationConf['update_function'])) {
@ -204,6 +206,10 @@ if (!isset($_ERRORS)) {
$GLOBALS['LSerror'] -> addErrorCode(1011); $GLOBALS['LSerror'] -> addErrorCode(1011);
} }
} }
else {
$GLOBALS['LSerror'] -> addErrorCode(1004,$relationConf['LSobject']);
}
}
else { else {
$GLOBALS['LSerror'] -> addErrorCode(1012); $GLOBALS['LSerror'] -> addErrorCode(1012);
} }
@ -225,6 +231,7 @@ if (!isset($_ERRORS)) {
$object = new $conf['objectType'](); $object = new $conf['objectType']();
if (($object -> loadData($conf['objectDn'])) && (isset($object->config['relations'][$conf['relationName']]))) { if (($object -> loadData($conf['objectDn'])) && (isset($object->config['relations'][$conf['relationName']]))) {
$relationConf = $object->config['relations'][$conf['relationName']]; $relationConf = $object->config['relations'][$conf['relationName']];
if ($GLOBALS['LSsession'] -> loadLSobject($relationConf['LSobject'])) {
if ($GLOBALS['LSsession'] -> relationCanEdit($object -> getValue('dn'),$conf['relationName'])) { if ($GLOBALS['LSsession'] -> relationCanEdit($object -> getValue('dn'),$conf['relationName'])) {
if (method_exists($relationConf['LSobject'],$relationConf['list_function'])) { if (method_exists($relationConf['LSobject'],$relationConf['list_function'])) {
$objRel = new $relationConf['LSobject'](); $objRel = new $relationConf['LSobject']();
@ -258,6 +265,10 @@ if (!isset($_ERRORS)) {
$GLOBALS['LSerror'] -> addErrorCode(1011); $GLOBALS['LSerror'] -> addErrorCode(1011);
} }
} }
else {
$GLOBALS['LSerror'] -> addErrorCode(1004,$relationConf['LSobject']);
}
}
else { else {
$GLOBALS['LSerror'] -> addErrorCode(1012); $GLOBALS['LSerror'] -> addErrorCode(1012);
} }
@ -316,9 +327,6 @@ if (!isset($_ERRORS)) {
} }
else { else {
$GLOBALS['LSerror'] -> addErrorCode(1012); $GLOBALS['LSerror'] -> addErrorCode(1012);
$data = array(
'LSerror' => $GLOBALS['LSerror']->getErrors()
);
} }
break; break;
} }

View file

@ -36,8 +36,6 @@ if($LSsession -> startLSsession()) {
$GLOBALS['Smarty']->assign('pagetitle',$object -> getLabel()); $GLOBALS['Smarty']->assign('pagetitle',$object -> getLabel());
$GLOBALS['Smarty']->assign('LSobject_list_objectname',$object -> getLabel()); $GLOBALS['Smarty']->assign('LSobject_list_objectname',$object -> getLabel());
$subDnLdapServer = $GLOBALS['LSsession'] -> getSortSubDnLdapServer();
if (isset($_SESSION['LSsession']['LSsearch'][$LSobject])) { if (isset($_SESSION['LSsession']['LSsearch'][$LSobject])) {
$filter = $_SESSION['LSsession']['LSsearch'][$LSobject]['filter']; $filter = $_SESSION['LSsession']['LSsearch'][$LSobject]['filter'];
if (isCompatibleDNs($_SESSION['LSsession']['LSsearch'][$LSobject]['topDn'],$GLOBALS['LSsession'] -> topDn)) { if (isCompatibleDNs($_SESSION['LSsession']['LSsearch'][$LSobject]['topDn'],$GLOBALS['LSsession'] -> topDn)) {
@ -67,6 +65,7 @@ if($LSsession -> startLSsession()) {
$selectedTopDn = $GLOBALS['LSsession'] -> topDn; $selectedTopDn = $GLOBALS['LSsession'] -> topDn;
$orderby = false; $orderby = false;
$ordersense = 'ASC'; $ordersense = 'ASC';
$subDnLdapServer = $GLOBALS['LSsession'] -> getSubDnLdapServer();
$doSubDn = (($subDnLdapServer)&&(!$GLOBALS['LSsession']->isSubDnLSobject($LSobject))); $doSubDn = (($subDnLdapServer)&&(!$GLOBALS['LSsession']->isSubDnLSobject($LSobject)));
} }
@ -211,12 +210,7 @@ if($LSsession -> startLSsession()) {
$subDn_name=false; $subDn_name=false;
if ($doSubDn) { if ($doSubDn) {
reset($subDnLdapServer); $subDn_name = $thisObject -> getSubDnName();
while (!$subDn_name && next($subDnLdapServer)) {
if (isCompatibleDNs(key($subDnLdapServer),$thisObject -> getValue('dn'))) {
$subDn_name=current($subDnLdapServer);
}
}
} }
$objectList[]=array( $objectList[]=array(

View file

@ -25,7 +25,7 @@
{if $LSsession_subDn!=""} {if $LSsession_subDn!=""}
<form action="index.php" method='post' id='LSsession_topDn_form'> <form action="index.php" method='post' id='LSsession_topDn_form'>
<label>{$label_level} <label>{$label_level}
<a href="index.php?LSsession_topDn_refresh"><img src='templates/images/refresh.png' alt='{$_refresh}' title='{$_refresh}' /></a> <a href="index.php?LSsession_refresh"><img src='templates/images/refresh.png' alt='{$_refresh}' title='{$_refresh}' /></a>
<select name='LSsession_topDn' id='LSsession_topDn'> <select name='LSsession_topDn' id='LSsession_topDn'>
{html_options values=$LSsession_subDn_indexes output=$LSsession_subDn_names selected=$LSsession_subDn} {html_options values=$LSsession_subDn_indexes output=$LSsession_subDn_names selected=$LSsession_subDn}
</select> </select>
@ -33,8 +33,8 @@
</form> </form>
{/if} {/if}
<ul class='menu'> <ul class='menu'>
{foreach from=$LSaccess item=item key=LSobject_type} {foreach from=$LSaccess item=label key=LSobject_type}
<li class='menu'><a href='view.php?LSobject={$LSobject_type}' class='menu'>{$item.label}</a></li> <li class='menu'><a href='view.php?LSobject={$LSobject_type}' class='menu'>{$label}</a></li>
{/foreach} {/foreach}
</ul> </ul>
</div> </div>

View file

@ -30,6 +30,8 @@ if($LSsession -> startLSsession()) {
$LSobject = $_REQUEST['LSobject']; $LSobject = $_REQUEST['LSobject'];
$dn = $_REQUEST['dn']; $dn = $_REQUEST['dn'];
if ($GLOBALS['LSsession'] -> in_menu($LSobject)) {
if ( $LSobject == 'SELF' ) { if ( $LSobject == 'SELF' ) {
$LSobject = $GLOBALS['LSsession']-> LSuserObject -> getType(); $LSobject = $GLOBALS['LSsession']-> LSuserObject -> getType();
$dn = $GLOBALS['LSsession']-> LSuserObject -> getValue('dn'); $dn = $GLOBALS['LSsession']-> LSuserObject -> getValue('dn');
@ -145,8 +147,6 @@ if($LSsession -> startLSsession()) {
$GLOBALS['Smarty']->assign('pagetitle',$object -> getLabel()); $GLOBALS['Smarty']->assign('pagetitle',$object -> getLabel());
$GLOBALS['Smarty']->assign('LSobject_list_objectname',$object -> getLabel()); $GLOBALS['Smarty']->assign('LSobject_list_objectname',$object -> getLabel());
$subDnLdapServer = $GLOBALS['LSsession'] -> getSortSubDnLdapServer();
if (isset($_SESSION['LSsession']['LSsearch'][$LSobject])) { if (isset($_SESSION['LSsession']['LSsearch'][$LSobject])) {
$filter = $_SESSION['LSsession']['LSsearch'][$LSobject]['filter']; $filter = $_SESSION['LSsession']['LSsearch'][$LSobject]['filter'];
$params = $_SESSION['LSsession']['LSsearch'][$LSobject]['params']; $params = $_SESSION['LSsession']['LSsearch'][$LSobject]['params'];
@ -172,6 +172,7 @@ if($LSsession -> startLSsession()) {
$approx = false; $approx = false;
$orderby = false; $orderby = false;
$ordersense = 'ASC'; $ordersense = 'ASC';
$subDnLdapServer = $GLOBALS['LSsession'] -> getSubDnLdapServer();
$doSubDn = (($subDnLdapServer)&&(!$GLOBALS['LSsession']->isSubDnLSobject($LSobject))); $doSubDn = (($subDnLdapServer)&&(!$GLOBALS['LSsession']->isSubDnLSobject($LSobject)));
} }
@ -292,23 +293,16 @@ if($LSsession -> startLSsession()) {
); );
$list=$object -> listObjects($filter,$topDn,$params); $list=$object -> listObjects($filter,$topDn,$params);
$nbObjects=count($list);
$searchData['LSobject_list_nbresult']=$nbObjects;
$c=0;
$nbObjects=0;
foreach($list as $thisObject) { foreach($list as $thisObject) {
if ($GLOBALS['LSsession'] -> canAccess($LSobject,$thisObject->getValue('dn'))) { if ($GLOBALS['LSsession'] -> canAccess($LSobject,$thisObject->getValue('dn'))) {
$subDn_name=false; $subDn_name=false;
if ($doSubDn) { if ($doSubDn) {
reset($subDnLdapServer); $subDn_name = $thisObject -> getSubDnName();
while (!$subDn_name && next($subDnLdapServer)) {
if (isCompatibleDNs(key($subDnLdapServer),$thisObject -> getValue('dn'))) {
$subDn_name=current($subDnLdapServer);
} }
} $nbObjects++;
}
$c++;
unset($actions); unset($actions);
$actions[] = array( $actions[] = array(
@ -348,10 +342,10 @@ if($LSsession -> startLSsession()) {
'subDn' => $subDn_name 'subDn' => $subDn_name
); );
} }
else {
debug($thisObject->getValue('dn'));
}
} }
$searchData['LSobject_list_nbresult']=$nbObjects;
$searchData['objectList']=$objectList; $searchData['objectList']=$objectList;
$searchData['LSview_actions'] = $LSview_actions; $searchData['LSview_actions'] = $LSview_actions;
if ($GLOBALS['LSsession'] -> cacheSearch()) { if ($GLOBALS['LSsession'] -> cacheSearch()) {
@ -428,6 +422,10 @@ if($LSsession -> startLSsession()) {
$GLOBALS['LSerror'] -> addErrorCode(1004,$LSobject); $GLOBALS['LSerror'] -> addErrorCode(1004,$LSobject);
} }
} }
else {
$GLOBALS['LSerror'] -> addErrorCode(1011);
}
}
else { else {
$GLOBALS['LSerror'] -> addErrorCode(1012); $GLOBALS['LSerror'] -> addErrorCode(1012);
} }