Code

Fixed saving of printer membership.
[gosa.git] / plugins / personal / environment / class_logonManagementDialog.inc
index 0587f834bb15c3284afd29f5a55076e9a0160a72..98ce41ff312a27e1e7454f321ab4c79e3ff2337b 100644 (file)
@@ -8,15 +8,17 @@ class logonManagementDialog extends plugin
 
   /* attribute list for save action */
   var $ignore_account       = TRUE;
-  var $attributes           = array("LogonName","LogonPriority","LogonLast","LogonOverload","LogonData");
+  var $attributes           = array("LogonName","LogonPriority","LogonLast","LogonOverload","LogonData","LogonDescription");
   var $objectclasses        = array("whatever");
   var $use_existing         = false;  
 
-  var $LogonName      ="";  // Name for the LogonScript
-  var $LogonPriority  ="";  // Priority defines the order in which the scripts will be processed 
-  var $LogonLast      ="";  // Is this script marked as the last, all following scripts will be skipped
-  var $LogonOverload  ="";  // If Overload is activated this script is overlaodable by a group script with same prio
-  var $LogonData      ="";  // The script itself
+  var $LogonName        ="";  // Name for the LogonScript
+  var $LogonPriority    ="";  // Priority defines the order in which the scripts will be processed 
+  var $LogonLast        ="";  // Is this script marked as the last, all following scripts will be skipped
+  var $LogonOverload    ="";  // If Overload is activated this script is overlaodable by a group script with same prio
+  var $LogonData        ="";  // The script itself
+  var $LogonDescription ="";
+    
   var $nameIsEditable = true;
 
   var $real_LogonName = "";
@@ -26,21 +28,30 @@ class logonManagementDialog extends plugin
     plugin::plugin ($config, $dn);
     
     if($data){
-      $this->LogonName      = $data['LogonName'];
-      $this->LogonPriority  = $data['LogonPriority'];
-      $this->LogonOverload  = $data['LogonOverload'];
-      $this->LogonLast      = $data['LogonLast'];
-      $this->LogonData      = $data['LogonData'];
-      $this->nameIsEditable = false;
-      $this->real_LogonName = $data['LogonName'];
+      $this->LogonName        = $data['LogonName'];
+      $this->LogonPriority    = $data['LogonPriority'];
+      $this->LogonOverload    = $data['LogonOverload'];
+      $this->LogonLast        = $data['LogonLast'];
+      $this->LogonData        = $data['LogonData'];
+      $this->LogonDescription = $data['LogonDescription'];
+      $this->nameIsEditable   = false;
+      $this->real_LogonName   = $data['LogonName'];
     }
   }
 
   function execute()
   {
+       /* Call parent execute */
+       plugin::execute();
+
     $smarty= get_smarty();
     $display= "";
 
+    if((isset($_POST['StartImport']))&&(isset($_FILES['importFile']))){
+      $this->LogonData = file_get_contents($_FILES['importFile']['tmp_name']);
+      @unlink($_FILES['importFile']['tmp_name']);
+    }
+
     foreach($this->attributes as $attr){
       $smarty->assign($attr,$this->$attr);
       if($this->$attr){
@@ -58,6 +69,7 @@ class logonManagementDialog extends plugin
     }else{
       $smarty->assign("LogonNameACL","");
     }
+  
 
     $display.= $smarty->fetch(get_template_path('logonManagement.tpl', TRUE,dirname(__FILE__)));
     return($display);
@@ -68,7 +80,7 @@ class logonManagementDialog extends plugin
     if(isset($_POST['dialogissubmitted'])){
       foreach($this->attributes as $attr){
         if(isset($_POST[$attr])){
-          $this->$attr= $_POST[$attr]
+          $this->$attr = stripslashes($_POST[$attr])
         }else{
           $this->$attr = false;
         }
@@ -76,6 +88,27 @@ class logonManagementDialog extends plugin
     }
   }
 
+  function check()
+  {
+    /* Call common method to give check the hook */
+    $message= plugin::check();
+  
+    if(preg_match("/[^a-z]/",$this->LogonName)){
+      $message[] = _("Specified name is invalid.");
+    } 
+
+    if(empty($this->LogonName)){
+      $message[] = _("Please specify a valid script name.");
+    }
+
+    if(preg_match("/[^a-z0-9,\.-;:_\(\)!\? ]/i",$this->LogonDescription)){
+      $message[] = _("Specified description contains invalid characters.");
+    }
+
+    return $message;
+  }
+
+
   function save()
   {
     $a_return= array();