From: hickert Date: Wed, 17 Oct 2007 12:36:08 +0000 (+0000) Subject: Added multiple edit to user (initial) X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=8905c24664f802581a45bbd2936251ebf99313e9;p=gosa.git Added multiple edit to user (initial) git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@7584 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/include/class_plugin.inc b/include/class_plugin.inc index 85082ed23..ccb7e5406 100644 --- a/include/class_plugin.inc +++ b/include/class_plugin.inc @@ -118,6 +118,10 @@ class plugin /* This can be set to render the tabulators in another stylesheet */ var $pl_notify= FALSE; + + /* This variable indicates that this class can handle multiple dns at once. */ + var $multiple_support = FALSE; + /*! \brief plugin constructor If 'dn' is set, the node loads the given 'dn' from LDAP diff --git a/include/class_tabs.inc b/include/class_tabs.inc index c543065b2..c7be1b784 100644 --- a/include/class_tabs.inc +++ b/include/class_tabs.inc @@ -33,6 +33,8 @@ class tabs var $by_object= array(); var $SubDialog = false; + var $multiple_entries = FALSE; + function tabs(&$config, $data, $dn, $acl_category= "") { /* Save dn */ @@ -41,7 +43,27 @@ class tabs $baseobject= NULL; + /* Check specified dn + */ + if(is_string($dn)){ + + }elseif(is_array($dn)&&count($dn) == 1){ + $this->dn = $dn[key($dn)]; + }elseif(is_array($dn)&&count($dn) > 1){ + $this->multiple_entries = TRUE; + } + + foreach ($data as &$tab){ + + /* Check we want to handle multiple obejcts at once + * and if this is supported by enabled plugins + */ + $tmp = get_class_vars($tab['CLASS']); + if($this->multiple_entries && !$tmp['multiple_support']){ + continue; + } + $this->by_name[$tab['CLASS']]= $tab['NAME']; if ($baseobject === NULL){ @@ -59,6 +81,11 @@ class tabs $this->current= $tab['CLASS']; } } + + /* Return false if tabs */ + if(!count($this->by_object)){ + return(FALSE); + } } function execute() @@ -310,12 +337,14 @@ class tabs function addSpecialTabs() { - $this->by_name['acl']= _("ACL"); - $this->by_object['acl']= new acl($this->config, $this, $this->dn); - $this->by_object['acl']->parent= &$this; - $this->by_name['reference']= _("References"); - $this->by_object['reference']= new reference($this->config, $this->dn); - $this->by_object['reference']->parent= &$this; + if(!is_array($this->dn)){ + $this->by_name['acl']= _("ACL"); + $this->by_object['acl']= new acl($this->config, $this, $this->dn); + $this->by_object['acl']->parent= &$this; + $this->by_name['reference']= _("References"); + $this->by_object['reference']= new reference($this->config, $this->dn); + $this->by_object['reference']->parent= &$this; + } } diff --git a/plugins/admin/users/class_divListUsers.inc b/plugins/admin/users/class_divListUsers.inc index 5a1c550d7..5f4639e8e 100644 --- a/plugins/admin/users/class_divListUsers.inc +++ b/plugins/admin/users/class_divListUsers.inc @@ -168,6 +168,8 @@ class divListUsers extends MultiSelectWindow title='"._("Remove selected user")."' alt='"._("Remove user")."' name='remove_multiple_users'> "; $listhead .= "  "; + $listhead .= "  "; /* Add multiple copy & cut icons */ if(is_object($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){ diff --git a/plugins/admin/users/class_userManagement.inc b/plugins/admin/users/class_userManagement.inc index 44c6dc30a..1f12ef099 100644 --- a/plugins/admin/users/class_userManagement.inc +++ b/plugins/admin/users/class_userManagement.inc @@ -62,7 +62,7 @@ class userManagement extends plugin plugin::execute(); /* LOCK MESSAGE Vars */ - $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^user_edit_/","/^user_del_/","/^item_selected/","/^remove_multiple_users/"); + $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^user_edit_/","/^user_del_/","/^item_selected/","/^remove_multiple_users/","/^multiple_edit/"); $smarty = get_smarty(); // Smarty instance $s_action = ""; // Contains the action to be taken @@ -78,7 +78,8 @@ class userManagement extends plugin foreach($_POST as $key => $val){ /* Get every possible POST combination and set s_action/s_entry accordingly */ - foreach(array("del" => "user_del", "edit" => "user_edit", + foreach(array("del" => "user_del", + "edit" => "user_edit", "new" => "user_new", "new_tpl" => "user_tplnew", "del_multiple" => "^remove_multiple_users", @@ -86,6 +87,7 @@ class userManagement extends plugin "change_pw" => "user_chgpw", "editPaste" => "editPaste", "copy_multiple" => "multiple_copy_users", + "multiple_edit" => "multiple_edit", "cut_multiple" => "multiple_cut_users", "multiple_password_change" => "multiple_password_change", "copy" => "^copy", @@ -269,15 +271,23 @@ class userManagement extends plugin ********************/ /* User wants to edit data? */ - if (($s_action=="edit") && (!isset($this->usertab->config))){ + if (($s_action == "multiple_edit" || $s_action=="edit") && (!isset($this->usertab->config))){ + $this->dn = array(); /* Get 'dn' from posted 'uid', must be unique */ - $this->dn= $this->list[trim($s_entry)]['dn']; + if($s_action == "multiple_edit"){ + foreach($this->list_get_selected_items() as $id){ + $this->dn[] = $this->list[trim($id)]['dn']; + } + }else{ + $this->dn= array($this->list[trim($s_entry)]['dn']); + } /* Check locking, save current plugin in 'back_plugin', so the dialog knows where to return. */ - if (($user= get_lock($this->dn)) != ""){ - return(gen_locked_message ($user, $this->dn)); + $users= get_multiple_locks($this->dn); + if (count($users)){ + return(gen_locked_message($users, $this->dn)); } /* Lock the current entry, so everyone will get the @@ -285,15 +295,18 @@ class userManagement extends plugin add_lock ($this->dn, $this->ui->dn); /* Register usertab to trigger edit dialog */ - $this->usertab= new usertabs($this->config, - $this->config->data['TABS']['USERTABS'], $this->dn); + $tbs = new usertabs($this->config,$this->config->data['TABS']['USERTABS'], $this->dn); - /* Switch tab, if it was requested by the user */ - $this->usertab->current = $s_tab; + if($tbs){ + $this->usertab = $tbs; - /* Set ACL and move DN to the headline */ - $this->usertab->set_acl_base($this->dn); - $_SESSION['objectinfo']= $this->dn; + /* Switch tab, if it was requested by the user */ + $this->usertab->current = $s_tab; + + /* Set ACL and move DN to the headline */ +# $this->usertab->set_acl_base($this->dn); + $_SESSION['objectinfo']= _("Multiple edit"); + } } diff --git a/plugins/personal/generic/class_user.inc b/plugins/personal/generic/class_user.inc index 0171a3c11..4cec1ec53 100644 --- a/plugins/personal/generic/class_user.inc +++ b/plugins/personal/generic/class_user.inc @@ -105,17 +105,25 @@ class user extends plugin "functionalTitle", "certificateSerialNumber", "publicVisible", "street", "role", "postalCode"); + var $multiple_support =TRUE; + /* constructor, if 'dn' is set, the node loads the given 'dn' from LDAP */ function user (&$config, $dn= NULL) { + $this->config= $config; /* Configuration is fine, allways */ if ($this->config->current['GOVERNMENTMODE']){ $this->attributes=array_merge($this->attributes,$this->govattrs); } + $this->dn = $dn; + if(is_array($dn)){ + return; + } + /* Load base attributes */ plugin::plugin ($config, $dn); @@ -223,6 +231,9 @@ class user extends plugin /* Call parent execute */ plugin::execute(); + if(is_array($this->dn)){ + return("Still not supported."); + } /* Log view */ if($this->is_account && !$this->view_logged){ $this->view_logged = TRUE;