Code

Updated enviroment.
[gosa.git] / gosa-plugins / goto / personal / environment / class_environment.inc
index b0b2a567eaf55831ada13bf72c1a9a2ee6127dc2..a19bb719f9654600ca2e5c2cbe60a92ee93a0ee2 100644 (file)
@@ -236,28 +236,55 @@ 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();
     $ldap = $this->config->get_ldap_link();
     $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/goShareServer","");
       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'))){
@@ -268,23 +295,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);
     }
   }
 
@@ -322,7 +345,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 */
@@ -414,6 +440,10 @@ class environment extends plugin
           $display= $this->show_enable_header(msgPool::addFeaturesButton(_("Environment")),
               msgPool::featuresDisabled(_("Environment")));
           return $display;
+        }elseif((isset($this->parent->by_object['ogroup']))){
+          $display= $this->show_enable_header(msgPool::addFeaturesButton(_("Environment")),
+              msgPool::featuresDisabled(_("Environment")));
+          return $display;
         }else{
           $display= $this->show_enable_header(msgPool::addFeaturesButton(_("Environment")),
               msgPool::featuresDisabled(_("Environment"), _("POSIX")), TRUE);
@@ -531,7 +561,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']);
@@ -757,7 +786,7 @@ class environment extends plugin
             title='"._("Reset password hash")."'>";
           $img.= "&nbsp;";
         }
-        $img.= "<input type='image' name='gotoShareDel_".base64_encode($key)." 'src='images/edittrash.png' alt='".msgPool::delButton()."' 
+        $img.= "<input type='image' name='gotoShareDel_".base64_encode($key)." 'src='images/lists/trash.png' alt='".msgPool::delButton()."' 
           title='"._("Delete share entry")."'>";
         $field1 = array("string" => $value , "attach" => "style='".$color."'");
         $field2 = array("string" => $img   , "attach" => "style='border-right:0px;'");
@@ -1113,7 +1142,7 @@ class environment extends plugin
     } 
     if(!$this->is_group){
       if((!((in_array("posixAccount",$this->attrs['objectClass']))||($this->parent->by_object['posixAccount']->is_account==true)))&&(!$this->is_group)){
-        $message[]= msgPool::featuresDisabled(_("environemnt"),_("POSIX"));  
+        $message[]= msgPool::featuresDisabled(_("environment"),_("POSIX"));  
       }
     }
     return ($message);
@@ -1168,6 +1197,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;
@@ -1177,6 +1207,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;