From e0f8c85d41b4b35b10aede1bdbcec66096aead43 Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 11 Oct 2005 05:16:32 +0000 Subject: [PATCH] Added seperate WS tab, but not configured it yet git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1554 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../systems/class_workstationService.inc | 304 ++++++++++++++++++ .../systems/class_workstationStartup.inc | 293 +++++++++++++++++ .../{service.tpl => terminalService.tpl} | 0 plugins/admin/systems/workstationService.tpl | 223 +++++++++++++ plugins/admin/systems/workstationStartup.tpl | 106 ++++++ 5 files changed, 926 insertions(+) create mode 100644 plugins/admin/systems/class_workstationService.inc create mode 100644 plugins/admin/systems/class_workstationStartup.inc rename plugins/admin/systems/{service.tpl => terminalService.tpl} (100%) create mode 100644 plugins/admin/systems/workstationService.tpl create mode 100644 plugins/admin/systems/workstationStartup.tpl diff --git a/plugins/admin/systems/class_workstationService.inc b/plugins/admin/systems/class_workstationService.inc new file mode 100644 index 000000000..d04d110a0 --- /dev/null +++ b/plugins/admin/systems/class_workstationService.inc @@ -0,0 +1,304 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* Generic terminal attributes */ + var $gotoLpdEnable= FALSE; + var $gotoXMonitor= ""; + var $gotoXMethod= ""; + var $gotoXdmcpServer= ""; + var $gotoFontPath= ""; + var $gotoXDriver= ""; + var $gotoXResolution= ""; + var $gotoXColordepth= ""; + var $gotoXHsync= ""; + var $gotoXVsync= ""; + var $gotoXKbModel= ""; + var $gotoXKbLayout= ""; + var $gotoXKbVariant= ""; + var $gotoXMouseType= ""; + var $gotoXMouseport= ""; + var $gotoLpdServer= ""; + var $gotoScannerEnable= ""; + var $gotoScannerModel= ""; + var $gotoScannerClients= ""; + var $gotoScannerBackend= ""; + var $goFonHardware= "automatic"; + + /* Needed values and lists */ + var $ignore_account= TRUE; + var $base= ""; + var $cn= ""; + var $orig_dn= ""; + var $XMethods= array(); + var $XDrivers= array("unknown", "ati", "atimisc", "chips", "cirrus", "cyrix", "fbdev", + "i128", "i740", "i810", "imstt", "mga", "neomagic", "newport", "nsc", "nv", + "r128", "radeon", "rendition", "s3", "s3virge", "savage", "siliconmotion", + "sis", "tdfx", "tga", "trident", "tseng", "vesa", "vga"); + var $XResolutions= array("default", "640x480", "800x600", "1024x768", "1152x864", "1280x1024", + "1400x1050", "1600x1200"); + var $XColordepths= array("default", "8", "15", "16", "24"); + var $XKbModels= array ("default", "btc9000", "chicony", "compaq", "dell", "dell101", "everex", + "flexpro", "geniuscomfy", "hp", "itouch", "jp106", "logicordless", + "logiinetnav", "logiinternet", "macintosh", "microsoft", + "microsoftpro", "omnikey101", "pc101", "pc102", "pc104", + "pc105", "rapidaccess", "rapidaccess2", "winbook"); + var $XKbLayouts= array ("default", "de", "intl", "us"); + var $XKbVariants= array ("default", "nodeadkeys", "basic"); + var $MouseTypes= array("AUTO", "ImPS/2", "PS/2", "Microsoft", "Logitech"); + var $MousePorts= array("AUTO", "/dev/ttyS0", "/dev/ttyS1", "/dev/psaux", "/dev/input/mice"); + var $gotoScannerModels= array(); + var $hardware_list= array(); + var $used_hardware= array(); + + + /* attribute list for save action */ + var $attributes= array("cn", "gotoLpdEnable", "gotoXMonitor", "gotoXMethod", "gotoXdmcpServer", + "gotoFontPath", "gotoXDriver", "gotoXResolution", "gotoXColordepth", + "gotoXHsync", "gotoXVsync", "gotoLpdEnable", "gotoLpdServer", + "gotoScannerEnable", "gotoScannerModel", "gotoScannerClients", + "gotoScannerBackend", "gotoXKbModel", "gotoXKbLayout", "gotoXKbVariant", + "gotoXMouseType", "gotoXMouseport", "goFonHardware"); + var $objectclasses= array("GOhard"); + + + function termservice ($config, $dn= NULL) + { + plugin::plugin ($config, $dn); + + /* Load scanner models */ + $fcontents = file ($this->config->basedir."/include/scanner.inc"); + while (list ($line_num, $line) = each ($fcontents)) { + preg_match('/^(\w+) "([^"]+)" "([^"]+)" "([^"]+)"/', "$line", $matches); + $this->gotoScannerModels[$matches[2]." - ".$matches[3]]= $matches[1]."|".$matches[4]; + } + ksort ($this->gotoScannerModels); + + /* Initialize methods */ + $this->XMethods["default"]= _("default"); + $this->XMethods["indirect"]= _("show chooser"); + $this->XMethods["query"]= _("direct"); +#$this->XMethods["squery"]= _("direct via ssh"); +#$this->XMethods["nquery"]= _("direct via nx"); + $this->XMethods["load"]= _("load balanced"); +#$this->XMethods["sload"]= _("load balanced via ssh"); +#$this->XMethods["nload"]= _("load balanced via nx"); + $this->XMethods["rdp"]= _("Windows RDP"); + $this->XMethods["citrix"]= _("ICA client"); + + $this->orig_dn= $this->dn; + + /* Load hardware list */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(objectClass=goFonHardware)", array('cn', 'description')); + while ($attrs= $ldap->fetch()){ + $cn= $attrs['cn'][0]; + if (isset($attrs['description'])){ + $description= " - ".$attrs['description'][0]; + } else { + $description= ""; + } + $this->hardware_list[$cn]= "$cn$description"; + } + + /* Eventually colorize phones */ + $ldap->cd($this->config->current['BASE']); + foreach ($this->hardware_list as $cn => $desc){ + $ldap->search("(goFonHardware=$cn)", array('cn')); + if ($ldap->count() > 0){ + $ldap->fetch(); + if ($ldap->getDN() != $this->dn){ + $this->used_hardware[$cn]= $ldap->getDN(); + } + } + } + + $this->hardware_list["automatic"]= _("automatic"); + ksort($this->hardware_list); + } + + function execute() + { + /* Do we need to flip is_account state? */ + if (isset($_POST['modify_state'])){ + $this->is_account= !$this->is_account; + } + + /* Do we represent a valid terminal? */ + if (!$this->is_account && $this->parent == NULL){ + $display= "\"\" ". + _("This 'dn' has no terminal features.").""; + return ($display); + } + + /* Show main page */ + $smarty= get_smarty(); + + /* Arrays */ + foreach(array("XMethods", "XDrivers", "XResolutions", "XColordepths", + "gotoScannerModels", "XKbModels", "XKbLayouts", "XKbVariants", + "MouseTypes", "MousePorts") as $val){ + $smarty->assign("$val", $this->$val); + } + $smarty->assign("xdmcpservers", $this->config->data['SERVERS']['TERMINAL']); + $smarty->assign("fontservers", $this->config->data['SERVERS']['FONT']); + $smarty->assign("nfsservers", $this->config->data['SERVERS']['NFS']); + $smarty->assign("nfsservers", $this->config->data['SERVERS']['NFS']); + + /* Variables - select */ + foreach(array("gotoXMethod", "gotoXdmcpServer", "gotoFontPath", + "gotoXDriver", "gotoXResolution", "gotoXColordepth", + "gotoLpdServer", "gotoScannerModel", "gotoXKbModel", "gotoXKbLayout", + "gotoXKbVariant", "gotoXMouseType", "gotoXMouseport") as $val){ + + $smarty->assign($val."_select", $this->$val); + $smarty->assign($val."ACL", chkacl($this->acl, $val)); + } + + /* Variables */ + foreach(array("gotoXHsync", "gotoXVsync") as $val){ + $smarty->assign($val, $this->$val); + $smarty->assign($val."ACL", chkacl($this->acl, $val)); + } + $smarty->assign("staticAddress", ""); + + /* Checkboxes */ + foreach(array("gotoLpdEnable", "gotoScannerEnable") as $val){ + if ($this->$val == TRUE) { + $smarty->assign("$val", "checked"); + } else { + $smarty->assign("$val", ""); + } + $smarty->assign($val."ACL", chkacl($this->acl, "gotoLpdEnable")); + } + + /* Phone stuff */ + $smarty->assign ("goFonHardware", $this->goFonHardware); + $hl= "\n"; + $smarty->assign ("hardware_list", $hl); + $smarty->assign ("gotoXMonitor", $this->gotoXMonitor); + + /* Show main page */ + return($smarty->fetch (get_template_path('service.tpl', TRUE))); + } + + function remove_from_parent() + { + $ldap= $this->config->get_ldap_link(); + $ldap->rmdir($this->dn); + show_ldap_error($ldap->get_error()); + $this->handle_post_events("remove"); + } + + + /* Save data to object */ + function save_object() + { + plugin::save_object(); + + /* Save checkbox state */ + if (isset ($_POST['gotoXMethod'])){ + foreach (array("gotoLpdEnable", "gotoScannerEnable") as $val){ + + if (!isset ($_POST["$val"]) && chkacl ($this->acl, "$val") == ""){ + $this->$val= FALSE; + } else { + $this->$val= TRUE; + } + } + } + } + + + /* Check supplied data */ + function check() + { + $message= array(); + + /* Default entries can use blank hsync/vsync entries */ + if ($this->dn != "" && $this->cn != "default" && $this->cn != "wdefault"){ + + /* Check vsync for correct usage */ + $val= preg_replace ("/\s/", "", $this->gotoXVsync); + if (!preg_match ("/^\d+(\.\d+)?(\-\d+(\.\d+)?)?$/", $val) + && chkacl ($this->acl, "gotoXVsync") == ""){ + + $message[]= _("Please specify a valid VSync range."); + } elseif (chkacl ($this->acl, "gotoXVsync") == ""){ + list($v1,$v2)= split ("-", $val); + if ($v2 != ""){ + if ($v1 > $v2){ + $message[]= _("Please specify a valid VSync range."); + } + } + } + + /* Check hsync for correct usage */ + $val= preg_replace ("/\s/", "", $this->gotoXHsync); + if (!preg_match ("/^\d+(\.\d+)?(\-\d+(\.\d+)?)?$/", $val) + && chkacl ($this->acl, "gotoXHsync") == ""){ + + $message[]= _("Please specify a valid HSync range."); + } elseif (chkacl ($this->acl, "gotoXHsync") == ""){ + list($v1,$v2)= split ("-", $val); + if ($v2 != ""){ + if ($v1 > $v2){ + $message[]= _("Please specify a valid HSync range."); + } + } + } + } + return ($message); + } + + + /* Save to LDAP */ + function save() + { + plugin::save(); + + /* Strip out 'default' values */ + foreach(array("gotoXMethod", "gotoXdmcpServer", "gotoFontPath", + "gotoXDriver", "gotoXResolution", "gotoXColordepth", + "gotoLpdServer", "gotoScannerModel", "gotoXKbModel", "gotoXKbLayout", + "gotoXKbVariant", "gotoXMouseType", "gotoXMouseport") as $val){ + + if ($this->attrs[$val] == "default"){ + $this->attrs[$val]= array(); + } + } + + /* Write back to ldap */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->dn); + $ldap->modify($this->attrs); + show_ldap_error($ldap->get_error()); + $this->handle_post_events("modify"); + } + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/plugins/admin/systems/class_workstationStartup.inc b/plugins/admin/systems/class_workstationStartup.inc new file mode 100644 index 000000000..67a8e6bf8 --- /dev/null +++ b/plugins/admin/systems/class_workstationStartup.inc @@ -0,0 +1,293 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* Generic terminal attributes */ + var $bootmode= "G"; + var $goLdapServerList= array("default"); + var $gotoBootKernel= "default"; + var $gotoKernelParameters= ""; + var $gotoLdapServer= ""; + var $gotoModules= array(); + var $gotoAutoFs= array(); + var $gotoFilesystem= array(); + var $gotoTerminalPath= ""; + + /* attribute list for save action */ + var $attributes= array("gotoLdapServer", "gotoBootKernel", "gotoKernelParameters"); + var $objectclasses= array("GOhard"); + + /* Helper */ + var $customParameters= ""; + var $orig_dn= ""; + var $ignore_account= TRUE; + + function termstartup ($config, $dn= NULL) + { + plugin::plugin ($config, $dn); + + /* Get arrays */ + foreach (array("gotoModules", "gotoAutoFs", "gotoFilesystem") as $val){ + if (isset($this->attrs["$val"]["count"])){ + for ($i= 0; $i<$this->attrs["count"]; $i++){ + if (isset($this->attrs["$val"][$i])){ + array_push($this->$val, $this->attrs["$val"][$i]); + } + } + } + sort ($this->$val); + $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= ""; + } + + $this->orig_dn= $this->dn; + } + + function execute() + { + /* Do we need to flip is_account state? */ + if (isset($_POST['modify_state'])){ + $this->is_account= !$this->is_account; + } + + /* Do we represent a valid terminal? */ + if (!$this->is_account && $this->parent == NULL){ + $display= "\"\" ". + _("This 'dn' has no terminal features.").""; + return ($display); + } + + /* Add module */ + if (isset ($_POST['add_module'])){ + if ($_POST['module'] != "" && chkacl ($this->acl, "gotoModule") == ""){ + $this->add_list ($this->gotoModules, $_POST['module']); + } + } + + /* Delete module */ + if (isset ($_POST['delete_module'])){ + if (count($_POST['modules_list']) && chkacl ($this->acl, "gotoModule") == ""){ + $this->del_list ($this->gotoModules, $_POST['modules_list']); + } + } + + /* Add autofs */ + if (isset ($_POST['add_autofs'])){ + if ($_POST['autofs'] != "" && chkacl ($this->acl, "gotoAutoFs") == ""){ + $this->add_list ($this->gotoAutoFs, $_POST['autofs']); + } + } + + /* Delete autofs */ + if (isset ($_POST['delete_autofs'])){ + if (count($_POST['autofs_list']) && chkacl ($this->acl, "gotoAutoFs") == ""){ + $this->del_list ($this->gotoAutoFs, $_POST['autofs_list']); + } + } + + /* Add filesystem */ + if (isset ($_POST['add_fs'])){ + if ($_POST['fstab'] != "" && chkacl ($this->acl, "gotoFilesystem") == ""){ + $this->add_list ($this->gotoFilesystem, $_POST['fstab']); + } + } + + /* Delete filesystem */ + if (isset ($_POST['delete_fs'])){ + if (count($_POST['fstab_list']) && chkacl ($this->acl, "gotoFilesystem") == ""){ + $this->del_list ($this->gotoFilesystem, $_POST['fstab_list']); + } + } + + /* Show main page */ + $smarty= get_smarty(); + + /* Arrays */ + $smarty->assign("ldapservers", $this->config->data['SERVERS']['LDAP']); + $smarty->assign("gotoLdapServer_select", $this->gotoLdapServer); + $smarty->assign("gotoLdapServerACL", chkacl($this->acl, "gotoLdapServer")); + foreach (array("gotoModules", "gotoAutoFs", "gotoFilesystem") as $val){ + $smarty->assign("$val", $this->$val); + } + + /* Values */ + foreach(array("gotoBootKernel", "customParameters") as $val){ + $smarty->assign($val, $this->$val); + $smarty->assign($val."ACL", chkacl($this->acl, $val)); + } + + /* Radio button group */ + if (preg_match("/G/", $this->bootmode)) { + $smarty->assign("graphicalbootup", "checked"); + } else { + $smarty->assign("graphicalbootup", ""); + } + if (preg_match("/T/", $this->bootmode)) { + $smarty->assign("textbootup", "checked"); + } else { + $smarty->assign("textbootup", ""); + } + if (preg_match("/D/", $this->bootmode)) { + $smarty->assign("debugbootup", "checked"); + } else { + $smarty->assign("debugbootup", ""); + } + + /* ACL's */ + foreach (array("gotoKernelParameters", "gotoModules", "gotoFilesystem") as $value){ + $smarty->assign($value."ACL", chkacl($this->acl, "$value")); + } + + /* Show main page */ + return($smarty->fetch (get_template_path('startup.tpl', TRUE))); + } + + function remove_from_parent() + { + $ldap= $this->config->get_ldap_link(); + $ldap->rmdir($this->dn); + show_ldap_error($ldap->get_error()); + $this->handle_post_events("remove"); + } + + + /* Save data to object */ + function save_object() + { + plugin::save_object(); + + /* Save group radio buttons */ + if (chkacl ($this->acl, "bootmode") == "" && isset($_POST["bootmode"])){ + $this->bootmode= $_POST["bootmode"]; + } + + /* Save kernel parameters */ + if (chkacl ($this->acl, "gotoKernelParameters") == "" && isset($_POST["customParameters"])){ + $this->customParameters= $_POST["customParameters"]; + } + } + + + /* Save to LDAP */ + function save() + { + /* Find proper terminal path for tftp configuration + FIXME: This is suboptimal when the default has changed to + another location! */ + if ($this->gotoTerminalPath == "default"){ + $ldap= $this->config->get_ldap_link(); + + /* Strip relevant part from dn, keep trailing ',' */ + $tmp= preg_replace("/^cn=[^,]+,ou=terminals,ou=systems,/i", "", $this->dn); + $tmp= preg_replace("/".$this->config->current['BASE']."$/i", "", $tmp); + + /* Walk from top to base and try to load default values for + 'gotoTerminalPath'. Abort when an entry is found. */ + while (TRUE){ + $tmp= preg_replace ("/^[^,]+,/", "", $tmp); + + $ldap->cat("cn=default,ou=terminals,ou=systems,$tmp". + $this->config->current['BASE']); + $attrs= $ldap->fetch(); + if (isset($attrs['gotoTerminalPath'])){ + $this->gotoTerminalPath= $attrs['gotoTerminalPath'][0]; + break; + } + + /* Nothing left? */ + if ($tmp == ""){ + break; + } + } + } + + /* Add semi automatic values */ + // FIXME: LDAP Server may not be set here... + $this->gotoKernelParameters= "root=/dev/nfs nfsroot=". + $this->gotoTerminalPath. + ",ro,hard,nolock,fg,rsize=8192 ". + "ip=::::::dhcp LDAP=".$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(); + + /* Add missing arrays */ + foreach (array("gotoFilesystem", "gotoAutoFs", "gotoModules") as $val){ + if (isset ($this->$val) && count ($this->$val) != 0){ + + $this->attrs["$val"]= array_unique($this->$val); + } + if(!isset($this->attrs["$val"])) $this->attrs["$val"]=array(); + } + + /* Strip out 'default' values */ + if ($this->attrs['gotoLdapServer'] == "default"){ + unset ($this->attrs['gotoLdapServer']); + } + + /* Write back to ldap */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->dn); + $ldap->modify($this->attrs); + show_ldap_error($ldap->get_error()); + $this->handle_post_events("modify"); + } + + /* Add value to array, check if unique */ + function add_list (&$array, $value) + { + if ($value != ""){ + $array[]= $value; + sort($array); + array_unique ($array); + } + } + + + /* Delete value to array, check if unique */ + function del_list (&$array, $list) + { + $tmp= array(); + foreach ($array as $mod){ + if (!in_array($mod, $list)){ + $tmp[]= $mod; + } + } + $array= $tmp; + } + + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/plugins/admin/systems/service.tpl b/plugins/admin/systems/terminalService.tpl similarity index 100% rename from plugins/admin/systems/service.tpl rename to plugins/admin/systems/terminalService.tpl diff --git a/plugins/admin/systems/workstationService.tpl b/plugins/admin/systems/workstationService.tpl new file mode 100644 index 000000000..d344c81eb --- /dev/null +++ b/plugins/admin/systems/workstationService.tpl @@ -0,0 +1,223 @@ + + + + + + + + + + + + +
+

{t}Keyboard{/t}

+ + + + + + + + + + + + + +
+ +
+ +
+ +
+ +
+   + +

{t}Mouse{/t}

+ + + + + + + + + +
+ +
+ +
+ +
+   + +

{t}Telephone hardware{/t}

+ + + + +
{t}Telephone{/t}  + {$hardware_list} +
+ +
+ + + + + + + + + + + + + +

+

{t}Graphic device{/t}

+ + + + + + + + + + + + + +
+ +
+ +
+ +
+
+   + +

{t}Display device{/t}

+ + + + + + + + + + + + + +
{t}Type{/t}{$gotoXMonitor}
kHz
Hz
+ +
+   + +

{t}Remote desktop{/t}

+ + + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ +
+ + + + + + + + + +

+

+ + {t}Provide print services{/t} +
+ + + + + + + +
+ +
+ +
+   + +

{t}Scan device{/t}

+ + {t}Provide scan services{/t} +
+ + + + + + +
+ +
+ +
+ +
diff --git a/plugins/admin/systems/workstationStartup.tpl b/plugins/admin/systems/workstationStartup.tpl new file mode 100644 index 000000000..12321d0c1 --- /dev/null +++ b/plugins/admin/systems/workstationStartup.tpl @@ -0,0 +1,106 @@ +

{t}Boot parameters{/t}

+ + + + + + + + +
+ + + + + + + + + + + + + + +
+ +
+ +
+   + + + {t}use graphical bootup{/t} +
+ + {t}use standard linux textual bootup{/t} +
+ + {t}use debug mode for startup{/t} +
+ + + + + + + + + +

+

+ {t}Kernel modules (format: name parameters){/t} +

+ +
+ +   + +
+

+ {t}Automount devices (format: complete autofs entry){/t} +

+ +
+ +   + +
+ + + + + + + +

+

+ {t}Additional fstab entries{/t} +

+ +
+ +   + +
+ + + -- 2.30.2