summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8180faf)
raw | patch | inline | side by side (parent: 8180faf)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 8 Jan 2008 14:51:37 +0000 (14:51 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 8 Jan 2008 14:51:37 +0000 (14:51 +0000) |
-Membership is now editable for multiple groups
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8251 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8251 594d385d-05f5-0310-b6e9-bd551577e9d8
diff --git a/gosa-core/plugins/admin/groups/class_groupGeneric.inc b/gosa-core/plugins/admin/groups/class_groupGeneric.inc
index 162788e35d18c12ae100a1044fcd71530ed3adca..ce23be1882cfd5cd1fd766713cef92524136f797 100644 (file)
var $description= "";
var $gidNumber= "";
var $memberUid= array();
+ var $memberUid_used_by_some= array();
/* Helpers */
var $base= "";
if (isset($this->attrs['memberUid'][0])){
$tmp= array();
for ($i= 0; $i<$this->attrs['memberUid']['count']; $i++){
- $tmp[]= $this->attrs['memberUid'][$i];
+ $tmp[$this->attrs['memberUid'][$i]]= $this->attrs['memberUid'][$i];
}
$this->memberUid= $tmp;
- sort ($this->memberUid);
+ ksort ($this->memberUid);
}
/* Save gidNumber for later use */
/* Multiple edit handling */
$smarty->assign("multiple_support",$this->multiple_support_active);
+ $smarty->assign("memberUid_All",$this->memberUid);
+ $smarty->assign("memberUid_Some",$this->memberUid_used_by_some);
foreach($this->attributes as $val){
if(in_array($val,$this->multi_boxes)){
function addUser($uid)
{
- $this->memberUid[]= $uid;
- $this->memberUid= array_unique($this->memberUid);
+ /* In mutliple edit we have to handle two arrays.
+ * memberUid : Containing users used in all groups
+ * memberUid_used_by_some : Those which are not used in all groups
+ * So we have to remove the given $uid from the ..used_by_some array first.
+ */
+ if($this->multiple_support_active){
+ if(isset($this->memberUid_used_by_some[$uid])){
+ unset($this->memberUid_used_by_some[$uid]);
+ }
+ }
+
+ $this->memberUid[$uid]= $uid;
}
+
function removeUser($uid)
{
$temp= array();
- foreach ($this->memberUid as $value){
- if ($value != $uid){
- $temp[]= $value;
+ if(isset($this->memberUid[$uid])){
+ unset($this->memberUid[$uid]);
+ }
+
+ /* We have two array contianing group members in multiple edit.
+ * this->memberUid : Groups used by all currently edited groups
+ * this->memberUid_used_by_some: Used by some
+ * So we have to remove the specified uid from both arrays.
+ */
+ if($this->multiple_support_active){
+ if(isset($this->memberUid_used_by_some[$uid])){
+ unset($this->memberUid_used_by_some[$uid]);
}
}
- $this->memberUid= $temp;
}
-
/* Reload data */
function reload()
{
/* Take members array */
if (count ($this->memberUid)){
- $this->attrs['memberUid']= array_unique($this->memberUid);
+ $this->attrs['memberUid']= array_values(array_unique($this->memberUid));
}
/* New accounts need proper 'dn', propagate it to remaining objects */
$ret[$attr] = $this->$attr;
}
}
+ $ret['memberUid'] = $this->memberUid;
+ $ret['memberUid_used_by_some'] = $this->memberUid_used_by_some;
return($ret);
}
{
return($this->execute());
}
+
+
+ /* Initialize plugin with given atribute arrays
+ */
+ function init_multiple_support($attrs,$all)
+ {
+ plugin::init_multiple_support($attrs,$all);
+
+ $this->memberUid = array();
+ $this->memberUid_used_by_some = array();
+ if (isset($attrs['memberUid'])){
+ for ($i= 0; $i<$attrs['memberUid']['count']; $i++){
+ $this->memberUid[$attrs['memberUid'][$i]]= $attrs['memberUid'][$i];
+ }
+ ksort($this->memberUid);
+ }
+
+ if (isset($all['memberUid'])){
+ for ($i= 0; $i<$all['memberUid']['count']; $i++){
+ if(!in_array($all['memberUid'][$i],$this->memberUid)){
+ $this->memberUid_used_by_some[$all['memberUid'][$i]]= $all['memberUid'][$i];
+ }
+ }
+ ksort($this->memberUid_used_by_some);
+ }
+ }
+
+ function set_multi_edit_values($attrs)
+ {
+ $users = array();
+
+ /* Update groupMembership, keep optinal group */
+ foreach($attrs['memberUid_used_by_some'] as $uid){
+ if(in_array($uid,$this->memberUid)){
+ $users[$uid] = $uid;
+ }
+ }
+
+ /* Update groupMembership, add forced groups */
+ foreach($attrs['memberUid'] as $uid){
+ $users[$uid] = $uid;
+ }
+ plugin::set_multi_edit_values($attrs);
+ $this->memberUid = $users;
+ }
+
+
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
diff --git a/gosa-core/plugins/admin/groups/generic.tpl b/gosa-core/plugins/admin/groups/generic.tpl
index 5c716d99e475f5bb39f0bcfc70380d03e4e2934b..fb55aaeddfae3af4f48e6f3759f2efeb6af6cdea 100644 (file)
<b><LABEL for="members">{t}Group members{/t}</LABEL></b>
<br>
{render acl=$memberUidACL}
+
+ {if $multiple_support}
+ <select style="width:100%; height:380px;" id="members" name="members[]" size=15 multiple>
+ {foreach from=$memberUid_All item=name key=key}
+ <option value="{$key}">{$name} ({t}In all groups{/t})</option>
+ {/foreach}
+ {foreach from=$memberUid_Some item=name key=key}
+ <option value="{$key}" style='color: #888888; background: #DDDDDD;background-color: #DDDDDD;'>{$name} ({t}Not in all groups{/t})</option>
+ {/foreach}
+ </select>
+ {else}
<select style="width:100%; height:380px;" id="members" name="members[]" size=15 multiple>
{html_options options=$members}
<option disabled> </option>
</select>
+ {/if}
{/render}
<br>
<input type=submit name="edit_membership" value="{t}Add{/t}">
diff --git a/gosa-core/plugins/personal/posix/class_posixAccount.inc b/gosa-core/plugins/personal/posix/class_posixAccount.inc
index 63fabf0019ad5e7c08ccc9a66fc376568e54e8ad..8f7770142639f0b02478d6c03888f68f4d5592b2 100644 (file)
foreach($attrs['groupMembership'] as $dn => $cn){
$groups[$dn] = $cn;
}
+ $this->is_modified = TRUE;
+ $this->is_account = TRUE;
plugin::set_multi_edit_values($attrs);
$this->groupMembership = $groups;
}