Code

Reverted Last commits, I've accidentally replaced to much.
[gosa.git] / gosa-plugins / goto / personal / environment / class_environment.inc
index c279028186de9b6ee2e1c802995190f167ace5a4..237de00d999dc04883004984baf6ce0ed6ba3fde 100644 (file)
@@ -6,7 +6,7 @@ class environment extends plugin
 
   /* attribute list for save action */
   var $ignore_account       = FALSE;
-  var $plHeadline           = "Environment";
+  var $plHeadline           = "Desktop";
   var $plDescription        = "This does something";
   var $dialog               = false;    // Indicates that we are currently editing in an seperate dialog
   
@@ -64,11 +64,11 @@ class environment extends plugin
   /* general settings */
   // Sets the attributes which will kept on page reload, which will be saved, ...
 
-  var $CopyPasteVars      = array("gotoHotplugDevices","gotoAvailableShares","gotoShareSelections","gotoPrinterSel","gotoProfileFlagL","gotoXResolutions","gotoProfileFlagC","gotoProfileServers","useProfile","is_group","in_dialog","OrigCn","gotoKioskProfile_Server","gotoKioskProfile_Profile");
+  var $CopyPasteVars      = array("gotoHotplugDevices","gotoAvailableShares","gotoShareSelections","gotoPrinterSel","gotoProfileFlagL","gotoXResolutions","gotoProfileFlagC","gotoProfileServers","useProfile","is_group","in_dialog","OrigCn","gotoKioskProfile_Server","gotoKioskProfile_Profile", "gotoLogonScripts","gotoLogonScript","gotoShare","gotoShares");
 
   var $attributes         = array("uid","gotoProfileServer","gotoProfileFlags","gotoHotplugDeviceDN",
       "gotoXResolution","gotoProfileQuota",
-      "gotoLogonScript",
+      "gotoLogonScript","gotoLogonScripts","gotoHotplugDevices",
       "gotoPrinter", "gosaDefaultPrinter",
       "gotoShare",
       "gotoKioskProfile");
@@ -80,6 +80,8 @@ class environment extends plugin
   var $multiple_support =TRUE;
 
   var $use_gotoPrinter;
+  var $shareList = NULL;
+
 
   function environment (&$config, $dn= NULL)
   {
@@ -217,8 +219,8 @@ class environment extends plugin
                                     "1280x768"  =>  "1280x768",
                                     "1280x1024" =>  "1280x1024");
 
-    if($this->config->get_cfg_value("resolutions") != ""){
-      $file = $this->config->get_cfg_value("resolutions");
+    if($this->config->get_cfg_value("core","resolutions") != ""){
+      $file = $this->config->get_cfg_value("core","resolutions");
 
       if(is_readable($file)){
         $str = file_get_contents($file);
@@ -260,6 +262,16 @@ class environment extends plugin
       }
     }
     $this->update_kiosk_profiles();
+
+    // Prepare lists
+    $this->shareList = new sortableListing();
+    $this->shareList->setDeleteable(false);
+    $this->shareList->setEditable(false);
+    $this->shareList->setWidth("100%");
+    $this->shareList->setHeight("120px");
+    $this->shareList->setHeader(array(_("Server"),_("Share name"),_("Mount point"), 
+            _("User"), _("Type"), _("Action")));
+    $this->shareList->setDefaultSortColumn(1);
   }
 
 
@@ -289,7 +301,8 @@ class environment extends plugin
       }
     }
 
