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

Fixes #4064 PHP errors when I delete a template

parent cf6ccf04
......@@ -667,8 +667,11 @@ class simpleManagement extends management
$type = $this->getType($dn);
if (preg_match('/^template_/', $type) && !$this->skipTemplates) {
$type = preg_replace('/^template_/', '', $type);
$info = objects::infos($type);
$info['mainAttr'] = 'cn';
} else {
$info = objects::infos($type);
}
$info = objects::infos($type);
$entry = $this->getHeadpage()->getEntry($dn);
$objects[] = array(
'name' => $entry[$info['mainAttr']][0],
......
......@@ -22,6 +22,9 @@ class userRoles extends simplePlugin
{
var $objectclasses = array();
protected $savedGroupsMembership = array();
protected $savedRolesMembership = array();
static function plInfo()
{
return array(
......@@ -126,17 +129,19 @@ class userRoles extends simplePlugin
function remove_from_parent()
{
/* Remove all groups */
foreach ($this->savedGroupsMembership as $ogroupdn) {
$g = objects::open($ogroupdn, 'ogroup');
$g->getBaseObject()->attributesAccess['member']->searchAndRemove($this->dn);
$g->save();
}
/* Remove all roles */
foreach ($this->savedRolesMembership as $roledn) {
$r = objects::open($roledn, 'role');
$r->getBaseObject()->attributesAccess['roleOccupant']->searchAndRemove($this->dn);
$r->save();
if (!$this->is_template) {
/* Remove all groups */
foreach ($this->savedGroupsMembership as $ogroupdn) {
$g = objects::open($ogroupdn, 'ogroup');
$g->getBaseObject()->attributesAccess['member']->searchAndRemove($this->dn);
$g->save();
}
/* Remove all roles */
foreach ($this->savedRolesMembership as $roledn) {
$r = objects::open($roledn, 'role');
$r->getBaseObject()->attributesAccess['roleOccupant']->searchAndRemove($this->dn);
$r->save();
}
}
}
......
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