X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-plugins%2Fgoto%2Fpersonal%2Fenvironment%2Fclass_environment.inc;h=b72ced3ce70b2584673ccef8f447eb45cba48c2d;hb=fd16381bbcb916810fe1c4899ff0fdd52f5e8dd3;hp=292fc578883deb1484b7d62f41432b5221e65bfa;hpb=fbf8e4356f625423e3ccfcb0c6520942726a44e1;p=gosa.git diff --git a/gosa-plugins/goto/personal/environment/class_environment.inc b/gosa-plugins/goto/personal/environment/class_environment.inc index 292fc5788..b72ced3ce 100644 --- a/gosa-plugins/goto/personal/environment/class_environment.inc +++ b/gosa-plugins/goto/personal/environment/class_environment.inc @@ -2,6 +2,8 @@ class environment extends plugin { + var $plIcon = "plugins/goto/images/plugin.png"; + /* attribute list for save action */ var $ignore_account = FALSE; var $plHeadline = "Environment"; @@ -13,7 +15,7 @@ class environment extends plugin var $is_group = false; var $view_logged = FALSE; - + /* Attribute definition */ @@ -145,7 +147,7 @@ class environment extends plugin unset($this->attrs['gotoLogonScript']['count']); foreach($this->attrs['gotoLogonScript'] as $device){ $tmp = $tmp2 = array(); - $tmp = split("\|",$device); + $tmp = explode("|",$device); $tmp2['LogonName'] = $tmp[0]; $tmp2['LogonPriority'] = $tmp[2]; if(preg_match("/O/i",$tmp[1])){ @@ -169,7 +171,7 @@ class environment extends plugin 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]; @@ -215,12 +217,12 @@ class environment extends plugin "1280x768" => "1280x768", "1280x1024" => "1280x1024"); - if(isset($this->config->data['MAIN']['RESOLUTION_HOOK'])){ - $file = $this->config->data['MAIN']['RESOLUTION_HOOK']; + if($this->config->get_cfg_value("resolutions") != ""){ + $file = $this->config->get_cfg_value("resolutions"); if(is_readable($file)){ $str = file_get_contents($file); - $lines = split("\n",$str); + $lines = preg_split("/\n/",$str); foreach($lines as $line){ $line = trim($line); if(!empty($line)){ @@ -236,13 +238,36 @@ class environment extends plugin $this->gotoProfileServers= $config->getShareServerList() ; $this->gotoShareSelections= $config->getShareList(true); $this->gotoAvailableShares= $config->getShareList(false); + + /* Ensure that a currently selected server will stay selected, even if the list of profile servers + is empty due to insufficient permissions. + */ + if(count($this->gotoProfileServers) && !empty($this->gotoProfileServer)){ + + /* The currently selected profile server is outdated/no longer available */ + if(!isset($this->gotoProfileServers[$this->gotoProfileServer])){ + }else{ + $c = $this->gotoProfileServers[$this->gotoProfileServer]; + if(!preg_match("/r/",$c['ACL'])){ + + /* We are not allowed to read to currently selected server. + But to ensure that the selection will be kept after saving the account, we + override the current ACL tag. + */ + $this->gotoProfileServers[$this->gotoProfileServer]['ACL'] .= "r"; + } + } + } $this->update_kiosk_profiles(); } function update_kiosk_profiles() { + $this->gotoKioskProfile_Server = preg_replace("/^.*:\/\/([^\/]*).*$/","\\1",$this->gotoKioskProfile); + $this->gotoKioskProfile_Profile= preg_replace("/^.*\//","",$this->gotoKioskProfile); + $tmp1 = array("none" => array(_("disabled"))); $tmp2 = array("none" => _("disabled")); $tmp3 = array(); @@ -250,15 +275,18 @@ class environment extends plugin $ldap->cd($this->config->current['BASE']); $ldap->search("(&(objectClass=goEnvironmentServer)(gotoKioskProfile=*)(cn=*))",array("cn","gotoKioskProfile")); $cnt = 0; + $ui = get_userinfo(); while($attrs = $ldap->fetch()){ + $acl = $ui->get_permissions($attrs['dn'],"server/goKioskService",""); for($i = 0 ; $i < $attrs['gotoKioskProfile']['count'] ; $i ++){ - $name = preg_replace("/^.*\//","",$attrs['gotoKioskProfile'][$i]); - $name = preg_replace("/^.*\//","",$attrs['gotoKioskProfile'][$i]); - $tmp1[$attrs['cn'][0]][] = $name; - $tmp3[$attrs['cn'][0]][$name] = $attrs['gotoKioskProfile'][$i]; + if(preg_match("/r/",$acl) || $this->gotoKioskProfile_Server == $attrs['cn'][0]){ + $name = preg_replace("/^.*\//","",$attrs['gotoKioskProfile'][$i]); + $tmp1[$attrs['cn'][0]][] = $name; + $tmp3[$attrs['cn'][0]][$name] = $attrs['gotoKioskProfile'][$i]; + $tmp2[$attrs['cn'][0]]= $attrs['cn'][0]; + $cnt ++; + } } - $tmp2[$attrs['cn'][0]]= $attrs['cn'][0]; - $cnt ++; } if($cnt && $this->config->search("environment","kioskpath",array('menu','tabs'))){ @@ -269,23 +297,19 @@ class environment extends plugin $this->gotoKioskProfiles['SERVERS'] = $tmp2; $this->gotoKioskProfiles['MAP'] = $tmp3; - $this->gotoKioskProfile_Server = preg_replace("/^.*:\/\/([^\/]*).*$/","\\1",$this->gotoKioskProfile); - $this->gotoKioskProfile_Profile= preg_replace("/^.*\//","",$this->gotoKioskProfile); - $error = false; - if(!in_array($this->gotoKioskProfile_Server, $this->gotoKioskProfiles['SERVERS'])){ - $this->gotoKioskProfile_Server = key($this->gotoKioskProfiles['SERVERS']); + if(!isset($this->gotoKioskProfiles['SERVERS'][$this->gotoKioskProfile_Server])){ $error = true; - } - - if(!in_array($this->gotoKioskProfile_Profile, $this->gotoKioskProfiles['BY_SERVER'][$this->gotoKioskProfile_Server])){ - $this->gotoKioskProfile_Profile = $this->gotoKioskProfiles['BY_SERVER'][$this->gotoKioskProfile_Server][0]; + }elseif(!in_array($this->gotoKioskProfile_Profile, $this->gotoKioskProfiles['BY_SERVER'][$this->gotoKioskProfile_Server])){ $error = true; } if($error && !empty($this->gotoKioskProfile)){ + msg_dialog::display(_("Warning"), sprintf(_("Kiosk profile '%s' located on server '%s' is not available anymore. Kiosk profile will be disabled!"), $this->gotoKioskProfile_Profile, $this->gotoKioskProfile_Server), WARNING_DIALOG); + $this->gotoKioskProfile_Server ="none"; + $this->gotoKioskProfile_Profile=""; + }elseif(empty($this->gotoKioskProfile)){ $this->gotoKioskProfile_Server ="none"; $this->gotoKioskProfile_Profile=""; - msg_dialog::display(_("Warning"), sprintf(_("Kiosk profile '%s' located on server '%s' is not available anymore. Kiosk profile will be disabled!"), $this->gotoKioskProfile_Profile, $this->gotoKioskProfile_Server), WARNING_DIALOG); } } @@ -323,7 +347,10 @@ class environment extends plugin /* Check profile server */ if($this->acl_is_writeable("gotoProfileServer",$WriteOnly)){ + if(!empty($this->gotoProfileServer) && !isset($this->gotoProfileServers[$this->gotoProfileServer])){ + + if(count($this->gotoProfileServers)){ /* Get First Profile */ @@ -536,7 +563,6 @@ class environment extends plugin if(!is_array($this->gotoProfileServers)){ $this->gotoProfileServers =array(); } - $smarty->assign("gotoProfileServerKeys",array_flip($this->gotoProfileServers)); /* Handle kiosk profiles*/ $smarty->assign("kiosk_servers" , $this->gotoKioskProfiles['SERVERS']); @@ -715,7 +741,7 @@ class environment extends plugin $tmp = array(); - if($this->acl_is_readable("gotoShares")){ + if($this->acl_is_readable("gotoShare")){ $tmp = $this->printOutAssignedShares(); } @@ -749,7 +775,8 @@ class environment extends plugin /* Create pwd reset images */ if($this->gotoShares[$key]['PwdHash'] != ""){ - $img.= ""; } $field1 = array("string" => "".$value."" , "attach" => "style='".$color."'"); @@ -758,7 +785,8 @@ class environment extends plugin /* Create pwd reset img && delete image */ if($this->gotoShares[$key]['PwdHash'] != ""){ - $img.= ""; $img.= " "; } @@ -968,7 +996,6 @@ class environment extends plugin } $smarty->assign("gotoPrinter",$this->printOutPrinterDevices()); - $smarty->assign("gotoPrinterKeys",array_flip($this->printOutPrinterDevices())); /* General behavior */ if(is_object($this->dialog)){ @@ -1173,6 +1200,7 @@ class environment extends plugin } /* Remove old entries */ + $ldap->cd($this->config->current['BASE']);; $ldap->search("(&(objectClass=gotoPrinter)(goto".$s_suffix."Printer=".$this->$useVar."))",array("*")); while($attr = $ldap->fetch()){ $printerObj = NULL; @@ -1182,6 +1210,7 @@ class environment extends plugin $printerObj->by_object['printgeneric']->save(); } + $ldap->cd($this->config->current['BASE']);; $ldap->search("(&(objectClass=gotoPrinter)(goto".$s_suffix."AdminPrinter=".$this->$useVar."))",array("*")); while($attr = $ldap->fetch()){ $printerObj = NULL; @@ -1211,7 +1240,7 @@ class environment extends plugin /* Prepare HotPlug devices */ $this->attrs['gotoHotplugDeviceDN'] = array(); foreach($this->gotoHotplugDevices as $name => $device){ - $this->attrs['gotoHotplugDeviceDN'][]= $device['dn']; + $this->attrs['gotoHotplugDeviceDN'][]= LDAP::fix($device['dn']); } /* Prepare LogonScripts */ @@ -1327,22 +1356,20 @@ class environment extends plugin function printOutPrinterDevices() { $a_return = array(); - - if($this->acl_is_readable("gotoPrinter")){ - if(is_array($this->gotoPrinter)){ - foreach($this->gotoPrinter as $printer){ - if($printer['mode'] == "admin"){ - $a_return[$printer['cn'][0]]= $printer['cn'][0]." - "._("Administrator"); - }else{ - $a_return[$printer['cn'][0]]= $printer['cn'][0]; - } - if ($printer['cn'][0] == $this->gosaDefaultPrinter){ - $a_return[$printer['cn'][0]].=" - "._("Default printer"); - } + if(is_array($this->gotoPrinter)){ + foreach($this->gotoPrinter as $printer){ + if($printer['mode'] == 'admin'){ + $a_return[$printer['cn'][0]]= $printer['cn'][0]." - "._("Administrator"); + }else{ + $a_return[$printer['cn'][0]]= $printer['cn'][0]; + } + if ($printer['cn'][0] == $this->gosaDefaultPrinter){ + $a_return[$printer['cn'][0]].=" - "._("Default printer"); } } } + asort($a_return); return($a_return); } @@ -1401,7 +1428,7 @@ class environment extends plugin unset($this->multi_attrs_all['gotoShare']['count']); foreach($this->multi_attrs_all['gotoShare'] as $share){ $tmp = $tmp2 = array(); - $tmp = split("\|",$share); + $tmp = explode("|",$share); $tmp2['server'] =$tmp[0]; $tmp2['name'] =$tmp[1]; @@ -1432,7 +1459,7 @@ class environment extends plugin unset($this->multi_attrs['gotoShare']['count']); foreach($this->multi_attrs['gotoShare'] as $share){ $tmp = $tmp2 = array(); - $tmp = split("\|",$share); + $tmp = explode("|",$share); $tmp2['server'] =$tmp[0]; $tmp2['name'] =$tmp[1]; @@ -1464,7 +1491,7 @@ class environment extends plugin unset($this->multi_attrs_all['gotoLogonScript']['count']); foreach($this->multi_attrs_all['gotoLogonScript'] as $device){ $tmp = $tmp2 = array(); - $tmp = split("\|",$device); + $tmp = explode("|",$device); $tmp2['LogonName'] = $tmp[0]; $tmp2['LogonPriority'] = $tmp[2]; if(preg_match("/O/i",$tmp[1])){ @@ -1489,7 +1516,7 @@ class environment extends plugin unset($this->multi_attrs['gotoLogonScript']['count']); foreach($this->multi_attrs['gotoLogonScript'] as $device){ $tmp = $tmp2 = array(); - $tmp = split("\|",$device); + $tmp = explode("|",$device); $tmp2['LogonName'] = $tmp[0]; $tmp2['LogonPriority'] = $tmp[2]; if(preg_match("/O/i",$tmp[1])){ @@ -1749,19 +1776,15 @@ class environment extends plugin "plProvidedAcls" => array( - "gotoProfileFlagL" => _("Resolution changeable during session") , - "gotoProfileFlagC" => _("Cache profile localy") , - - "gotoProfileQuota" => _("Profile quota") , "gotoProfileServer" => _("Profile server") , - - "gotoXResolution" => _("Resolution") , - "gotoKioskProfile" => _("Kiosk profile") , - - "gosaDefaultPrinter" => _("Default printer") , - "gotoLogonScript" => _("Logon script") , + "gotoProfileQuota" => _("Profile quota") , + "gotoProfileFlagC" => _("Cache profile localy") , + "gotoShare" => _("Shares"), "gotoHotplugDevice" => _("Hotplug devices"), - "gotoShare" => _("Shares")) + "gotoKioskProfile" => _("Kiosk profile") , + "gotoProfileFlagL" => _("Resolution changeable during session") , + "gotoXResolution" => _("Resolution") , + "gotoLogonScript" => _("Logon script")) )); } }