Code

Added environement images- Test
[gosa.git] / gosa-plugins / goto / personal / environment / class_environment.inc
index f3a1d06eaa3855b8e40133fd0b00638bceba3a4e..497db5f8d31c6bcfa2dcd4143426a5d5db64f626 100644 (file)
@@ -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";
@@ -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,9 +297,6 @@ 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(!isset($this->gotoKioskProfiles['SERVERS'][$this->gotoKioskProfile_Server])){
       $error = true;
@@ -322,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 */
@@ -535,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']);
@@ -714,7 +741,7 @@ class environment extends plugin
 
 
     $tmp = array();
-    if($this->acl_is_readable("gotoShares")){
+    if($this->acl_is_readable("gotoShare")){
       $tmp = $this->printOutAssignedShares();
     }
 
@@ -1328,19 +1355,16 @@ 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");
         }
       }
     }
@@ -1750,19 +1774,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"))
             ));
   }
 }