LSrelation : improve and make it easy to configure simple relation

This commit is contained in:
Benjamin Renard 2017-04-28 02:13:05 +02:00
parent 992dc08cc9
commit 8deb9a8508
9 changed files with 3072 additions and 2851 deletions

View file

@ -2,6 +2,13 @@
<title>LSrelation</title>
<para>Cette section décrit la manière de configurer les relations entre les
&LSobjects; appelées &LSrelation;.</para>
<para>Dans le cadre d'une liaison dîte <emphasis>simple</emphasis>, c'est à
dire une liaison au travers la valeur d'un attribut qui fera directement
référence à un autre objet (<emphasis>DN</emphasis> ou la première valeur
d'un attribut de référence), pourra être configurée simplement en spécifiant
l'attribut de liaison et le type de valeur qu'il contient. Dans le cas d'une
liaison plus complexe, il sera possible de développer vous même des méthodes
de mise en relation.</para>
<programlisting>
<citetitle>Structure</citetitle>
@ -11,6 +18,12 @@
'emptyText' => "[texte affiché si aucune relation avec d'autres objets
n'existe pour l'objet courant]",
'LSobject' => '[le type d'LSobjet en relation]',
// Liaison simple
'linkAttribute' => '[attribut de liaison]',
'linkAttributeValue' => '[value de l'attribut de liaison]',
// Liaison complexe
'list_function' => '[méthode1]',
'getkeyvalue_function' => '[methode2]',
'update_function' => '[methode3]',
@ -18,6 +31,7 @@
'rename_function' => '[methode5]',
'canEdit_function' => '[methode6]',
'canEdit_attribute' => '[nom d'attribut]',
'rights' => array(
'LSprofile1' => 'r',
'LSprofile2' => 'w',
@ -49,7 +63,30 @@
<varlistentry>
<term>LSobject</term>
<listitem>
<simpara>Le type d'&LSobject; en relation avec le type courant.</simpara>
<simpara>Le type d'&LSobject; en relation avec le type courant.
<emphasis>(Facultatif en cas de liaison complexe)</emphasis></simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>linkAttribute</term>
<listitem>
<simpara>Dans le cadre d'une relation simple, il s'agit de l'attribut de
liaison du type d'&LSobject; en relation avec le type courant, c'est à dire
l'attribut dans lequel on retrouve une valeur en relation avec l'objet
courant. <emphasis>(Facultatif en cas de liaison complexe)</emphasis></simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>linkAttributeValue</term>
<listitem>
<simpara>Dans le cadre d'une relation simple, il s'agit du type de valeur pris
par l'attribut de liaison du type d'&LSobject; en relation avec le type courant.
Il peut s'agir du mot clé <literal>dn</literal> si l'attribut de liaison contient
le <emphasis>DN</emphasis> de l'objet courant ou bien le nom d'un attribut du type
d'objet courant dont la première valeur sera stockée par l'attribut de liaison.
<emphasis>(Facultatif en cas de liaison simple)</emphasis></simpara>
</listitem>
</varlistentry>
@ -57,7 +94,8 @@
<term>list_function</term>
<listitem>
<simpara>La méthode de la classe du type d'&LSobject; en relation, permettant
de lister les objets de ce type en relation avec l'objet courant.</simpara>
de lister les objets de ce type en relation avec l'objet courant.
<emphasis>(Facultatif en cas de liaison simple)</emphasis></simpara>
</listitem>
</varlistentry>
@ -66,7 +104,8 @@
<listitem>
<simpara>La méthode de la classe du type d'&LSobject; en relation, permettant
d'obtenir la valeur clé à stocker pour établir la relation entre l'objet
courant et d'autres objets du type concerné.</simpara>
courant et d'autres objets du type concerné. <emphasis>(Facultatif en cas de
liaison simple)</emphasis></simpara>
</listitem>
</varlistentry>
@ -76,7 +115,8 @@
<simpara>La méthode de la classe du type d'&LSobject; en relation, permettant
de mettre à jour les relations existantes entre l'objet courant et les objets
du type concerné. Cette liste d'objets en relation est établie par
l'utilisateur à travers l'interface.</simpara>
l'utilisateur à travers l'interface. <emphasis>(Facultatif en cas de liaison
simple)</emphasis></simpara>
</listitem>
</varlistentry>
@ -85,7 +125,8 @@
<listitem>
<simpara>La méthode de la classe du type d'&LSobject; en relation permettant
de supprimer une relation existante entre l'objet courant et un objet du
type concerné.</simpara>
type concerné. <emphasis>(Facultatif en cas de liaison simple)</emphasis>
</simpara>
</listitem>
</varlistentry>
@ -95,7 +136,8 @@
<simpara>La méthode de la classe du type d'&LSobject; en relation permettant
d'effectuer les actions nécessaires lorsque l'objet courant est renommé dans
le but de maintenir les valeurs clés permettant d'établir les relations entre
l'objet courant et les objets en relation avec lui.</simpara>
l'objet courant et les objets en relation avec lui. <emphasis>(Facultatif en
cas de liaison simple)</emphasis></simpara>
</listitem>
</varlistentry>
@ -104,7 +146,8 @@
<listitem>
<simpara>La méthode de la classe du type d'&LSobject; en relation permettant
de vérifier que l'utilisateur à le droit de modifier la relation avec un objet
en particulier.</simpara>
en particulier. <emphasis>(Facultatif en cas de liaison simple)</emphasis>
</simpara>
</listitem>
</varlistentry>
@ -113,7 +156,8 @@
<listitem>
<simpara>Le nom de l'attibut du type d'&LSobject; en relation devant être
éditable par l'utilisateur pour que celui-ci puisse modifier la relation.
</simpara>
Dans le cadre d'une relation simple, celui-ci peut, si nécessaire, être
différent du paramètre <literal>linkAttribute</literal>.</simpara>
</listitem>
</varlistentry>

