'lscompany'
),
'rdn' => 'ou',
- 'orderby' => 'displayName', // possible cases : 'displayName' ou 'subDn'
'container_dn' => 'ou=companies',
'display_name_format' => '%{ou}',
'label' => 'Companies',
'posixGroup'
),
'rdn' => 'cn',
- 'orderby' => 'displayName', // Valeurs possibles : 'displayName' ou 'subDn'
'container_dn' => 'ou=groups',
'container_auto_create' => array(
'objectclass' => array(
'view' => 1,
'rights' => array(
'admin' => 'w',
+ 'admingroup' => 'w',
'godfather' => 'w'
),
'form' => array (
'posixAccount',
'sambaSamAccount',
),
- 'orderby' => 'displayName', // Valeurs possibles : 'displayName' ou 'subDn'
'rdn' => 'uid',
'container_dn' => 'ou=people',
'update_function' => 'updateUserGroups',
'remove_function' => 'deleteOneMember',
'rename_function' => 'renameOneMember',
+ 'canEdit_function' => 'canEditGroupRelation',
+ 'canEdit_attribute' => 'uniqueMember',
'rights' => array(
'self' => 'r',
- 'admin' => 'w'
+ 'admin' => 'w',
+ 'admingroup' => 'w'
)
)
),
'LSobject' => 'LSgroup'
)
)
+ ),
+ 'admingroup' => array (
+ 'ou=company1,ou=companies,o=ls' => array (
+ 'uid=user1,ou=people,ou=company1,ou=companies,o=ls' => NULL
+ )
)
),
'authObjectType' => 'LSpeople',
* @param[in] $attrValue La valeur que doit avoir l'attribut :
* - soit le dn (par defaut)
* - soit la valeur [0] d'un attribut
+ * @param[in] $canEditFunction Le nom de la fonction pour vérifier que la
+ * relation avec l'objet est éditable par le user
*
* @retval boolean true si l'objet à été ajouté, False sinon
**/
- function addOneObjectInRelation($object,$attr,$objectType,$attrValue='dn') {
+ function addOneObjectInRelation($object,$attr,$objectType,$attrValue='dn',$canEditFunction=NULL) {
if ((!$attr)||(!$objectType)) {
LSerror :: addErrorCode('LSrelations_05','addOneObjectInRelation');
return;
}
if ($object instanceof $objectType) {
+ if ($canEditFunction) {
+ if (!$this -> $canEditFunction()) {
+ LSerror :: addErrorCode('LSsession_11');
+ return;
+ }
+ }
if ($this -> attrs[$attr] instanceof LSattribute) {
if ($attrValue=='dn') {
$val = $object -> getDn();
* @param[in] $attrValue La valeur que doit avoir l'attribut :
* - soit le dn (par defaut)
* - soit la valeur [0] d'un attribut
+ * @param[in] $canEditFunction Le nom de la fonction pour vérifier que la
+ * relation avec l'objet est éditable par le user
*
* @retval boolean true si l'objet à été supprimé, False sinon
**/
- function deleteOneObjectInRelation($object,$attr,$objectType,$attrValue='dn') {
+ function deleteOneObjectInRelation($object,$attr,$objectType,$attrValue='dn',$canEditFunction=NULL) {
if ((!$attr)||(!$objectType)) {
LSerror :: addErrorCode('LSrelations_05','deleteOneObjectInRelation');
return;
}
if ($object instanceof $objectType) {
+ if ($canEditFunction) {
+ if (!$this -> $canEditFunction()) {
+ LSerror :: addErrorCode('LSsession_11');
+ return;
+ }
+ }
if ($this -> attrs[$attr] instanceof LSattribute) {
if ($attrValue=='dn') {
$val = $object -> getDn();
* @param[in] $attrValue La valeur que doit avoir l'attribut :
* - soit le dn (par defaut)
* - soit la valeur [0] d'un attribut
+ * @param[in] $canEditFunction Le nom de la fonction pour vérifier que la
+ * relation avec l'objet est éditable par le user
*
* @retval boolean true si tout c'est bien passé, False sinon
**/
- function updateObjectsInRelation($object,$listDns,$attr,$objectType,$attrValue='dn') {
+ function updateObjectsInRelation($object,$listDns,$attr,$objectType,$attrValue='dn',$canEditFunction=NULL) {
if ((!$attr)||(!$objectType)) {
LSerror :: addErrorCode('LSrelations_05','updateObjectsInRelation');
return;
continue;
}
else {
- if (!$currentObjects[$i] -> deleteOneObjectInRelation($object,$attr,$objectType,$attrValue)) {
+ if (!$currentObjects[$i] -> deleteOneObjectInRelation($object,$attr,$objectType,$attrValue,$canEditFunction)) {
return;
}
}
else {
$obj = new $type();
if ($obj -> loadData($dn)) {
- if (!$obj -> addOneObjectInRelation($object,$attr,$objectType,$attrValue)) {
+ if (!$obj -> addOneObjectInRelation($object,$attr,$objectType,$attrValue,$canEditFunction)) {
return;
}
}
foreach($listDns as $dn) {
$obj = new $type();
if ($obj -> loadData($dn)) {
- if (!$obj -> addOneObjectInRelation($object,$attr,$objectType,$attrValue)) {
+ if (!$obj -> addOneObjectInRelation($object,$attr,$objectType,$attrValue,$canEditFunction)) {
return;
}
}
* @retval boolean true si l'utilisateur à été ajouté, False sinon
**/
function addOneMember($object) {
- return $this -> addOneObjectInRelation($object,$this -> memberAttr, $this -> userObjectType);
+ return $this -> addOneObjectInRelation($object,$this -> memberAttr, $this -> userObjectType,'dn','canEditGroupRelation');
}
/**
* @retval boolean true si l'utilisateur à été supprimé, False sinon
**/
function deleteOneMember($object) {
- return $this -> deleteOneObjectInRelation($object,$this -> memberAttr,$this -> userObjectType);
+ return $this -> deleteOneObjectInRelation($object,$this -> memberAttr,$this -> userObjectType,'dn','canEditGroupRelation');
}
/**
* @retval boolean true si tout c'est bien passé, False sinon
**/
function updateUserGroups($object,$listDns) {
- return $this -> updateObjectsInRelation($object,$listDns,$this -> memberAttr,$this -> userObjectType);
+ return $this -> updateObjectsInRelation($object,$listDns,$this -> memberAttr,$this -> userObjectType,'dn','canEditGroupRelation');
+ }
+
+ /**
+ * Test si l'utilisateur peut d'editer la relation avec ce groupe
+ *
+ * @retval boolean true si tout l'utilisateur peut éditer la relation, False sinon
+ **/
+ function canEditGroupRelation($dn=NULL) {
+ if (!$dn) {
+ $dn=$this -> dn;
+ }
+ return LSsession :: canEdit($this -> type_name,$this -> dn,$this -> memberAttr);
}
}
if (LSsession :: relationCanEdit($object -> getValue('dn'),$object->getType(),$relationName)) {
$return['actions'][] = array(
'label' => _('Modify'),
- 'url' => 'select.php?LSobject='.$relationConf['LSobject'].'&multiple=1',
+ 'url' => 'select.php?LSobject='.$relationConf['LSobject'].'&multiple=1'.((isset($relationConf['canEdit_attribute']))?'&editableAttr='.$relationConf['canEdit_attribute']:''),
'action' => 'modify'
);
}
'text' => $o -> getDisplayName(NULL,true),
'dn' => $o -> getDn()
);
+ if (isset($relationConf['canEdit_function'])) {
+ $o_infos['canEdit']= $o -> $relationConf['canEdit_function']();
+ }
+ else {
+ $o_infos['canEdit']=true;
+ }
$return['objectList'][] = $o_infos;
}
}
$list = $objRel -> $relationConf['list_function']($object);
if (is_array($list)&&(!empty($list))) {
foreach($list as $o) {
- $data['html'].= "<li class='LSrelation'><a href='view.php?LSobject=".$relationConf['LSobject']."&dn=".$o -> getDn()."' class='LSrelation' id='".$o -> getDn()."'>".$o -> getDisplayName(NULL,true)."</a></li>\n";
+ if (isset($relationConf['canEdit_function'])) {
+ if ($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']."&dn=".$o -> getDn()."' class='LSrelation$class' id='".$o -> getDn()."'>".$o -> getDisplayName(NULL,true)."</a></li>\n";
}
}
else {
$ok=false;
foreach($list as $o) {
if($o -> getDn() == $_REQUEST['dn']) {
+ if (isset($relationConf['canEdit_function'])) {
+ if (!$o -> $relationConf['canEdit_function']()) {
+ LSerror :: addErrorCode('LSsession_11');
+ break;
+ }
+ }
if (!$o -> $relationConf['remove_function']($object)) {
LSerror :: addErrorCode('LSrelations_03',$conf['relationName']);
}
else {
$ok = true;
}
+ break;
}
}
if (!$ok) {
el.destroy();
}, this);
this.deleteBtnId = 0;
- $$('a.LSrelation').each(function(a) {
+ $$('a.LSrelation_editable').each(function(a) {
this.deleteBtn[this.deleteBtnId] = new Element('img');
this.deleteBtn[this.deleteBtnId].src = varLSdefault.imagePath('delete.png');
this.deleteBtn[this.deleteBtnId].setStyle('cursor','pointer');
{/if}
<ul id='LSrelation_ul_{$item.id}' class='LSrelation'>
{foreach from=$item.objectList item=object}
- <li class='LSrelation'><a href='view.php?LSobject={$item.LSobject}&dn={$object.dn}' class='LSrelation' id='{$object.dn}'>{$object.text}</a></li>
+ <li class='LSrelation'><a href='view.php?LSobject={$item.LSobject}&dn={$object.dn}' class='LSrelation{if $object.canEdit} LSrelation_editable{/if}' id='{$object.dn}'>{$object.text}</a></li>
{foreachelse}
<li class='LSrelation'>{$item.emptyText}</li>
{/foreach}