Browse Source

enabled PosixGroup support

master
Andrea Cimbalo 11 years ago
parent
commit
ba557e03c4
1 changed files with 27 additions and 5 deletions
  1. +27
    -5
      lilikuser.php

+ 27
- 5
lilikuser.php View File

@ -240,9 +240,13 @@ class GroupAdapter extends Adapter{
$this->add_getter('member');
$this->add_setter('member');
$this->add_getter('memberUid');
$this->add_setter('memberUid');
}
}
abstract class pippo{
function __construct($id){
global $HOST, $PORT, $LOGIN_DN, $LOGIN_PASS;
@ -320,22 +324,30 @@ abstract class pippo{
}
class LilikGroup extends pippo{
function __construct($id){
function __construct($id, $is_posix=False){
global $HOST, $PORT, $LOGIN_DN;
parent::__construct($id);
$this->adapters=[new GroupAdapter("cn=%s,o=Group,dc=lilik,dc=it")];
$this->is_posix=$is_posix;
}
function get_id($id){
if ($is_posix)
return $id;
else
return sprintf($user->adapters[1]->dn,$user->id);
}
function add_user($user){
return $this->add_in_list('member', sprintf($user->adapters[1]->dn,$user->id));
return $this->add_in_list('member', get_id($user->id));
}
function del_user($user){
return $this->del_in_list('member', sprintf($user->adapters[1]->dn,$user->id));
return $this->del_in_list('member', get_id($user->id));
}
function is_user($user){
if (in_array(sprintf($user->adapters[1]->dn,$user->id), $this->get_attr('member'))){
if (in_array(get_id($user->id), $this->get_attr('member'))){
return True;
}
return False;
@ -352,12 +364,13 @@ class LilikUser extends pippo{
'users'=>'users');
$this->_member=array('admin'=>'admin',
'wiki'=>'wiki',
'users_sites'=>'users_sites',
'lilik.it'=>'lilik.it',
'cloud'=>'cloud',
'projects'=>'projects',
'teambox'=>'teambox'
);
$this->_posix_member=array('users_sites'=>'users_sites');
if ($this->exist()){
$this->sanitize();
}
@ -379,6 +392,9 @@ class LilikUser extends pippo{
}elseif (array_key_exists($service, $this->_member)){
$l=new LilikGroup($this->_member[$service]);
return $l->add_user($this);
}elseif (array_key_exists($service, $this->_posix_member)){
$l=new LilikGroup($this->_member[$service], True);
return $l->add_user($this);
}else{
throw new Exception("Service not found");
}
@ -392,6 +408,9 @@ class LilikUser extends pippo{
}elseif (array_key_exists($service, $this->_member)){
$l=new LilikGroup($this->_member[$service]);
return $l->del_user($this);
}elseif (array_key_exists($service, $this->_posix_member)){
$l=new LilikGroup($this->_member[$service], True);
return $l->del_user($this);
}else{
throw new Exception("Service not found");
}
@ -411,6 +430,9 @@ class LilikUser extends pippo{
}elseif (array_key_exists($service, $this->_member)){
$l=new LilikGroup($this->_member[$service]);
return $l->is_user($this);
}elseif (array_key_exists($service, $this->_posix_member)){
$l=new LilikGroup($this->_member[$service], True);
return $l->is_user($this);
}else{
throw new Exception("Service not found");
}


Loading…
Cancel
Save