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 4e122d898bf859c892051095fa47f56c8ae8bc56..305aefbbd8d21bd9db9b05bb64ec1c7fd7fa6835 100644 (file)
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",
var $XKbLayouts =array();
var $XKbVariants =array();
+ var $InheritXYSync = TRUE;
+
function workservice (&$config, $dn= NULL, $parent= NULL)
{
plugin::plugin ($config, $dn, $parent);
$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':
- $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;
+ 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 */
$this->XKbVariants= array('default' => _("inherited"));
$this->MouseTypes= array('default' => _("inherited"));
$this->MousePorts= array('default' => _("inherited"));
+ $this->member_of_ogroup = TRUE;
}
+
}
function execute()
/* 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);
$smarty->assign($name."ACL",$this->getacl($name));
}
+ $smarty->assign("member_of_ogroup", $this->member_of_ogroup);
+
/* Arrays */
foreach(array("XDrivers", "XResolutions", "XColordepths",
"XKbModels", "XKbVariants",
$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__))));
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);
}
$this->AutoSync = false;
}
}
+ if(isset($_POST['workservicePosted'])) {
+ if(isset($_POST['InheritXYSync'])) {
+ $this->InheritXYSync = TRUE;
+ }else {
+ $this->InheritXYSync = FALSE;
+ }
+ }
}
/* Check supplied data */
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{
$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{
}
}
}
+
+ /* 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"));
+ }
+ }
}
}
}
}
- 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";
}
}
+ 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()
{