diff --git a/trunk/conf/config.error_code.php b/trunk/conf/config.error_code.php index 968a84f6..beb7b121 100644 --- a/trunk/conf/config.error_code.php +++ b/trunk/conf/config.error_code.php @@ -248,7 +248,7 @@ $GLOBALS['LSerror_code'] = array ( 'level' => 'c' ), 1011 => array ( - 'msg' => _("LSsession : Vous n'êtes pas authorisé à effectuer cette action."), + 'msg' => _("LSsession : Vous n'êtes pas authorisé à  effectuer cette action."), 'level' => 'c' ), 1012 => array ( diff --git a/trunk/conf/config.inc.php b/trunk/conf/config.inc.php index 258386df..46dff9d7 100644 --- a/trunk/conf/config.inc.php +++ b/trunk/conf/config.inc.php @@ -54,10 +54,15 @@ $GLOBALS['LSconfig'] = array( ) ) ), - 'cacheLSrights' => false, + 'cacheLSrights' => true, 'cacheSearch' => true, 'authobject' => 'LSeepeople', 'authobject_pwdattr' => 'userPassword', + 'LSaccess' => array( + 'LSeepeople', + 'LSeegroup', + 'LSeecompany' + ), 'recoverPassword' => array( 'mailAttr' => 'mail', 'recoveryHashAttr' => 'lsRecoveryHash', @@ -71,12 +76,7 @@ $GLOBALS['LSconfig'] = array( 'msg' => "Votre nouveau mot de passe : %{mdp}" ) ), - 'emailSender' => 'noreply@lsexample.net', - 'LSobjects' => array ( - 'LSeepeople', - 'LSeegroup', - 'LSeecompany' - ) + 'emailSender' => 'noreply@lsexample.net' ) ) ); diff --git a/trunk/create.php b/trunk/create.php index 83b7493b..4d101826 100644 --- a/trunk/create.php +++ b/trunk/create.php @@ -36,7 +36,7 @@ if($LSsession -> startLSsession()) { if (isset($LSobject)) { // Création d'un LSobject - if (class_exists($LSobject)) { + if ($GLOBALS['LSsession'] -> loadLSobject($LSobject)) { if ( $GLOBALS['LSsession'] -> canCreate($LSobject) ) { $object = new $LSobject(); diff --git a/trunk/includes/class/class.LSldapObject.php b/trunk/includes/class/class.LSldapObject.php index 2f367cb3..cebfff53 100644 --- a/trunk/includes/class/class.LSldapObject.php +++ b/trunk/includes/class/class.LSldapObject.php @@ -40,6 +40,7 @@ class LSldapObject { var $other_values=array(); var $submitError=true; var $_whoami=NULL; + var $_subDn_value=NULL; /** * Constructeur @@ -929,6 +930,38 @@ class LSldapObject { function isNew() { 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()]; + } } ?> diff --git a/trunk/includes/class/class.LSsession.php b/trunk/includes/class/class.LSsession.php index 752a059e..54c748dd 100644 --- a/trunk/includes/class/class.LSsession.php +++ b/trunk/includes/class/class.LSsession.php @@ -144,31 +144,6 @@ class LSsession { 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 * @@ -245,30 +220,36 @@ class LSsession { $this -> ldapServerId = $_SESSION['LSsession']['ldapServerId']; $this -> tmp_file = $_SESSION['LSsession']['tmp_file']; - if ( $this -> cacheLSrights() ) { + if ( $this -> cacheLSrights() && !isset($_REQUEST['LSsession_refresh']) ) { $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(); } - if ( $this -> cacheSudDn() && (!isset($_REQUEST['LSsession_topDn_refresh'])) ) { + if ( $this -> cacheSudDn() && (!isset($_REQUEST['LSsession_refresh'])) ) { $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 -> loadData($this -> dn); - $this -> loadLSaccess(); + + if ( !$this -> cacheLSrights() || isset($_REQUEST['LSsession_refresh']) ) { + $this -> loadLSaccess(); + } + $GLOBALS['Smarty'] -> assign('LSsession_username',$this -> LSuserObject -> getDisplayValue()); if ($_POST['LSsession_topDn']) { @@ -293,8 +274,6 @@ class LSsession { $this -> setLdapServer(0); } - $this -> loadLSobjects(); - // Connexion au serveur LDAP if ($this -> LSldapConnect()) { @@ -564,9 +543,9 @@ class LSsession { 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; + foreach($subDn_config as $LSobject_name => $LSoject_config) { + if ($LSoject_config['topDn']) { + $topDn = $LSoject_config['topDn']; } else { $topDn = NULL; @@ -595,7 +574,9 @@ class LSsession { } } 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()) { @@ -616,15 +597,11 @@ class LSsession { * @return array() Tableau des subDn trié */ function getSortSubDnLdapServer() { - if(isset($_SESSION['LSsession']['LSview_subDnLdapServer']) && $this -> cacheSudDn()) { - return $_SESSION['LSsession']['LSview_subDnLdapServer']; - } $subDnLdapServer = $this -> getSubDnLdapServer(); if (!$subDnLdapServer) { return array(); } uksort($subDnLdapServer,"compareDn"); - $_SESSION['LSsession']['LSview_subDnLdapServer']=$subDnLdapServer; return $subDnLdapServer; } @@ -850,8 +827,8 @@ class LSsession { $Css_txt.="\n"; } $GLOBALS['Smarty'] -> assign('LSsession_css',$Css_txt); - - $GLOBALS['Smarty'] -> assign('LSaccess',$this -> LSaccess); + + $GLOBALS['Smarty'] -> assign('LSaccess',$this -> LSaccess[$this -> topDn]); // Niveau $listTopDn = $this -> getSubDnLdapServer(); @@ -942,26 +919,91 @@ class LSsession { * @retval void */ function loadLSaccess() { - if ($this -> canAccess($this -> LSuserObject -> getType(),$this -> dn)) { - $LSaccess = array( - 'SELF' => array( - 'label' => _('Mon compte'), - 'DNs' => $this -> dn - ) - ); - } - else { - $LSaccess = array(); - } - foreach ($GLOBALS['LSobjects'] as $objecttype => $objectconf) { - if ($this -> canAccess($objecttype) ) { - $LSaccess[$objecttype] = array ( - 'label' => $objectconf['label'], - 'Dns' => 'All' - ); + $LSaccess=array(); + if (is_array($this -> ldapServer['subDn'])) { + foreach($this -> ldapServer['subDn'] as $name => $config) { + if ($name=='LSobject') { + 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 { + $GLOBALS['LSerror'] -> addErrorCode(1004,$type); + } + } + } + foreach($tbl as $dn => $dn_name) { + $LSaccess[$dn]=$access; + } + } + } + } + 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; + $_SESSION['LSsession']['LSaccess'] = $LSaccess; } /** @@ -1013,10 +1055,24 @@ class LSsession { * @retval boolean True si l'utilisateur a accès, false sinon */ function canAccess($LSobject,$dn=NULL,$right=NULL,$attr=NULL) { - if (!$this -> loadLSobject($LSobject)) + if (!$this -> loadLSobject($LSobject)) { + $GLOBALS['LSerror'] -> addErrorCode(1004,$LSobject); return; + } if ($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 { $objectdn=$GLOBALS['LSobjects'][$LSobject]['container_dn'].','.$this -> topDn; @@ -1272,7 +1328,7 @@ class LSsession { * * @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) { if (!$subDn) { @@ -1291,10 +1347,9 @@ class LSsession { * * @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) { - debug('seach : '.$type); $result = false; if (is_array($this -> ldapServer['subDn']['LSobject'])) { foreach($this -> ldapServer['subDn']['LSobject'] as $key => $value) { @@ -1305,6 +1360,18 @@ class LSsession { } 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]); + } } ?> diff --git a/trunk/index_ajax.php b/trunk/index_ajax.php index 085ff355..810fcc21 100644 --- a/trunk/index_ajax.php +++ b/trunk/index_ajax.php @@ -20,7 +20,6 @@ if (!isset($_ERRORS)) { $GLOBALS['LSsession'] -> setLdapServer($_REQUEST['server']); if ( $GLOBALS['LSsession'] -> LSldapConnect() ) { session_start(); - $GLOBALS['LSsession'] -> loadLSobjects(); $list = $GLOBALS['LSsession'] -> getSubDnLdapServerOptions($_SESSION['LSsession_topDn']); if (is_string($list)) { $list=""; @@ -29,15 +28,6 @@ if (!isset($_ERRORS)) { '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; @@ -47,71 +37,77 @@ if (!isset($_ERRORS)) { switch($_REQUEST['action']) { case 'onAddFieldBtnClick': if ((isset($_REQUEST['attribute'])) && (isset($_REQUEST['objecttype'])) && (isset($_REQUEST['objectdn'])) && (isset($_REQUEST['idform'])) && (isset($_REQUEST['img'])) ) { - $object = new $_REQUEST['objecttype'](); - $object -> loadData($_REQUEST['objectdn']); - $form = $object -> getForm($_REQUEST['idform']); - $emptyField=$form -> getEmptyField($_REQUEST['attribute']); - if ( $emptyField ) { - $data = array( - 'html' => $form -> getEmptyField($_REQUEST['attribute']), - 'img' => $_REQUEST['img'], - ); + if ($GLOBALS['LSsession'] -> loadLSobject($_REQUEST['objecttype'])) { + $object = new $_REQUEST['objecttype'](); + $object -> loadData($_REQUEST['objectdn']); + $form = $object -> getForm($_REQUEST['idform']); + $emptyField=$form -> getEmptyField($_REQUEST['attribute']); + if ( $emptyField ) { + $data = array( + 'html' => $form -> getEmptyField($_REQUEST['attribute']), + 'img' => $_REQUEST['img'], + ); + } } else { - $data = array('LSerror' => $GLOBALS['LSerror']->getErrors()); + $GLOBALS['LSerror'] -> addErrorCode(1004,$_REQUEST['objecttype']); } } break; case 'refreshField': if ((isset($_REQUEST['attribute'])) && (isset($_REQUEST['objecttype'])) && (isset($_REQUEST['objectdn'])) && (isset($_REQUEST['idform'])) ) { - $object = new $_REQUEST['objecttype'](); - //$object -> loadData($_REQUEST['objectdn']); - $form = $object -> getForm($_REQUEST['idform']); - $field=$form -> getElement($_REQUEST['attribute']); - $val = $field -> getDisplay(true); - if ( $val ) { - $data = array( - 'html' => $val['html'] - ); + if ($GLOBALS['LSsession'] -> loadLSobject($_REQUEST['objecttype'])) { + $object = new $_REQUEST['objecttype'](); + $form = $object -> getForm($_REQUEST['idform']); + $field=$form -> getElement($_REQUEST['attribute']); + $val = $field -> getDisplay(true); + if ( $val ) { + $data = array( + 'html' => $val['html'] + ); + } } else { - $data = array( - 'LSerror' => $GLOBALS['LSerror']->getErrors() - ); + $GLOBALS['LSerror'] -> addErrorCode(1004,$_REQUEST['objecttype']); } } break; case 'generatePassword': if ((isset($_REQUEST['attribute'])) && (isset($_REQUEST['objecttype'])) && (isset($_REQUEST['viewBtnId'])) && (isset($_REQUEST['fieldId'])) && (isset($_REQUEST['idform'])) ) { - $object = new $_REQUEST['objecttype'](); - $form = $object -> getForm($_REQUEST['idform']); - $field=$form -> getElement($_REQUEST['attribute']); - $val = $field -> generatePassword(); - if ( $val ) { - $data = array( - 'generatePassword' => $val, - 'fieldId' => $_REQUEST['fieldId'], - 'viewBtnId' => $_REQUEST['viewBtnId'] - ); + if ($GLOBALS['LSsession'] -> loadLSobject($_REQUEST['objecttype'])) { + $object = new $_REQUEST['objecttype'](); + $form = $object -> getForm($_REQUEST['idform']); + $field=$form -> getElement($_REQUEST['attribute']); + $val = $field -> generatePassword(); + if ( $val ) { + $data = array( + 'generatePassword' => $val, + 'fieldId' => $_REQUEST['fieldId'], + 'viewBtnId' => $_REQUEST['viewBtnId'] + ); + } } else { - $data = array( - 'LSerror' => $GLOBALS['LSerror']->getErrors() - ); + $GLOBALS['LSerror'] -> addErrorCode(1004,$_REQUEST['objecttype']); } } break; case 'verifyPassword': if ((isset($_REQUEST['attribute'])) && (isset($_REQUEST['objecttype'])) && (isset($_REQUEST['fieldId'])) && (isset($_REQUEST['fieldValue'])) && (isset($_REQUEST['idform'])) && (isset($_REQUEST['objectdn'])) ) { - $object = new $_REQUEST['objecttype'](); - $form = $object -> getForm($_REQUEST['idform']); - $object -> loadData($_REQUEST['objectdn']); - $field=$form -> getElement($_REQUEST['attribute']); - $val = $field -> verifyPassword($_REQUEST['fieldValue']); - $data = array( - 'verifyPassword' => $val, - 'fieldId' => $_REQUEST['fieldId'] - ); + if ($GLOBALS['LSsession'] -> loadLSobject($_REQUEST['objecttype'])) { + $object = new $_REQUEST['objecttype'](); + $form = $object -> getForm($_REQUEST['idform']); + $object -> loadData($_REQUEST['objectdn']); + $field=$form -> getElement($_REQUEST['attribute']); + $val = $field -> verifyPassword($_REQUEST['fieldValue']); + $data = array( + 'verifyPassword' => $val, + 'fieldId' => $_REQUEST['fieldId'] + ); + } + else { + $GLOBALS['LSerror'] -> addErrorCode(1004,$_REQUEST['objecttype']); + } } break; } @@ -126,27 +122,32 @@ if (!isset($_ERRORS)) { $object = new $conf['objectType'](); if (($object -> loadData($conf['objectDn'])) && (isset($object->config['relations'][$conf['relationName']]))) { $relationConf = $object->config['relations'][$conf['relationName']]; - if ($GLOBALS['LSsession'] -> relationCanEdit($object -> getValue('dn'),$conf['relationName'])) { - if (method_exists($relationConf['LSobject'],$relationConf['list_function'])) { - $objRel = new $relationConf['LSobject'](); - $list = $objRel -> $relationConf['list_function']($object); - $_SESSION['LSselect'][$relationConf['LSobject']]=array(); - if (is_array($list)) { - foreach($list as $o) { - $_SESSION['LSselect'][$relationConf['LSobject']][] = $o -> getDn(); + if ($GLOBALS['LSsession'] -> loadLSobject($relationConf['LSobject'])) { + if ($GLOBALS['LSsession'] -> relationCanEdit($object -> getValue('dn'),$conf['relationName'])) { + if (method_exists($relationConf['LSobject'],$relationConf['list_function'])) { + $objRel = new $relationConf['LSobject'](); + $list = $objRel -> $relationConf['list_function']($object); + $_SESSION['LSselect'][$relationConf['LSobject']]=array(); + if (is_array($list)) { + foreach($list as $o) { + $_SESSION['LSselect'][$relationConf['LSobject']][] = $o -> getDn(); + } } + $data = array( + 'href' => $_REQUEST['href'], + 'id' => $_REQUEST['id'] + ); + } + else { + $GLOBALS['LSerror'] -> addErrorCode(1013,$relationName); } - $data = array( - 'href' => $_REQUEST['href'], - 'id' => $_REQUEST['id'] - ); } else { - $GLOBALS['LSerror'] -> addErrorCode(1013,$relationName); + $GLOBALS['LSerror'] -> addErrorCode(1011); } } else { - $GLOBALS['LSerror'] -> addErrorCode(1011); + $GLOBALS['LSerror'] -> addErrorCode(1004,$relationConf['LSobject']); } } else { @@ -170,38 +171,43 @@ if (!isset($_ERRORS)) { $object = new $conf['objectType'](); if (($object -> loadData($conf['objectDn'])) && (isset($object->config['relations'][$conf['relationName']]))) { $relationConf = $object->config['relations'][$conf['relationName']]; - if ($GLOBALS['LSsession'] -> relationCanEdit($object -> getValue('dn'),$conf['relationName'])) { - if (is_array($_SESSION['LSselect'][$relationConf['LSobject']])) { - if (method_exists($relationConf['LSobject'],$relationConf['update_function'])) { - $objRel = new $relationConf['LSobject'](); - if($objRel -> $relationConf['update_function']($object,$_SESSION['LSselect'][$relationConf['LSobject']])) { - if (method_exists($relationConf['LSobject'],$relationConf['list_function'])) { - $list = $objRel -> $relationConf['list_function']($object); - if (is_array($list)) { - foreach($list as $o) { - $data['html'].= "
  • ".$o -> getDisplayValue()."
  • \n"; + if ($GLOBALS['LSsession'] -> loadLSobject($relationConf['LSobject'])) { + if ($GLOBALS['LSsession'] -> relationCanEdit($object -> getValue('dn'),$conf['relationName'])) { + if (is_array($_SESSION['LSselect'][$relationConf['LSobject']])) { + if (method_exists($relationConf['LSobject'],$relationConf['update_function'])) { + $objRel = new $relationConf['LSobject'](); + if($objRel -> $relationConf['update_function']($object,$_SESSION['LSselect'][$relationConf['LSobject']])) { + if (method_exists($relationConf['LSobject'],$relationConf['list_function'])) { + $list = $objRel -> $relationConf['list_function']($object); + if (is_array($list)) { + foreach($list as $o) { + $data['html'].= "
  • ".$o -> getDisplayValue()."
  • \n"; + } } + else { + $data['html'] = "
  • "._('Liste vide.')."
  • \n"; + } + $data['id'] = $_REQUEST['id']; } else { - $data['html'] = "
  • "._('Liste vide.')."
  • \n"; + $GLOBALS['LSerror'] -> addErrorCode(1013,$relationName); } - $data['id'] = $_REQUEST['id']; } else { - $GLOBALS['LSerror'] -> addErrorCode(1013,$relationName); + $GLOBALS['LSerror'] -> addErrorCode(1015,$relationName); } } else { - $GLOBALS['LSerror'] -> addErrorCode(1015,$relationName); + $GLOBALS['LSerror'] -> addErrorCode(1014,$relationName); } } - else { - $GLOBALS['LSerror'] -> addErrorCode(1014,$relationName); - } + } + else { + $GLOBALS['LSerror'] -> addErrorCode(1011); } } else { - $GLOBALS['LSerror'] -> addErrorCode(1011); + $GLOBALS['LSerror'] -> addErrorCode(1004,$relationConf['LSobject']); } } else { @@ -225,37 +231,42 @@ if (!isset($_ERRORS)) { $object = new $conf['objectType'](); if (($object -> loadData($conf['objectDn'])) && (isset($object->config['relations'][$conf['relationName']]))) { $relationConf = $object->config['relations'][$conf['relationName']]; - if ($GLOBALS['LSsession'] -> relationCanEdit($object -> getValue('dn'),$conf['relationName'])) { - if (method_exists($relationConf['LSobject'],$relationConf['list_function'])) { - $objRel = new $relationConf['LSobject'](); - $list = $objRel -> $relationConf['list_function']($object); - if (is_array($list)) { - $ok=false; - foreach($list as $o) { - if($o -> getDisplayValue() == $_REQUEST['value']) { - if (!$o -> deleteOneMember($object)) { - $GLOBALS['LSerror'] -> addErrorCode(1015,$conf['relationName']); - } - else { - $ok = true; + if ($GLOBALS['LSsession'] -> loadLSobject($relationConf['LSobject'])) { + if ($GLOBALS['LSsession'] -> relationCanEdit($object -> getValue('dn'),$conf['relationName'])) { + if (method_exists($relationConf['LSobject'],$relationConf['list_function'])) { + $objRel = new $relationConf['LSobject'](); + $list = $objRel -> $relationConf['list_function']($object); + if (is_array($list)) { + $ok=false; + foreach($list as $o) { + if($o -> getDisplayValue() == $_REQUEST['value']) { + if (!$o -> deleteOneMember($object)) { + $GLOBALS['LSerror'] -> addErrorCode(1015,$conf['relationName']); + } + else { + $ok = true; + } } } + if (!$ok) { + $GLOBALS['LSerror'] -> addErrorCode(1015,$conf['relationName']); + } } - if (!$ok) { + else { $GLOBALS['LSerror'] -> addErrorCode(1015,$conf['relationName']); + $GLOBALS['LSerror'] -> addErrorCode(1); } } else { - $GLOBALS['LSerror'] -> addErrorCode(1015,$conf['relationName']); - $GLOBALS['LSerror'] -> addErrorCode(1); + $GLOBALS['LSerror'] -> addErrorCode(1013,$conf['relationName']); } } else { - $GLOBALS['LSerror'] -> addErrorCode(1013,$conf['relationName']); + $GLOBALS['LSerror'] -> addErrorCode(1011); } } else { - $GLOBALS['LSerror'] -> addErrorCode(1011); + $GLOBALS['LSerror'] -> addErrorCode(1004,$relationConf['LSobject']); } } else { @@ -316,9 +327,6 @@ if (!isset($_ERRORS)) { } else { $GLOBALS['LSerror'] -> addErrorCode(1012); - $data = array( - 'LSerror' => $GLOBALS['LSerror']->getErrors() - ); } break; } diff --git a/trunk/select.php b/trunk/select.php index 42d54285..8cd4a290 100644 --- a/trunk/select.php +++ b/trunk/select.php @@ -36,8 +36,6 @@ if($LSsession -> startLSsession()) { $GLOBALS['Smarty']->assign('pagetitle',$object -> getLabel()); $GLOBALS['Smarty']->assign('LSobject_list_objectname',$object -> getLabel()); - $subDnLdapServer = $GLOBALS['LSsession'] -> getSortSubDnLdapServer(); - if (isset($_SESSION['LSsession']['LSsearch'][$LSobject])) { $filter = $_SESSION['LSsession']['LSsearch'][$LSobject]['filter']; if (isCompatibleDNs($_SESSION['LSsession']['LSsearch'][$LSobject]['topDn'],$GLOBALS['LSsession'] -> topDn)) { @@ -67,6 +65,7 @@ if($LSsession -> startLSsession()) { $selectedTopDn = $GLOBALS['LSsession'] -> topDn; $orderby = false; $ordersense = 'ASC'; + $subDnLdapServer = $GLOBALS['LSsession'] -> getSubDnLdapServer(); $doSubDn = (($subDnLdapServer)&&(!$GLOBALS['LSsession']->isSubDnLSobject($LSobject))); } @@ -211,12 +210,7 @@ if($LSsession -> startLSsession()) { $subDn_name=false; if ($doSubDn) { - reset($subDnLdapServer); - while (!$subDn_name && next($subDnLdapServer)) { - if (isCompatibleDNs(key($subDnLdapServer),$thisObject -> getValue('dn'))) { - $subDn_name=current($subDnLdapServer); - } - } + $subDn_name = $thisObject -> getSubDnName(); } $objectList[]=array( diff --git a/trunk/templates/top.tpl b/trunk/templates/top.tpl index ac7624b5..d158d625 100644 --- a/trunk/templates/top.tpl +++ b/trunk/templates/top.tpl @@ -25,7 +25,7 @@ {if $LSsession_subDn!=""}