From: hickert Date: Wed, 10 Oct 2007 09:11:26 +0000 (+0000) Subject: Added multiple ldap server select option, to workstation startup X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=b858b36d35f0c732370b85e6009969f4cea6bb96;p=gosa.git Added multiple ldap server select option, to workstation startup git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@7485 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/systems/class_workstationStartup.inc b/plugins/admin/systems/class_workstationStartup.inc index 95ab4bc15..70b0e8088 100644 --- a/plugins/admin/systems/class_workstationStartup.inc +++ b/plugins/admin/systems/class_workstationStartup.inc @@ -6,9 +6,13 @@ class workstartup extends plugin var $cli_description= "Some longer text\nfor help"; var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser"); + /* Ldap server list */ + var $gotoLdapServers = array(); + var $gotoLdapServerList = array(); + var $gotoLdap_inherit = FALSE; + /* Generic terminal attributes */ var $bootmode = "G"; - var $goLdapServerList = array(); var $gotoBootKernel = "default-inherited"; var $gotoKernelParameters = ""; var $gotoLdapServer = "default-inherited"; @@ -85,9 +89,17 @@ class workstartup extends plugin $ldap->cd($this->config->current['BASE']); foreach($this->config->data['SERVERS']['LDAP'] as $server) { - $this->goLdapServerList[$server]= $server; // $this->config->data['SERVERS']['LDAP']; + $this->gotoLdapServerList[]= $server; + } + + if(isset($this->attrs['gotoLdapServer'])){ + for($i = 0 ; $i < $this->attrs['gotoLdapServer']['count'];$i++){ + $this->gotoLdapServers[] = $this->attrs['gotoLdapServer'][$i]; + } + } + if(!count($this->gotoLdapServers)){ + $this->gotoLdap_inherit = TRUE; } - /* FAI Initialization Skip this if FAI is not activated @@ -317,9 +329,9 @@ class workstartup extends plugin } if($this->fai_activated){ - $map= array("gotoLdapServer","FAIclass","FAIdebianMirror"); + $map= array("gotoBootKernel","FAIclass","FAIdebianMirror"); }else{ - $map= array("gotoLdapServer"); + $map= array("gotoBootKernel"); } $attrs= $ldap->fetch(); @@ -329,10 +341,6 @@ class workstartup extends plugin } switch ($name){ - case 'gotoLdapServer': - $this->goLdapServerList= array_merge(array('default-inherited' => _("inherited").' ['.$attrs[$name][0].']' ), $this->goLdapServerList); - break; - case 'gotoBootKernel': $this->gotoBootKernels['default-inherited']= _("inherited").' ['.$attrs[$name][0].']' ; break; @@ -654,8 +662,6 @@ class workstartup extends plugin $smarty->assign($name."ACL",$this->getacl($name)); } - $smarty->assign("SelectBoxLdapServer",""); - /* In this section server shares will be defined * A user can select one of the given shares and a mount point * and attach this combination to his setup. @@ -693,44 +699,66 @@ class workstartup extends plugin $smarty->assign("gotoShareKeys",array_flip($this->printOutAssignedShares())); $smarty->assign("gotoBootKernels",$this->gotoBootKernels); - /* Arrays */ - $tmp = $this->goLdapServerList; - /* Create divSelectBox for ldap server selection */ $SelectBoxLdapServer = new divSelectBox("LdapServer"); $SelectBoxLdapServer->SetHeight(130); - /* Set first entry as selected, if $this->gotoLdapServer is empty - * or given entry is no longer available ... - */ - $found = false; - foreach($tmp as $server){ - if($this->gotoLdapServer==$server){ - $found = true; + /* Add new ldap server to the list */ + if(!$this->gotoLdap_inherit && isset($_POST['add_ldap_server']) && isset($_POST['ldap_server_to_add'])){ + if(isset($this->gotoLdapServerList[$_POST['ldap_server_to_add']])){ + $to_add = $this->gotoLdapServerList[$_POST['ldap_server_to_add']]; + if(!in_array($to_add,$this->gotoLdapServers)){ + $this->gotoLdapServers[] = $to_add; + } } } - + + /* Move ldap servers up and down */ + if(!$this->gotoLdap_inherit){ + foreach($_POST as $name => $value){ + if(preg_match("/sort_ldap_up_/",$name)){ + $id = preg_replace("/^sort_ldap_up_([0-9]*)_(x|y)$/","\\1",$name); + $from = $id; + $to = $id -1; + $tmp = $this->array_switch_item($this->gotoLdapServers,$from,$to); + if($tmp){ + $this->gotoLdapServers = $tmp; + } + break; + } + if(preg_match("/sort_ldap_down_/",$name)){ + $id = preg_replace("/^sort_ldap_down_([0-9]*)_(x|y)$/","\\1",$name); + $from = $id; + $to = $id +1; + $tmp = $this->array_switch_item($this->gotoLdapServers,$from,$to); + if($tmp){ + $this->gotoLdapServers = $tmp; + } + break; + } + } + } + /* Add Entries */ - foreach($tmp as $key => $server){ - $use =""; - if(($this->gotoLdapServer == $server) || ($found == false)) { - $found = true; - $use = " checked "; - }; - - $display = $server; - + foreach($this->gotoLdapServers as $key => $server){ $SelectBoxLdapServer->AddEntry( - array( - array("string"=>"", - "attach"=>"style='border-left:0px;'"), - array("string"=>$display) - )); + array(array("string" => $server), + array("string" => " ". + "", + "attach" => "style='border-right:0px;'"))); } - $smarty->assign("SelectBoxLdapServer",$SelectBoxLdapServer->DrawList()); + if($this->gotoLdap_inherit){ + $smarty->assign("gotoLdapServerACL_inherit", preg_replace("/w/","",$this->getacl("gotoLdapServer")));; + }else{ + $smarty->assign("gotoLdapServerACL_inherit", $this->getacl("gotoLdapServer")); + } + $smarty->assign("gotoLdapServers", $SelectBoxLdapServer->DrawList()); + $smarty->assign("gotoLdapServerList", $this->gotoLdapServerList); + $smarty->assign("gotoLdap_inherit", $this->gotoLdap_inherit); + $smarty->assign("JS", $_SESSION['js']); foreach (array("gotoModules", "gotoAutoFs", "gotoFilesystem") as $val){ $smarty->assign("$val", $this->$val); @@ -964,16 +992,23 @@ class workstartup extends plugin { plugin::save_object(); - /* Save group radio buttons */ - if ($this->acl_is_writeable("bootmode") && isset($_POST["bootmode"])){ - $this->bootmode= $_POST["bootmode"]; - } + if(isset($_POST['WorkstationStarttabPosted'])){ + if(isset($_POST['gotoLdap_inherit'])){ + $this->gotoLdap_inherit = TRUE; + }else{ + $this->gotoLdap_inherit = FALSE; + } - /* Save kernel parameters */ - if ($this->acl_is_writeable("gotoKernelParameters") && isset($_POST["customParameters"])){ - $this->customParameters= $_POST["customParameters"]; - } + /* Save group radio buttons */ + if ($this->acl_is_writeable("bootmode") && isset($_POST["bootmode"])){ + $this->bootmode= $_POST["bootmode"]; + } + /* Save kernel parameters */ + if ($this->acl_is_writeable("gotoKernelParameters") && isset($_POST["customParameters"])){ + $this->customParameters= $_POST["customParameters"]; + } + } } @@ -1081,9 +1116,12 @@ class workstartup extends plugin if(!isset($this->attrs["$val"])) $this->attrs["$val"]=array(); } - /* Strip out 'default' values */ - if ($this->attrs['gotoLdapServer'] == "default-inherited"){ - $this->attrs['gotoLdapServer']= array(); + /* Prepare list of ldap servers */ + $this->attrs['gotoLdapServer'] = array(); + if(!$this->gotoLdap_inherit){ + foreach($this->gotoLdapServers as $server){ + $this->attrs['gotoLdapServer'][] = $server; + } } if (($this->attrs['gotoBootKernel'] == "default-inherited") || ($this->attrs['gotoBootKernel'] == "%default%")){ @@ -1202,6 +1240,25 @@ class workstartup extends plugin } } + + function array_switch_item($ar,$from,$to) + { + if(!is_array($ar)){ + return(false); + } + if(!isset($ar[$from])){ + return(false); + } + if(!isset($ar[$to])){ + return(false); + } + + $tmp = $ar[$from]; + $ar[$from] = $ar[$to]; + $ar[$to] = $tmp; + return($ar); + } + /* Return plugin informations for acl handling */ function plInfo() diff --git a/plugins/admin/systems/workstationStartup.tpl b/plugins/admin/systems/workstationStartup.tpl index 281fcd7c3..57670d507 100644 --- a/plugins/admin/systems/workstationStartup.tpl +++ b/plugins/admin/systems/workstationStartup.tpl @@ -26,7 +26,23 @@
{render acl=$gotoLdapServerACL} - {$SelectBoxLdapServer} + + {t}Inherit ldap server settings from group{/t} +{if !$JS} + +{/if} +{/render} +{render acl=$gotoLdapServerACL_inherit} + {$gotoLdapServers} +{/render} +{render acl=$gotoLdapServerACL_inherit} + +{/render} +{render acl=$gotoLdapServerACL_inherit} + {/render}