From c16d7588512de02e85618a51e3f45fb0a8f72dbf Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 15 Sep 2011 08:20:53 +0000 Subject: [PATCH] Backports from 2.7 -Updated the dyngroup plugin, to avoid saving objects members that were collected via dyngroup as real object members. .e.g There is a group that uses dyngroup to include all users an memberUid attribue. If we now save the group, we do not want to get this memberUid attributes saved as real properties, instead they have to stay dynamic git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.7@20996 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../dyngroup/class_DynamicLdapGroup.inc | 13 ++++ .../plugins/admin/groups/class_group.inc | 39 +++++++++--- gosa-core/plugins/admin/groups/generic.tpl | 61 ++++++++++++------- .../plugins/admin/ogroups/class_ogroup.inc | 32 ++++++++-- gosa-core/plugins/admin/ogroups/generic.tpl | 7 +++ 5 files changed, 115 insertions(+), 37 deletions(-) diff --git a/gosa-core/plugins/addons/dyngroup/class_DynamicLdapGroup.inc b/gosa-core/plugins/addons/dyngroup/class_DynamicLdapGroup.inc index 60f05865f..bedc5eecc 100644 --- a/gosa-core/plugins/addons/dyngroup/class_DynamicLdapGroup.inc +++ b/gosa-core/plugins/addons/dyngroup/class_DynamicLdapGroup.inc @@ -96,6 +96,19 @@ class DynamicLdapGroup extends plugin } + /*!\brief Checks whether the given attribute is managed by this dyngroup extension or not. + */ + function isAttributeDynamic($attr) + { + if($this->is_account){ + foreach($this->labeledURIparsed as $uri){ + if($uri['attr'] == $attr) return(TRUE); + } + } + return(FALSE); + } + + public function check () { $messages = plugin::check(); diff --git a/gosa-core/plugins/admin/groups/class_group.inc b/gosa-core/plugins/admin/groups/class_group.inc index cab9e58ff..b0d44f6f1 100644 --- a/gosa-core/plugins/admin/groups/class_group.inc +++ b/gosa-core/plugins/admin/groups/class_group.inc @@ -203,7 +203,7 @@ class group extends plugin // Prepare lists $this->memberList = new sortableListing(); $this->memberList->setDeleteable(true); - $this->memberList->setInstantDelete(true); + $this->memberList->setInstantDelete(false); $this->memberList->setEditable(false); $this->memberList->setWidth("100%"); $this->memberList->setHeight("300px"); @@ -327,8 +327,8 @@ class group extends plugin foreach($this->members as $uid => $member){ $data[$uid] = $member; $givenName = $sn = _("Unknown"); - if(isset($member['sn'][0])) $sn = $member['sn'][0]; - if(isset($member['givenName'][0])) $givenName = $member['givenName'][0]; + if(isset($member['sn']) && isset($member['sn'][0])) $sn = $member['sn'][0]; + if(isset($member['givenName']) && isset($member['givenName'][0])) $givenName = $member['givenName'][0]; $image = image('images/false.png'); if(isset($member['sn'])){ $image = image('plugins/users/images/select_user.png'); @@ -336,6 +336,8 @@ class group extends plugin $lData[$uid] = array('data' => array($image,$sn, $givenName, $uid)); } $this->memberList->setListData($data,$lData); + $bool = $this->isRestrictedByDynGroup(); + $this->memberList->setDeleteable(!$bool); $this->memberList->update(); $smarty->assign("memberList", $this->memberList->render()); }else{ @@ -362,11 +364,11 @@ class group extends plugin $data = $lData = array(); foreach($this->memberUid_used_by_some as $uid => $member){ - $member = $this->members[$member]; + $member = (isset($this->members[$member])) ? $this->members[$member] : NULL; $data[$uid] = $member; $givenName = $sn = _("Unknown"); - if(isset($member['sn'][0])) $sn = $member['sn'][0]; - if(isset($member['givenName'][0])) $givenName = $member['givenName'][0]; + if(isset($member['sn']) && isset($member['sn'][0])) $sn = $member['sn'][0]; + if(isset($member['givenName'][0]) && isset($member['givenName'][0])) $givenName = $member['givenName'][0]; $image = image('images/false.png'); if(isset($member['sn'])){ $image = image('plugins/users/images/select_user.png'); @@ -437,9 +439,26 @@ class group extends plugin } } + $bool = $this->isRestrictedByDynGroup(); + $smarty->assign("restrictedByDynGroup", $bool); + if($bool){ + $smarty->assign("memberUidACL", preg_replace("/[^r]/","",$this->getacl('memberUid'))); + + } return($smarty->fetch (get_template_path('generic.tpl', TRUE))); } + + function isRestrictedByDynGroup() + { + $bool = FALSE; + if(isset($this->parent->by_object['DynamicLdapGroup'])){ + $bool = $this->parent->by_object['DynamicLdapGroup']->isAttributeDynamic('memberUid') || + $this->parent->by_object['DynamicLdapGroup']->isAttributeDynamic('member'); + } + return($bool); + } + function addUser($uid) { /* In mutliple edit we have to handle two arrays. @@ -794,7 +813,8 @@ class group extends plugin } /* Take members array */ - if (count ($this->memberUid)){ + + if (!$this->isRestrictedByDynGroup() && count ($this->memberUid)){ $this->attrs['memberUid']= array_values(array_unique($this->memberUid)); } @@ -808,7 +828,6 @@ class group extends plugin $this->attrs['member'] = array(); if (count($this->memberUid)){ foreach($this->attrs['memberUid'] as $uid) { - if(isset($this->dnMapping[$uid])){ $this->attrs['member'][]= $this->dnMapping[$uid]; } @@ -1183,7 +1202,7 @@ class group extends plugin // - ond one which represents those users which are only part of SOME groups. $this->commonList = new sortableListing(); $this->commonList->setDeleteable(true); - $this->commonList->setInstantDelete(true); + $this->commonList->setInstantDelete(false); $this->commonList->setEditable(false); $this->commonList->setWidth("100%"); $this->commonList->setHeight("120px"); @@ -1193,7 +1212,7 @@ class group extends plugin $this->partialList = new sortableListing(); $this->partialList->setDeleteable(true); - $this->partialList->setInstantDelete(true); + $this->partialList->setInstantDelete(false); $this->partialList->setEditable(false); $this->partialList->setWidth("100%"); $this->partialList->setHeight("120px"); diff --git a/gosa-core/plugins/admin/groups/generic.tpl b/gosa-core/plugins/admin/groups/generic.tpl index 5a591fd79..c2015f6f0 100644 --- a/gosa-core/plugins/admin/groups/generic.tpl +++ b/gosa-core/plugins/admin/groups/generic.tpl @@ -170,29 +170,44 @@
- {if $multiple_support} -

{t}Common group members{/t}

- {render acl=$memberUidACL} - {$commonList} - {/render} - {render acl=$memberUidACL} - - {/render} - -
-

{t}Partial group members{/t}

- {render acl=$memberUidACL} - {$partialList} - {/render} - {else} -

{t}Group members{/t}

- {render acl=$memberUidACL} - {$memberList} - {/render} - {render acl=$memberUidACL} - - {/render} - {/if} + + {if $restrictedByDynGroup} + {t}The group members are part of a dyn-group and cannot be managed!{/t} + {if $multiple_support} + {render acl=$memberUidACL} + {$commonList} + {/render} + {else} + {render acl=$memberUidACL} + {$memberList} + {/render} + {/if} + {else} + + {if $multiple_support} +

{t}Common group members{/t}

+ {render acl=$memberUidACL} + {$commonList} + {/render} + {render acl=$memberUidACL} + + {/render} + +
+

{t}Partial group members{/t}

+ {render acl=$memberUidACL} + {$partialList} + {/render} + {else} +

{t}Group members{/t}

+ {render acl=$memberUidACL} + {$memberList} + {/render} + {render acl=$memberUidACL} + + {/render} + {/if} + {/if}
diff --git a/gosa-core/plugins/admin/ogroups/class_ogroup.inc b/gosa-core/plugins/admin/ogroups/class_ogroup.inc index c68ac83f4..cb719055c 100644 --- a/gosa-core/plugins/admin/ogroups/class_ogroup.inc +++ b/gosa-core/plugins/admin/ogroups/class_ogroup.inc @@ -66,7 +66,7 @@ class ogroup extends plugin var $view_logged = FALSE; var $copyMembers = TRUE; - + var $wasDyGroup = FALSE; var $baseSelector; /* Already assigned Workstations. Will be hidden in selection. @@ -361,6 +361,17 @@ class ogroup extends plugin $data[$key] = $dn; $lData[$key] = array('data'=> array(image($image),$name)); } + + if($this->isRestrictedByDynGroup()){ + $this->memberListing->setDeleteable(false); + $smarty->assign("memberACL", preg_replace("/[^r]/", "", $this->getacl("member"))); + $smarty->assign("isRestrictedByDynGroup", TRUE); + + }else{ + $this->memberListing->setDeleteable(true); + $smarty->assign("isRestrictedByDynGroup", FALSE); + } + $this->memberListing->setListData($data,$lData); $this->memberListing->update(); $smarty->assign("memberList",$this->memberListing->render()); @@ -374,6 +385,17 @@ class ogroup extends plugin } + function isRestrictedByDynGroup() + { + $bool = FALSE; + if(isset($this->parent->by_object['DynamicLdapGroup'])){ + $bool = $this->parent->by_object['DynamicLdapGroup']->isAttributeDynamic('member'); + } + $this->wasDyGroup |= $bool; + return($bool); + } + + function set_acl_base($base) { plugin::set_acl_base($base); @@ -710,9 +732,11 @@ class ogroup extends plugin plugin::save(); /* Move members to target array */ - $this->attrs['member'] =array(); - foreach ($this->member as $key => $desc){ - $this->attrs['member'][]= LDAP::fix($key); + if(!$this->wasDyGroup && !$this->isRestrictedByDynGroup()){ + $this->attrs['member'] =array(); + foreach ($this->member as $key => $desc){ + $this->attrs['member'][]= LDAP::fix($key); + } } $ldap= $this->config->get_ldap_link(); diff --git a/gosa-core/plugins/admin/ogroups/generic.tpl b/gosa-core/plugins/admin/ogroups/generic.tpl index 34b4d8c2a..e99cc8ac0 100644 --- a/gosa-core/plugins/admin/ogroups/generic.tpl +++ b/gosa-core/plugins/admin/ogroups/generic.tpl @@ -37,15 +37,22 @@ {$trustModeDialog} + {if $isRestrictedByDynGroup} + {t}The group members are part of a dyn-group and cannot be managed!{/t} +
+
+ {/if}  ({$combinedObjects})
{render acl=$memberACL} {$memberList} {/render} +{if !$isRestrictedByDynGroup} {render acl=$memberACL}   {/render} +{/if} -- 2.30.2