2008-02-05 17:11:21 +01:00
|
|
|
<?php
|
|
|
|
/*******************************************************************************
|
|
|
|
* Copyright (C) 2007 Easter-eggs
|
|
|
|
* http://ldapsaisie.labs.libre-entreprise.org
|
|
|
|
*
|
|
|
|
* Author: See AUTHORS file in top-level directory.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License version 2
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
/**
|
2009-04-17 12:39:03 +02:00
|
|
|
* Objet Ldap group
|
2008-02-05 17:11:21 +01:00
|
|
|
*
|
|
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
|
|
*/
|
2009-04-17 12:39:03 +02:00
|
|
|
class LSgroup extends LSldapObject {
|
2008-02-05 17:11:21 +01:00
|
|
|
|
2009-04-17 12:39:03 +02:00
|
|
|
var $userObjectType = 'LSpeople';
|
2008-10-08 15:42:42 +02:00
|
|
|
var $memberAttr = 'uniqueMember';
|
2011-10-03 18:19:36 +02:00
|
|
|
var $memberAttrValue = 'dn';
|
2008-07-29 15:45:02 +02:00
|
|
|
|
2008-10-08 15:42:42 +02:00
|
|
|
/* ========== Members ========== */
|
2008-10-09 11:50:38 +02:00
|
|
|
/**
|
|
|
|
* Retourne la valeur clef d'un membre
|
|
|
|
*
|
|
|
|
* @param[in] $object Un object utilisateur
|
|
|
|
*
|
|
|
|
* @retval Mixed La valeur clef d'un membre
|
|
|
|
**/
|
|
|
|
function getMemberKeyValue($object) {
|
2011-10-03 18:19:36 +02:00
|
|
|
return $this -> getObjectKeyValueInRelation($object,$this -> memberAttr,$this -> userObjectType);
|
2008-10-09 11:50:38 +02:00
|
|
|
}
|
|
|
|
|
2008-02-26 18:40:05 +01:00
|
|
|
/**
|
2008-10-08 15:42:42 +02:00
|
|
|
* Retourne la liste des groupes pour utilisateur
|
2008-02-26 18:40:05 +01:00
|
|
|
*
|
2009-04-17 12:39:03 +02:00
|
|
|
* Retourne un tableau de LSgroup correspondant aux groupes
|
2008-02-26 18:40:05 +01:00
|
|
|
* auxquels appartient un utilisateur
|
|
|
|
*
|
2008-07-29 15:45:02 +02:00
|
|
|
* @param[in] $userObject Un object user (type : $this -> userObjectType)
|
2008-02-26 18:40:05 +01:00
|
|
|
*
|
2009-04-17 12:39:03 +02:00
|
|
|
* @retval Array of LSgroup Les groupes de l'utilisateur
|
2008-02-26 18:40:05 +01:00
|
|
|
**/
|
|
|
|
function listUserGroups($userObject) {
|
2011-10-03 18:19:36 +02:00
|
|
|
return $this -> listObjectsInRelation($userObject,$this -> memberAttr,$this -> userObjectType,$this -> memberAttrValue);
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Ajoute un utilisateur au groupe
|
|
|
|
*
|
2008-07-29 15:45:02 +02:00
|
|
|
* @param[in] $object Un object user ($this -> userObjectType) : l'utilisateur à ajouter
|
2008-02-26 18:40:05 +01:00
|
|
|
*
|
2008-04-25 16:09:27 +02:00
|
|
|
* @retval boolean true si l'utilisateur à été ajouté, False sinon
|
2008-02-26 18:40:05 +01:00
|
|
|
**/
|
|
|
|
function addOneMember($object) {
|
2011-10-03 18:19:36 +02:00
|
|
|
return $this -> addOneObjectInRelation($object,$this -> memberAttr, $this -> userObjectType,$this -> memberAttrValue,'canEditGroupRelation');
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Supprime un utilisateur du groupe
|
|
|
|
*
|
2008-07-29 15:45:02 +02:00
|
|
|
* @param[in] $object Un object (type : $this -> userObjectType) : l'utilisateur à supprimer
|
2008-02-26 18:40:05 +01:00
|
|
|
*
|
2008-04-25 16:09:27 +02:00
|
|
|
* @retval boolean true si l'utilisateur à été supprimé, False sinon
|
2008-02-26 18:40:05 +01:00
|
|
|
**/
|
|
|
|
function deleteOneMember($object) {
|
2011-10-03 18:19:36 +02:00
|
|
|
return $this -> deleteOneObjectInRelation($object,$this -> memberAttr,$this -> userObjectType,$this -> memberAttrValue,'canEditGroupRelation');
|
2008-07-29 15:45:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-10-08 15:42:42 +02:00
|
|
|
* Renome un utilisateur du groupe
|
2008-07-29 15:45:02 +02:00
|
|
|
*
|
|
|
|
* @param[in] $object Un object (type : $this -> userObjectType) : l'utilisateur à renomer
|
|
|
|
* @param[in] $oldDn string L'ancien DN de l'utilisateur
|
|
|
|
*
|
|
|
|
* @retval boolean True en cas de succès, False sinon
|
|
|
|
*/
|
|
|
|
function renameOneMember($object,$oldDn) {
|
2011-10-03 18:19:36 +02:00
|
|
|
return $this -> renameOneObjectInRelation($object,$oldDn,$this -> memberAttr,$this -> userObjectType,$this -> memberAttrValue);
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-04-25 16:09:27 +02:00
|
|
|
* Met à jour les groupes d'un utilisateur
|
2008-02-26 18:40:05 +01:00
|
|
|
*
|
2008-10-08 15:42:42 +02:00
|
|
|
* @param[in] $object Mixed Un object (type : $this -> userObjectType) : l'utilisateur
|
2008-02-26 18:40:05 +01:00
|
|
|
* @param[in] $listDns Array(string) Un tableau des DNs des groupes de l'utilisateur
|
|
|
|
*
|
2008-04-25 16:09:27 +02:00
|
|
|
* @retval boolean true si tout c'est bien passé, False sinon
|
2008-02-26 18:40:05 +01:00
|
|
|
**/
|
2008-10-08 15:42:42 +02:00
|
|
|
function updateUserGroups($object,$listDns) {
|
2011-10-03 18:19:36 +02:00
|
|
|
return $this -> updateObjectsInRelation($object,$listDns,$this -> memberAttr,$this -> userObjectType,$this -> memberAttrValue,'canEditGroupRelation');
|
2009-11-11 21:00:59 +01:00
|
|
|
}
|
2011-10-03 18:19:36 +02:00
|
|
|
|
2009-11-11 21:00:59 +01:00
|
|
|
/**
|
|
|
|
* 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);
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
2008-02-05 17:11:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|