X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=trunk%2Fgosa-plugins%2Fgoto%2Fadmin%2Fsystems%2Fgoto%2Fclass_workstationService.inc;h=305aefbbd8d21bd9db9b05bb64ec1c7fd7fa6835;hb=b22711d4d6001fed5939a6c5a7e9b5d3ddd87ed4;hp=11394020cb07940417786a3ab4acb400a7635757;hpb=022668acbab76da7ebcb7ffc0cd563a13c422ae4;p=gosa.git diff --git a/trunk/gosa-plugins/goto/admin/systems/goto/class_workstationService.inc b/trunk/gosa-plugins/goto/admin/systems/goto/class_workstationService.inc index 11394020c..305aefbbd 100644 --- a/trunk/gosa-plugins/goto/admin/systems/goto/class_workstationService.inc +++ b/trunk/gosa-plugins/goto/admin/systems/goto/class_workstationService.inc @@ -33,7 +33,8 @@ class workservice extends plugin var $MousePorts= array(); var $hardware_list= array(); var $used_hardware= array(); - + var $ogroup = FALSE; + var $member_of_ogroup = FALSE; /* attribute list for save action */ var $attributes= array("gotoXMonitor", "gotoXDriver", "gotoXResolution", "gotoXColordepth", @@ -48,6 +49,8 @@ class workservice extends plugin var $XKbLayouts =array(); var $XKbVariants =array(); + var $InheritXYSync = TRUE; + function workservice (&$config, $dn= NULL, $parent= NULL) { plugin::plugin ($config, $dn, $parent); @@ -185,49 +188,14 @@ class workservice extends plugin $this->gotoXVsync = preg_replace("/\+/","-",$this->gotoXVsync); } - /* Load hardware list */ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".LDAP::prepare4filter($this->dn)."))"); - if ($ldap->count() == 1){ - $map= array("gotoXResolution", "gotoXColordepth", "gotoXKbModel", "gotoXKbLayout", - "gotoXKbVariant", "gotoXMouseType", "gotoXMouseport", "gotoXDriver"); - $attrs= $ldap->fetch(); - - foreach ($map as $name){ - if (!isset($attrs[$name][0])){ - continue; - } - - switch ($name){ - case 'gotoXDriver': - $this->XDrivers = array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->XDrivers; - break; - case 'gotoXResolution': - $this->XResolutions= array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->XResolutions; - break; - case 'gotoXColordepth': - $this->XColordepths= array('default' => _("inherited").' ['.$attrs[$name][0].' '._('Bit').']') + $this->XColordepths; - break; - case 'gotoXKbModel': - $this->XKbModels= array('default' => _("inherited").' ['.$attrs[$name][0].']') + $this->XKbModels; - break; - case 'gotoXKbLayout': - $this->XKbLayouts= array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->XKbLayouts; - break; - case 'gotoXKbVariant': - $this->XKbVariants= array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->XKbVariants; - break; - case 'gotoXMouseType': - $this->MouseTypes= array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->MouseTypes; - break; - case 'gotoXMouseport': - $this->MousePorts= array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->MousePorts; - break; + if (isset($this->attrs['gotoXHsync']) && isset($this->attrs['gotoXVsync'])) { + if(!empty($this->attrs['gotoXHsync'][0]) && !empty($this->attrs['gotoXVsync'][0])) { + $this->InheritXYSync = FALSE; + } + } else { + if($this->dn == "new") { + $this->InheritXYSync = FALSE; } - - } - } /* Workaround to fill in inherited values if we've specified an objectclass */ @@ -241,7 +209,9 @@ class workservice extends plugin $this->XKbVariants= array('default' => _("inherited")); $this->MouseTypes= array('default' => _("inherited")); $this->MousePorts= array('default' => _("inherited")); + $this->member_of_ogroup = TRUE; } + } function execute() @@ -249,6 +219,15 @@ class workservice extends plugin /* Call parent execute */ plugin::execute(); + /* Load hardware list */ + $this->loadHardwareList(); + + if(preg_match("/\+/",$this->gotoXHsync)){ + $this->AutoSync = true; + $this->gotoXHsync = preg_replace("/\+/","-",$this->gotoXHsync); + $this->gotoXVsync = preg_replace("/\+/","-",$this->gotoXVsync); + } + if($this->is_account && !$this->view_logged){ $this->view_logged = TRUE; new log("view","workstation/".get_class($this),$this->dn); @@ -277,6 +256,8 @@ class workservice extends plugin $smarty->assign($name."ACL",$this->getacl($name)); } + $smarty->assign("member_of_ogroup", $this->member_of_ogroup); + /* Arrays */ foreach(array("XDrivers", "XResolutions", "XColordepths", "XKbModels", "XKbVariants", @@ -348,6 +329,14 @@ class workservice extends plugin $smarty->assign("AutoSyncCHK"," "); $smarty->assign("hiddenState",""); } + if($this->InheritXYSync && !isset($this->parent->by_object['ogroup'])) { + $smarty->assign("InheritXYSync", " checked "); + $smarty->assign("hiddenState", " disabled "); + $smarty->assign("AutoSynchiddenState", " disabled "); + } else { + $smarty->assign("InheritXYSync", ""); + $smarty->assign("AutoSynchiddenState", ""); + } /* Show main page */ return($smarty->fetch (get_template_path('workstationService.tpl',TRUE,dirname(__FILE__)))); @@ -355,6 +344,17 @@ class workservice extends plugin function remove_from_parent() { + /* Cancel if there's nothing to do here */ + if ((!$this->acl_is_removeable())){ + return; + } + + /* Remove and write to LDAP */ + plugin::remove_from_parent(); + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify($this->attrs); $this->handle_post_events("remove"); new log("remove","workstation/".get_class($this),$this->dn); } @@ -371,6 +371,13 @@ class workservice extends plugin $this->AutoSync = false; } } + if(isset($_POST['workservicePosted'])) { + if(isset($_POST['InheritXYSync'])) { + $this->InheritXYSync = TRUE; + }else { + $this->InheritXYSync = FALSE; + } + } } /* Check supplied data */ @@ -383,14 +390,18 @@ class workservice extends plugin if ($this->dn != "" && $this->cn != "default" && $this->cn != "wdefault"){ /* But only if no auto sync is enabled... */ - if (!$this->AutoSync){ + if (!$this->AutoSync && !$this->InheritXYSync){ + + + $vsync_empty = FALSE; + $hsync_empty = FALSE; /* Check vsync for correct usage */ $val= preg_replace ("/\s/", "", $this->gotoXVsync); if($this->acl_is_writeable("gotoXVsync")){ if(empty($val)){ - $message[]= msgPool::required(_("VSync")); + $vsync_empty = TRUE; }elseif (!preg_match ("/^\d+(\.\d+)?([-]\d+(\.\d+)?)?$/", $val)){ $message[]= msgPool::invalid(_("VSync")); } else{ @@ -407,7 +418,7 @@ class workservice extends plugin $val= preg_replace ("/\s/", "", $this->gotoXHsync); if($this->acl_is_writeable("gotoXHsync")){ if(empty($val)){ - $message[]= msgPool::required(_("HSync")); + $hsync_empty = TRUE; }elseif (!preg_match ("/^\d+(\.\d+)?([-]\d+(\.\d+)?)?$/", $val)){ $message[]= msgPool::invalid(_("HSync")); } else{ @@ -419,6 +430,27 @@ class workservice extends plugin } } } + + /* Decide weither show empty value errors, if this is not an object group it + * will always be shown... */ + $show_errors = TRUE; + if ($vsync_empty || $hsync_empty) { + + if (isset($this->attrs['gosaGroupObjects'])) { + /* ... but an object group can contain empty values if both values are empty */ + if ($vsync_empty != $hsync_empty) { + $show_errors = TRUE; + } else { + $show_errors = FALSE; + } + } + if ($show_errors && $vsync_empty) { + $message[]= msgPool::required(_("VSync")); + } + if ($show_errors && $hsync_empty) { + $message[] = msgPool::required(_("HSync")); + } + } } } @@ -447,7 +479,10 @@ class workservice extends plugin } } - if($this->AutoSync){ + if($this->InheritXYSync) { + $this->attrs['gotoXHsync'] = array(); + $this->attrs['gotoXVsync'] = array(); + } elseif ($this->AutoSync) { $this->attrs['gotoXHsync'] = "30+55"; $this->attrs['gotoXVsync'] = "50+70"; } @@ -472,6 +507,77 @@ class workservice extends plugin } + function loadHardwareList() + { + $ldap= $this->config->get_ldap_link(); + + if ($this->ogroup) { + $ldap->cat($this->ogroup); + } else { + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".LDAP::prepare4filter($this->dn)."))"); + } + if ($ldap->count() >= 1){ + $this->member_of_ogroup = TRUE; + $attrs= $ldap->fetch(); + $map= array("gotoXResolution", "gotoXColordepth", "gotoXKbModel", "gotoXKbLayout", + "gotoXKbVariant", "gotoXMouseType", "gotoXMouseport", "gotoXDriver", + "gotoXVsync", "gotoXHsync" + ); + + foreach ($map as $name){ + if (!isset($attrs[$name][0])){ + continue; + } + + switch ($name){ + case 'gotoXHsync': + if (empty($this->$name) && !empty($attrs[$name])) { + $this->$name = $attrs[$name][0]; + $this->InheritXYSync = TRUE; + } + break; + case 'gotoXVsync': + if (empty($this->$name) && !empty($attrs[$name])) { + $this->$name = $attrs[$name][0]; + $this->InheritXYSync = TRUE; + } + break; + case 'gotoXDriver': + $ogroup_driver = $attrs['gotoXDriver'][0]; + if (in_array($ogroup_driver, $this->XDrivers) && (empty($this->attrs['gotoXDriver']))) { + $this->XDrivers = array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->XDrivers; + } + break; + case 'gotoXResolution': + $this->XResolutions= array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->XResolutions; + break; + case 'gotoXColordepth': + $this->XColordepths= array('default' => _("inherited").' ['.$attrs[$name][0].' '._('Bit').']') + $this->XColordepths; + break; + case 'gotoXKbModel': + $this->XKbModels= array('default' => _("inherited").' ['.$attrs[$name][0].']') + $this->XKbModels; + break; + case 'gotoXKbLayout': + $this->XKbLayouts= array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->XKbLayouts; + break; + case 'gotoXKbVariant': + $this->XKbVariants= array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->XKbVariants; + break; + case 'gotoXMouseType': + $this->MouseTypes= array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->MouseTypes; + break; + case 'gotoXMouseport': + $this->MousePorts= array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->MousePorts; + break; + } + + } + + } + + + } function getListOfXDrivers() {