-    if($cnt && $this->config->search("environment","kioskpath",array('menu','tabs'))){
+    $tmp = $this->config->get_cfg_value("environment","kioskPath");
+    if($cnt && !empty($tmp)){
       $this->kiosk_enabled = TRUE;
     }
 
@@ -429,8 +442,8 @@ class environment extends plugin
       }
       /* Group Dialog with enabled environment options */
       if ($this->is_account){
-        $display= $this->show_enable_header(msgPool::removeFeaturesButton(_("Environment")),
-            msgPool::featuresEnabled(_("Environment")));
+        $display= $this->show_disable_header(msgPool::removeFeaturesButton(_("Desktop")),
+            msgPool::featuresEnabled(_("Desktop")));
       } else {
 
         /* Environment is disabled 
@@ -438,16 +451,16 @@ class environment extends plugin
            environment extensions
          */
         if((isset($this->parent->by_object['group']))||(isset($this->attrs['objectClass']))&&((in_array("posixAccount",$this->attrs['objectClass'])))){
-          $display= $this->show_enable_header(msgPool::addFeaturesButton(_("Environment")),
-              msgPool::featuresDisabled(_("Environment")));
+          $display= $this->show_enable_header(msgPool::addFeaturesButton(_("Desktop")),
+              msgPool::featuresDisabled(_("Desktop")));
           return $display;
         }elseif((isset($this->parent->by_object['ogroup']))){
-          $display= $this->show_enable_header(msgPool::addFeaturesButton(_("Environment")),
-              msgPool::featuresDisabled(_("Environment")));
+          $display= $this->show_enable_header(msgPool::addFeaturesButton(_("Desktop")),
+              msgPool::featuresDisabled(_("Desktop")));
           return $display;
         }else{
-          $display= $this->show_enable_header(msgPool::addFeaturesButton(_("Environment")),
-              msgPool::featuresDisabled(_("Environment"), _("POSIX")), TRUE);
+          $display= $this->show_enable_header(msgPool::addFeaturesButton(_("Desktop")),
+              msgPool::featuresDisabled(_("Desktop"), _("POSIX")), TRUE);
           return $display;
         }
       }
@@ -469,17 +482,17 @@ class environment extends plugin
 
         // 3. Account enabled . Editing from adminmenu
         if ($this->is_account){
-          $display= $this->show_enable_header(msgPool::removeFeaturesButton(_("Environment")),
-              msgPool::featuresEnabled(_("Environment")));
+          $display= $this->show_disable_header(msgPool::removeFeaturesButton(_("Desktop")),
+              msgPool::featuresEnabled(_("Desktop")));
         } else {
 
           if($this->parent->by_object['posixAccount']->is_account==true){
-            $display= $this->show_enable_header(msgPool::addFeaturesButton(_("Environment")),
-                msgPool::featuresDisabled(_("Environment")));
+            $display= $this->show_enable_header(msgPool::addFeaturesButton(_("Desktop")),
+                msgPool::featuresDisabled(_("Desktop")));
             return $display;
           }else{
-            $display= $this->show_enable_header(msgPool::addFeaturesButton(_("Environment")),
-                msgPool::featuresDisabled(_("Environment"), _("POSIX")), TRUE);
+            $display= $this->show_enable_header(msgPool::addFeaturesButton(_("Desktop")),
+                msgPool::featuresDisabled(_("Desktop"), _("POSIX")), TRUE);
             return $display;
           }
         }
@@ -735,30 +748,23 @@ class environment extends plugin
         }
       }
     }
-    $divlistShares = new divSelectBox("gotoShares");
-    $divlistShares->SetHeight(100);
-
-
-    $tmp = array();
-    if($this->acl_is_readable("gotoShare")){
-      $tmp = $this->printOutAssignedShares();
-    }
 
