- LSsession :: relationCanAcces() && relationCanEdit()

-> Ajout d'un paramètre $LSobject au lieu de supposé que le type est celui
		 de authUserObject
	-> Modification en conséquence dans les autres fichiers
This commit is contained in:
Benjamin Renard 2008-10-08 14:50:48 +00:00
parent 08862558a7
commit 9ad151312e
3 changed files with 10 additions and 9 deletions

View file

@ -1243,13 +1243,13 @@ class LSsession {
* Retourne le droit de l'utilisateur à gérer la relation d'objet * Retourne le droit de l'utilisateur à gérer la relation d'objet
* *
* @param[in] string $dn Le DN de l'objet (le container_dn du type de l'objet par défaut) * @param[in] string $dn Le DN de l'objet (le container_dn du type de l'objet par défaut)
* @param[in] string $LSobject Le type de l'objet
* @param[in] string $relationName Le nom de la relation avec l'objet * @param[in] string $relationName Le nom de la relation avec l'objet
* @param[in] string $right Le type de droit a vérifier ('r' ou 'w') * @param[in] string $right Le type de droit a vérifier ('r' ou 'w')
* *
* @retval boolean True si l'utilisateur a accès, false sinon * @retval boolean True si l'utilisateur a accès, false sinon
*/ */
function relationCanAccess($dn,$relationName,$right=NULL) { function relationCanAccess($dn,$LSobject,$relationName,$right=NULL) {
$LSobject=$this -> LSuserObject -> getType();
if (!isset($GLOBALS['LSobjects'][$LSobject]['relations'][$relationName])) if (!isset($GLOBALS['LSobjects'][$LSobject]['relations'][$relationName]))
return; return;
$whoami = $this -> whoami($dn); $whoami = $this -> whoami($dn);
@ -1271,12 +1271,13 @@ class LSsession {
* Retourne le droit de l'utilisateur à modifier la relation d'objet * Retourne le droit de l'utilisateur à modifier la relation d'objet
* *
* @param[in] string $dn Le DN de l'objet (le container_dn du type de l'objet par défaut) * @param[in] string $dn Le DN de l'objet (le container_dn du type de l'objet par défaut)
* @param[in] string $LSobject Le type de l'objet
* @param[in] string $relationName Le nom de la relation avec l'objet * @param[in] string $relationName Le nom de la relation avec l'objet
* *
* @retval boolean True si l'utilisateur a accès, false sinon * @retval boolean True si l'utilisateur a accès, false sinon
*/ */
function relationCanEdit($dn,$relationName) { function relationCanEdit($dn,$LSobject,$relationName) {
return $this -> relationCanAccess($dn,$relationName,'w'); return $this -> relationCanAccess($dn,$LSobject,$relationName,'w');
} }
/** /**

View file

@ -124,7 +124,7 @@ if (!isset($_ERRORS)) {
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'] -> loadLSobject($relationConf['LSobject'])) {
if ($GLOBALS['LSsession'] -> relationCanEdit($object -> getValue('dn'),$conf['relationName'])) { if ($GLOBALS['LSsession'] -> relationCanEdit($object -> getValue('dn'),$object -> getType(),$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']();
$list = $objRel -> $relationConf['list_function']($object); $list = $objRel -> $relationConf['list_function']($object);
@ -173,7 +173,7 @@ if (!isset($_ERRORS)) {
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'] -> loadLSobject($relationConf['LSobject'])) {
if ($GLOBALS['LSsession'] -> relationCanEdit($object -> getValue('dn'),$conf['relationName'])) { if ($GLOBALS['LSsession'] -> relationCanEdit($object -> getValue('dn'),$object -> getType(),$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'])) {
$objRel = new $relationConf['LSobject'](); $objRel = new $relationConf['LSobject']();
@ -233,7 +233,7 @@ if (!isset($_ERRORS)) {
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'] -> loadLSobject($relationConf['LSobject'])) {
if ($GLOBALS['LSsession'] -> relationCanEdit($object -> getValue('dn'),$conf['relationName'])) { if ($GLOBALS['LSsession'] -> relationCanEdit($object -> getValue('dn'),$object -> getType(),$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']();
$list = $objRel -> $relationConf['list_function']($object); $list = $objRel -> $relationConf['list_function']($object);

View file

@ -82,7 +82,7 @@ if($LSsession -> startLSsession()) {
if (is_array($object -> config['relations'])) { if (is_array($object -> config['relations'])) {
$LSrelations=array(); $LSrelations=array();
foreach($object -> config['relations'] as $relationName => $relationConf) { foreach($object -> config['relations'] as $relationName => $relationConf) {
if ($GLOBALS['LSsession'] -> relationCanAccess($object -> getValue('dn'),$relationName)) { if ($GLOBALS['LSsession'] -> relationCanAccess($object -> getValue('dn'),$LSobject,$relationName)) {
$return=array( $return=array(
'label' => $relationConf['label'], 'label' => $relationConf['label'],
'LSobject' => $relationConf['LSobject'] 'LSobject' => $relationConf['LSobject']
@ -95,7 +95,7 @@ if($LSsession -> startLSsession()) {
'objectType' => $object -> getType(), 'objectType' => $object -> getType(),
'objectDn' => $object -> getDn(), 'objectDn' => $object -> getDn(),
); );
if ($GLOBALS['LSsession'] -> relationCanEdit($object -> getValue('dn'),$relationName)) { if ($GLOBALS['LSsession'] -> relationCanEdit($object -> getValue('dn'),$LSobject,$relationName)) {
$return['actions'][] = array( $return['actions'][] = array(
'label' => _('Modifier'), 'label' => _('Modifier'),
'url' => 'select.php?LSobject='.$relationConf['LSobject'].'&multiple=1', 'url' => 'select.php?LSobject='.$relationConf['LSobject'].'&multiple=1',