Code

Added a first set of reference changes - nearly untested
[gosa.git] / plugins / personal / environment / class_environment.inc
index 976ebd641aa8c64bda031b32d28851d1fb4a2f2f..36597d19b987b4efde492f321f83129c39f044f8 100644 (file)
@@ -17,6 +17,7 @@ class environment extends plugin
   var $uid                  = "";
 
   var $is_group             = false;
+  var $view_logged = FALSE;
   
   /* Attribute definition
    */
@@ -52,18 +53,21 @@ class environment extends plugin
   var $gotoKioskProfile   = "none";     // The selected Kiosk Profile
   var $gotoKioskProfiles  = array();// All available Kiosk profiles
   var $newKioskProfiles   = array();
+  var $kioskProfileList   = array(); // Displayed List of Profiles
 
   /* Hotplug Devices */
   var $gotoHotplugDevice  = array();     // Selected hotplug
   var $gotoHotplugDevices = array();// Already configured hotplug devices 
 
+  var $NewAddedPrinters   = array();
+  var $NewDeletedPrinters = array();
 
   /* general settings */
   // Sets the attributes which will kept on page reload, which will be saved, ...
 
   var $CopyPasteVars      = array("gotoHotplugDevices","newKioskProfiles","gotoAvailableShares","gotoShareSelections","gotoPrinterSel","gotoProfileFlagL","gotoXResolutions","gotoProfileFlagC","gotoProfileServers","useProfile","is_group","in_dialog","OrigCn");
 
-  var $attributes         = array("uid","gotoProfileServer","gotoProfileFlags",
+  var $attributes         = array("uid","gotoProfileServer","gotoProfileFlags","gotoHotplugDevice",
       "gotoXResolution","gotoProfileQuota",
       "gotoLogonScripts","gotoLogonScript",
       "gotoPrinter", "gosaDefaultPrinter",
@@ -73,11 +77,17 @@ class environment extends plugin
   var $objectclasses      = array("gotoEnvironment"); // Specifies the objectClass which contains the attributes edited here 
   var $cn;
   var $OrigCn;
+  var $add_del_printer_member_was_called = false;
 
-  function environment ($config, $dn= NULL)
+  function environment (&$config, $dn= NULL)
   {
     plugin::plugin ($config, $dn);
 
+    /* Setting uid to default */
+    if(isset($this->attrs['uid'][0])){
+      $this->uid = $this->attrs['uid'][0];
+    }
+
     /* Check : Are we currently editing a group or user dialog */
     if((isset($this->attrs['cn'][0]))&&(!isset($this->attrs['uid'][0]))){
       $suffix="Group";
@@ -196,11 +206,6 @@ class environment extends plugin
       $this->useProfile = false;
     }
 
-    /* Set to group environment if we editing a group */
-    if(!isset($this->parent)){
-      $this->is_group = true;
-    }
-
     /* Set resolutions */
     $this->gotoXResolutions = array("auto"=>_("auto"),
                                     "640x480"   =>  "640x480",
@@ -228,24 +233,75 @@ class environment extends plugin
       }
     }
 
-
     $this->gotoProfileServers= $config->getShareServerList() ;
     $this->gotoShareSelections= $config->getShareList(true);
     $this->gotoAvailableShares= $config->getShareList(false);  
 
+    $tmp = new kioskManagementDialog($this->config,$this->dn);
+    $list = $tmp->getKioskProfiles($this->newKioskProfiles);
+    $list['none']=_("None");
+    $this->kioskProfileList = array_reverse($list);
+  }
+
+
+  /* Detect type of edited object (user|group)*/
+  function detect_grouptype()
+  {
+    if((!isset($this->parent))&&(!$this->is_account)){
+      $this->is_group     = false;
+    }elseif((isset($this->parent))&&(!isset($this->parent->by_object['posixAccount']))){
+      $this->is_group     = true;
+    }else{
+      $this->is_group     = false;
+    }
   }
 
+
   function execute()
   {
     /* Call parent execute */
     plugin::execute();
+    /* Log view */
+    if($this->is_account && !$this->view_logged){
+      $this->view_logged = TRUE;
+      if(in_array("gosaAccount",$this->attrs['objectClass'])){
+        new log("view","users/".get_class($this),$this->dn);
+      }else{
+        new log("view","groups/".get_class($this),$this->dn);
+      }
+    }
+
+    /* Are we editing from MyAccount and not editing a user */
+    $WriteOnly = (!isset($this->parent)|| !$this->parent) && !isset($_SESSION['edit']);
+
+    /* 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 */
+          $new = key($this->gotoProfileServers);
+
+          /* Another profile server found */
+          print_red(sprintf(_("Your selected profile server '%s' is no longer available. Setting profile server to '%s'."),
+                $this->gotoProfileServer,$new));
+        }else{
+
+          /* No other profile servers found */
+          print_red(sprintf(_("Your selected profile server '%s' is no longer available. Profile server configuration is resetted."),
+                $this->gotoProfileServer));
+          $this->gotoProfileServer = "";
+        }
+      }
+    }    
+
+    $this->detect_grouptype();
 
     /* Fill templating stuff */
     $smarty= get_smarty();
     $display= "";
 
