X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-plugins%2Fgoto%2Fadmin%2Fsystems%2Fgoto%2Fclass_workstationStartup.inc;h=f902a92e0608c4a8a6f759164175b8cf81f13f1b;hb=84795129287efd59af4a0f0e4817d0e6655de076;hp=107a3efd62cb9d8d78b83059ca9ab35a89a1d40f;hpb=e1b170490c61df9cdc32629e6dfcd2c59946337a;p=gosa.git
diff --git a/gosa-plugins/goto/admin/systems/goto/class_workstationStartup.inc b/gosa-plugins/goto/admin/systems/goto/class_workstationStartup.inc
index 107a3efd6..f902a92e0 100644
--- a/gosa-plugins/goto/admin/systems/goto/class_workstationStartup.inc
+++ b/gosa-plugins/goto/admin/systems/goto/class_workstationStartup.inc
@@ -7,7 +7,9 @@ class workstartup extends plugin
var $gotoLdap_inherit = FALSE;
/* Generic terminal attributes */
- var $bootmode = "G";
+ # This is disabled as long there is no possiblilty to set these parameters
+ #var $bootmode = "G";
+ var $bootmode = "";
var $gotoBootKernel = "default-inherited";
var $gotoKernelParameters = "";
var $gotoLdapServer = "default-inherited";
@@ -29,7 +31,6 @@ class workstartup extends plugin
var $gotoAvailableShares= array();// Available Shares for this account
/* Helper */
- var $customParameters = "";
var $orig_dn = "";
var $ignore_account = TRUE;
@@ -90,8 +91,14 @@ class workstartup extends plugin
*/
$ldap = $this->config->get_ldap_link();
$ldap->cd($this->config->current['BASE']);
- foreach($this->config->data['SERVERS']['LDAP'] as $server) {
- $this->gotoLdapServerList[]= $server;
+ $ui = get_userinfo();
+ foreach($this->config->data['SERVERS']['LDAP'] as $dn => $data){
+ if($ui->get_category_permissions($data['dn'],"server",TRUE)){
+ for($i = 0; $i < $data['goLdapBase']['count']; $i ++){
+ $name = $data["cn"][0].":".$data["goLdapBase"][$i];
+ $this->gotoLdapServerList[]= $name;
+ }
+ }
}
/* Get list of assigned ldap servers
@@ -114,8 +121,6 @@ class workstartup extends plugin
*/
if($this->fai_activated) {
- $this->update_fai_cache(TRUE);
-
/* Parse used FAIclasses (stored as string).
* The single classes are seperated by ' '.
* There is also the release type given, after first
@@ -123,7 +128,7 @@ class workstartup extends plugin
*/
$this->FAIclass =array();
if(isset($this->attrs['FAIclass'][0])){
- $tmp = split(" ",$this->attrs['FAIclass'][0]);
+ $tmp = explode(" ",$this->attrs['FAIclass'][0]);
$tmp2 =array();
foreach($tmp as $class){
@@ -150,28 +155,12 @@ class workstartup extends plugin
$this->$val= array_unique($this->$val);
}
- /* Parse Kernel Parameters to decide what boot mode is enabled */
- if (preg_match("/ splash=silent/", $this->gotoKernelParameters)){
- $this->bootmode= "G";
- } elseif (preg_match("/ debug/", $this->gotoKernelParameters)){
- $this->bootmode= "D";
- } elseif ($this->gotoKernelParameters == "") {
- $this->bootmode= "G";
- } else {
- $this->bootmode= "T";
- }
- if (preg_match("/ o /", $this->gotoKernelParameters)){
- $this->customParameters= preg_replace ("/^.* o /", "", $this->gotoKernelParameters);
- } else {
- $this->customParameters= "";
- }
-
/* Prepare Shares */
if((isset($this->attrs['gotoShare']))&&(is_array($this->attrs['gotoShare']))){
unset($this->attrs['gotoShare']['count']);
foreach($this->attrs['gotoShare'] as $share){
$tmp = $tmp2 = array();
- $tmp = split("\|",$share);
+ $tmp = explode("|",$share);
$tmp2['server'] =$tmp[0];
$tmp2['name'] =$tmp[1];
$tmp2['mountPoint'] =$tmp[2];
@@ -222,8 +211,8 @@ class workstartup extends plugin
break;
case 'FAIclass':
- $str = split(":",$attrs[$name][0]);
- $this->InheritedFAIclass = split("\ ",trim($str[0]));
+ $str = explode(":",$attrs[$name][0]);
+ $this->InheritedFAIclass = explode(" ",trim($str[0]));
$this->InheritedFAIrelease = trim($str[1]);
break;
@@ -234,6 +223,7 @@ class workstartup extends plugin
}
}
+ $this->update_fai_cache();
if($this->fai_activated && !$this->si_fai_action_failed && $this->si_active){
@@ -261,6 +251,16 @@ class workstartup extends plugin
$this->update_fai_cache();
}
}
+
+
+ // Prepare lists
+ $this->ldapList = new sortableListing(array(),array(), TRUE);
+ $this->ldapList->setDeleteable(true);
+ $this->ldapList->setEditable(false);
+ $this->ldapList->setWidth("100%");
+ $this->ldapList->setHeight("100px");
+ $this->ldapList->setHeader(array(_("LDAP server")));
+ $this->ldapList->setDefaultSortColumn(0);
}
@@ -291,8 +291,7 @@ class workstartup extends plugin
/* Do we represent a valid terminal? */
if (!$this->is_account && $this->parent === NULL){
- $display= " ".
- msgPool::noValidExtension(_("workstation"))."";
+ $display= image("images/small-error.png")."".msgPool::noValidExtension(_("workstation"))."";
return ($display);
}
@@ -352,7 +351,7 @@ class workstartup extends plugin
}
if(($sort_type)&&(!$sort)){
- $value = base64_decode(preg_replace("/_.*$/i","",preg_replace("/".$sort_type."/i","",$name)));
+ $value = postDecode(preg_replace("/_.*$/i","",preg_replace("/".$sort_type."/i","",$name)));
$sort = true;
$last = -1;
@@ -399,7 +398,7 @@ class workstartup extends plugin
}
if(preg_match("/fai_remove/i",$name)){
- $value = base64_decode(preg_replace("/_.*$/i","",preg_replace("/fai_remove_/i","",$name)));
+ $value = postDecode(preg_replace("/fai_remove_/i","",$name));
unset($this->FAIclass[$value]);
}
}
@@ -464,10 +463,7 @@ class workstartup extends plugin
$smarty->assign("gotoShareKeys",array_flip($this->printOutAssignedShares()));
$smarty->assign("gotoBootKernels",$this->gotoBootKernels);
- /* Create divSelectBox for ldap server selection
- */
- $SelectBoxLdapServer = new divSelectBox("LdapServer");
- $SelectBoxLdapServer->SetHeight(130);
+ $this->ldapList->setAcl($this->getacl('gotoLdapServer'));
/* Add new ldap server to the list */
if($this->acl_is_writeable("gotoLdapServer") &&
@@ -483,65 +479,38 @@ class workstartup extends plugin
}
/* Move ldap servers up and down */
- if(!$this->gotoLdap_inherit && $this->acl_is_writeable("gotoLdapServer")){
- 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;
- }
- if(preg_match("/gotoLdapRemove_/",$name)){
- $id = preg_replace("/^gotoLdapRemove_([0-9]*)_(x|y)$/","\\1",$name);
- $value = $this->gotoLdapServers[$id];
- $this->gotoLdapServers = array_remove_entries(array($value),$this->gotoLdapServers);
- break;
- }
- }
+ $this->ldapList->save_object();
+ $action = $this->ldapList->getAction();
+ if($action['action'] == 'reorder'){
+ $this->gotoLdapServers = array_values($this->ldapList->getMaintainedData());
+ }
+ if($action['action'] == 'delete'){
+ $id = $this->ldapList->getKey($action['targets'][0]);
+ $value = $this->gotoLdapServers[$id];
+ $this->gotoLdapServers = array_remove_entries(array($value),$this->gotoLdapServers);
}
-
- /* Add Entries */
- if($this->acl_is_readable("gotoLdapServer")){
- foreach($this->gotoLdapServers as $key => $server){
+ /* Add Entries */
+ $data = $lData = array();
+ foreach($this->gotoLdapServers as $key => $server){
+ $data[$key]=$server;
/* Announce missing entries */
if(!in_array($server,$this->gotoLdapServerList)){
- $server = $server." (missing)";
+ $server = $server." (missing)";
}
/* Convert old style entry */
if (!preg_match('%:ldaps?://%', $server)){
- $server= "ldap://".preg_replace('/^([^:]+):/', '\1/', $server);
-
- /* Beautify new style entries */
- } else {
- $server= preg_replace("/^[^:]+:/", "", $server);
- }
-
- $SelectBoxLdapServer->AddEntry(
- array(array("string" => $server),
- array("string" =>
- " ".
- " ".
- "",
- "attach" => "style='text-align:right;width:40px;border-right:0px;'")));
- }
- }
+ $server= "ldap://".preg_replace('/^([^:]+):/', '\1/', $server);
+ } else {
+ $server= preg_replace("/^[^:]+:/", "", $server);
+ $lData[$key] = array('data'=>array($server));
+ }
+ }
+ $this->ldapList->setListData($data,$lData);
+ $this->ldapList->update();
+ $smarty->assign("usePrototype", "true");
if($this->gotoLdap_inherit){
$smarty->assign("gotoLdapServerACL_inherit", preg_replace("/w/","",$this->getacl("gotoLdapServer")));;
@@ -565,7 +534,7 @@ class workstartup extends plugin
$list[$key] = $entry;
}
}
- $smarty->assign("gotoLdapServers", $SelectBoxLdapServer->DrawList());
+ $smarty->assign("gotoLdapServers", $this->ldapList->render());
$smarty->assign("gotoLdapServerList", $list);
$smarty->assign("gotoLdap_inherit", $this->gotoLdap_inherit);
$smarty->assign("JS", session::get('js'));
@@ -575,7 +544,7 @@ class workstartup extends plugin
}
/* Values */
- foreach(array("gotoBootKernel", "customParameters", "gotoShare","FAIclasses","FAIclass","FAIdebianMirror","FAIrelease") as $val){
+ foreach(array("gotoBootKernel","gotoShare","FAIclasses","FAIclass","FAIdebianMirror","FAIrelease") as $val){
$smarty->assign($val, $this->$val);
}
@@ -585,6 +554,9 @@ class workstartup extends plugin
$this->update_fai_cache();
$smarty->assign("si_fai_action_failed",$this->si_fai_action_failed);
$smarty->assign("si_active",$this->si_active);
+
+ $div = new divSelectBox("WSFAIscriptClasses");
+ $div -> SetHeight("100");
if(!$this->si_fai_action_failed && $this->si_active && $this->fai_activated){
@@ -605,12 +577,14 @@ class workstartup extends plugin
$smarty->assign("gotoBootKernels",$this->cache['KERNELS'][$release]);
$smarty->assign("InheritedFAIrelease",$this->InheritedFAIrelease);
- $div = new divSelectBox("WSFAIscriptClasses");
- $div -> SetHeight("110");
- $str_up = " ";
- $str_down = " ";
- $str_remove = " ";
- $str_empty = " ";
+ $str_empty = image('images/empty.png');
+ if($this->acl_is_writeable("FAIclass")){
+ $str_up = image('images/lists/sort-up.png','sort_up_%s');
+ $str_down = image('images/lists/sort-down.png','sort_down_%s');
+ $str_remove = image('images/lists/trash.png','fai_remove_%s');
+ }else{
+ $str_up=$str_down=$str_remove=$str_empty;
+ }
/* Get classes */
if($this->FAIdebianMirror == "inherited"){
@@ -624,57 +598,71 @@ class workstartup extends plugin
/* Draw every single entry */
$i = 1;
- foreach($tmp as $class){
+ if($this->acl_is_readable("FAIclass")){
+ foreach($tmp as $class){
- /* Mark invalid classes. (Not in selected release)
- */
- $marker = "";
- if(in_array_ics($class,$invalid)){
- $marker = " ("._("Not available in current setup").")";
- }
+ /* Mark invalid classes. (Not in selected release)
+ */
+ $marker = "";
+ if(in_array_ics($class,$invalid)){
+ $marker = " ("._("Not available in current setup").")";
+ }
- /* Create up/down priority icons
- * Skip this, if we have inherited the FAI classes.
- */
- if($this->FAIdebianMirror == "inherited"){
- $str = "";
- }else{
- if($i==1){
- $str = $str_empty.$str_down.$str_remove;
- }elseif($i == count($this->FAIclass)){
- $str = $str_up.$str_empty.$str_remove;
+ /* Create up/down priority icons
+ * Skip this, if we have inherited the FAI classes.
+ */
+ if($this->FAIdebianMirror == "inherited"){
+ $str = "";
}else{
- $str = $str_up.$str_down.$str_remove;
+ if($i==1){
+ $str = $str_empty.$str_down.$str_remove;
+ }elseif($i == count($this->FAIclass)){
+ $str = $str_up.$str_empty.$str_remove;
+ }else{
+ $str = $str_up.$str_down.$str_remove;
+ }
}
- }
- $i ++ ;
-
- /* Get Description tag
- * There may be several FAI objects with the same class name,
- * use the description from FAIprofile, if possible.
- */
- $desc = "";
- if(isset($this->cache['CLASSES'][$this->FAIrelease][$class])){
- foreach($this->cache['CLASSES'][$this->FAIrelease][$class] as $types ){
- if(isset($types['Desc'])){
- $desc= $types['Desc'];
- if($types['Type'] == "FAIprofile"){
- break;
+ $i ++ ;
+
+ /* Get Description tag
+ * There may be several FAI objects with the same class name,
+ * use the description from FAIprofile, if possible.
+ */
+ $desc = "";
+
+ $objects = array(
+ "Pl" => array("IMG"=> "plugins/fai/images/fai_partitionTable.png"),
+ "Pt" => array("IMG"=> "plugins/fai/images/fai_packages.png"),
+ "S" => array("IMG"=> "plugins/fai/images/fai_script.png"),
+ "V" => array("IMG"=> "plugins/fai/images/fai_variable.png"),
+ "H" => array("IMG"=> "plugins/fai/images/fai_hook.png"),
+ "P" => array("IMG"=> "plugins/fai/images/fai_profile.png"),
+ "T" => array("IMG"=> "plugins/fai/images/fai_template.png"));
+
+ if(isset($this->cache['CLASSES'][$this->FAIrelease][$class])){
+ $desc ="";
+ foreach($this->cache['CLASSES'][$this->FAIrelease][$class] as $types ){
+ if(isset($types['Abbr'])){
+ $desc.= image($objects[$types['Abbr']]['IMG']);
+ if($types['Type'] == "FAIprofile"){
+ break;
+ }
}
}
}
- }
- if(!empty($desc)){
- $desc = " [".trim($desc)."]";
- }
-
- $div->AddEntry(array(
- array("string"=>$class.$desc.$marker),
- array("string"=>preg_replace("/\%s/",base64_encode($class),$str),"attach"=>"style='width:50px;border-right:none;'")
- ));
- }
- $smarty->assign("FAIScriptlist",$div->DrawList());
+ if(!empty($desc)){
+ $desc = " ".trim($desc)."";
+ }
+
+ $div->AddEntry(array(
+ array("string"=>$class.$marker),
+ array("string"=>$desc),
+ array("string"=>preg_replace("/\%s/",postEncode($class),$str),"attach"=>"style='width:60px;border-right:none;'")
+ ));
+ }
+ }// END FAI output generation
}// END FAI output generation
+ $smarty->assign("FAIScriptlist",$div->DrawList());
/* Radio button group */
if (preg_match("/G/", $this->bootmode)) {
@@ -694,6 +682,7 @@ class workstartup extends plugin
}
/* Show main page */
+ $smarty->assign("gotoKernelParameters",$this->gotoKernelParameters);
return($smarty->fetch (get_template_path('workstationStartup.tpl', TRUE,dirname(__FILE__))));
}
@@ -729,11 +718,6 @@ class workstartup extends plugin
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"];
- }
}
}
@@ -772,7 +756,7 @@ class workstartup extends plugin
$ldap= $this->config->get_ldap_link();
/* Strip relevant part from dn, keep trailing ',' */
- $tmp= preg_replace("/^cn=[^,]+,".get_ou('terminalRDN')."/i", "", $this->dn);
+ $tmp= preg_replace("/^cn=[^,]+,".preg_quote(get_ou('terminalRDN'), '/')."/i", "", $this->dn);
$tmp= preg_replace("/".$this->config->current['BASE']."$/i", "", $tmp);
/* Walk from top to base and try to load default values for
@@ -795,22 +779,6 @@ class workstartup extends plugin
}
}
- /* Add semi automatic values */
- // FIXME: LDAP Server may not be set here...
- $this->gotoKernelParameters= "ldap=".base64_encode($this->gotoLdapServer);
-
- switch ($this->bootmode){
- case "D":
- $this->gotoKernelParameters.= " debug";
- break;
- case "G":
- $this->gotoKernelParameters.= " splash=silent";
- break;
- }
- if ($this->customParameters != ""){
- $this->gotoKernelParameters.= " o ".$this->customParameters;
- }
-
plugin::save();
unset( $this->attrs['FAIrelease'] );
@@ -887,7 +855,7 @@ class workstartup extends plugin
/* prepare share settings */
$tmp = array();
foreach($this->gotoShares as $name => $settings){
- $tmp2= split("\|",$name);
+ $tmp2= explode("|",$name);
$name = $tmp2[0];
$tmp[] = $settings['server']."|".$name."|".$settings['mountPoint'];
}
@@ -998,7 +966,8 @@ class workstartup extends plugin
plugin::PrepareForCopyPaste($source);
$source_o = new workstartup ($this->config, $source['dn']);
foreach(array("FAIclass","gotoModules", "gotoAutoFs", "gotoFilesystem",
- "gotoKernelParameters","gotoShares","customParameters") as $attr){
+ "gotoKernelParameters","gotoShares","gotoLdapServers","gotoLdapServerList",
+ "gotoLdap_inherit") as $attr){
$this->$attr = $source_o->$attr;
}
}
@@ -1038,6 +1007,7 @@ class workstartup extends plugin
"plProvidedAcls"=> array(
"gotoLdapServer" => _("Ldap server"),
"gotoBootKernel" => _("Boot kernel"),
+ "bootmode" => _("Boot mode"),
"gotoKernelParameters" => _("Kernel parameter"),
"gotoModules" => _("Kernel modules"),
@@ -1078,6 +1048,7 @@ class workstartup extends plugin
$this->cache = array();
return;
}else{
+
foreach($tmp as $entry){
$rel = $entry['FAI_RELEASE'];
$this->cache['SERVERS']['auto'][$rel] = $rel;
@@ -1107,7 +1078,10 @@ class workstartup extends plugin
/* Check if the selected release is available */
if($this->FAIdebianMirror != "inherited" && !isset($this->cache['SERVERS'][$this->FAIdebianMirror][$this->FAIrelease])){
- trigger_error("There was a problem with the selected FAIrelease. This release ('".$this->FAIrelease."') is not available");
+
+ if($this->FAIrelease != ""){
+ trigger_error("There was a problem with the selected FAIrelease. This release ('".$this->FAIrelease."') is not available");
+ }
$this->FAIrelease = key($this->cache['SERVERS'][$this->FAIdebianMirror]);
}
}
@@ -1127,6 +1101,7 @@ class workstartup extends plugin
*/
$o_queue = new gosaSupportDaemon();
$tmp = $o_queue->FAI_get_classes($release);
+
$this->cache['CLASSES'][$release] = array();
if($o_queue->is_error()){
msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
@@ -1136,7 +1111,7 @@ class workstartup extends plugin
}else{
foreach($tmp as $entry){
$class = $entry['CLASS'];
- $this->cache['CLASSES'][$release][$class] = $this->analyse_fai_object($entry);
+ $this->cache['CLASSES'][$release][$class][] = $this->analyse_fai_object($entry);
}
}
@@ -1144,19 +1119,19 @@ class workstartup extends plugin
*/
$lines= $this->GetHookElements();
foreach ($lines as $hline){
- $entries= split(";", $hline);
+ $entries= explode(";", $hline);
$server = $entries['0'];
$url = $entries['1'];
if (!empty($url)){
/* Split releases */
if (isset($entries[2])){
- $releases= split(",", $entries[2]);
+ $releases= explode(",", $entries[2]);
foreach ($releases as $release_data){
$release_c = preg_replace('/:.*$/', '', $release_data);
- $sections_c = split(':', preg_replace('/^[^:]+:([^|]+)|.*$/', '\1', $release_data));
- $classes_c = split('\|', preg_replace('/^[^|]+\|(.*)$/', '\1', $release_data));
+ $sections_c = explode(':', preg_replace('/^[^:]+:([^|]+)|.*$/', '\1', $release_data));
+ $classes_c = explode('|', preg_replace('/^[^|]+\|(.*)$/', '\1', $release_data));
if($release_c == $release){
$this->cache['SERVERS'][$url][$release_c]=$release_c;
@@ -1246,6 +1221,7 @@ class workstartup extends plugin
$ret= array();
foreach($classes as $class_name => $class_types){
if(!in_array($class_name,$this->FAIclass)){
+ $Abbr = "";
foreach($class_types as $type){
if(!preg_match("/".$type['Abbr']."/",$Abbr)){
$Abbr .= $type['Abbr']." ";
@@ -1313,9 +1289,9 @@ class workstartup extends plugin
if((!$res)){
msg_dialog::display(_("Configuration error"), msgPool::cmdexecfailed("repositoryBranchHook", $cmd), ERROR_DIALOG);
}elseif(empty($res2)){
- msg_dialog::display(_("Configuration error"), _("repositoryBranchHook returned no result!"), ERROR_DIALOG);
+ msg_dialog::display(_("Configuration error"), _("'repositoryBranchHook' returned no result!"), ERROR_DIALOG);
}else{
- $tmp = split("\n",$res);
+ $tmp = preg_split("/\n/",$res);
foreach($tmp as $line){
if(empty($line)) continue;
$ret[]= $line;
@@ -1331,8 +1307,8 @@ class workstartup extends plugin
*/
function dn_to_release_name($dn)
{
- $relevant = preg_replace("/,".normalizePreg(get_ou("faiBaseRDN")).".*$/","",$dn);
- $parts = array_reverse(split("\,",$relevant));
+ $relevant = preg_replace("/,".preg_quote(get_ou("faiBaseRDN"), '/').".*$/i","",$dn);
+ $parts = array_reverse(explode(",",$relevant));
$str ="";
foreach($parts as $part){
$str .= preg_replace("/^ou=/","",$part)."/";