Code

Fixed problem in deletion/pw reset
[gosa.git] / plugins / personal / environment / class_environment.inc
index be9e18f04a991f990669166c41b71c211d2e471d..4132771b48a963cde6528fd5e8cafa49b5df3eaf 100644 (file)
@@ -68,8 +68,8 @@ class environment extends plugin
                                     "gotoLogonScripts","gotoLogonScript",
                                     "gotoPrinter", "gosaDefaultPrinter",
                                     "gotoShares","gotoShare",
-                                    "gotoKioskProfile","gotoKioskProfiles",
-                                    "gotoHotplugDevice");
+                                    "gotoKioskProfile","gotoKioskProfiles"
+                                    );
   var $objectclasses      = array("gotoEnvironment"); // Specifies the objectClass which contains the attributes edited here 
   var $cn;
   var $OrigCn;
@@ -151,9 +151,9 @@ class environment extends plugin
         $tmp2['name']        =$tmp[1];
         $tmp2['mountPoint']  =$tmp[2];
         if(isset($tmp[3])){
-          $tmp2['OtherStuff']  =$tmp[3];
+          $tmp2['PwdHash']  =$tmp[3];
         }else{
-          $tmp2['OtherStuff']  ="";
+          $tmp2['PwdHash']  ="";
         }
         if(isset($tmp[4])){
           $tmp2['Username']  =$tmp[4];
@@ -547,7 +547,7 @@ class environment extends plugin
         /* Preparing the new assignment */ 
         $this->gotoShares[$a_share['name']."|".$a_share['server']]=$a_share;
         $this->gotoShares[$a_share['name']."|".$a_share['server']]['Username']=$s_user;
-        $this->gotoShares[$a_share['name']."|".$a_share['server']]['OtherStuff']="";
+        $this->gotoShares[$a_share['name']."|".$a_share['server']]['PwdHash']="";
         $this->gotoShares[$a_share['name']."|".$a_share['server']]['mountPoint']=$s_mount;
       }
     }  
@@ -555,12 +555,62 @@ class environment extends plugin
     /* if the Post  gotoShareDel is set, someone asked GOsa to delete the selected entry (if there is one selected)
      * If there is no defined share selected, we will abort the deletion without any message 
      */
-    if((isset($_POST['gotoShareDel']))&&(isset($_POST['gotoShare']))){
-      unset($this->gotoShares[$_POST['gotoShare']]);
+    $once = true;
+    foreach($_POST as $name => $value){
+      if((preg_match("/^gotoShareDel_/",$name)) && ($once)){
+        $once = false;  
+        $key  = preg_replace("/^gotoShareDel_/","",$name);
+        $key  = preg_replace("/_+[xy]$/","",$key);
+        $key  = preg_replace("/_/", ".", $key);
+        if(isset($this->gotoShares[$key])) {
+          unset($this->gotoShares[$key]);
+        }
+      }
+      if((preg_match("/^gotoShareResetPwd_/",$name)) && ($once)){
+        $once = false;
+        $key  = preg_replace("/^gotoShareResetPwd_/","",$name);
+        $key  = preg_replace("/_+[xy]$/","",$key);
+        $key  = preg_replace("/_/", ".", $key);
+        $this->gotoShares[$key]['PwdHash'] = "";
+      }
     }
 
-    $smarty->assign("gotoShares",$this->printOutAssignedShares());
-    $smarty->assign("gotoShareKeys",array_flip($this->printOutAssignedShares()));
+    $divlistShares = new divSelectBox("gotoShares");
+    $divlistShares->SetHeight(100);
+    $tmp = $this->printOutAssignedShares();
+    
+    foreach($tmp as $key => $value){
+      $img = "";
+   
+      /* Check if entry starts with an ! */
+      if(preg_match("/^!/",$this->gotoShares[$key]['server'])){
+
+        /* If we are currently editing groups environment, skip those ! entries */ 
+        if($this->is_group) continue;
+    
+        /* Create pwd reset images */
+        if($this->gotoShares[$key]['PwdHash'] != ""){
+          $img.= "<input type='image' name='gotoShareResetPwd_".$key." 'src='images/list_reset_password.png' alt='"._("Reset password hash")."' 
+            title='"._("Reset password hash")."'>";
+        }
+        $field1 = array("string" => "<font style=\"color:#C0C0C0\">".$value."</font>" );
+        $field2 = array("string" => $img   , "attach" => "style='border-right:0px;'");
+      }else{
+
+        /* Create pwd reset img && delete image */
+        if($this->gotoShares[$key]['PwdHash'] != ""){
+          $img.= "<input type='image' name='gotoShareResetPwd_".$key." 'src='images/list_reset_password.png' alt='"._("Reset password hash")."' 
+            title='"._("Reset password hash")."'>";
+          $img.= "&nbsp;";
+        }
+        $img.= "<input type='image' name='gotoShareDel_".$key." 'src='images/edittrash.png' alt='"._("Delete")."' 
+          title='"._("Delete share entry")."'>";
+        $field1 = array("string" => $value);
+        $field2 = array("string" => $img   , "attach" => "style='border-right:0px;'");
+      }
+      $divlistShares->AddEntry(array($field1,$field2));
+    }
+    $smarty->assign("divlistShares",$divlistShares->DrawList());
 
     /* Hotplug devices will be handled here 
      * There are 3 possible methods for this feature
@@ -577,7 +627,9 @@ class environment extends plugin
 
     /* We have to delete the selected hotplug from the list*/
     if((isset($_POST['gotoHotplugDeviceDel']))&&(isset($_POST['gotoHotplugDevice']))){
-      unset($this->gotoHotplugDevices[$_POST['gotoHotplugDevice']]);
+      foreach($_POST['gotoHotplugDevice'] as $name){
+        unset($this->gotoHotplugDevices[$name]);
+      }
     }
 
     /* There are already defined hotplugs from other users we could use */
@@ -603,8 +655,11 @@ class environment extends plugin
       }else{
         $this->dialog->save_object();
         $a_tmp = $this->dialog->save();
+       
         if(is_array($a_tmp)){
-          $this->gotoHotplugDevices[$a_tmp['name']]= $a_tmp; 
+          foreach($a_tmp as $name => $hotplug){
+            $this->gotoHotplugDevices[$name]= $hotplug; 
+          }
         }
         unset($this->dialog);
         $this->dialog= NULL;
@@ -1035,7 +1090,7 @@ $ldap->modify ($attrs);
     /* Prepare Shares */
     $this->attrs['gotoShare']=array();
     foreach($this->gotoShares as $name => $share){
-      $this->attrs['gotoShare'][] =$share['server']."|".$share['name']."|".$share['mountPoint']."|".$share['OtherStuff']."|".$share['Username'];
+      $this->attrs['gotoShare'][] =$share['server']."|".$share['name']."|".$share['mountPoint']."|".$share['PwdHash']."|".$share['Username'];
     }
 
 
@@ -1093,7 +1148,9 @@ $ldap->modify ($attrs);
     $a_return = array();
     if(is_array($this->gotoShares)){
       foreach($this->gotoShares as $share){
-        if (!preg_match('/^!/', $share['server'])){
+        if(preg_match("/^!/",$share['server'])){
+          $a_return[$share['name']."|".$share['server']]= preg_replace("/^!/","",$share['server'])."://".$share['name']." - "._("group share"); 
+        }else{
           $a_return[$share['name']."|".$share['server']]= $share['server']."://".$share['name']." on ".$share['mountPoint']." as ".$share['Username'];
         }
       }