Commit af27f0c2 authored by Côme Bernigaud's avatar Côme Bernigaud Committed by Benoit Mortier
Browse files

Fixes: #1922 Added foreign keys in group and user

parent 59b1c428
......@@ -980,8 +980,7 @@ class group extends plugin
/* Remove ACL dependencies too,
*/
if($this->dn != $this->orig_dn && $this->orig_dn != "new"){
$tmp = new acl($this->config,$this->dn,$this->parent);
$tmp->update_acl_membership($this->orig_dn,$this->dn);
acl::update_acl_membership($this->orig_dn,$this->dn);
}
if($this->initially_was_account){
......@@ -1120,6 +1119,10 @@ class group extends plugin
'icon' => 'plugins/groups/images/iconMini.png',
'mainAttr' => 'cn',
)),
'plForeignKeys' => array(
'memberUid' => array('user','uid')
),
"plProvidedAcls" => array(
"cn" => _("Name"),
......@@ -1139,6 +1142,27 @@ class group extends plugin
);
}
function foreignKeyUpdate ($field, $oldvalue, $newvalue, $source)
{
if ($field == 'memberUid' && $source == 'uid') {
if (isset($this->memberUid[$oldvalue])) {
$this->removeUser($oldvalue);
$this->addUser($newvalue);
}
} else {
return parent::foreignKeyUpdate($field, $oldvalue, $newvalue, $source);
}
}
function foreignKeyCheck ($field, $value, $source)
{
if ($field == 'memberUid' && $source == 'uid') {
return isset($this->memberUid[$value]);
} else {
return parent::foreignKeyCheck($field, $value, $source);
}
}
/*! \brief Get a new SambaSID for a group */
function getSambaSID()
{
......
......@@ -1068,8 +1068,7 @@ class user extends plugin
/* Remove ACL dependencies too */
if ($this->dn != $this->orig_dn && $this->orig_dn != "new") {
$tmp = new acl($this->config, $this->dn, $this->parent);
$tmp->update_acl_membership($this->orig_dn, $this->dn);
acl::update_acl_membership($this->orig_dn, $this->dn);
}
if($mode == "modify"){
......@@ -1488,6 +1487,9 @@ class user extends plugin
'icon' => 'plugins/users/images/iconMini.png',
'ou' => get_ou('userRDN'),
)),
'plForeignKeys' => array(
'manager' => array('user','dn')
),
"plProvidedAcls" => array(
"sn" => _("Surname"),
......@@ -1539,6 +1541,26 @@ class user extends plugin
return $ret;
}
function foreignKeyUpdate ($field, $oldvalue, $newvalue, $source)
{
if ($field == 'manager' && $source == 'dn') {
if ($this->manager == $oldvalue) {
$this->manager = $newvalue;
}
} else {
return parent::foreignKeyUpdate($field, $oldvalue, $newvalue, $source);
}
}
function foreignKeyCheck ($field, $value, $source)
{
if ($field == 'manager' && $source == 'dn') {
return ($this->manager == $value);
} else {
return parent::foreignKeyCheck($field, $value, $source);
}
}
function convertLoginRestriction()
{
$all = array_unique(array_merge($this->gosaLoginRestriction,$this->gosaLoginRestriction_some));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment