Code

Updated buttons
[gosa.git] / gosa-plugins / goto / personal / environment / class_environment.inc
index 072e40d7eea78907da56ac78bce6fe83bd7c5995..5e8448abca8cbb8b6b4cc739f1a62beba0bbb0e2 100644 (file)
@@ -15,7 +15,7 @@ class environment extends plugin
 
   var $is_group             = false;
   var $view_logged = FALSE;
- vn 
+
   /* Attribute definition
    */
 
@@ -147,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])){
@@ -171,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];
 
@@ -217,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)){
@@ -342,11 +342,8 @@ class environment extends plugin
       }
     }
 
-    /* Are we editing from MyAccount and not editing a user */
-    $WriteOnly = (!isset($this->parent)|| !$this->parent) && !session::is_set('edit');
-
     /* Check profile server */
-    if($this->acl_is_writeable("gotoProfileServer",$WriteOnly)){
+    if($this->acl_is_writeable("gotoProfileServer")){
 
       if(!empty($this->gotoProfileServer) && !isset($this->gotoProfileServers[$this->gotoProfileServer])){
 
@@ -389,7 +386,7 @@ class environment extends plugin
       }
 
       /* Prepare ACL settings*/
-      $smarty->assign($s_attr."ACL",$this->getacl($s_attr,$WriteOnly));
+      $smarty->assign($s_attr."ACL",$this->getacl($s_attr));
     }
 
     /* Is accout enabled | are we editing from usermenu or admin menu 
@@ -509,14 +506,14 @@ class environment extends plugin
       }
 
       /* Prepare ACL settings*/
-      $smarty->assign($s_attr."ACL",$this->getacl($s_attr,$WriteOnly));
+      $smarty->assign($s_attr."ACL",$this->getacl($s_attr));
     }
 
     foreach(array("gotoHotplugDevice","gotoProfileFlagC","gotoProfileFlagL") as $s_attr){
-      $smarty->assign($s_attr."ACL",$this->getacl($s_attr,$WriteOnly));
+      $smarty->assign($s_attr."ACL",$this->getacl($s_attr));
     }
 
-    if($WriteOnly) {
+    if($this->read_only) {
       $smarty->assign("gotoPrinterACL","r");
     }else{
       $smarty->assign("gotoPrinterACL","rw");
@@ -526,15 +523,15 @@ class environment extends plugin
     $smarty->assign("useProfile",$this->useProfile);
     if(empty($this->useProfile) && !$this->multiple_support_active){
       $smarty->assign("useProfileCHK","");
-      $smarty->assign("gotoProfileServerACL" , preg_replace("/w/","",$this->getacl("gotoProfileServer",$WriteOnly)));
-      $smarty->assign("gotoProfileQuotaACL" , preg_replace("/w/","",$this->getacl("gotoProfileQuota",$WriteOnly)));
-      $smarty->assign("gotoProfileFlagCACL" , preg_replace("/w/","",$this->getacl("gotoProfileFlagC",$WriteOnly)));
+      $smarty->assign("gotoProfileServerACL" , preg_replace("/w/","",$this->getacl("gotoProfileServer")));
+      $smarty->assign("gotoProfileQuotaACL" , preg_replace("/w/","",$this->getacl("gotoProfileQuota")));
+      $smarty->assign("gotoProfileFlagCACL" , preg_replace("/w/","",$this->getacl("gotoProfileFlagC")));
     }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));
+    $smarty->assign("gotoProfileServerWriteable", $this->acl_is_writeable("gotoProfileServer"));
+    $smarty->assign("gotoProfileACL", $this->getacl("gotoProfileServer").$this->getacl("gotoProfileQuota"));
 
     /* HANDLE Profile Settings here 
      * Assign available Quota and resolution settings
@@ -775,7 +772,8 @@ class environment extends plugin
 
         /* Create pwd reset images */
         if($this->gotoShares[$key]['PwdHash'] != ""){
-          $img.= "<input type='image' name='gotoShareResetPwd_".base64_encode($key)." 'src='images/list_reset_password.png' alt='"._("Reset password hash")."' 
+          $img.= "<input type='image' name='gotoShareResetPwd_".base64_encode($key)." 
+            'src='plugins/goto/images/list_reset_password.png' alt='"._("Reset password hash")."' 
             title='"._("Reset password hash")."'>";
         }
         $field1 = array("string" => "<font style=\"color:#C0C0C0\">".$value."</font>" , "attach" => "style='".$color."'");
@@ -784,7 +782,8 @@ class environment extends plugin
 
         /* Create pwd reset img && delete image */
         if($this->gotoShares[$key]['PwdHash'] != ""){
-          $img.= "<input type='image' name='gotoShareResetPwd_".base64_encode($key)." 'src='images/list_reset_password.png' alt='"._("Reset password hash")."' 
+          $img.= "<input type='image' name='gotoShareResetPwd_".base64_encode($key)." 
+            'src='plugins/goto/images/list_reset_password.png' alt='"._("Reset password hash")."' 
             title='"._("Reset password hash")."'>";
           $img.= "&nbsp;";
         }
@@ -819,41 +818,45 @@ class environment extends plugin
       foreach($this->gotoHotplugDevices as $plugs){
         $tmp[] = $plugs['name'];
       }
-      $this->dialog = new hotplugDialog($this->config,$tmp);
+      $this->dialog = new hotplugSelect($this->config, get_userinfo());
       $this->is_dialog = true;
     }
 
     /* Dialog Aborted */
-    if(isset($_POST['HotPlugCancel'])){
-      unset($this->dialog);
+    if(isset($_POST['hotplugSelect_cancel'])){
       $this->dialog= FALSE;
       $this->is_dialog = false;
     }
 
     /* Dialod saved */
-    if(isset($_POST['HotPlugSave'])){
-
-      $this->dialog->save_object();
-      if(count($this->dialog->check())!=0){
-        foreach($this->dialog->check() as $msg){
-          msg_dialog::display(_("Error"), $msg, ERROR_DIALOG);
-        }
-      }else{
-        $this->dialog->save_object();
-        $a_tmp = $this->dialog->save();
-
-        if(is_array($a_tmp)){
-          foreach($a_tmp as $name => $hotplug){
-            if($this->multiple_support_active){
-              $hotplug['UsedByAllUsers'] = TRUE;
-            }
-            $this->gotoHotplugDevices[$name]= $hotplug; 
-          }
+    if(isset($_POST['hotplugSelect_save'])){
+
+      $res = $this->dialog->save();
+      foreach($res as $hotplug){
+        $name = $hotplug['cn'][0];
+        $entry['dn'] = $hotplug['dn'];
+
+        /* Set class values */
+        $tmp = preg_split("/\|/",$hotplug['gotoHotplugDevice'][0]);
+        $entry['name']          = $hotplug['cn'][0];
+        $entry['description'] = $tmp[0];
+        $entry['id']       = $tmp[1];
+        $entry['produkt']      = $tmp[2];
+        $entry['vendor']     = $tmp[3];
+        if($this->multiple_support_active){
+          $entry['UsedByAllUsers'] = TRUE;
         }
-        unset($this->dialog);
-        $this->dialog= FALSE;
-        $this->is_dialog = false;
+        $this->gotoHotplugDevices[$name]= $entry; 
       }
+      $this->dialog= FALSE;
+      $this->is_dialog = false;
+    }
+
+    if($this->dialog instanceOf hotplugSelect){
+    
+      // Build up blocklist
+      session::set('filterBlacklist', array('cn' => array_keys($this->gotoHotplugDevices)));
+      return($this->dialog->execute());
     }
 
     if($this->multiple_support_active){
@@ -872,34 +875,27 @@ class environment extends plugin
 
     /* First handle Add Post. Open a dialog that allows us to select a printer or two */ 
     if(isset($_POST['gotoPrinterAdd'])){
-
+      $this->dialog = new printerSelect($this->config,get_userinfo());
       $this->is_dialog=true;
-      $this->dialog = new selectPrinterDialog($this->config,$this->dn,$this->gotoPrinter);
     }
 
-    if(isset($_POST['PrinterCancel'])){
+    if(isset($_POST['printerSelect_cancel']) && $this->dialog instanceOf printerSelect){
       $this->is_dialog=false;
-      unset($this->dialog);
       $this->dialog=FALSE;
     }
 
-    if(isset($_POST['PrinterSave'])){
-      if(count($this->dialog->check())!=0){
-        $tmp = $this->dialog->check();
-        foreach($tmp as $msg){
-          msg_dialog::display(_("Error"), $msg, ERROR_DIALOG);
-        } 
-      }else{
-        $this->dialog->save_object();
-        $tmp = $this->dialog->save();
-        $tmp2= $this->dialog->getPrinter(true);
+    if(isset($_POST['printerSelect_save'])  && $this->dialog instanceOf printerSelect){
+
+      $res = $this->dialog->save();
+        foreach($res as $printer){
 
-        foreach($tmp as $pname){
-          $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$tmp2[$pname]['dn'],"printer");
-          $printerObj->set_acl_base($tmp2[$pname]['dn']);
+          $pname = $printer['cn'][0];
+          $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'], $printer['dn'],"printer");
+          $printerObj->set_acl_base($printer['dn']);
 
           $type = false;
 
+          
           if($this->is_group){
             if($this->dn == "new"){  
               $type = "AddGroup";
@@ -919,7 +915,7 @@ class environment extends plugin
           }
 
           if($type){
-            $this->gotoPrinter[$pname]=$tmp2[$pname];
+            $this->gotoPrinter[$pname]=$printer;
             $this->gotoPrinter[$pname]['mode']="user";
             $this->add_del_printer_member_was_called = true;
 
@@ -933,9 +929,17 @@ class environment extends plugin
         $this->is_dialog=false;
         unset($this->dialog);
         $this->dialog   =FALSE;
-      }
     }
 
+    // Display printer selection dialog 
+    if($this->dialog instanceOf printerSelect){
+
+      // Build up blocklist
+      session::set('filterBlacklist',array('cn' => array_keys($this->gotoPrinter)));
+      return($this->dialog->execute());
+    }
+
+
     if((isset($_POST['gotoPrinterDel']))&&(isset($_POST['gotoPrinterSel']))&&(!empty($_POST['gotoPrinterSel']))){
       $printer = $_POST['gotoPrinterSel'];
       foreach($printer as $pname){
@@ -994,7 +998,6 @@ class environment extends plugin
     }
 
     $smarty->assign("gotoPrinter",$this->printOutPrinterDevices());
-    $smarty->assign("gotoPrinterKeys",array_flip($this->printOutPrinterDevices()));
 
     /* General behavior */
     if(is_object($this->dialog)){
@@ -1068,10 +1071,9 @@ class environment extends plugin
     /* Get all Posted vars 
      * Setup checkboxes 
      */
-    $WriteOnly = (!isset($this->parent)|| !$this->parent) && !session::is_set('edit');
     if(isset($_POST['iamposted'])){
 
-      $PACL =  $this->getacl("gotoProfileServer",$WriteOnly).$this->getacl("gotoProfileQuota",$WriteOnly);
+      $PACL =  $this->getacl("gotoProfileServer").$this->getacl("gotoProfileQuota");
 
       if(isset($_POST['kiosk_server'])){
         $tmp = $_POST['kiosk_server'];
@@ -1239,7 +1241,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 */
@@ -1358,7 +1360,7 @@ class environment extends plugin
 
     if(is_array($this->gotoPrinter)){
       foreach($this->gotoPrinter as $printer){
-        if($printer['mode'] == "admin"){
+        if($printer['mode'] == 'admin'){
           $a_return[$printer['cn'][0]]= $printer['cn'][0]." - "._("Administrator");
         }else{
           $a_return[$printer['cn'][0]]= $printer['cn'][0]; 
@@ -1368,6 +1370,7 @@ class environment extends plugin
         }
       }
     }
+               asort($a_return);
     return($a_return);
   }
 
@@ -1426,7 +1429,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];
 
@@ -1457,7 +1460,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];
 
@@ -1489,7 +1492,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])){
@@ -1514,7 +1517,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])){