Code

Commented out "ip & port information" for phone configuretion in user list.
[gosa.git] / plugins / admin / systems / class_goVirusServer.inc
index 273fba3ce389a68849db32ba884592ca16bce716..6335956b77b66de5c1cf303d6658c38a8f3b28e2 100644 (file)
@@ -1,10 +1,10 @@
 <?php
 
-class goVirusServer extends plugin{
+class govirusserver extends plugin{
        
   /* This plugin only writes its objectClass */
   var $objectclasses    = array("goVirusServer");
-  var $attributes       = array("avMaxThreads","avMaxDirectoryRecursions",/*"avUser",*/"avFlags","avArchiveMaxFileSize","avArchiveMaxRecursion",
+  var $attributes       = array("avMaxThreads","avMaxDirectoryRecursions","avUser","avFlags","avArchiveMaxFileSize","avArchiveMaxRecursion",
                                 "avArchiveMaxCompressionRatio","avDatabaseMirror","avChecksPerDay","avHttpProxyURL");
   var $StatusFlag       = "avStatus";
  
@@ -14,7 +14,7 @@ class goVirusServer extends plugin{
   var $DisplayName      = "";
   var $dn               = NULL;
   var $cn               = "";
-  var $saStatus         = "";
+  var $avStatus         = "";
 
   var $dialog           = NULL;
   var $ui               = NULL;
@@ -22,11 +22,11 @@ class goVirusServer extends plugin{
 
   var $Flags            = array("D","S","A","E");
   
-  var $avFlags          = "DSAE";
+  var $avFlags          = "DS";
   var $avFlagsD         = TRUE;
   var $avFlagsS         = TRUE;
-  var $avFlagsA         = TRUE;
-  var $avFlagsE         = TRUE;
+  var $avFlagsA         = FALSE;
+  var $avFlagsE         = FALSE;
 
   var $avMaxThreads                 = 5;
   var $avMaxDirectoryRecursions     = 4;    
@@ -35,14 +35,14 @@ class goVirusServer extends plugin{
   var $avArchiveMaxCompressionRatio = 95;
   var $avChecksPerDay               = 12;
 
-//  var $avUser                       = "";
+  var $avUser                       = "";
   var $avHttpProxyURL               = "";
   var $avDatabaseMirror             = "";
 
-  function goVirusServer($config,$dn)
+  function govirusserver($config,$dn, $parent= NULL)
   {
     /* Init class */
-    plugin::plugin($config,$dn);
+    plugin::plugin($config,$dn, $parent);
     $this->DisplayName = _("Anti virus");
 
     /* Get userinfo & acls */
@@ -64,25 +64,34 @@ class goVirusServer extends plugin{
 
   function execute()
   {
-    /* Do we need to flip is_account state? */
-    if (isset($_POST['modify_state'])) {
-      $this->is_account = !$this->is_account;
-    }
-    /* Show tab dialog headers */
-    if ($this->is_account) {
-      /* call Add Acoount to add account */
-      $display = $this->show_header(_("Remove anti virus extension"), 
-        _("This server has anti virus features enabled. You can disable them by clicking below."));
-    } else {
-      /* call remove Account */
-      $display = $this->show_header(_("Add anti virus service"), 
-        _("This server has anti virus features disabled. You can enable them by clicking below."));
-      return ($display);
+    $smarty = get_smarty(); 
+    if(get_class($this->parent) == "servtabs"){
+
+      $smarty->assign("servtabs",TRUE);
+
+      /* Do we need to flip is_account state? */
+      if (isset($_POST['modify_state'])) {
+        $this->is_account = !$this->is_account;
+      }
+
+      /* Show tab dialog headers */
+      if ($this->is_account) {
+        /* call Add Acoount to add account */
+        $display = $this->show_header(_("Remove anti virus extension"), 
+            _("This server has anti virus features enabled. You can disable them by clicking below."));
+      } else {
+        /* call remove Account */
+        $display = $this->show_header(_("Add anti virus service"), 
+            _("This server has anti virus features disabled. You can enable them by clicking below."));
+        return ($display);
+      }
+    }else{
+      $display = "";
+      $smarty->assign("servtabs",FALSE);
+      $this->is_account = true;
     }
 
     /* Assign smarty vars */
-    $smarty = get_smarty(); 
     foreach($this->attributes as $attr){
       $smarty->assign($attr,$this->$attr);
       $smarty->assign($attr."ACL",chkacl($this->acl,$attr));
@@ -106,6 +115,12 @@ class goVirusServer extends plugin{
     }
     $smarty->assign("ThreadValues",$tmp);
 
+    if($this->avFlagsA){
+      $smarty->assign("avFlagsAState" , "" );
+    }else{
+      $smarty->assign("avFlagsAState" , " disabled " );
+    }
+
     return($display.$smarty->fetch(get_template_path("goVirusServer.tpl",TRUE,dirname(__FILE__))));
   }
 
@@ -114,8 +129,15 @@ class goVirusServer extends plugin{
   function remove_from_parent()
   {
     if(!$this->is_account && $this->initially_was_account){
+
       plugin::remove_from_parent();
 
+      /* Remove status flag, it is not a memeber of
+         this->attributes, so ensure that it is deleted too */
+      if(!empty($this->StatusFlag)){
+        $this->attrs[$this->StatusFlag] = array();
+      }
+
       /* Check if this is a new entry ... add/modify */
       $ldap = $this->config->get_ldap_link();
       $ldap->cat($this->dn,array("objectClass"));
@@ -147,6 +169,14 @@ class goVirusServer extends plugin{
 
     plugin::save();
 
+    if(!$this->avFlagsA){
+      $arr = array("avArchiveMaxFileSize","avArchiveMaxRecursion","avArchiveMaxCompressionRatio");
+      foreach($arr as $attr){
+        $this->attrs[$attr] =  array();
+      }
+      $this->attrs['avFlags'] = preg_replace("/E/","",$this->attrs['avFlags']);
+    }
+
     /* Check if this is a new entry ... add/modify */
     $ldap = $this->config->get_ldap_link();
     $ldap->cat($this->dn,array("objectClass"));
@@ -171,6 +201,7 @@ class goVirusServer extends plugin{
     $message = plugin::check();
 
     $mustBeNumeric = array(
+          "avMaxDirectoryRecursions"     =>_("Maximum directory recursions"),
           "avMaxThreads"                 =>_("Maximum threads"),
           "avArchiveMaxFileSize"         =>_("Maximum file size"),
           "avArchiveMaxRecursion"        =>_("Maximum recursions"),
@@ -183,12 +214,6 @@ class goVirusServer extends plugin{
       }
     }
 
-
-
-
-
-
-
     return($message);
   }
   
@@ -209,40 +234,9 @@ class goVirusServer extends plugin{
   }  
 
   
-  /* Return plugin informations for acl handling 
-  function plInfo()
-  {
-    return (array(
-          "plShortName"   => _("Anti virus"),
-          "plDescription" => _("Anti virus service"),
-          "plSelfModify"  => FALSE,
-          "plDepends"     => array(),
-          "plPriority"    => 0,
-          "plSection"     => array("administration"),
-          "plCategory"    => array("server"),
-          "plProvidedAcls"=> array(
-
-
-          "avFlagsD"         =>_("Enable debugging"),
-          "avFlagsS"         =>_("Enable mail scanning"),
-          "avFlagsA"         =>_("Enable scanning of archives"),
-          "avFlagsE"         =>_("Block encrypted archives"),
-
-          "avMaxThreads"                 =>_("Maximum threads"),
-//          "avMaxDirectoryRecursions"     =>_(""),
-//          "avUser"                       =>_(""),
-          "avArchiveMaxFileSize"         =>_("Maximum file size"),
-          "avArchiveMaxRecursion"        =>_("Maximum recursions"),
-          "avArchiveMaxCompressionRatio" =>_("Maximum compression ratio"),
-          "avDatabaseMirror"             =>_("Database mirror"),
-          "avChecksPerDay"               =>_("Checks per day"),
-          "avHttpProxyURL"               =>_("Http proxy URL"))
-          ));
-  }
-  */
 
   /* For newer service management dialogs */
-  /*function getListEntry()
+  function getListEntry()
   {
     $this->updateStatusState();
     $flag                   = $this->StatusFlag;
@@ -272,27 +266,28 @@ class goVirusServer extends plugin{
       $this->$flag = $attrs[$flag][0];
     }
   }
+
   function action_hook($add_attrs= array())
   {
-    /* Find postcreate entries for this class * /
+    /* Find postcreate entries for this class */
     $command= search_config($this->config->data['MENU'], get_class($this), "ACTION_HOOK");
     if ($command == "" && isset($this->config->data['TABS'])){
       $command= search_config($this->config->data['TABS'], get_class($this), "ACTION_HOOK");
     }
     if ($command != ""){
-      /* Walk through attribute list * /
+      /* Walk through attribute list */
       foreach ($this->attributes as $attr){
         if (!is_array($this->$attr)){
           $command= preg_replace("/%$attr/", $this->$attr, $command);
         }
       }
       $command= preg_replace("/%dn/", $this->dn, $command);
-      /* Additional attributes * /
+      /* Additional attributes */
       foreach ($add_attrs as $name => $value){
         $command= preg_replace("/%$name/", $value, $command);
       }
 
-      /* If there are still some %.. in our command, try to fill these with some other class vars * /
+      /* If there are still some %.. in our command, try to fill these with some other class vars */
       if(preg_match("/%/",$command)){
         $attrs = get_object_vars($this);
         foreach($attrs as $name => $value){
@@ -313,7 +308,7 @@ class goVirusServer extends plugin{
     }
   }
 
-  /* Directly save new status flag * /
+  /* Directly save new status flag */
   function setStatus($value)
   {
     if($value == "none") return;
@@ -336,9 +331,37 @@ class goVirusServer extends plugin{
     }
   }
 
+  /* Return plugin informations for acl handling 
+  function plInfo()
+  {
+    return (array(
+          "plShortName"   => _("Anti virus"),
+          "plDescription" => _("Anti virus service"),
+          "plSelfModify"  => FALSE,
+          "plDepends"     => array(),
+          "plPriority"    => 0,
+          "plSection"     => array("administration"),
+          "plCategory"    => array("server"),
+          "plProvidedAcls"=> array(
+
 
-  */
+          "avFlagsD"         =>_("Enable debugging"),
+          "avFlagsS"         =>_("Enable mail scanning"),
+          "avFlagsA"         =>_("Enable scanning of archives"),
+          "avFlagsE"         =>_("Block encrypted archives"),
 
+          "avMaxThreads"                 =>_("Maximum threads"),
+          "avMaxDirectoryRecursions"     =>_("Maximum directory recursions"),
+          "avUser"                       =>_("Anti virus user"),
+          "avArchiveMaxFileSize"         =>_("Maximum file size"),
+          "avArchiveMaxRecursion"        =>_("Maximum recursions"),
+          "avArchiveMaxCompressionRatio" =>_("Maximum compression ratio"),
+          "avDatabaseMirror"             =>_("Database mirror"),
+          "avChecksPerDay"               =>_("Checks per day"),
+          "avHttpProxyURL"               =>_("Http proxy URL"))
+          ));
+  }
+  */
 }
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>