From 16ecdbabee20bef8c900d555a65d2925be5b994c Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 18 Oct 2007 10:10:38 +0000 Subject: [PATCH] Updated multiple user edit git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@7591 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/class_location.inc | 6 +- include/class_tabs.inc | 7 +- plugins/admin/users/class_userManagement.inc | 10 +- plugins/personal/generic/class_user.inc | 106 ++++- plugins/personal/generic/multiple_generic.tpl | 398 +++++++++++------- 5 files changed, 365 insertions(+), 162 deletions(-) diff --git a/include/class_location.inc b/include/class_location.inc index 359a25d15..7b86a7979 100644 --- a/include/class_location.inc +++ b/include/class_location.inc @@ -245,9 +245,10 @@ $class_mapping= array( "passwordMethod" => "include/class_password-methods.inc", "mailMethodGolab" => "include/class_mail-methods-golab.inc", "pgre_sql" => "include/class_pgsql_opengw.inc", - "msg_dialog" => "include/class_msg_dialog.inc", + "passwordMethodheimdal" => "include/class_password-methods-heimdal.inc", "mailMethodKolab" => "include/class_mail-methods-kolab.inc", "passwordMethodsha" => "include/class_password-methods-sha.inc", + "msg_dialog" => "include/class_msg_dialog.inc", "passwordMethodkerberos" => "include/class_password-methods-kerberos.inc", "parseXml" => "include/functions_helpviewer.inc", "divlist" => "include/class_divlist.inc", @@ -258,7 +259,6 @@ $class_mapping= array( "tabs" => "include/class_tabs.inc", "Print_a_class" => "include/functions_debug.inc", "divSelectBox" => "include/class_divSelectBox.inc", - "dhcpPlugin" => "include/class_dhcpPlugin.inc", "passwordMethodssha" => "include/class_password-methods-ssha.inc", "ogw" => "include/class_opengw.inc", "acl" => "include/class_acl.inc", @@ -271,7 +271,7 @@ $class_mapping= array( "mailMethodSendmailCyrus" => "include/class_mail-methods-sendmail-cyrus.inc", "LDAP" => "include/class_ldap.inc", "log" => "include/class_log.inc", - "passwordMethodheimdal" => "include/class_password-methods-heimdal.inc", + "dhcpPlugin" => "include/class_dhcpPlugin.inc", "Step_Ldap" => "setup/class_setupStep_Ldap.inc", "Step_Finish" => "setup/class_setupStep_Finish.inc", "setup_step" => "setup/class_setupStep.inc", diff --git a/include/class_tabs.inc b/include/class_tabs.inc index 036d42d42..059e47700 100644 --- a/include/class_tabs.inc +++ b/include/class_tabs.inc @@ -270,8 +270,11 @@ class tabs function save($ignore_account= FALSE) { if($this->multiple_entries){ - echo "Save is not supported for multiple entries yet"; - + foreach ($this->by_object as $key => &$obj){ + @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, + $key, "Saving"); + $obj->save(); + } }else{ /* Save all plugins */ foreach ($this->by_object as $key => &$obj){ diff --git a/plugins/admin/users/class_userManagement.inc b/plugins/admin/users/class_userManagement.inc index 1f12ef099..77cd106fe 100644 --- a/plugins/admin/users/class_userManagement.inc +++ b/plugins/admin/users/class_userManagement.inc @@ -304,8 +304,14 @@ class userManagement extends plugin $this->usertab->current = $s_tab; /* Set ACL and move DN to the headline */ -# $this->usertab->set_acl_base($this->dn); - $_SESSION['objectinfo']= _("Multiple edit"); + if(count($this->dn) == 1){ + reset($this->dn) ; + $dn = current($this->dn); + $this->usertab->set_acl_base($dn); + $_SESSION['objectinfo'] = $dn; + }else{ + $_SESSION['objectinfo']= _("Multiple edit"); + } } } diff --git a/plugins/personal/generic/class_user.inc b/plugins/personal/generic/class_user.inc index 3e8e1e3d7..4a31c21f4 100644 --- a/plugins/personal/generic/class_user.inc +++ b/plugins/personal/generic/class_user.inc @@ -107,7 +107,8 @@ class user extends plugin var $multiple_support = TRUE; var $multiple_handle = FALSE; - + var $attrs_to_update = array(); + var $multiple_user_handles = array(); /* constructor, if 'dn' is set, the node loads the given 'dn' from LDAP */ function user (&$config, $dn= NULL) @@ -229,22 +230,37 @@ class user extends plugin function construct_multiple() { /* Configuration is fine, allways */ - $this->multiple_attrs = array(); + $this->multiple_user_handles = array(); foreach($this->dn as $dn){ - $this->multiple_attrs[] = new user($this->config,$dn); + $this->multiple_user_handles[] = new user($this->config,$dn); } } + function save_object_multiple() + { + foreach(array("pw_storage","base","edit_cert") as $attr){ + if(isset($_POST["use_".$attr])){ + $this->attrs_to_update[$attr] = TRUE; + }else{ + $this->attrs_to_update[$attr] = FALSE; + } + } + foreach($this->attributes as $attr){ + if(isset($_POST["use_".$attr])){ + $this->attrs_to_update[$attr] = TRUE; + }else{ + $this->attrs_to_update[$attr] = FALSE; + } + } + } function execute_multiple() { - $smarty =get_smarty(); - $u_attrs = array(); $d_attrs = array(); foreach($this->attributes as $attr){ - foreach($this->multiple_attrs as $class){ + foreach($this->multiple_user_handles as $class){ if(!isset($u_attrs[$attr]) && !empty($class->$attr)){ $u_attrs[$attr] = $class->$attr; }elseif(isset($u_attrs[$attr]) && !empty($class->$attr)){ @@ -252,13 +268,55 @@ class user extends plugin } } } - print_a(array($u_attrs,$d_attrs)); + $language= array_merge(array(0 => " ") ,get_languages(TRUE)); + $smarty->assign("preferredLanguage_list", $language); + @$smarty->assign("bases", $this->allowedBasesToMoveTo()); + $smarty->assign("base_select", $this->base); + + /* Save government mode attributes */ + if (isset($this->config->current['GOVERNMENTMODE']) && + preg_match('/true/i', $this->config->current['GOVERNMENTMODE'])){ + $smarty->assign("governmentmode", "true"); + $ivbbmodes= array("nein", "ivbv", "testa", "ivbv,testa", "internet", + "internet,ivbv", "internet,testa", "internet,ivbv,testa"); + $smarty->assign("ivbbmodes", $ivbbmodes); + foreach ($this->govattrs as $val){ + $smarty->assign("$val", $this->$val); + $smarty->assign("$val"."ACL", $this->getacl($val,(!is_object($this->parent) && !isset($_SESSION['edit'])))); + } + } else { + $smarty->assign("governmentmode", "false"); + } + + $temp= passwordMethod::get_available_methods(); + $hashes = $temp['name']; + $test= new $temp[$this->pw_storage]($this->config); + $is_configurable= $test->is_configurable(); + $smarty->assign("pwmode", $hashes); + $smarty->assign("pwmode_select", $this->pw_storage); + $smarty->assign("pw_configurable", $is_configurable); + foreach($this->attributes as $attr){ - if(!isset($u_attrs[$attr])){ - $u_attrs[$attr] = "empty"; +# if(!isset($u_attrs[$attr])){ +# $u_attrs[$attr] = "empty"; +# } + + if(isset($this->attrs_to_update[$attr]) && $this->attrs_to_update[$attr] == TRUE){ + $smarty->assign("use_".$attr,TRUE); + }else{ + $smarty->assign("use_".$attr,FALSE); + } + $smarty->assign($attr,$this->$attr); + } + foreach(array("pw_storage","base","edit_cert") as $attr){ + if(isset($this->attrs_to_update[$attr]) && $this->attrs_to_update[$attr] == TRUE){ + $smarty->assign("use_".$attr,TRUE); + }else{ + $smarty->assign("use_".$attr,FALSE); } - $smarty->assign($attr,$u_attrs[$attr]); } + + return($smarty->fetch (get_template_path('multiple_generic.tpl', TRUE, dirname(__FILE__)))); } @@ -695,7 +753,10 @@ class user extends plugin /* Save data to object */ function save_object() { - if (isset($_POST['generic'])){ + if (isset($_POST['multiple_user_posted'])){ + $this->save_object_multiple(); + } + if(isset($_POST['generic']) || isset($_POST['multiple_user_posted'])){ /* Make a backup of the current selected base */ $base_tmp = $this->base; @@ -770,16 +831,34 @@ class user extends plugin } } + + function multiple_save() + { + foreach($this->multiple_user_handles as $handle){ + foreach($this->attributes as $attr){ + if(isset($this->attrs_to_update[$attr]) && $this->attrs_to_update[$attr] == TRUE){ + $handle->$attr = $this->$attr; + } + } + $handle->save(); + } + } + + + /* Save data to LDAP, depending on is_account we save or delete */ function save() { + if($this->multiple_handle){ + return($this->multiple_save()); + } + /* Only force save of changes .... If this attributes aren't changed, avoid saving. */ if($this->gender=="0") $this->gender =""; if($this->preferredLanguage=="0") $this->preferredLanguage =""; - /* First use parents methods to do some basic fillup in $this->attrs */ plugin::save (); @@ -1164,7 +1243,8 @@ class user extends plugin /* Indicate whether a password change is needed or not */ function password_change_needed() { - return ($this->pw_storage != $this->last_pw_storage); + + return (!$this->multiple_handle && $this->pw_storage != $this->last_pw_storage); } diff --git a/plugins/personal/generic/multiple_generic.tpl b/plugins/personal/generic/multiple_generic.tpl index ce2e24246..a9c3143fe 100644 --- a/plugins/personal/generic/multiple_generic.tpl +++ b/plugins/personal/generic/multiple_generic.tpl @@ -1,12 +1,12 @@
-

{t}Personal information{/t}

+ +

{t}Personal information{/t}

-
@@ -14,24 +14,26 @@
-
-
- + +
- + + @@ -39,328 +41,440 @@
-
- +
+
+
-
- - +
+
+ + +
-
- - +
- - + - + - + - + - - {if $is_template ne "true"} - + - {/if} -
- + + + + +
- - + + + + +
- + + + +
-
+
+
- - {if $pw_configurable eq "true"} -   - {/if} + + + +
- + + + +
- -

 

- +

- - - {if $governmentmode ne "true"} - - - - - {else} - - - - {/if} + {/if}
-

 {t}Organizational information{/t}

+

+ +  {t}Organizational information{/t}

- +
- - + - + - + - + - +
- + + + + +
- + + + +
- + + + +
- + + + +
- + + + +
  - +
- + - {if $has_phoneaccount ne "true"} - + - {/if} - + - + - +
- + + + +
- + + + +
- + + + +
- + + + +
- + + + +
  - +
- + - + - +
- + + + +
- + + + +
+ + - + +
- +
- + - + - + - + - +
- + + + +
- + + + +
- + + + +
- + + + +
- + + + +
- +
- + - + - + - - + - +
- + + + +
- + + + +
- + + + +
- + + + + +
- + + + +
- +
- + - + - + - + - +
- + + + +
- {if $has_phoneaccount ne "true"} - - {else} - {t}Please use the phone tab{/t} - {/if} + + + +
- + + + +
- + + + +
- + + + +
- - - + -- 2.30.2