X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fadmin%2Fusers%2Fclass_userManagement.inc;h=88936bd503a44fca137274790f3a877074bdd5c7;hb=c3a786a7af7dcec35d946e2e7f551ab29f05ad1c;hp=7c87e833002d167849e25125a7662471024fc821;hpb=317f1e4c9f590ddfacb40f5d8f7f92283c92e1ba;p=gosa.git diff --git a/plugins/admin/users/class_userManagement.inc b/plugins/admin/users/class_userManagement.inc index 7c87e8330..88936bd50 100644 --- a/plugins/admin/users/class_userManagement.inc +++ b/plugins/admin/users/class_userManagement.inc @@ -41,7 +41,7 @@ class userManagement extends plugin $this->ui= $ui; /* Get global filter config */ - if (!is_global("userfilter")){ + if (!isset($_SESSION["userfilter"])){ $base= get_base_from_people($ui->dn); $userfilter= array( "mailusers" => "checked", "unixusers" => "checked", @@ -53,12 +53,15 @@ class userManagement extends plugin "functionalusers" => "checked", "depselect" => $base, "regex" => "*"); - register_global("userfilter", $userfilter); + $_SESSION["userfilter"] = $userfilter; } } function execute() { + /* Call parent execute */ + plugin::execute(); + $smarty = get_smarty(); // Smarty instance $userfilter = get_global("userfilter"); // contains Filter Settings $s_action = ""; // Contains the action to proceed @@ -67,10 +70,9 @@ class userManagement extends plugin /* Start for New List Managment */ if(isset($_GET['act'])&&($_GET['act']=="dep_open")){ - $s_action="open"; - $s_entry = base64_decode($_GET['dep_id']); - $userfilter['depselect']= "".$this->config->departments[trim($s_entry)]; - $this->reload(); + $s_action="open"; + $s_entry = base64_decode($_GET['dep_id']); + $userfilter['depselect']= "".$this->config->departments[trim($s_entry)]; } /* Test Posts */ @@ -97,32 +99,39 @@ class userManagement extends plugin $s_entry = preg_replace("/user_chgpw_/i","",$key); }elseif(preg_match("/dep_root.*/i",$key)){ $s_action="root"; + }elseif(preg_match("/userfrom_tpl.*/i",$key)){ + $s_action="create_user_from_tpl"; + $s_entry = preg_replace("/userfrom_tpl_/i","",$key); } } - + if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){ - $s_action ="edit"; + $s_action = "edit"; $s_entry = $_GET['id']; } $s_entry = preg_replace("/_.$/","",$s_entry); + if(preg_match("/.*-.*/",$s_entry)){ + $s_tab = preg_replace("/^.*-/i","",$s_entry); + $s_entry = preg_replace("/-.*$/i","",$s_entry); + }else{ + $s_tab = "user"; + }; + /* Department changed? */ if(isset($_POST['depselect']) && $_POST['depselect']){ $userfilter['depselect']= $_POST['depselect']; - $this->reload(); } /* Homebutton is posted */ if($s_action=="home"){ $userfilter['depselect']=(preg_replace("/^[^,]+,/","",$this->ui->dn)); $userfilter['depselect']=(preg_replace("/^[^,]+,/","",$userfilter['depselect'])); - $this->reload(); } if($s_action=="root"){ $userfilter['depselect']=($this->config->current['BASE']); - $this->reload(); } @@ -136,20 +145,17 @@ class userManagement extends plugin }else{ $userfilter['depselect']= $this->config->departments["/"]; } - $this->reload(); } /* End for new List Managment */ /* Save filter data if we are in the headpage */ if (!isset($this->usertab)){ - foreach( array("regex") as $type){ - if (isset($_POST[$type])){ - $userfilter[$type]= $_POST[$type]; - } + if (isset($_POST['regexit'])){ + $userfilter["regex"]= $_POST['regexit']; } } - if(isset($_POST['regex'])){ + if(isset($_POST['regexit'])){ foreach( array("functionalusers", "unixusers", "mailusers","sambausers", "proxyusers", "faxusers", "templates", "subsearch") as $type){ if (isset($_POST[$type])) { $userfilter[$type]= "checked"; @@ -166,7 +172,7 @@ class userManagement extends plugin $userfilter['regex']= $s; } register_global("userfilter", $userfilter); - + /* React on user interaction here */ if (($_SERVER["REQUEST_METHOD"] == "POST")||($_SERVER["REQUEST_METHOD"]== "GET")){ @@ -175,7 +181,7 @@ class userManagement extends plugin if ($s_action=="edit"){ /* Get 'dn' from posted 'uid', must be unique */ - + $this->dn= $this->list[trim($s_entry)]['dn']; /* Check locking, save current plugin in 'back_plugin', so @@ -194,6 +200,10 @@ class userManagement extends plugin /* Register usertab to trigger edit dialog */ $this->usertab= new usertabs($this->config, $this->config->data['TABS']['USERTABS'], $this->dn); + // $_POST[$s_tab]=$s_tab; + + // This would be better + $this->usertab->current = $s_tab; $this->usertab->set_acl($acl); $_SESSION['objectinfo']= $this->dn; @@ -268,18 +278,37 @@ class userManagement extends plugin return($smarty->fetch(get_template_path('password.tpl', TRUE))); } + $config= $this->config; + $ldap_ui= $this->config->get_ldap_link(); + if(isset($this->usertab->dn)){ + $user = ($ldap_ui->fetch($ldap_ui->cat($this->usertab->dn))); + }else{ + $user = ($ldap_ui->fetch($ldap_ui->cat($this->dn))); + } + if((is_array($user))&&(isset($user['uid']))){ + $username= $user['uid'][0]; + } + /* Set password, perform required steps */ if ($this->usertab){ if ($this->usertab->password_change_needed()){ $obj= $this->usertab->by_object['user']; change_password ($this->usertab->dn, $_POST['new_password'], 0, $obj->pw_storage); + if (isset($config->data['MAIN']['EXTERNALPWDHOOK'])){ + exec($config->data['MAIN']['EXTERNALPWDHOOK']." ".$username." ".$_POST['new_password'], $resarr); + } + gosa_log ("Password for '".$this->usertab->dn."' has been changed"); unset($this->usertab); $this->usertab= NULL; } } else { change_password ($this->dn, $_POST['new_password']); + if (isset($config->data['MAIN']['EXTERNALPWDHOOK'])){ + exec($config->data['MAIN']['EXTERNALPWDHOOK']." ".$username." ".$_POST['new_password'], $resarr); + } + gosa_log ("Password for '".$this->dn."' has been changed"); } } else { @@ -321,7 +350,7 @@ class userManagement extends plugin /* Lock the current entry, so nobody will edit it during deletion */ add_lock ($this->dn, $this->ui->dn); - $smarty->assign("info", sprintf(_("You're about to delete the user %s."), $this->dn)); + $smarty->assign("info", sprintf(_("You're about to delete the user %s."), LDAP::fix($this->dn))); return($smarty->fetch(get_template_path('remove.tpl', TRUE))); } else { @@ -430,16 +459,27 @@ class userManagement extends plugin } /* Generate template list */ - if ($s_action=="new"){ + if (($s_action=="new")||($s_action=="create_user_from_tpl")){ + $this->templates= array(); + $ldap= $this->config->get_ldap_link(); + + /* Create list of tempaltes */ foreach ($this->config->departments as $key => $value){ + + /* Get acls from different ou's */ $acl= get_permissions (get_people_ou().$value, $this->ui->subtreeACL); $acl= get_module_permission($acl, "user", get_people_ou().$value); + + /* If creation of a new user is allowed, append this template */ if (chkacl($acl, "create") == ""){ + + /* Search all templates from the current dn */ $ldap->cd (get_people_ou().$value); $ldap->search ("(objectClass=gosaUserTemplate)", array("uid")); + /* Append */ if ($ldap->count() != 0){ while ($attrs= $ldap->fetch()){ $this->templates[$ldap->getDN()]= @@ -449,12 +489,14 @@ class userManagement extends plugin } } } + + /* Sort templates */ natcasesort ($this->templates); reset ($this->templates); } /* New user/template request */ - if (($s_action=="new") || ($s_action=="new_tpl")){ + if (($s_action=="create_user_from_tpl")||($s_action=="new") || ($s_action=="new_tpl")){ /* By default we set 'dn' to 'new', all relevant plugins will react on this. */ $this->dn= "new"; @@ -468,6 +510,7 @@ class userManagement extends plugin $this->usertab= new usertabs($this->config, $this->config->data['TABS']['USERTABS'], $this->dn); $this->usertab->set_acl(array(':all')); + $this->usertab->by_object['user']->base= $userfilter['depselect']; /* Take care about templates */ if ($s_action=="new_tpl"){ @@ -478,23 +521,23 @@ class userManagement extends plugin } /* Use template if there are any of them */ - if (count($this->templates) && !isset($_POST['new_template'])){ + + if ((count($this->templates) && ($s_action!='new_tpl'))||($s_action=="create_user_from_tpl")){ foreach(array("sn", "givenName", "uid", "got_uid", "templates") as $attr){ $smarty->assign("$attr", $this->$attr); } - if (isset($_POST['template'])){ - $smarty->assign("template", $_POST['template']); + if ($s_action=="create_user_from_tpl"){ + $smarty->assign("template", $this->dn= $this->list[trim($s_entry)]['dn']); } else { - $smarty->assign("template", ""); + $smarty->assign("template", "none"); } $smarty->assign("edit_uid", ""); return($smarty->fetch(get_template_path('template.tpl', TRUE))); } - } /* Continue template editing */ - if (isset($_POST['template_continue']) && $_POST['template'] != 'none' && !isset($_POST['uid'])){ + if ((isset($_POST['template_continue']) && $_POST['template'] != 'none' && !isset($_POST['uid']))){ $this->sn= $_POST['sn']; $this->givenName= $_POST['givenName']; @@ -530,7 +573,7 @@ class userManagement extends plugin $this->uid= current($uids); } } else { - $smarty->assign("edit_uid", ""); + $smarty->assign("edit_uid", ""); $this->uid= ""; } $this->got_uid= true; @@ -558,23 +601,27 @@ class userManagement extends plugin if (isset($_POST['template_continue']) && $_POST['template'] != 'none' && (isset($_POST['uid']))){ /* Might not be filled if IDGEN is unset */ - $this->sn= $_POST['sn']; - $this->givenName= $_POST['givenName']; + $this->sn = $_POST['sn']; + $this->givenName = $_POST['givenName']; /* Move user supplied data to sub plugins */ - $this->uid= $_POST['uid']; - $this->usertab->uid= $this->uid; - $this->usertab->sn= $this->sn; - $this->usertab->givenName= $this->givenName; - $template_dn= $_POST['template']; + $this->uid = $_POST['uid']; + $this->usertab->uid = $this->uid; + $this->usertab->sn = $this->sn; + $this->usertab->givenName = $this->givenName; + $template_dn = $_POST['template']; $this->usertab->adapt_from_template($template_dn); - $template_base= preg_replace("/^[^,]+,".get_people_ou()."/", '', $template_dn); + $template_base = preg_replace("/^[^,]+,".get_people_ou()."/", '', $template_dn); $this->usertab->by_object['user']->base= $template_base; /* Set up the users ACL's for this 'dn' */ $acl= get_permissions ($template_base, $this->ui->subtreeACL); $this->usertab->set_acl($acl); } + + if (isset($_POST['template_continue']) && ($_POST['template'] == 'none')){ + $this->usertab->by_object['user']->base= $userfilter['depselect']; + } /* Show tab dialog if object is present */ if ($this->usertab){ @@ -611,103 +658,221 @@ class userManagement extends plugin /* Prepare departments */ $options= ""; foreach ($this->config->idepartments as $key => $value){ - if ($userfilter['depselect'] == $key){ - $options.= ""; - } else { - $options.= ""; - } + if ($userfilter['depselect'] == $key){ + $options.= ""; + } else { + $options.= ""; + } } - + /* NEW LIST MANAGMENT */ $listhead = "