-    
-    foreach($tmp as $key => $value){
+    // Build up share list
+    $data = $lData = array(); 
+    foreach($this->gotoShares as $key => $entry){
       $img = "";
 
-      /* Skip apssword only entries */
-      if( empty($this->gotoShares[$key]['server']) && 
-          empty($this->gotoShares[$key]['name']) &&
-          empty($this->gotoShares[$key]['mountPoint']) &&
-          empty($this->gotoShares[$key]['Username'])){
+      // Skip password only entries
+      if( empty($entry['server']) && empty($entry['name']) &&
+          empty($entry['mountPoint']) && empty($entry['Username'])){
         continue;
       } 
 
+      // While editing mutlipe users at once we've to seperate 
+      //  entries used by all users and those used by only some.
       $color = "";
       if($this->multiple_support_active){
-        if($this->gotoShares[$key]['UsedByAllUsers']){
+        if($entry['UsedByAllUsers']){
           $value .= "&nbsp;(<b>"._("Used by all users")."</b>)";
         }else{
           $color = "color: #999999;";
@@ -766,38 +772,44 @@ class environment extends plugin
         }
       }
 
-      /* Check if entry starts with an ! */
+      // Create password reset image button 
+      if($entry['PwdHash'] != ""){
+          $img.= 
+              image('plugins/goto/images/list_reset_password.png',
+                      'gotoShareResetPwd_'.postEncode($key),
+                      _("Reset password hash"));
+      }
+
+      // Build up list entries - Handle entries starting with '!' here.
+      $data[$key]=$key;
       if(preg_match("/^!/",$this->gotoShares[$key]['server'])){
 
-        /* If we are currently editing groups environment, skip those ! entries */ 
+        // 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.= 
-            image('plugins/goto/images/list_reset_password.png',
-                'gotoShareResetPwd_'.postEncode($key),
-                _("Reset password hash"));
-        }
-        $field1 = array("string" => "<font style=\"color:#C0C0C0\">".$value."</font>" , "attach" => "style='".$color."'");
-        $field2 = array("string" => $img   , "attach" => "style='border-right:0px;'");
+        $lData[$key] = array('data' => array(
+                    $entry['server']."://",
+                    $entry['name'], 
+                    "",
+                    "",
+                    image("plugins/groups/images/select_group.png","",_("Group share")),
+                    $img));
       }else{
 
-        /* Create pwd reset img && delete image */
-        if($this->gotoShares[$key]['PwdHash'] != ""){
-          $img.= 
-            image('plugins/goto/images/list_reset_password.png',
-                'gotoShareResetPwd_'.postEncode($key),
-                _("Reset password hash"));
-          $img.= "&nbsp;";
-        }
         $img.= image('images/lists/trash.png',"gotoShareDel_".postEncode($key),msgPool::delButton());
-        $field1 = array("string" => $value , "attach" => "style='".$color."'");
-        $field2 = array("string" => $img   , "attach" => "style='border-right:0px;'");
+        $lData[$key] = array('data' => array(
+                    $entry['server']."://",
+                    $entry['name'], 
+                    $entry['mountPoint'], 
+                    $entry['Username'], 
+                    image("plugins/users/images/select_user.png","",_("User share")),
+                    $img));
       }
-      $divlistShares->AddEntry(array($field1,$field2));
     }
-    $smarty->assign("divlistShares",$divlistShares->DrawList());
+    $this->shareList->setListData($data,$lData);
+    $this->shareList->update();
+    $this->shareList->setAcl($this->getacl("gotoShare"));
+    $smarty->assign("shareList",$this->shareList->render());
 
     /* Hotplug devices will be handled here 
      * There are 3 possible methods for this feature
@@ -912,6 +924,8 @@ class environment extends plugin
               $type = "AddUser";
             }elseif(isset($this->NewDeletedPrinters[$pname])){
               $type = "AddUser";
+            }elseif($this->dn == "new"){  
+              $type = "AddUser";
             }elseif($printerObj->by_object['printgeneric']->AddMember("AddUser",$this->dn)){
               $type = "AddUser";
             }
@@ -1321,24 +1335,6 @@ class environment extends plugin
     $this->handle_post_events($mode,array("uid"=>$this->uid));
   }
 
-  /* Generate ListBox frindly output for the defined shares 
-   * Possibly Add or remove an attribute here, 
-   */
-  function printOutAssignedShares()
-  {
-    $a_return = array();
-    if(is_array($this->gotoShares)){
-      foreach($this->gotoShares as $share){
-        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'];
-        }
-      }
-      natcasesort($a_return);
-    }
-    return($a_return);
-  }
 
   /* Generate ListBox frindly output for the definedhotplugs 
    * Possibly Add or remove an attribute here,
@@ -1767,8 +1763,8 @@ class environment extends plugin
 #FIXME these ACLs should work for groups too */ 
   static function plInfo()
   {
-    return (array("plShortName"     => _("Environment"),
-          "plDescription"   => _("Environment settings"),         // Description
+    return (array("plShortName"     => _("Desktop"),
+          "plDescription"   => _("Desktop settings"),         // Description
           "plSelfModify"    => TRUE,                              
           "plDepends"       => array("user", "posixAccount"),     // This plugin depends on 
           "plPriority"      => 3,                                 // Position in tabs