-    /* Are we editing from MyAccount and not editing a user */
-    $WriteOnly = (!isset($this->parent)|| !$this->parent) && !isset($_SESSION['edit']);
+    $smarty->assign("is_group",$this->is_group);
 
     /* Prepare all variables for smarty */
     foreach($this->attributes as $s_attr){
@@ -289,7 +345,6 @@ class environment extends plugin
        */
     }elseif((isset($this->parent))&&(!isset($this->parent->by_object['posixAccount']))){
       $smarty->assign("is_account","true");
-      $this->is_group     = true;
       $this->uid          = $this->cn;
       $this->attrs['uid'] = $this->cn;
 
@@ -328,8 +383,6 @@ class environment extends plugin
        */
       $smarty->assign("is_account","true");
 
-      $this->is_group = false;
-
       /* Change state if needed */
       if (isset($_POST['modify_state'])){
         if(($this->acl_is_createable() && !$this->is_account) || 
@@ -398,8 +451,8 @@ class environment extends plugin
     }else{
       $smarty->assign("useProfileCHK"," checked ");
     }
-
-
+    
+    $smarty->assign("gotoProfileServerWriteable", $this->acl_is_writeable("gotoProfileServer",$WriteOnly));
     $smarty->assign("gotoProfileACL", $this->getacl("gotoProfileServer",$WriteOnly).$this->getacl("gotoProfileQuota",$WriteOnly));
 
     /* HANDLE Profile Settings here 
@@ -455,12 +508,8 @@ class environment extends plugin
       $this->dialog->acl = $this->acl;
       $this->is_dialog = true;
     }
-    $tmp = new kioskManagementDialog($this->config,$this->dn);
-    $list = $tmp->getKioskProfiles($this->newKioskProfiles);
-    $list['none']=_("None");
-    $list = array_reverse($list);
-    $smarty->assign("gotoKioskProfiles",$list);
-    $smarty->assign("gotoKioskProfileKeys",array_flip($list));
+    $smarty->assign("gotoKioskProfiles",$this->kioskProfileList);
+    $smarty->assign("gotoKioskProfileKeys",array_flip($this->kioskProfileList));
 
     /* Logonscript Management
      * Get available LogonScripts (possibly grey out (or mark) these script that are defined for the group) 
@@ -551,6 +600,8 @@ class environment extends plugin
       /* We assign a share to this user, if we don't know where to mount the share */
       if((!isset($_POST['gotoShareMountPoint']))||(empty($_POST['gotoShareMountPoint']))||(preg_match("/[\|]/i",$_POST['gotoShareMountPoint']))){
         print_red(_("You must specify a valid mount point."));
+      }elseif(preg_match('/ /', $_POST['gotoShareMountPoint'])){
+        print_red(_("Spaces are not allowed in the mount path!"));
       }elseif(!(
             preg_match("/^\//",$_POST['gotoShareMountPoint'])  ||
             preg_match("/^~/",$_POST['gotoShareMountPoint']) ||
@@ -610,8 +661,14 @@ class environment extends plugin
     }
     $divlistShares = new divSelectBox("gotoShares");
     $divlistShares->SetHeight(100);
-    $tmp = $this->printOutAssignedShares();
 
+
+    $tmp = array();
+    if($this->acl_is_readable("gotoShares")){
+      $tmp = $this->printOutAssignedShares();
+    }
+
+    
     foreach($tmp as $key => $value){
       $img = "";
 
@@ -659,9 +716,9 @@ class environment extends plugin
     }
 
     /* We have to delete the selected hotplug from the list*/
-    if((isset($_POST['gotoHotplugDeviceDel']))&&(isset($_POST['gotoHotplugDevice'])) && $this->acl_is_writeable("gotoHotplugDevice")){
+    if((isset($_POST['gotoHotplugDeviceDel']))&&(isset($_POST['gotoHotplugDevice_post'])) && $this->acl_is_writeable("gotoHotplugDevice")){
       if($this->acl_is_writeable("gotoHotplugDevice")){
-        foreach($_POST['gotoHotplugDevice'] as $name){
+        foreach($_POST['gotoHotplugDevice_post'] as $name){
           unset($this->gotoHotplugDevices[$name]);
         }
       }
@@ -741,10 +798,35 @@ class environment extends plugin
         $tmp2= $this->dialog->getPrinter(true);
 
         foreach($tmp as $pname){
-        $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$tmp2[$pname]['dn']);
-          if($printerObj->by_object['printgeneric']->AddMember("AddUser",$this->dn)){
+          $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$tmp2[$pname]['dn'],"printer");
+          $printerObj->set_acl_base($tmp2[$pname]['dn']);
+
+          $type = false;
+
+          if($this->is_group){
+
+            if(isset($this->NewDeletedPrinters[$pname])){
+              $type = "AddGroup";
+            }elseif($printerObj->by_object['printgeneric']->AddMember("AddGroup",$this->dn)){
+              $type = "AddGroup";
+            }
+          }else{
+            if(isset($this->NewDeletedPrinters[$pname])){
+              $type = "AddUser";
+            }elseif($printerObj->by_object['printgeneric']->AddMember("AddUser",$this->dn)){
+              $type = "AddUser";
+            }
+          }
+
+          if($type){
             $this->gotoPrinter[$pname]=$tmp2[$pname];
             $this->gotoPrinter[$pname]['mode']="user";
+            $this->add_del_printer_member_was_called = true;
+
+            $this->NewAddedPrinters[$pname] = $pname;
+            if(isset($this->NewDeletedPrinters[$pname])){
+              unset($this->NewDeletedPrinters[$pname]);
+            }
           }
         }
 
@@ -758,18 +840,38 @@ class environment extends plugin
       $printer = $_POST['gotoPrinterSel'];
       foreach($printer as $pname){
 
-        $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$this->gotoPrinter[$pname]['dn']);
-        if($printerObj->by_object['printgeneric']->DelMember("AddUser",$this->dn)){
+        $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$this->gotoPrinter[$pname]['dn'],"printer");
+        $printerObj->set_acl_base($this->gotoPrinter[$pname]['dn']);
+
+        $type = false;
+        if($this->is_group){
+          if(isset($this->NewAddedPrinters[$pname])){
+            $type = "Group";
+          }elseif($printerObj->by_object['printgeneric']->DelMember("AddGroup",$this->cn)){
+            $type = "Group";
+          }
+        }else{
+          if(isset($this->NewAddedPrinters[$pname])){
+            $type = "User";
+          }elseif($printerObj->by_object['printgeneric']->DelMember("AddUser",$this->uid)){
+            $type = "User";
+          }
+        }
+        if($type){
+          $this->add_del_printer_member_was_called = true;
           unset($this->gotoPrinter[$pname]);
+
+          $this->NewDeletedPrinters[$pname] = $pname;
+          if(isset($this->NewAddedPrinters[$pname])){
+            UNSET($this->NewAddedPrinters[$pname]);
+          }
         }
       }
     }
 
     if((isset($_POST['gotoPrinterEdit']))&&(isset($_POST['gotoPrinterSel']))&&(!empty($_POST['gotoPrinterSel']))){
-
-
       $printers = $_POST['gotoPrinterSel'];
-
+      $this->add_del_printer_member_was_called = true;
       foreach($printers as $printer){
         if($this->gotoPrinter[$printer]['mode']=="user"){
           $this->gotoPrinter[$printer]['mode']="admin";
@@ -780,10 +882,14 @@ class environment extends plugin
     }
 
     if((isset($_POST['gotoPrinterDefault']))&&(isset($_POST['gotoPrinterSel']))&&(!empty($_POST['gotoPrinterSel']))){
-      if ($this->gosaDefaultPrinter == $_POST['gotoPrinterSel'][0]){
-        $this->gosaDefaultPrinter= "";
-      } else {
-        $this->gosaDefaultPrinter= $_POST['gotoPrinterSel'][0];
+      if($this->is_group){
+        print_red(_("GOsa default printer flag is not allowed within groups."));
+      }else{
+        if ($this->gosaDefaultPrinter == $_POST['gotoPrinterSel'][0]){
+          $this->gosaDefaultPrinter= "";
+        } else {
+          $this->gosaDefaultPrinter= $_POST['gotoPrinterSel'][0];
+        }
       }
     }
 
@@ -791,7 +897,6 @@ class environment extends plugin
     $smarty->assign("gotoPrinterKeys",array_flip($this->printOutPrinterDevices()));
 
     /* General behavior */
-    if($this->acl_is_writeable("gotoKioskProfile")){
     if((isset($this->dialog))&&($this->dialog!=NULL)&&(!empty($this->dialog))){
       $this->dialog->save_object();
       $disp =$this->dialog->execute();
@@ -805,7 +910,6 @@ class environment extends plugin
         $this->gotoKioskProfile = 'none';
       }
       return($disp);
-      }
     }
 
     /* Als smarty vars are set. Get smarty template and generate output */
@@ -840,10 +944,16 @@ class environment extends plugin
     $this->cleanup();
     $ldap->modify ($this->attrs); 
 
+    if($this->is_group){
+      new log("remove","groups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+    }else{
+      new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+    }
+
     show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/environment account with dn '%s' failed."),$this->dn));
 
     /* Optionally execute a command after we're done */
-    $this->handle_post_events("remove");
+    $this->handle_post_events("remove",array("uid" => $this->uid));
   }
 
 
@@ -853,35 +963,49 @@ class environment extends plugin
     /* Get all Posted vars 
      * Setup checkboxes 
      */
-
+    $WriteOnly = (!isset($this->parent)|| !$this->parent) && !isset($_SESSION['edit']);
     if(isset($_POST['iamposted'])){
-      if(isset($_POST['useProfile'])){
-        $this->useProfile = true;
-      }else{
-        $this->useProfile = false;
+
+      $PACL =  $this->getacl("gotoProfileServer",$WriteOnly).$this->getacl("gotoProfileQuota",$WriteOnly);
+
+      if(preg_match("/w/",$PACL)){
+        if(isset($_POST['useProfile'])){
+          $this->useProfile = true;
+        }else{
+          $this->useProfile = false;
+        }
       }
-      if(isset($_POST['gotoProfileFlagC'])){
-        $this->gotoProfileFlagC = $_POST['gotoProfileFlagC'];
-      }else{
-        $this->gotoProfileFlagC = false;
+
+      if($this->acl_is_writeable("gotoProfileFlagC")){
+        if(isset($_POST['gotoProfileFlagC'])){
+          $this->gotoProfileFlagC = $_POST['gotoProfileFlagC'];
+        }else{
+          $this->gotoProfileFlagC = false;
+        }
       }
-      if(isset($_POST['gotoProfileFlagL'])){
-        $this->gotoProfileFlagL = $_POST['gotoProfileFlagL'];
-      }else{
-        $this->gotoProfileFlagL = false;
+
+      if($this->acl_is_writeable("gotoProfileFlagL")){
+        if(isset($_POST['gotoProfileFlagL'])){
+          $this->gotoProfileFlagL = $_POST['gotoProfileFlagL'];
+        }else{
+          $this->gotoProfileFlagL = false;
+        }
       }
 
-      $tmp= $this->gosaDefaultPrinter;
       plugin::save_object();
       foreach($this->attributes as $s_attr){
-        if(in_array($s_attr,array("gotoShares","gotoHotplugDevices","gotoPrinter","gotoLogonScripts","uid"))) continue;
-        if(isset($_POST[$s_attr])){
-          $this->$s_attr = $_POST[$s_attr];
-        }else{
-          $this->$s_attr = false;
+        if((!isset($_POST[$s_attr])) || 
+            in_array($s_attr,array("gosaDefaultPrinter","gotoShares","gotoHotplugDevices","gotoPrinter","gotoLogonScripts","uid"))) continue;
+        if(!$this->acl_is_writeable($s_attr)){
+          continue;
+        }else{ 
+          if(isset($_POST[$s_attr])){
+            $this->$s_attr = $_POST[$s_attr];
+          }else{
+            $this->$s_attr = false;
+          }
         }
       }
-      $this->gosaDefaultPrinter= $tmp;
     }
   }
 
@@ -892,6 +1016,8 @@ class environment extends plugin
     /* Call common method to give check the hook */
     $message= plugin::check();
 
+    $this->detect_grouptype();
+
     if(preg_match("/[^0-9]/",$this->gotoProfileQuota)) {
       $message[]=_("Please set a valid profile quota size.");
     } 
@@ -961,55 +1087,69 @@ class environment extends plugin
      * 2.1 There are different types of members: Users / Groups, this will be defined in $suffix
      * 2.2 And each type has two modes, Admin (e.g. 'gotoUserAdminPrinter') and Normal 
      */
-    $types = array( "gotoUserPrinter"       => "AddUser",
-        "gotoGroupPrinter"      => "AddGroup",
-        "gotoUserAdminPrinter"  => "AddAdminUser",
-        "gotoGroupAdminPrinter" => "AddAdminGroup");
+    
+    $this->detect_grouptype();
 
-    if($this->is_group){
-      $s_suffix = "Group";
-      $useVar   = "cn";
-    }else{
-      $useVar   = "uid";
-      $s_suffix = "User";
-    }
+    if($this->add_del_printer_member_was_called){
 
-    /* Remove old entries */
-    $ldap->search("(&(objectClass=gotoPrinter)(goto".$s_suffix."Printer=".$this->uid."))",array("*"));
-    while($attr = $ldap->fetch()){
-      $printerObj = NULL;
-      $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$attr['dn']);
-      $printerObj->by_object['printgeneric']->DelMember($types["goto".$s_suffix."Printer"],$this->uid);
-      $printerObj->by_object['printgeneric']->save();
-    }
+      $types = array( "gotoUserPrinter"       => "AddUser",
+          "gotoGroupPrinter"      => "AddGroup",
+          "gotoUserAdminPrinter"  => "AddAdminUser",
+          "gotoGroupAdminPrinter" => "AddAdminGroup");
 
-    $ldap->search("(&(objectClass=gotoPrinter)(goto".$s_suffix."AdminPrinter=".$this->uid."))",array("*"));
-    while($attr = $ldap->fetch()){
-      $printerObj = NULL;
-      $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$attr['dn']);
-      $printerObj->by_object['printgeneric']->DelMember($types["goto".$s_suffix."AdminPrinter"],$this->uid);
-      $printerObj->by_object['printgeneric']->save();
-    }
+      if($this->is_group){
+        $s_suffix = "Group";
+        $useVar   = "cn";
+      }else{
+        $useVar   = "uid";
+        $s_suffix = "User";
+      }
 
-    foreach($this->gotoPrinter as $printer){
-      $printerObj = NULL;
-      $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$printer['dn']);
+      /* Remove old entries */
+      $ldap->search("(&(objectClass=gotoPrinter)(goto".$s_suffix."Printer=".$this->$useVar."))",array("*"));
+      while($attr = $ldap->fetch()){
+        $printerObj = NULL;
+        $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$attr['dn'],"printer");
+        $printerObj->set_acl_base($attr['dn']);
+        $printerObj->by_object['printgeneric']->DelMember($types["goto".$s_suffix."Printer"],$this->$useVar);
+        $printerObj->by_object['printgeneric']->save();
+      }
 
-      if($printer['mode'] == "admin") {
-        $attribute = "goto".$s_suffix."AdminPrinter";
-      }else{
-        $attribute = "goto".$s_suffix."Printer";
+      $ldap->search("(&(objectClass=gotoPrinter)(goto".$s_suffix."AdminPrinter=".$this->$useVar."))",array("*"));
+      while($attr = $ldap->fetch()){
+        $printerObj = NULL;
+        $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$attr['dn'],"printer");
+        $printerObj->set_acl_base($attr['dn']);
+        $printerObj->by_object['printgeneric']->DelMember($types["goto".$s_suffix."AdminPrinter"],$this->$useVar);
+        $printerObj->by_object['printgeneric']->save();
       }
 
-      $printerObj->by_object['printgeneric']->AddMember($types[$attribute],$this->dn);
-      $printerObj->by_object['printgeneric']->save();
-    }
+      foreach($this->gotoPrinter as $printer){
+        $printerObj = NULL;
+        $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$printer['dn'],"printer");
+        $printerObj->set_acl_base($printer['dn']);
+
+
+        if($printer['mode'] == "admin") {
+          $attribute = "goto".$s_suffix."AdminPrinter";
+        }else{
+          $attribute = "goto".$s_suffix."Printer";
+        }
+
+        $printerObj->by_object['printgeneric']->AddMember($types[$attribute],$this->dn);
+        $printerObj->by_object['printgeneric']->save();
+      }
+    }    
 
     /* Prepare HotPlug devices */
     $this->attrs['gotoHotplugDevice'] = array();
     foreach($this->gotoHotplugDevices as $name => $device){
-      $this->attrs['gotoHotplugDevice'][] = $device['name']."|".$device['description']."|".$device['id'].
-        "|".$device['produkt']."|".$device['vendor'];
+
+      $tmp= $device['name']."|".$device['description']."|".$device['id'];
+      if (isset($device['produkt']) && isset($device['vendor'])){
+        $tmp.= "|".$device['produkt']."|".$device['vendor'];
+      }
+      $this->attrs['gotoHotplugDevice'][]= $tmp;
     }
 
     /* Prepare LogonScripts */
@@ -1026,7 +1166,7 @@ class environment extends plugin
     $this->attrs['gotoShare']=array();
     foreach($this->gotoShares as $name => $share){
       $mntp= $share['mountPoint'];
-      if (!preg_match('=^[a-z0-9+_/%-]+$=i', $mntp)){
+      if (!preg_match('=^[a-z0-9+\._/%-]+$=i', $mntp)){
         $mntp= base64_encode($mntp);
       }
       $this->attrs['gotoShare'][] =$share['server']."|".$share['name']."|".$mntp."|".$share['PwdHash']."|".$share['Username'];
@@ -1067,8 +1207,21 @@ class environment extends plugin
     $ldap->cd($this->dn);
     $this->cleanup();
     $ldap->$mode($this->attrs);
+
+    $cat = "users";
+    if($this->is_group){
+      $cat = "groups";
+    }
+
+    /* Log last action */ 
+    if($this->initially_was_account){
+      new log("modify",$cat."/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+    }else{
+      new log("create",$cat."/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+    }
+
     show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/environment account with dn '%s' failed."),$this->dn));
-    $this->handle_post_events($mode);
+    $this->handle_post_events($mode,array("uid"=>$this->uid));
   }
 
   /* Generate ListBox frindly output for the defined shares 
@@ -1110,21 +1263,35 @@ class environment extends plugin
   function printOutPrinterDevices()
   {
     $a_return = array();
-    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($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");
+          }
         }
       }
     }
     return($a_return);
   }
 
+
+  function saveCopyDialog()
+  {
+    if(isset($_POST['cn'])){
+      $this->cn = $_POST['cn'];
+      $this->uid = $_POST['cn'];
+    }
+  }
+
+
   /* Generates ListBox frienly output of used logonscripts 
    */
   function printOutLogonScripts()
@@ -1147,9 +1314,10 @@ class environment extends plugin
           "plDescription"   => _("Environment settings"),         // Description
           "plSelfModify"    => TRUE,                              
           "plDepends"       => array("user", "posixAccount"),     // This plugin depends on 
-          "plPriority"      => 2,                                 // Position in tabs 
-          "plSection"       => "personal",                        // This belongs to personal
-          "plCategory"      => array("users", "groups"),          // Add to following categories 
+          "plPriority"      => 3,                                 // Position in tabs 
+          "plSection"     => array("personal" => _("My account")),
+          "plCategory"    => array("users",
+                                   "groups"),
           "plOptions"       => array("resolution_hook" => array("type" => "string",
               "description" => _("Command to extend the list of possible screen resolutions"))),