From 27f3a949520630c71498f41f8c056e11c0dba182 Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 12 Dec 2007 10:54:56 +0000 Subject: [PATCH] Updated multiple edit -Added plugin array 'multi_attr' and 'multi_attr_all' which contain user attribute values. -Added simple multi edit to posix. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8095 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/class_multi_plug.inc | 15 ++++- include/class_plugin.inc | 18 +++-- plugins/personal/generic/class_user.inc | 9 --- plugins/personal/posix/class_posixAccount.inc | 57 +++++++++++++++- plugins/personal/posix/generic.tpl | 66 +++++++++++-------- 5 files changed, 121 insertions(+), 44 deletions(-) diff --git a/include/class_multi_plug.inc b/include/class_multi_plug.inc index 98cbf6688..b74f963dc 100644 --- a/include/class_multi_plug.inc +++ b/include/class_multi_plug.inc @@ -128,22 +128,31 @@ class multi_plug private function detect_multiple_used_attributes() { $attrs = array(); - restore_error_handler(); + $all = array(); $first = $this->o_tab->current; foreach($this->a_handles as $handle){ if(count($attrs) == 0){ $attrs = $handle->by_object[$first]->attrs; }else{ - foreach($attrs as $key => $attr){ if(!isset($handle->by_object[$first]->attrs[$key]) || !($attr === $handle->by_object[$first]->attrs[$key])){ unset($attrs[$key]); } + if(!is_numeric($key)){ + if(!isset($all[$key])){ + $all[$key] = $attr; + }elseif(isset($attr['count'])){ + for($i = 0; $i < $attr['count'] ; $i ++){ + $all[$key][] = $attr[$i]; + } + $all[$key] = array_unique($all[$key]); + } + } } } } foreach($this->o_tab->by_object as $name => $obj){ - $this->o_tab->by_object[$name]->init_multiple_support($attrs); + $this->o_tab->by_object[$name]->init_multiple_support($attrs,$all); } } diff --git a/include/class_plugin.inc b/include/class_plugin.inc index 5a209ab39..da0a6c4d1 100644 --- a/include/class_plugin.inc +++ b/include/class_plugin.inc @@ -123,7 +123,9 @@ class plugin var $CSN_check_active = FALSE; /* This variable indicates that this class can handle multiple dns at once. */ - var $multiple_support = FALSE; + var $multiple_support = FALSE; + var $multi_attrs = array(); + var $multi_attrs_all = array(); /* This aviable indicates, that we are currently in multiple edit handle */ var $multiple_support_active = FALSE; @@ -1694,16 +1696,17 @@ class plugin * Update plugin attributes with given array of attribtues. * @param array Array with attributes that must be updated. */ - function init_multiple_support($attrs) + function init_multiple_support($attrs,$all) { $ldap= $this->config->get_ldap_link(); - $this->attrs= $attrs; + $this->multi_attrs = $attrs; + $this->multi_attrs_all= $all; /* Copy needed attributes */ foreach ($this->attributes as $val){ - $found= array_key_ics($val, $this->attrs); + $found= array_key_ics($val, $this->multi_attrs); if ($found != ""){ - $this->$val= $this->attrs["$found"][0]; + $this->$val= $this->multi_attrs["$found"][0]; } } } @@ -1749,9 +1752,14 @@ class plugin } /* Save values to object */ + $this->multi_boxes = array(); foreach ($this->attributes as $val){ if ($this->acl_is_writeable($val) && isset ($_POST["$val"])){ + if(isset($_POST["use_".$val])){ + $this->multi_boxes[] = $val; + } + /* Check for modifications */ if (get_magic_quotes_gpc()) { $data= stripcslashes($_POST["$val"]); diff --git a/plugins/personal/generic/class_user.inc b/plugins/personal/generic/class_user.inc index 80fd1d59f..57414ef0c 100644 --- a/plugins/personal/generic/class_user.inc +++ b/plugins/personal/generic/class_user.inc @@ -107,9 +107,6 @@ class user extends plugin "postalCode"); var $multiple_support = TRUE; - var $multiple_user_handles = array(); - - var $multi_boxes = array(); /* constructor, if 'dn' is set, the node loads the given 'dn' from LDAP */ @@ -1513,12 +1510,6 @@ class user extends plugin } if(isset($_POST['user_mulitple_edit'])){ - $this->multi_boxes = array(); - foreach($this->attributes as $val){ - if(isset($_POST["use_".$val])){ - $this->multi_boxes[] = $val; - } - } foreach(array("base","pw_storage","edit_picture") as $val){ if(isset($_POST["use_".$val])){ $this->multi_boxes[] = $val; diff --git a/plugins/personal/posix/class_posixAccount.inc b/plugins/personal/posix/class_posixAccount.inc index 1453f4570..e1a5412c9 100644 --- a/plugins/personal/posix/class_posixAccount.inc +++ b/plugins/personal/posix/class_posixAccount.inc @@ -79,6 +79,7 @@ class posixAccount extends plugin var $objectclasses= array("posixAccount", "shadowAccount"); var $uid= ""; + var $multiple_support = TRUE; /* constructor, if 'dn' is set, the node loads the given 'dn' from LDAP */ @@ -237,7 +238,11 @@ class posixAccount extends plugin $_SESSION['CurrentMainBase']= validate($_POST['depselect']); } - if(!$isCopyPaste){ + if($this->multiple_support_active){ + $this->is_account = TRUE; + } + + if(!$isCopyPaste && ! $this->multiple_support_active){ /* Do we need to flip is_account state? */ if(isset($_POST['modify_state'])){ @@ -535,8 +540,23 @@ class posixAccount extends plugin $smarty->assign("force_idsACL", $this->getacl("uidNumber",$SkipWrite).$this->getacl("gidNumber",$SkipWrite)); + foreach(array("primaryGroup") as $val){ + if(in_array($val,$this->multi_boxes)){ + $smarty->assign("use_".$val,TRUE); + }else{ + $smarty->assign("use_".$val,FALSE); + } + } + + /* Load attributes and acl's */ foreach($this->attributes as $val){ + if(in_array($val,$this->multi_boxes)){ + $smarty->assign("use_".$val,TRUE); + }else{ + $smarty->assign("use_".$val,FALSE); + } + if(($_SESSION["js"])&&(($val=="uidNumber")||($val=="gidNumber"))) { $smarty->assign("$val"."ACL",$this->getacl($val,$SkipWrite)); @@ -585,6 +605,7 @@ class posixAccount extends plugin $smarty->assign("workstations", $this->accessTo); $smarty->assign("apply", apply_filter()); + $smarty->assign("multiple_support" , $this->multiple_support_active); $display.= $smarty->fetch (get_template_path('generic.tpl', TRUE, dirname(__FILE__))); return($display); } @@ -1345,6 +1366,12 @@ class posixAccount extends plugin } + function multiple_execute() + { + return($this->execute()); + } + + static function plInfo() { return (array( @@ -1372,6 +1399,34 @@ class posixAccount extends plugin "trustModel" => _("System trust model"))) ); } + + function get_multi_edit_values() + { + $ret = plugin::get_multi_edit_values(); + return($ret); + } + + + function multiple_save_object() + { + if(isset($_POST['posix_mulitple_edit'])){ + plugin::multiple_save_object(); + foreach(array("primaryGroup") as $val){ + if(isset($_POST["use_".$val])){ + $this->multi_boxes[] = $val; + } + } + + /* Save primary group settings */ + if($this->acl_is_writeable("primaryGroup") && isset($_POST['primaryGroup'])){ + $data= $_POST['primaryGroup']; + if ($this->primaryGroup != $data){ + $this->is_modified= TRUE; + } + $this->primaryGroup= $_POST['primaryGroup']; + } + } + } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: diff --git a/plugins/personal/posix/generic.tpl b/plugins/personal/posix/generic.tpl index 65d5ba7e0..c9dc98d47 100644 --- a/plugins/personal/posix/generic.tpl +++ b/plugins/personal/posix/generic.tpl @@ -6,42 +6,47 @@ {$must} - {render acl=$homeDirectoryACL} +{render acl=$homeDirectoryACL checkbox=$multiple_support checked=$use_homeDirectory} - {/render} +{/render} - {render acl=$loginShellACL} +{render acl=$loginShellACL checkbox=$multiple_support checked=$use_loginShell} - {/render} +{/render} - {render acl=$gidNumberACL} +{render acl=$gidNumberACL checkbox=$multiple_support checked=$use_primaryGroup} - {/render} +{/render} +{if !$multiple_support} {t}Status{/t} {$status} +{/if} + +{if !$multiple_support} + @@ -62,12 +67,13 @@
- {render acl=$force_idsACL} +{render acl=$force_idsACL} - {/render} +{/render} @@ -51,9 +56,9 @@ - {render acl=$uidNumberACL} +{render acl=$uidNumberACL} - {/render} +{/render}
- {render acl=$gidNumberACL} +{render acl=$gidNumberACL} - {/render} +{/render}
+{/if}   @@ -78,18 +84,23 @@ {t}(Warning: more than 16 groups are not supported by NFS!){/t}
{/if} - {render acl=$groupMembershipACL} +{render acl=$groupMembershipACL} - {/render} +{/render}
- {render acl=$groupMembershipACL} +{render acl=$groupMembershipACL}   - {/render} - {render acl=$groupMembershipACL} +{/render} +{render acl=$groupMembershipACL} - {/render} +{/render} @@ -108,29 +119,32 @@

{t}System trust{/t}

{t}Trust mode{/t}  - {render acl=$trustmodeACL} +{render acl=$trustmodeACL} - {/render} - {render acl=$trustmodeACL} +{/render} +{render acl=$trustmodeACL} - {/render} +{/render}
- {render acl=$trustmodeACL} +{render acl=$trustmodeACL}   - {/render} - {render acl=$trustmodeACL} +{/render} +{render acl=$trustmodeACL} - {/render} +{/render} +{if $multiple_support} + +{/if} -- 2.30.2