View file

@ -91,6 +91,18 @@ $GLOBALS['LSobjects']['LSpeople'] = array (
'admin' => 'w',
'admingroup' => 'w'
)
),
'godfather' => array(
'label' => 'Godfather of ...',
'emptyText' => "Doesn't sponsor any user.",
'LSobject' => "LSpeople",
'linkAttribute' => "lsGodfatherDn",
'linkAttributeValue' => "dn",
'rights' => array(
'self' => 'r',
'admin' => 'w',
'admingroup' => 'w'
)
)
),

View file

@ -1106,38 +1106,22 @@ class LSldapObject {
*/
function updateLSrelationsCache() {
$this -> _LSrelationsCache=array();
if (is_array($this->config['LSrelation'])) {
if (is_array($this->config['LSrelation']) && LSsession :: loadLSclass('LSrelation')) {
$type = $this -> getType();
$me = new $type();
$me -> loadData($this -> getDn());
foreach($this->config['LSrelation'] as $relation_name => $relation_conf) {
if ( isset($relation_conf['list_function']) ) {
if (LSsession :: loadLSobject($relation_conf['LSobject'])) {
$obj = new $relation_conf['LSobject']();
if ((method_exists($obj,$relation_conf['list_function']))&&(method_exists($obj,$relation_conf['getkeyvalue_function']))) {
$list = call_user_func(array($obj, $relation_conf['list_function']), $me);
if (is_array($list)) {
// Key Value
$key = call_user_func(array($obj, $relation_conf['getkeyvalue_function']), $me);
$this -> _LSrelationsCache[$relation_name] = array(
'list' => $list,
'keyvalue' => $key
);
}
else {
LSdebug('Problème durant la mise en cache de la relation '.$relation_name);
return;
}
}
else {
LSdebug('Les méthodes de mise en cache de la relation '.$relation_name. ' ne sont pas toutes disponibles.');
return;
}
}
else {
return;
}
$relation = new LSrelation($me, $relation_name);
$list = $relation -> listRelatedObjects();
if (is_array($list)) {
$this -> _LSrelationsCache[$relation_name] = array(
'list' => $list,
'keyvalue' => $relation -> getRelatedKeyValue()
);
}
else {
LSdebug('Problème durant la mise en cache de la relation '.$relation_name);
return;
}
}
}
@ -1177,15 +1161,10 @@ class LSldapObject {
// LSrelations
foreach($this -> _LSrelationsCache as $relation_name => $objInfos) {
if ((isset($this->config['LSrelation'][$relation_name]['rename_function']))&&(is_array($objInfos['list']))) {
$relation = new LSrelation($this, $relation_name);
if (is_array($objInfos['list'])) {
foreach($objInfos['list'] as $obj) {
$meth = $this->config['LSrelation'][$relation_name]['rename_function'];
if (method_exists($obj,$meth)) {
if (!(call_user_func(array($obj, $meth), $this, $objInfos['keyvalue']))) {
$error=1;
}
}
else {
if (!$relation -> renameRelationWithObject($obj, $objInfos['keyvalue'])) {
$error=1;
}
}
@ -1229,17 +1208,13 @@ class LSldapObject {
// LSrelations
foreach($this -> _LSrelationsCache as $relation_name => $objInfos) {
if ((isset($this->config['LSrelation'][$relation_name]['remove_function']))&&(is_array($objInfos['list']))) {
$relation = new LSrelation($this, $relation_name);
if (is_array($objInfos['list'])) {
foreach($objInfos['list'] as $obj) {
$meth = $this->config['LSrelation'][$relation_name]['remove_function'];
if (method_exists($obj,$meth)) {
if (!(call_user_func(array($obj, $meth), $this))) {
$error=1;
}
}
else {
$error=1;
if (!$relation -> canEditRelationWithObject($obj)) {
LSerror :: addErrorCode('LSsession_11');
}
elseif (!$relation -> removeRelationWithObject($obj)) $error=1;
}
}
}
@ -1416,6 +1391,10 @@ class LSldapObject {
return;
}
}
elseif (!LSsession::canEdit($this -> getType(), $this -> getDn(), $attr)) {
LSerror :: addErrorCode('LSsession_11');
return;
}
if ($this -> attrs[$attr] instanceof LSattribute) {
if ($attrValue=='dn') {
$val = $object -> getDn();
@ -1474,6 +1453,10 @@ class LSldapObject {
return;
}
}
elseif (!LSsession::canEdit($this -> getType(), $this -> getDn(), $attr)) {
LSerror :: addErrorCode('LSsession_11');
return;
}
if ($this -> attrs[$attr] instanceof LSattribute) {
if ($attrValue=='dn') {
$val = $object -> getDn();

View file

@ -40,7 +40,7 @@ class LSgroup extends LSldapObject {
* @retval Mixed La valeur clef d'un membre
**/
function getMemberKeyValue($object) {
return $this -> getObjectKeyValueInRelation($object,$this -> memberAttr,$this -> userObjectType);
return $this -> getObjectKeyValueInRelation($object,$this -> userObjectType,$this -> memberAttrValue);
}
/**

View file

@ -22,6 +22,152 @@
class LSrelation {
private $obj = null;
private $relationName = null;
private $config = null;
public function LSrelation(&$obj,$relationName) {
$this -> obj =& $obj;
$this -> relationName = $relationName;
if (isset($obj->config['LSrelation'][$relationName]) && is_array($obj->config['LSrelation'][$relationName])) {
$this -> config = $obj->config['LSrelation'][$relationName];
}
else {
LSerror :: addErrorCode('LSrelations_02',array('relation' => $relationName,'LSobject' => $obj -> getType()));
}
}
public function canEdit() {
return LSsession :: relationCanEdit($this -> obj -> getValue('dn'),$this -> obj -> getType(),$this -> relationName);
}
public function listRelatedObjects() {
if (LSsession :: loadLSobject($this -> config['LSobject'])) {
$objRel = new $this -> config['LSobject']();
if (isset($this -> config['list_function'])) {
if (method_exists($this -> config['LSobject'],$this -> config['list_function'])) {
return call_user_func(array($objRel, $this -> config['list_function']), $this -> obj);
}
LSerror :: addErrorCode('LSrelations_01',array('function' => $this -> config['list_function'], 'action' => _('listing related objects'), 'relation' => $this -> relationName));
return False;
}
elseif (isset($this -> config['linkAttribute']) && isset($this -> config['linkAttributeValue'])) {
return $objRel -> listObjectsInRelation($this -> obj, $this -> config['linkAttribute'], $this -> obj -> getType(), $this -> config['linkAttributeValue']);
}
else {
LSerror :: addErrorCode('LSrelations_05',array('relation' => $this -> relationName,'LSobject' => $this -> config['LSobject'],'action' => _('listing related objects')));
}
}
else {
LSerror :: addErrorCode('LSrelations_04',array('relation' => $this -> relationName,'LSobject' => $this -> config['LSobject']));
}
return;
}
public function getRelatedKeyValue() {
if (LSsession :: loadLSobject($this -> config['LSobject'])) {
$objRel = new $this -> config['LSobject']();
if (isset($this -> config['getkeyvalue_function'])) {
if (method_exists($this -> config['LSobject'],$this -> config['getkeyvalue_function'])) {
return call_user_func(array($objRel, $this -> config['getkeyvalue_function']), $this -> obj);
}
LSerror :: addErrorCode('LSrelations_01',array('function' => $this -> config['getkeyvalue_function'], 'action' => _('getting key value'), 'relation' => $this -> relationName));
}
elseif (isset($this -> config['linkAttribute']) && isset($this -> config['linkAttributeValue'])) {
return $objRel -> getObjectKeyValueInRelation($this -> obj, $this -> obj -> getType(), $this -> config['linkAttributeValue']);
}
else {
LSerror :: addErrorCode('LSrelations_05',array('relation' => $this -> relationName,'LSobject' => $this -> config['LSobject'],'action' => _('getting key value')));
}
}
else {
LSerror :: addErrorCode('LSrelations_04',array('relation' => $this -> relationName,'LSobject' => $this -> config['LSobject']));
}
return;
}
public function getRelatedEditableAttribute() {
if (isset($this -> config['canEdit_attribute'])) {
return $this -> config['canEdit_attribute'];
}
elseif (isset($this -> config['linkAttribute'])) {
return $this -> config['linkAttribute'];
}
return False;
}
public function canEditRelationWithObject($objRel) {
if (isset($this -> config['canEdit_function'])) {
if (method_exists($objRel,$this -> config['canEdit_function'])) {
return call_user_func(array($objRel, $this -> config['canEdit_function']));
}
LSerror :: addErrorCode('LSrelations_01',array('function' => $this -> config['canEdit_function'], 'action' => _('checking right on relation with specific object'), 'relation' => $this -> relationName));
return False;
}
elseif ($this -> getRelatedEditableAttribute()) {
return LSsession :: canEdit($objRel -> getType(),$objRel -> getDn(),$this -> getRelatedEditableAttribute());
}
else {
LSerror :: addErrorCode('LSrelations_05',array('relation' => $this -> relationName,'LSobject' => $this -> config['LSobject'],'action' => _('checking right on relation with specific object')));
}
}
public function removeRelationWithObject($objRel) {
if (isset($this -> config['remove_function'])) {
if (method_exists($this -> config['LSobject'],$this -> config['remove_function'])) {
return call_user_func(array($objRel, $this -> config['remove_function']),$this -> obj);
}
LSerror :: addErrorCode('LSrelations_01',array('function' => $this -> config['remove_function'], 'action' => _('deleting'), 'relation' => $this -> relationName));
return False;
}
elseif (isset($this -> config['linkAttribute']) && isset($this -> config['linkAttributeValue'])) {
return $objRel -> deleteOneObjectInRelation($this -> obj, $this -> config['linkAttribute'], $this -> obj -> getType(), $this -> config['linkAttributeValue']);
}
else {
LSerror :: addErrorCode('LSrelations_05',array('relation' => $this -> relationName,'LSobject' => $this -> config['LSobject'],'action' => _('removing relation with specific object')));
}
return;
}
public function renameRelationWithObject($objRel,$oldKeyValue) {
if (isset($this -> config['rename_function'])) {
if (method_exists($objRel,$this -> config['rename_function'])) {
return call_user_func(array($objRel, $this -> config['rename_function']), $this -> obj, $oldKeyValue);
}
LSerror :: addErrorCode('LSrelations_01',array('function' => $this -> config['rename_function'], 'action' => _('renaming'), 'relation' => $this -> relationName));
return False;
}
elseif (isset($this -> config['linkAttribute']) && isset($this -> config['linkAttributeValue'])) {
return $objRel -> renameOneObjectInRelation($this -> obj, $oldKeyValue, $this -> config['linkAttribute'], $this -> obj -> getType(), $this -> config['linkAttributeValue']);
}
else {
LSerror :: addErrorCode('LSrelations_05',array('relation' => $this -> relationName,'LSobject' => $this -> config['LSobject'],'action' => _('checking right on relation with specific object')));
}
return;
}
public function updateRelations($listDns) {
if (LSsession :: loadLSobject($this -> config['LSobject'])) {
$objRel = new $this -> config['LSobject']();
if (isset($this -> config['update_function'])) {
if (method_exists($objRel,$this -> config['update_function'])) {
return call_user_func(array($objRel, $this -> config['update_function']), $this -> obj, $listDns);
}
LSerror :: addErrorCode('LSrelations_01',array('function' => $this -> config['update_function'], 'action' => _('updating'), 'relation' => $this -> relationName));
}
elseif (isset($this -> config['linkAttribute']) && isset($this -> config['linkAttributeValue'])) {
return $objRel -> updateObjectsInRelation($this -> obj, $listDns, $this -> config['linkAttribute'], $this -> obj -> getType(), $this -> config['linkAttributeValue'],null);
}
else {
LSerror :: addErrorCode('LSrelations_05',array('relation' => $this -> relationName,'LSobject' => $this -> config['LSobject'],'action' => _('updating relations')));
}
}
else {
LSerror :: addErrorCode('LSrelations_04',array('relation' => $this -> relationName,'LSobject' => $this -> config['LSobject']));
}
return;
}
/*
* Méthode chargeant les dépendances d'affichage
*
@ -77,52 +223,33 @@ class LSrelation {
'objectType' => $object -> getType(),
'objectDn' => $object -> getDn(),
);
if (LSsession :: relationCanEdit($object -> getValue('dn'),$object->getType(),$relationName)) {
$relation = new LSrelation($object, $relationName);
if ($relation -> canEdit()) {
$return['actions'][] = array(
'label' => _('Modify'),
'url' => 'select.php?LSobject='.$relationConf['LSobject'].'&amp;multiple=1'.((isset($relationConf['canEdit_attribute']))?'&amp;editableAttr='.$relationConf['canEdit_attribute']:''),
'url' => 'select.php?LSobject='.$relationConf['LSobject'].'&amp;multiple=1'.($relation -> getRelatedEditableAttribute()?'&amp;editableAttr='.$relation -> getRelatedEditableAttribute():''),
'action' => 'modify'
);
}
if (LSsession :: loadLSclass('LSrelation')) {
LSrelation :: loadDependenciesDisplay();
}
if(LSsession :: loadLSobject($relationConf['LSobject'])) {
if (method_exists($relationConf['LSobject'],$relationConf['list_function'])) {
$objRel = new $relationConf['LSobject']();
$list = call_user_func(array($objRel, $relationConf['list_function']), $object);
if (is_array($list)) {
foreach($list as $o) {
$o_infos = array(
'text' => $o -> getDisplayName(NULL,true),
'dn' => $o -> getDn()
);
if (isset($relationConf['canEdit_function'])) {
$o_infos['canEdit']= call_user_func(array($o, $relationConf['canEdit_function']));
}
else {
$o_infos['canEdit']=true;
}
$return['objectList'][] = $o_infos;
}
}
else {
$return['objectList']=array();
}
$list = $relation -> listRelatedObjects();
if (is_array($list)) {
foreach($list as $o) {
$return['objectList'][] = array(
'text' => $o -> getDisplayName(NULL,true),
'dn' => $o -> getDn(),
'canEdit' => $relation -> canEditRelationWithObject($o)
);
}
else {
LSerror :: addErrorCode('LSrelations_01',$relationName);
}
$LSrelations[]=$return;
}
else {
LSerror :: addErrorCode('LSrelations_04',array('relation' => $relationName,'LSobject' => $relationConf['LSobject']));
$return['objectList']=array();
}
$LSrelations[]=$return;
}
}
self :: loadDependenciesDisplay();
LStemplate :: assign('LSrelations',$LSrelations);
LSsession :: addJSconfigParam('LSrelations',$LSrelations_JSparams);
}
@ -135,30 +262,23 @@ class LSrelation {
if (LSsession ::loadLSobject($conf['objectType'])) {
$object = new $conf['objectType']();
if (($object -> loadData($conf['objectDn'])) && (isset($object->config['LSrelation'][$conf['relationName']]))) {
$relationConf = $object->config['LSrelation'][$conf['relationName']];
if (LSsession ::loadLSobject($relationConf['LSobject'])) {
if (LSsession :: relationCanEdit($object -> getValue('dn'),$object -> getType(),$conf['relationName'])) {
if (method_exists($relationConf['LSobject'],$relationConf['list_function'])) {
$objRel = new $relationConf['LSobject']();
$list = call_user_func(array($objRel, $relationConf['list_function']), $object);
$_SESSION['LSselect'][$relationConf['LSobject']]=array();
if (is_array($list)) {
foreach($list as $o) {
$_SESSION['LSselect'][$relationConf['LSobject']][] = $o -> getDn();
}
}
$return = array(
'href' => $_REQUEST['href'],
'id' => $_REQUEST['id']
);
}
else {
LSerror :: addErrorCode('LSrelations_01',$relationName);
$relation = new LSrelation($object, $conf['relationName']);
$LSobjectInRelation = $object->config['LSrelation'][$conf['relationName']]['LSobject'];
if ($relation -> canEdit()) {
$list = $relation -> listRelatedObjects();
$_SESSION['LSselect'][$LSobjectInRelation]=array();
if (is_array($list)) {
foreach($list as $o) {
$_SESSION['LSselect'][$LSobjectInRelation][] = $o -> getDn();
}
}
else {
LSerror :: addErrorCode('LSsession_11');
}
$return = array(
'href' => $_REQUEST['href'],
'id' => $_REQUEST['id']
);
}
else {
LSerror :: addErrorCode('LSsession_11');
}
}
else {
@ -182,58 +302,35 @@ class LSrelation {
if (LSsession ::loadLSobject($conf['objectType'])) {
$object = new $conf['objectType']();
if (($object -> loadData($conf['objectDn'])) && (isset($object->config['LSrelation'][$conf['relationName']]))) {
$relation = new LSrelation($object, $conf['relationName']);
$LSobjectInRelation = $object->config['LSrelation'][$conf['relationName']]['LSobject'];
$relationConf = $object->config['LSrelation'][$conf['relationName']];
if (LSsession ::loadLSobject($relationConf['LSobject'])) {
if (LSsession :: relationCanEdit($object -> getValue('dn'),$object -> getType(),$conf['relationName'])) {
if (is_array($_SESSION['LSselect'][$relationConf['LSobject']])) {
if (method_exists($relationConf['LSobject'],$relationConf['update_function'])) {
$objRel = new $relationConf['LSobject']();
if(call_user_func(array($objRel, $relationConf['update_function']), $object,$_SESSION['LSselect'][$relationConf['LSobject']])) {
if (method_exists($relationConf['LSobject'],$relationConf['list_function'])) {
$list = call_user_func(array($objRel, $relationConf['list_function']), $object);
if (is_array($list)&&(!empty($list))) {
$data['html']="";
foreach($list as $o) {
if (isset($relationConf['canEdit_function'])) {
if (call_user_func(array($o, $relationConf['canEdit_function']))) {
$class=' LSrelation_editable';
}
else {
$class='';
}
}
else {
$class=' LSrelation_editable';
}
$data['html'].= "<li class='LSrelation'><a href='view.php?LSobject=".$relationConf['LSobject']."&amp;dn=".urlencode($o -> getDn())."' class='LSrelation$class' id='LSrelation_".$_REQUEST['id']."_".$o -> getDn()."'>".$o -> getDisplayName(NULL,true)."</a></li>\n";
}
}
else {
if (isset($relationConf['emptyText'])) {
$data['html'] = "<li>".__($relationConf['emptyText'])."</li>\n";
}
else {
$data['html'] = "<li>"._('No object.')."</li>\n";
}
}
$data['id'] = $_REQUEST['id'];
}
else {
LSerror :: addErrorCode('LSrelations_01',$relationName);
}
}
else {
LSerror :: addErrorCode('LSrelations_03',$relationName);
}
if($relation -> updateRelations($_SESSION['LSselect'][$LSobjectInRelation])) {
$list = $relation -> listRelatedObjects();
if (is_array($list)&&(!empty($list))) {
$data['html']="";
foreach($list as $o) {
if ($relation -> canEditRelationWithObject($o)) {
$class=' LSrelation_editable';
}
else {
LSerror :: addErrorCode('LSrelations_02',$relationName);
$class='';
}
$data['html'].= "<li class='LSrelation'><a href='view.php?LSobject=$LSobjectInRelation&amp;dn=".urlencode($o -> getDn())."' class='LSrelation$class' id='LSrelation_".$_REQUEST['id']."_".$o -> getDn()."'>".$o -> getDisplayName(NULL,true)."</a></li>\n";
}
}
else {
LSerror :: addErrorCode('LSsession_11');
if (isset($relationConf['emptyText'])) {
$data['html'] = "<li>".__($relationConf['emptyText'])."</li>\n";
}
else {
$data['html'] = "<li>"._('No object.')."</li>\n";
}
}
$data['id'] = $_REQUEST['id'];
}
else {
LSerror :: addErrorCode('LSrelations_03',$relationName);
}
}
else {
@ -257,54 +354,44 @@ class LSrelation {
if (LSsession ::loadLSobject($conf['objectType'])) {
$object = new $conf['objectType']();
if (($object -> loadData($conf['objectDn'])) && (isset($object->config['LSrelation'][$conf['relationName']]))) {
$relationConf = $object->config['LSrelation'][$conf['relationName']];
if (LSsession ::loadLSobject($relationConf['LSobject'])) {
if (LSsession :: relationCanEdit($object -> getValue('dn'),$object -> getType(),$conf['relationName'])) {
if (method_exists($relationConf['LSobject'],$relationConf['list_function'])) {
$objRel = new $relationConf['LSobject']();
$list = call_user_func(array($objRel, $relationConf['list_function']), $object);
if (is_array($list)) {
$ok=false;
foreach($list as $o) {
if($o -> getDn() == $_REQUEST['dn']) {
if (isset($relationConf['canEdit_function'])) {
if (!call_user_func(array($o, $relationConf['canEdit_function']))) {
LSerror :: addErrorCode('LSsession_11');
break;
}
}
if (!call_user_func(array($o, $relationConf['remove_function']), $object)) {
LSerror :: addErrorCode('LSrelations_03',$conf['relationName']);
}
else {
$ok = true;
}
break;
}
$relation = new LSrelation($object, $conf['relationName']);
if ($relation -> canEdit()) {
$list = $relation -> listRelatedObjects();
if (is_array($list)) {
$ok=false;
foreach($list as $o) {
if($o -> getDn() == $_REQUEST['dn']) {
if (!$relation -> canEditRelationWithObject($o)) {
LSerror :: addErrorCode('LSsession_11');
return;
}
if (!$ok) {
LSdebug($_REQUEST['value']." introuvé parmi la liste");
if (!$relation -> removeRelationWithObject($o)) {
LSerror :: addErrorCode('LSrelations_03',$conf['relationName']);
}
else {
$data=array(
'dn' => $_REQUEST['dn'],
'id' => $_REQUEST['id']
);
$ok = true;
}
}
else {
LSerror :: addErrorCode('LSrelations_03',$conf['relationName']);
break;
}
}
if (!$ok) {
LSdebug($_REQUEST['value']." introuvé parmi la liste");
LSerror :: addErrorCode('LSrelations_03',$conf['relationName']);
}
else {
LSerror :: addErrorCode('LSrelations_01',$conf['relationName']);
$data=array(
'dn' => $_REQUEST['dn'],
'id' => $_REQUEST['id']
);
}
}
else {
LSerror :: addErrorCode('LSsession_11');
LSerror :: addErrorCode('LSrelations_03',$conf['relationName']);
}
}
else {
LSerror :: addErrorCode('LSsession_11');
}
}
else {
LSerror :: addErrorCode('LSsession_12');
@ -325,10 +412,10 @@ class LSrelation {
* Error Codes
**/
LSerror :: defineError('LSrelations_01',
_("LSrelation : The listing function for the relation %{relation} is unknow.")
_("LSrelation : The function %{function} for action '%{action}' on the relation %{relation} is unknow.")
);
LSerror :: defineError('LSrelations_02',
_("LSrelation : The update function of the relation %{relation} is unknow.")
_("LSrelation : Relation %{relation} of object type %{LSobject} unknow.")
);
LSerror :: defineError('LSrelations_03',
_("LSrelation : Error during relation update of the relation %{relation}.")
@ -336,5 +423,6 @@ _("LSrelation : Error during relation update of the relation %{relation}.")
LSerror :: defineError('LSrelations_04',
_("LSrelation : Object type %{LSobject} unknow (Relation : %{relation}).")
);
?>
LSerror :: defineError('LSrelations_05',
_("LSrelation : Incomplete configuration for LSrelation %{relation} of object type %{LSobject} for action : %{action}.")
);

File diff suppressed because it is too large Load diff

View file

@ -2,9 +2,6 @@
$GLOBALS['LSlang'] = array (
"%{value} (unrecognized value)" =>
"%{value} (valeur non-reconnue)",
"== All ==" =>
"== Toutes ==",
@ -35,15 +32,15 @@ $GLOBALS['LSlang'] = array (
"Doesn't belong to any group." =>
"N'appartient à aucun groupe.",
"Doesn't sponsor any user." =>
"Ne parraine aucun utilisateur.",
"E-mail address" =>
"Adresse e-mail",
"Entity %{id} (unrecognized)" =>
"Entité %{id} (non-reconnue)",
"Errors" =>
"Erreurs",
"File" =>
"Fichier",
@ -65,15 +62,15 @@ $GLOBALS['LSlang'] = array (
"Given email address is invalid." =>
"L'adresse mail saisie est invalide.",
"Godfather of ..." =>
"Parrain de ...",
"Groups" =>
"Groupes",
"Home Directory" =>
"Dossier personnel",
"Identifier" =>
"Identifiant",
"Identifier must contain alphanumeric values, dots (.) and dashes (-) only." =>
"L'identifiant doit contenir uniquement des valeurs alpha-numériques, avec eventuellement des points (.) et des tirets (-).",
@ -140,9 +137,6 @@ $GLOBALS['LSlang'] = array (
"Only validate data" =>
"Validation des données uniquement",
"Password" =>
"Mot de passe",
"Password recovery hash" =>
"Hash de récupération de mot de passe",

File diff suppressed because it is too large Load diff