Code

Moved spam/virus to services
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 17 Jan 2008 16:49:22 +0000 (16:49 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 17 Jan 2008 16:49:22 +0000 (16:49 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8481 594d385d-05f5-0310-b6e9-bd551577e9d8

12 files changed:
gosa-core/plugins/admin/systems/services/spam/class_goSpamServer.inc [deleted file]
gosa-core/plugins/admin/systems/services/spam/class_goSpamServerRule.inc [deleted file]
gosa-core/plugins/admin/systems/services/spam/goSpamServer.tpl [deleted file]
gosa-core/plugins/admin/systems/services/spam/goSpamServerRule.tpl [deleted file]
gosa-core/plugins/admin/systems/services/virus/class_goVirusServer.inc [deleted file]
gosa-core/plugins/admin/systems/services/virus/goVirusServer.tpl [deleted file]
gosa-plugins/mail/admin/systems/services/spam/class_goSpamServer.inc [new file with mode: 0644]
gosa-plugins/mail/admin/systems/services/spam/class_goSpamServerRule.inc [new file with mode: 0644]
gosa-plugins/mail/admin/systems/services/spam/goSpamServer.tpl [new file with mode: 0644]
gosa-plugins/mail/admin/systems/services/spam/goSpamServerRule.tpl [new file with mode: 0644]
gosa-plugins/mail/admin/systems/services/virus/class_goVirusServer.inc [new file with mode: 0644]
gosa-plugins/mail/admin/systems/services/virus/goVirusServer.tpl [new file with mode: 0644]

diff --git a/gosa-core/plugins/admin/systems/services/spam/class_goSpamServer.inc b/gosa-core/plugins/admin/systems/services/spam/class_goSpamServer.inc
deleted file mode 100644 (file)
index 68c04e0..0000000
+++ /dev/null
@@ -1,357 +0,0 @@
-<?php
-
-class gospamserver extends goService{
-
-  /* CLI vars */
-  var $cli_summary= "Manage server base objects";
-  var $cli_description= "Some longer text\nfor help";
-  var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
-  /* This plugin only writes its objectClass */
-  var $objectclasses    = array("goSpamServer");
-  var $attributes       = array("saRewriteHeader","saTrustedNetworks","saRequiredScore","saFlags","saRule");
-  var $StatusFlag       = "saStatus";
-  /* This class can't be assigned twice so it conflicts with itsself */
-  var $conflicts        = array("goSpamServer");
-  var $Flags            = array("B","b","C","R","D","P");
-
-  var $DisplayName      = "";
-  var $dn               = NULL;
-  var $cn               = "";
-  var $saStatus         = "";
-
-  var $saRewriteHeader  = "";
-  var $saTrustedNetworks= array();
-  var $TrustedNetworks  = array();
-  var $saRequiredScore  = 0;
-  var $saFlags          = "";
-  var $Rules            = array();
-  var $saRule           = array();
-
-  var $saFlagsB         = false;
-  var $saFlagsb         = false;
-  var $saFlagsC         = false;
-  var $saFlagsR         = false;
-  var $saFlagsD         = false;
-  var $saFlagsP         = false;
-  var $ui               = NULL;
-  var $acl              = NULL;
-  var $view_logged  =FALSE;
-
-  function gospamserver(&$config,$dn, $parent= NULL)
-  {
-    /* Init class */
-    goService::goService($config,$dn, $parent);
-    $this->DisplayName = _("Spamassassin");
-
-    /* Get userinfo & acls */
-    $this->ui = get_userinfo();
-
-    /* Get Flags */
-    foreach($this->Flags as $flag){
-      $var = "saFlags".$flag;
-      if(preg_match("/".$flag."/",$this->saFlags)){
-        $this->$var = TRUE;
-      }
-    }
-    
-    /* Get trusted networks */
-    $this->TrustedNetworks = array();
-    if(isset($this->attrs['saTrustedNetworks']) && is_array($this->attrs['saTrustedNetworks'])){
-      $var = $this->attrs['saTrustedNetworks'];
-      for($i = 0 ; $i < $var['count'] ; $i ++ ){
-        $var2 = $this->attrs['saTrustedNetworks'][$i];
-        $this->TrustedNetworks[ $var2 ] = $var2; 
-      }
-    }
-
-    /* Get rules */
-    $this->Rules = array();
-    if(isset($this->attrs['saRule']) && is_array($this->attrs['saRule'])){  
-      $var = $this->attrs['saRule'];
-      for($i = 0 ; $i < $var['count'] ; $i ++ ){
-        $var2 = $this->attrs['saRule'][$i];
-        $name = preg_replace("/:.*$/","",$var2);
-        $value= base64_decode(preg_replace("/^.*:/","",$var2));
-        $this->Rules[ $name ] = $value;
-      }
-    }
-  }
-
-
-  function execute()
-  {
-    $display ="";
-    $smarty = get_smarty(); 
-    
-    if($this->is_account && !$this->view_logged){
-      $this->view_logged = TRUE;
-      new log("view","server/".get_class($this),$this->dn);
-    }
-
-    /* If displayed, it is ever true*/
-    $this->is_account =true;
-
-    /* Get acls */
-    $tmp = $this->plinfo();
-    foreach($tmp['plProvidedAcls'] as $name => $translation){
-      $smarty->assign($name."ACL",$this->getacl($name));
-    }
-
-    /* Add new trusted network */
-    if(isset($_POST['AddNewTrust']) && ($this->acl_is_writeable("saTrustedNetworks"))){
-      $this->AddTrust($_POST['NewTrustName']);
-    }
-  
-    /* Delete selected trusted network */
-    if(isset($_POST['DelTrust']) && ($this->acl_is_writeable("saTrustedNetworks"))){
-      $this->DelTrust($_POST['TrustedNetworks']);
-    }
-
-    /* Add a new rule */
-    if(isset($_POST['AddRule']) && $this->acl_is_writeable("saRule")){
-      $this->dialog = new goSpamServerRule($this->config,$this->dn);
-    }
-  
-    /* Cancel adding/editing specified rule */
-    if(isset($_POST['CancelRule'])){
-      $this->dialog = FALSE;
-    }
-
-    /* Handle post to delete rules */
-    $once = true;
-    foreach($_POST as $name => $value){
-      if(preg_match("/^editRule_/",$name) && $once && $this->acl_is_readable("saRule")){
-        $once = false;
-        $entry = preg_replace("/^editRule_/","",$name);
-        $entry = preg_replace("/_(x|y)$/","",$entry);
-        $rule = $this->Rules[$entry];
-        $name = $entry;
-        $this->dialog = new goSpamServerRule($this->config,$this->dn,$name,$rule);
-      }
-      if(preg_match("/^delRule_/",$name) && $once && $this->acl_is_writeable("saRule")){
-        $once = false;
-        $entry = preg_replace("/^delRule_/","",$name);
-        $entry = preg_replace("/_(x|y)$/","",$entry);
-        unset($this->Rules[$entry]);
-      }
-    }
-
-    /* Save rules */
-    if(isset($_POST['SaveRule'])){
-      $this->dialog->save_object();
-      $msgs = $this->dialog->check();
-      if(count($msgs)){
-        foreach($msgs as $msg){
-          print_red($msg);
-        }
-      }elseif($this->acl_is_writeable("saRule")){
-        $ret = $this->dialog->save();
-        if((!empty($ret['orig_name'])) && isset($this->Rules[$ret['orig_name']])){
-          unset($this->Rules[$ret['orig_name']]);
-        }
-        $this->Rules[$ret['name']] = $ret['rule'];
-        $this->dialog = FALSE;
-      }
-    }
-   
-    /* Display dialog if available */ 
-    if($this->dialog && $this->dialog->config){
-      $this->dialog->save_object();
-      return($this->dialog->execute());
-    }
-
-    /* Assign smarty vars */
-    foreach($this->attributes as $attr){
-      $smarty->assign($attr,$this->$attr);
-    }
-
-    /* Assign checkbox states */
-    foreach($this->Flags as $Flag){
-      $var = "saFlags".$Flag;
-      $smarty->assign("saFlags".$Flag."ACL", $this->getacl($Flag));
-      if($this->$var){
-        $smarty->assign("saFlags".$Flag."CHK"," checked " );
-      }else{
-        $smarty->assign("saFlags".$Flag."CHK","");
-      }
-    }
-
-    /* Create divlist */
-    $DivRules = new divSelectBox("SpamRules");
-    $DivRules->SetHeight(130);
-
-    if($this->acl_is_writeable("saTrustedNetworks")){
-      $actions = "";
-    }else{
-    
-      $actions = "<input type='image' src='images/edit.png'      name='editRule_%s'>";
-      if($this->acl_is_writeable("saRule")){
-        $actions.= "<input type='image' src='images/edittrash.png' name='delRule_%s'>";
-      }
-    }
-
-    foreach($this->Rules as $key => $net){
-      $field1 = array("string" => $key );
-      $field2 = array("string" => sprintf($actions,$key,$key) , "attach" => "style='border-right:0px;width:36px;'");
-      $DivRules->AddEntry(array($field1,$field2));
-    }
-    $smarty->assign("divRules",$DivRules->DrawList()); 
-    $smarty->assign("TrustedNetworks",$this->TrustedNetworks); 
-
-    /* Create Spam score select box entries */
-    $tmp = array();
-    for($i = 0 ; $i <= 20 ; $i ++ ){
-      $tmp[$i] = $i;
-    }
-    $smarty->assign("SpamScore",$tmp);
-
-    return($display.$smarty->fetch(get_template_path("goSpamServer.tpl",TRUE,dirname(__FILE__))));
-  }
-
-
-  /* Add $post to list of configured trusted */
-  function AddTrust($post)
-  {
-    if(!empty($post)){
-      if(tests::is_ip($post) || tests::is_domain($post) || (tests::is_ip_with_subnetmask($post))){
-        $this->TrustedNetworks[$post] = $post;
-      }else{
-        print_red(_("Specified value is not a valid 'trusted network' value."));
-      }
-    }
-  }
-
-
-  /* Delete trusted network */
-  function DelTrust($posts)
-  {
-    foreach($posts as $post){
-      if(isset($this->TrustedNetworks[$post])){
-        unset($this->TrustedNetworks[$post]);     
-      }
-    }
-  }
-
-  function save()
-  {
-    if(!$this->is_account) return;
-    plugin::save();
-
-    /* Create Flags */     
-    $this->attrs['saFlags'] = array();
-    foreach($this->Flags as $flag){
-      $var = "saFlags".$flag;
-      if($this->$var){
-        $this->attrs['saFlags'].=$flag;
-      }
-    }
-
-    /* Create trusted network entries */
-    $this->attrs['saTrustedNetworks'] = array();
-    foreach($this->TrustedNetworks as $net){
-      $this->attrs['saTrustedNetworks'][] = $net; 
-    }    
-
-    /* Rules */
-    $this->attrs['saRule'] = array();
-    foreach($this->Rules as $name => $rule){
-      $this->attrs['saRule'][] = $name.":".base64_encode($rule);
-    }
-
-    /* Check if this is a new entry ... add/modify */
-    $ldap = $this->config->get_ldap_link();
-    $ldap->cat($this->dn,array("objectClass"));
-    if($ldap->count()){
-      $ldap->cd($this->dn);
-      $ldap->modify($this->attrs);
-    }else{
-      $ldap->cd($this->dn);
-      $ldap->add($this->attrs);
-    }
-    if($this->initially_was_account){
-      $this->handle_post_events("modify");
-      new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
-    }else{
-      $this->handle_post_events("add");
-      new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
-    }
-
-    show_ldap_error($ldap->get_error(), sprintf(_("Saving of server services/spamassassin with dn '%s' failed."),$this->dn));
-  }
-
-  function check()
-  { 
-    $message = plugin::check();
-
-    /* Check if required score is numeric */
-    if(!is_numeric($this->saRequiredScore)){
-      $message[] = _("Required score must be a numeric value.");
-    }
-
-    return($message);
-  }
-  
-
-  function save_object()
-  {
-    if(isset($_POST['goSpamServer'])){
-
-      plugin::save_object();
-
-      /* Check flags */
-      foreach($this->Flags as $flag){
-        $var = "saFlags".$flag;
-
-        if($this->acl_is_writeable($var)){
-          if(isset($_POST[$var])){
-            $this->$var = TRUE;
-          }else{
-            $this->$var = FALSE;
-          }
-        }
-      }
-    }    
-  }  
-
-  
-  /* Return plugin informations for acl handling  */
-  static function plInfo()
-  {
-    return (array(
-          "plShortName"   => _("Spamassassin"),
-          "plDescription" => _("Spamassassin")." ("._("Services").")",
-          "plSelfModify"  => FALSE,
-          "plDepends"     => array(),
-          "plPriority"    => 89,
-          "plSection"     => array("administration"),
-          "plCategory"    => array("server"),
-          "plProvidedAcls"=> array(
-
-            "saRewriteHeader"   => _("Rewrite header"),
-            "saTrustedNetworks" => _("Trusted networks"),
-            "saRequiredScore"   => _("Required score"),
-            "saRule"            => _("Rules"),
-
-            "saFlagB"           => _("Enable use of bayes filtering"),
-            "saFlagb"           => _("Enabled bayes auto learning"),
-            "saFlagC"           => _("Enable RBL checks"),
-            "saFlagR"           => _("Enable use of Razor"),
-            "saFlagD"           => _("Enable use of DDC"),
-            "saFlagP"           => _("Enable use of Pyzor"))
-          ));
-  }
-
-  /* For newer service management dialogs */
-  function getListEntry()
-  {
-    $fields                 = goService::getListEntry();
-    $fields['Message']      = _("Spamassassin");
-    $fields['AllowEdit']    = true;
-    return($fields);
-  }
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-core/plugins/admin/systems/services/spam/class_goSpamServerRule.inc b/gosa-core/plugins/admin/systems/services/spam/class_goSpamServerRule.inc
deleted file mode 100644 (file)
index c8eed5d..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-<?php
-class goSpamServerRule extends plugin {
-
-       var $attributes = array("name","rule");
-       var $name = "";
-       var $rule = "";
-       
-       var $orig_name = "";
-  var $view_logged  =FALSE;
-       
-       function goSpamServerRule(&$config,$dn,$name = "",$rule ="")
-       {
-               plugin::plugin($config,$dn);
-               $this->name = $this->orig_name= $name;
-               $this->rule = $rule;
-       }
-
-
-       function execute()
-       {
-               $smarty = get_smarty();
-
-    if($this->is_account && !$this->view_logged){
-      $this->view_logged = TRUE;
-      new log("view","server/".get_class($this),$this->dn);
-    }
-
-               foreach($this->attributes as $attr){
-                       $smarty->assign($attr,$this->$attr);
-               }
-               return($smarty->fetch(get_template_path("goSpamServerRule.tpl",TRUE,dirname(__FILE__))));                       
-       }
-
-       function save_object()
-       {
-               plugin::save_object();
-               foreach($this->attributes as $attr){
-                       if(isset($_POST[$attr])){
-                               $this->$attr = $_POST[$attr];
-                       }
-               }
-       }
-
-
-       function save()
-       {
-               $ret =array();
-               $ret['orig_name'] = $this->orig_name;
-               $ret['name'] = $this->name;
-               $ret['rule'] = $this->rule;
-               return($ret);
-       }
-       
-       function check()
-       {
-               $messages = plugin::check();
-               return($messages);
-       }
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-core/plugins/admin/systems/services/spam/goSpamServer.tpl b/gosa-core/plugins/admin/systems/services/spam/goSpamServer.tpl
deleted file mode 100644 (file)
index c8b5885..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-<table style='width:100%'>
- <tr>
-  <td style='width:50%;vertical-align:top;'><h2>Spam tagging</h2>
-
-   <table>
-    <tr>
-     <td>
-      {t}Rewrite header{/t}      
-     </td>
-     <td>
-{render acl=$saRewriteHeaderACL}
-      <input type='text' name='saRewriteHeader' value='{$saRewriteHeader}'>
-{/render}
-     </td>
-    </tr>
-    <tr>
-     <td>
-      {t}Required score{/t}      
-     </td>
-     <td>
-{render acl=$saRequiredScoreACL}
-      <select name='saRequiredScore' title='{t}Select required score to tag mail as spam{/t}'>
-       {html_options options=$SpamScore selected=$saRequiredScore}
-      </select>
-{/render}
-     </td>
-    </tr>
-   </table>
-
-  </td>
-  <td style="vertical-align:top;border-left:1px solid #A0A0A0;"><h2>Trusted networks</h2>
-
-   <table width='100%'>
-    <tr>
-     <td>
-{render acl=$saTrustedNetworksACL}
-      <select name='TrustedNetworks[]' size=4 style='width:100%;' multiple>
-       {html_options options=$TrustedNetworks}
-      </select><br>
-{/render}
-{render acl=$saTrustedNetworksACL}
-      <input type='text'       name='NewTrustName' value=''>&nbsp;
-{/render}
-{render acl=$saTrustedNetworksACL}
-      <input type='submit'      name='AddNewTrust'  value='{t}Add{/t}'>
-{/render}
-{render acl=$saTrustedNetworksACL}
-      <input type='submit'      name='DelTrust'     value='{t}Remove{/t}'>
-{/render}
-     </td>
-    </tr>
-   </table>
-
-  </td>
- </tr>
- <tr>
-  <td colspan=2>
-   <p class='seperator'>&nbsp;</p>
-  </td>
- </tr>
- <tr>
-  <td>
-       <h2>Flags</h2>
-       
-   <table>
-    <tr>
-     <td>
-{render acl=$saFlagsBACL}
-      <input type='checkbox' name='saFlagsB' value='1' {$saFlagsBCHK}> &nbsp;{t}Enable use of bayes filtering{/t}<br>
-{/render}
-{render acl=$saFlagsbACL}
-      <input type='checkbox' name='saFlagsb' value='1' {$saFlagsbCHK}> &nbsp;{t}Enable bayes auto learning{/t}<br>
-{/render}
-{render acl=$saFlagsCACL}
-      <input type='checkbox' name='saFlagsC' value='1' {$saFlagsCCHK}> &nbsp;{t}Enable RBL checks{/t}
-{/render}
-     </td>
-    </tr>
-   </table>
-  </td>
-  <td style="vertical-align:bottom;border-left:1px solid #A0A0A0;">
-   <table>
-    <tr>
-     <td>
-{render acl=$saFlagsRACL}
-      <input type='checkbox' name='saFlagsR' value='1' {$saFlagsRCHK}> &nbsp;{t}Enable use of Razor{/t}<br>
-{/render}
-{render acl=$saFlagsDACL}
-      <input type='checkbox' name='saFlagsD' value='1' {$saFlagsDCHK}> &nbsp;{t}Enable use of DDC{/t}<br>
-{/render}
-{render acl=$saFlagsPACL}
-      <input type='checkbox' name='saFlagsP' value='1' {$saFlagsPCHK}> &nbsp;{t}Enable use of Pyzor{/t}
-{/render}
-     </td>
-    </tr>
-   </table>
-
-  </td>
- </tr>
- <tr>
-  <td colspan=2>
-   <p class='seperator'>&nbsp;</p>
-  </td>
- </tr>
- <tr>
-  <td colspan='2'><h2>Rules</h2>
-
-   <table width='100%'>
-    <tr>
-     <td>
-      {$divRules}<br>
-{render acl=$saTrustedNetworksACL}
-      <input type='submit' name='AddRule' value='{t}Add{/t}'> 
-{/render}
-     </td>
-    </tr>
-   </table>
-
-  </td>
-</table>
-<input type='hidden' value='1' name='goSpamServer'>
-
-<p class='seperator'>&nbsp;</p>
-<div style="width:100%; text-align:right;padding-top:10px;padding-bottom:3px;">
-    <input type='submit' name='SaveService' value='{t}Save{/t}'>
-    &nbsp;
-    <input type='submit' name='CancelService' value='{t}Cancel{/t}'>
-</div>
-
diff --git a/gosa-core/plugins/admin/systems/services/spam/goSpamServerRule.tpl b/gosa-core/plugins/admin/systems/services/spam/goSpamServerRule.tpl
deleted file mode 100644 (file)
index 6448ab5..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-<h2>Edit spam rule</h2>
-
-<table style='width:100%;'>
- <tr>
-  <td width='70'>
-   {t}Name{/t}
-  </td>
-  <td>
-   <input type='text' name='name' value='{$name}' >
-  </td>
- </tr>
- <tr>
-  <td colspan=2>
-   {t}Rule{/t}
-   <textarea name='rule' style='width:100%;'>{$rule}</textarea>
-  </td>
- </tr>
-</table>
-<p class='seperator'>&nbsp;</p>
-<div style="width:100%; text-align:right;padding-top:10px;padding-bottom:3px;">
-    <input type='submit' name='SaveRule' value='{t}Save{/t}'>
-    &nbsp;
-    <input type='submit' name='CancelRule' value='{t}Cancel{/t}'>
-</div>
-
diff --git a/gosa-core/plugins/admin/systems/services/virus/class_goVirusServer.inc b/gosa-core/plugins/admin/systems/services/virus/class_goVirusServer.inc
deleted file mode 100644 (file)
index f91c5f5..0000000
+++ /dev/null
@@ -1,248 +0,0 @@
-<?php
-
-class govirusserver extends goService{
-       
-  /* This plugin only writes its objectClass */
-  var $objectclasses    = array("goVirusServer");
-  var $attributes       = array("avMaxThreads","avMaxDirectoryRecursions","avUser","avFlags","avArchiveMaxFileSize","avArchiveMaxRecursion",
-                                "avArchiveMaxCompressionRatio","avDatabaseMirror","avChecksPerDay","avHttpProxyURL");
-  var $StatusFlag       = "avStatus";
-  /* This class can't be assigned twice so it conflicts with itsself */
-  var $conflicts        = array("goVirusServer");
-
-  var $DisplayName      = "";
-  var $dn               = NULL;
-  var $cn               = "";
-  var $avStatus         = "";
-
-  var $ui               = NULL;
-
-  var $Flags            = array("D","S","A","E");
-  
-  var $avFlags          = "DS";
-  var $avFlagsD         = TRUE;
-  var $avFlagsS         = TRUE;
-  var $avFlagsA         = FALSE;
-  var $avFlagsE         = FALSE;
-
-  var $avMaxThreads                 = 5;
-  var $avMaxDirectoryRecursions     = 4;    
-  var $avArchiveMaxFileSize         = 4000;
-  var $avArchiveMaxRecursion        = 5;
-  var $avArchiveMaxCompressionRatio = 95;
-  var $avChecksPerDay               = 12;
-
-  var $avUser                       = "";
-  var $avHttpProxyURL               = "";
-  var $avDatabaseMirror             = "";
-  var $view_logged  =FALSE;
-
-  function govirusserver(&$config,$dn, $parent= NULL)
-  {
-    /* Init class */
-    goService::goService($config,$dn, $parent);
-    $this->DisplayName = _("Anti virus");
-
-    /* Get userinfo & acls */
-    $this->ui = get_userinfo();
-
-    /* Get Flags */
-    foreach($this->Flags as $flag){
-      $var = "avFlags".$flag;
-      if(preg_match("/".$flag."/",$this->avFlags)){
-        $this->$var = TRUE;
-      }
-    }
-  }
-
-
-  function execute()
-  {
-    $smarty = get_smarty(); 
-
-    if($this->is_account && !$this->view_logged){
-      $this->view_logged = TRUE;
-      new log("view","server/".get_class($this),$this->dn);
-    }
-
-
-    /* Set acls */
-    $tmp = $this->plInfo();
-    foreach($tmp['plProvidedAcls'] as $name => $translation) { 
-      $smarty->assign($name."ACL",$this->getacl($name));
-    }
-
-    $display = "";
-    $smarty->assign("servtabs",FALSE);
-    $this->is_account = true;
-
-    /* Assign smarty vars */
-    foreach($this->attributes as $attr){
-      $smarty->assign($attr,$this->$attr);
-    }
-
-    /* Assign checkbox states */
-    foreach($this->Flags as $Flag){
-      $var = "avFlags".$Flag;
-      if($this->$var){
-        $smarty->assign("avFlags".$Flag."CHK"," checked " );
-      }else{
-        $smarty->assign("avFlags".$Flag."CHK","");
-      }
-    }
-
-    /* Assign value for max thread select box */
-    $tmp = array();
-    for($i = 1 ; $i <= 20 ; $i ++){
-      $tmp[$i] = $i;
-    }
-    $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__))));
-  }
-
-
-  function save()
-  {
-    if(!$this->is_account) return;
-
-    /* Create Flags */     
-    $this->avFlags = "";
-    foreach($this->Flags as $flag){
-      $var = "avFlags".$flag;
-      if($this->$var){
-        $this->avFlags .=$flag;
-      }
-    }
-
-    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"));
-    if($ldap->count()){
-      $ldap->cd($this->dn);
-      $ldap->modify($this->attrs);
-    }else{
-      $ldap->cd($this->dn);
-      $ldap->add($this->attrs);
-    }
-    if($this->initially_was_account){
-      $this->handle_post_events("modify");
-      new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
-    }else{
-      $this->handle_post_events("add");
-      new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
-    }
-
-    show_ldap_error($ldap->get_error(), sprintf(_("Saving of server services/anti virus with dn '%s' failed."),$this->dn));
-  }
-
-  function check()
-  { 
-    $message = plugin::check();
-
-    $mustBeNumeric = array(
-          "avMaxDirectoryRecursions"     =>_("Maximum directory recursions"),
-          "avMaxThreads"                 =>_("Maximum threads"),
-          "avArchiveMaxFileSize"         =>_("Maximum file size"),
-          "avArchiveMaxRecursion"        =>_("Maximum recursions"),
-          "avArchiveMaxCompressionRatio" =>_("Maximum compression ratio"),
-          "avChecksPerDay"               =>_("Checks per day"));
-
-    foreach($mustBeNumeric as $key => $trans){
-      if(!is_numeric($this->$key)){
-        $message[] = sprintf(_("The specified value for '%s' must be a numeric value."),$trans);
-      }
-    }
-
-    foreach(array("avUser"=>_("Database user"),"avHttpProxyURL"=>_("Http proxy URL"),"avDatabaseMirror"=>_("Database mirror")) as $attr => $name){
-      if(!preg_match("/^[a-z0-9:_\-\.\/]*$/",$this->$attr)){
-        $message[] = sprintf(_("Please specify a valid value for '%s'."),$name);
-      }
-    }
-  
-    return($message);
-  }
-  
-
-  function save_object()
-  {
-    if(isset($_POST['goVirusServer'])){
-      plugin::save_object();
-      foreach($this->Flags as $flag){
-
-        $var = "avFlags".$flag;
-        if($this->acl_is_writeable($var)){
-          if(isset($_POST[$var])){
-            $this->$var = TRUE;
-          }else{
-            $this->$var = FALSE;
-          }
-        }
-      }
-    }    
-  }  
-  
-
-  /* For newer service management dialogs */
-  function getListEntry()
-  {
-    $fields       = goService::getListEntry();
-    $fields['AllowEdit']    = true;
-    $fields['Message']      = _("Anti virus");
-    return($fields);
-  }
-
-
-  /* Return plugin informations for acl handling */ 
-  static function plInfo()
-  {
-    return (array(
-          "plShortName"   => _("Anti virus"),
-          "plDescription" => _("Anti virus")." ("._("Services").")",
-          "plSelfModify"  => FALSE,
-          "plDepends"     => array(),
-          "plPriority"    => 96,
-          "plSection"     => array("administration"),
-          "plCategory"    => array("server"),
-          "plProvidedAcls"=> array(
-
-          "start"         => _("Start"),
-          "stop"          => _("Stop"),
-          "restart"       => _("Restart"),
-
-          "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:
-?>
diff --git a/gosa-core/plugins/admin/systems/services/virus/goVirusServer.tpl b/gosa-core/plugins/admin/systems/services/virus/goVirusServer.tpl
deleted file mode 100644 (file)
index af14a2b..0000000
+++ /dev/null
@@ -1,172 +0,0 @@
-
-<table style='width:100%;'>
- <tr>
-  <td colspan=2>
-       <h2>{t}Generic virus filtering{/t}</h2>
-  </td>
- </tr>
- <tr>
-  <td style="vertical-align:top;">
-       <table>
-        <tr>
-         <td>
-               {t}Database user{/t}
-         </td>
-         <td>
-{render acl=$avUserACL}
-               <input type='text' name='avUser' value='{$avUser}' style='width:220px;'>
-{/render}
-         </td>
-        </tr>
-        <tr>
-         <td>
-               {t}Database mirror{/t}
-         </td>
-         <td>
-{render acl=$avDatabaseMirrorACL}
-               <input type='text' name='avDatabaseMirror' value='{$avDatabaseMirror}' style='width:220px;'>
-{/render}
-         </td>
-        </tr>
-        <tr>
-         <td>
-               {t}Http proxy URL{/t}
-         </td>
-         <td>
-{render acl=$avHttpProxyURLACL}
-               <input type='text' name='avHttpProxyURL' value='{$avHttpProxyURL}' style='width:220px;'>
-{/render}
-         </td>
-        </tr>
-        <tr>
-         <td>
-               {t}Maximum threads{/t}
-         </td>
-         <td>
-{render acl=$avMaxThreadsACL}
-               <select name="avMaxThreads" title='{t}Select number of maximal threads{/t}'>
-                {html_options options=$ThreadValues selected=$avMaxThreads}
-               </select>
-{/render}
-         </td>
-        </tr>
-       </table>
-  </td>
-  <td style='border-left:1px solid #A0A0A0;vertical-align:top;'>
-  
-       <table>
-        <tr>
-         <td>
-               {t}Max directory recursions{/t}
-         </td>
-         <td>
-{render acl=$avMaxDirectoryRecursionsACL}
-               <input type='text' name='avMaxDirectoryRecursions' value='{$avMaxDirectoryRecursions}' >
-{/render}
-         </td>
-        </tr>
-        <tr>
-         <td>
-               {t}Checks per day{/t}
-         </td>
-         <td>
-{render acl=$avChecksPerDayACL}
-               <input type='text' name='avChecksPerDay' value='{$avChecksPerDay}'> 
-{/render}
-         </td>
-        </tr>
-        <tr>
-         <td colspan=2>
-{render acl=$avFlagsDACL}
-               <input type='checkbox' name='avFlagsD' {$avFlagsDCHK} value='1'>
-{/render}
-               {t}Enable debugging{/t}
-         </td>
-        </tr>
-        <tr>
-         <td colspan=2>
-{render acl=$avFlagsSACL}
-               <input type='checkbox' name='avFlagsS' {$avFlagsSCHK} value='1'>
-{/render}
-               {t}Enable mail scanning{/t}
-         </td>
-        </tr>
-       </table>
-  </td>
- </tr>
- <tr>
-  <td colspan=2>
-   <p class='seperator'>&nbsp;</p>
-       <h2>{t}Archive scanning{/t}</h2> 
-  </td>
- </tr>
- <tr>
-  <td style='vertical-align:top;'>
-       <table>
-        <tr>
-         <td>
-{render acl=$avFlagsAACL}
-               <input type='checkbox' name='avFlagsA' {$avFlagsACHK} value='1'
-                       onClick=" changeState('avFlagsE') ; 
-                                 changeState('avArchiveMaxFileSize') ; 
-                                 changeState('avArchiveMaxRecursion') ; 
-                                 changeState('avArchiveMaxCompressionRatio') ; "
-               >
-{/render}
-               {t}Enable scanning of archives{/t}
-         </td>
-        </tr>
-        <tr>
-         <td>
-{render acl=$avFlagsEACL}
-               <input type='checkbox' name='avFlagsE' {$avFlagsECHK} {$avFlagsAState} value='1' id='avFlagsE'>
-{/render}
-               {t}Block encrypted archives{/t}
-         </td>
-        </tr>
-       </table>
-  
-  </td>
-  <td  style="vertical-align:top;width:50%;border-left:1px solid #A0A0A0;">
-       <table>
-        <tr>
-         <td>{t}Maximum file size{/t}
-         </td>
-         <td>
-{render acl=$avArchiveMaxFileSizeACL}
-          <input name='avArchiveMaxFileSize' id='avArchiveMaxFileSize' value='{$avArchiveMaxFileSize}'  {$avFlagsAState} >
-{/render}
-         </td>
-        </tr>
-        <tr>
-         <td>{t}Maximum recursion{/t}
-         </td>
-         <td>
-{render acl=$avArchiveMaxRecursionACL}
-          <input name='avArchiveMaxRecursion' id='avArchiveMaxRecursion' value='{$avArchiveMaxRecursion}'  {$avFlagsAState} >
-{/render}
-         </td>
-        </tr>
-        <tr>
-         <td>{t}Maximum compression ratio{/t}
-         </td>
-         <td>
-{render acl=$avArchiveMaxCompressionRatioACL}
-          <input name='avArchiveMaxCompressionRatio' id='avArchiveMaxCompressionRatio' value='{$avArchiveMaxCompressionRatio}' {$avFlagsAState}>
-{/render}
-         </td>
-        </tr>
-       </table>
-  
-  </td>
- </tr>
-</table>
-<input type='hidden' name='goVirusServer' value='1'>
-<p class='seperator'>&nbsp;</p>
-<div style="width:100%; text-align:right;padding-top:10px;padding-bottom:3px;">
-    <input type='submit' name='SaveService' value='{t}Save{/t}'>
-    &nbsp;
-    <input type='submit' name='CancelService' value='{t}Cancel{/t}'>
-</div>
-
diff --git a/gosa-plugins/mail/admin/systems/services/spam/class_goSpamServer.inc b/gosa-plugins/mail/admin/systems/services/spam/class_goSpamServer.inc
new file mode 100644 (file)
index 0000000..68c04e0
--- /dev/null
@@ -0,0 +1,357 @@
+<?php
+
+class gospamserver extends goService{
+
+  /* CLI vars */
+  var $cli_summary= "Manage server base objects";
+  var $cli_description= "Some longer text\nfor help";
+  var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+  /* This plugin only writes its objectClass */
+  var $objectclasses    = array("goSpamServer");
+  var $attributes       = array("saRewriteHeader","saTrustedNetworks","saRequiredScore","saFlags","saRule");
+  var $StatusFlag       = "saStatus";
+  /* This class can't be assigned twice so it conflicts with itsself */
+  var $conflicts        = array("goSpamServer");
+  var $Flags            = array("B","b","C","R","D","P");
+
+  var $DisplayName      = "";
+  var $dn               = NULL;
+  var $cn               = "";
+  var $saStatus         = "";
+
+  var $saRewriteHeader  = "";
+  var $saTrustedNetworks= array();
+  var $TrustedNetworks  = array();
+  var $saRequiredScore  = 0;
+  var $saFlags          = "";
+  var $Rules            = array();
+  var $saRule           = array();
+
+  var $saFlagsB         = false;
+  var $saFlagsb         = false;
+  var $saFlagsC         = false;
+  var $saFlagsR         = false;
+  var $saFlagsD         = false;
+  var $saFlagsP         = false;
+  var $ui               = NULL;
+  var $acl              = NULL;
+  var $view_logged  =FALSE;
+
+  function gospamserver(&$config,$dn, $parent= NULL)
+  {
+    /* Init class */
+    goService::goService($config,$dn, $parent);
+    $this->DisplayName = _("Spamassassin");
+
+    /* Get userinfo & acls */
+    $this->ui = get_userinfo();
+
+    /* Get Flags */
+    foreach($this->Flags as $flag){
+      $var = "saFlags".$flag;
+      if(preg_match("/".$flag."/",$this->saFlags)){
+        $this->$var = TRUE;
+      }
+    }
+    
+    /* Get trusted networks */
+    $this->TrustedNetworks = array();
+    if(isset($this->attrs['saTrustedNetworks']) && is_array($this->attrs['saTrustedNetworks'])){
+      $var = $this->attrs['saTrustedNetworks'];
+      for($i = 0 ; $i < $var['count'] ; $i ++ ){
+        $var2 = $this->attrs['saTrustedNetworks'][$i];
+        $this->TrustedNetworks[ $var2 ] = $var2; 
+      }
+    }
+
+    /* Get rules */
+    $this->Rules = array();
+    if(isset($this->attrs['saRule']) && is_array($this->attrs['saRule'])){  
+      $var = $this->attrs['saRule'];
+      for($i = 0 ; $i < $var['count'] ; $i ++ ){
+        $var2 = $this->attrs['saRule'][$i];
+        $name = preg_replace("/:.*$/","",$var2);
+        $value= base64_decode(preg_replace("/^.*:/","",$var2));
+        $this->Rules[ $name ] = $value;
+      }
+    }
+  }
+
+
+  function execute()
+  {
+    $display ="";
+    $smarty = get_smarty(); 
+    
+    if($this->is_account && !$this->view_logged){
+      $this->view_logged = TRUE;
+      new log("view","server/".get_class($this),$this->dn);
+    }
+
+    /* If displayed, it is ever true*/
+    $this->is_account =true;
+
+    /* Get acls */
+    $tmp = $this->plinfo();
+    foreach($tmp['plProvidedAcls'] as $name => $translation){
+      $smarty->assign($name."ACL",$this->getacl($name));
+    }
+
+    /* Add new trusted network */
+    if(isset($_POST['AddNewTrust']) && ($this->acl_is_writeable("saTrustedNetworks"))){
+      $this->AddTrust($_POST['NewTrustName']);
+    }
+  
+    /* Delete selected trusted network */
+    if(isset($_POST['DelTrust']) && ($this->acl_is_writeable("saTrustedNetworks"))){
+      $this->DelTrust($_POST['TrustedNetworks']);
+    }
+
+    /* Add a new rule */
+    if(isset($_POST['AddRule']) && $this->acl_is_writeable("saRule")){
+      $this->dialog = new goSpamServerRule($this->config,$this->dn);
+    }
+  
+    /* Cancel adding/editing specified rule */
+    if(isset($_POST['CancelRule'])){
+      $this->dialog = FALSE;
+    }
+
+    /* Handle post to delete rules */
+    $once = true;
+    foreach($_POST as $name => $value){
+      if(preg_match("/^editRule_/",$name) && $once && $this->acl_is_readable("saRule")){
+        $once = false;
+        $entry = preg_replace("/^editRule_/","",$name);
+        $entry = preg_replace("/_(x|y)$/","",$entry);
+        $rule = $this->Rules[$entry];
+        $name = $entry;
+        $this->dialog = new goSpamServerRule($this->config,$this->dn,$name,$rule);
+      }
+      if(preg_match("/^delRule_/",$name) && $once && $this->acl_is_writeable("saRule")){
+        $once = false;
+        $entry = preg_replace("/^delRule_/","",$name);
+        $entry = preg_replace("/_(x|y)$/","",$entry);
+        unset($this->Rules[$entry]);
+      }
+    }
+
+    /* Save rules */
+    if(isset($_POST['SaveRule'])){
+      $this->dialog->save_object();
+      $msgs = $this->dialog->check();
+      if(count($msgs)){
+        foreach($msgs as $msg){
+          print_red($msg);
+        }
+      }elseif($this->acl_is_writeable("saRule")){
+        $ret = $this->dialog->save();
+        if((!empty($ret['orig_name'])) && isset($this->Rules[$ret['orig_name']])){
+          unset($this->Rules[$ret['orig_name']]);
+        }
+        $this->Rules[$ret['name']] = $ret['rule'];
+        $this->dialog = FALSE;
+      }
+    }
+   
+    /* Display dialog if available */ 
+    if($this->dialog && $this->dialog->config){
+      $this->dialog->save_object();
+      return($this->dialog->execute());
+    }
+
+    /* Assign smarty vars */
+    foreach($this->attributes as $attr){
+      $smarty->assign($attr,$this->$attr);
+    }
+
+    /* Assign checkbox states */
+    foreach($this->Flags as $Flag){
+      $var = "saFlags".$Flag;
+      $smarty->assign("saFlags".$Flag."ACL", $this->getacl($Flag));
+      if($this->$var){
+        $smarty->assign("saFlags".$Flag."CHK"," checked " );
+      }else{
+        $smarty->assign("saFlags".$Flag."CHK","");
+      }
+    }
+
+    /* Create divlist */
+    $DivRules = new divSelectBox("SpamRules");
+    $DivRules->SetHeight(130);
+
+    if($this->acl_is_writeable("saTrustedNetworks")){
+      $actions = "";
+    }else{
+    
+      $actions = "<input type='image' src='images/edit.png'      name='editRule_%s'>";
+      if($this->acl_is_writeable("saRule")){
+        $actions.= "<input type='image' src='images/edittrash.png' name='delRule_%s'>";
+      }
+    }
+
+    foreach($this->Rules as $key => $net){
+      $field1 = array("string" => $key );
+      $field2 = array("string" => sprintf($actions,$key,$key) , "attach" => "style='border-right:0px;width:36px;'");
+      $DivRules->AddEntry(array($field1,$field2));
+    }
+    $smarty->assign("divRules",$DivRules->DrawList()); 
+    $smarty->assign("TrustedNetworks",$this->TrustedNetworks); 
+
+    /* Create Spam score select box entries */
+    $tmp = array();
+    for($i = 0 ; $i <= 20 ; $i ++ ){
+      $tmp[$i] = $i;
+    }
+    $smarty->assign("SpamScore",$tmp);
+
+    return($display.$smarty->fetch(get_template_path("goSpamServer.tpl",TRUE,dirname(__FILE__))));
+  }
+
+
+  /* Add $post to list of configured trusted */
+  function AddTrust($post)
+  {
+    if(!empty($post)){
+      if(tests::is_ip($post) || tests::is_domain($post) || (tests::is_ip_with_subnetmask($post))){
+        $this->TrustedNetworks[$post] = $post;
+      }else{
+        print_red(_("Specified value is not a valid 'trusted network' value."));
+      }
+    }
+  }
+
+
+  /* Delete trusted network */
+  function DelTrust($posts)
+  {
+    foreach($posts as $post){
+      if(isset($this->TrustedNetworks[$post])){
+        unset($this->TrustedNetworks[$post]);     
+      }
+    }
+  }
+
+  function save()
+  {
+    if(!$this->is_account) return;
+    plugin::save();
+
+    /* Create Flags */     
+    $this->attrs['saFlags'] = array();
+    foreach($this->Flags as $flag){
+      $var = "saFlags".$flag;
+      if($this->$var){
+        $this->attrs['saFlags'].=$flag;
+      }
+    }
+
+    /* Create trusted network entries */
+    $this->attrs['saTrustedNetworks'] = array();
+    foreach($this->TrustedNetworks as $net){
+      $this->attrs['saTrustedNetworks'][] = $net; 
+    }    
+
+    /* Rules */
+    $this->attrs['saRule'] = array();
+    foreach($this->Rules as $name => $rule){
+      $this->attrs['saRule'][] = $name.":".base64_encode($rule);
+    }
+
+    /* Check if this is a new entry ... add/modify */
+    $ldap = $this->config->get_ldap_link();
+    $ldap->cat($this->dn,array("objectClass"));
+    if($ldap->count()){
+      $ldap->cd($this->dn);
+      $ldap->modify($this->attrs);
+    }else{
+      $ldap->cd($this->dn);
+      $ldap->add($this->attrs);
+    }
+    if($this->initially_was_account){
+      $this->handle_post_events("modify");
+      new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+    }else{
+      $this->handle_post_events("add");
+      new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+    }
+
+    show_ldap_error($ldap->get_error(), sprintf(_("Saving of server services/spamassassin with dn '%s' failed."),$this->dn));
+  }
+
+  function check()
+  { 
+    $message = plugin::check();
+
+    /* Check if required score is numeric */
+    if(!is_numeric($this->saRequiredScore)){
+      $message[] = _("Required score must be a numeric value.");
+    }
+
+    return($message);
+  }
+  
+
+  function save_object()
+  {
+    if(isset($_POST['goSpamServer'])){
+
+      plugin::save_object();
+
+      /* Check flags */
+      foreach($this->Flags as $flag){
+        $var = "saFlags".$flag;
+
+        if($this->acl_is_writeable($var)){
+          if(isset($_POST[$var])){
+            $this->$var = TRUE;
+          }else{
+            $this->$var = FALSE;
+          }
+        }
+      }
+    }    
+  }  
+
+  
+  /* Return plugin informations for acl handling  */
+  static function plInfo()
+  {
+    return (array(
+          "plShortName"   => _("Spamassassin"),
+          "plDescription" => _("Spamassassin")." ("._("Services").")",
+          "plSelfModify"  => FALSE,
+          "plDepends"     => array(),
+          "plPriority"    => 89,
+          "plSection"     => array("administration"),
+          "plCategory"    => array("server"),
+          "plProvidedAcls"=> array(
+
+            "saRewriteHeader"   => _("Rewrite header"),
+            "saTrustedNetworks" => _("Trusted networks"),
+            "saRequiredScore"   => _("Required score"),
+            "saRule"            => _("Rules"),
+
+            "saFlagB"           => _("Enable use of bayes filtering"),
+            "saFlagb"           => _("Enabled bayes auto learning"),
+            "saFlagC"           => _("Enable RBL checks"),
+            "saFlagR"           => _("Enable use of Razor"),
+            "saFlagD"           => _("Enable use of DDC"),
+            "saFlagP"           => _("Enable use of Pyzor"))
+          ));
+  }
+
+  /* For newer service management dialogs */
+  function getListEntry()
+  {
+    $fields                 = goService::getListEntry();
+    $fields['Message']      = _("Spamassassin");
+    $fields['AllowEdit']    = true;
+    return($fields);
+  }
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/mail/admin/systems/services/spam/class_goSpamServerRule.inc b/gosa-plugins/mail/admin/systems/services/spam/class_goSpamServerRule.inc
new file mode 100644 (file)
index 0000000..c8eed5d
--- /dev/null
@@ -0,0 +1,61 @@
+<?php
+class goSpamServerRule extends plugin {
+
+       var $attributes = array("name","rule");
+       var $name = "";
+       var $rule = "";
+       
+       var $orig_name = "";
+  var $view_logged  =FALSE;
+       
+       function goSpamServerRule(&$config,$dn,$name = "",$rule ="")
+       {
+               plugin::plugin($config,$dn);
+               $this->name = $this->orig_name= $name;
+               $this->rule = $rule;
+       }
+
+
+       function execute()
+       {
+               $smarty = get_smarty();
+
+    if($this->is_account && !$this->view_logged){
+      $this->view_logged = TRUE;
+      new log("view","server/".get_class($this),$this->dn);
+    }
+
+               foreach($this->attributes as $attr){
+                       $smarty->assign($attr,$this->$attr);
+               }
+               return($smarty->fetch(get_template_path("goSpamServerRule.tpl",TRUE,dirname(__FILE__))));                       
+       }
+
+       function save_object()
+       {
+               plugin::save_object();
+               foreach($this->attributes as $attr){
+                       if(isset($_POST[$attr])){
+                               $this->$attr = $_POST[$attr];
+                       }
+               }
+       }
+
+
+       function save()
+       {
+               $ret =array();
+               $ret['orig_name'] = $this->orig_name;
+               $ret['name'] = $this->name;
+               $ret['rule'] = $this->rule;
+               return($ret);
+       }
+       
+       function check()
+       {
+               $messages = plugin::check();
+               return($messages);
+       }
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/mail/admin/systems/services/spam/goSpamServer.tpl b/gosa-plugins/mail/admin/systems/services/spam/goSpamServer.tpl
new file mode 100644 (file)
index 0000000..c8b5885
--- /dev/null
@@ -0,0 +1,129 @@
+<table style='width:100%'>
+ <tr>
+  <td style='width:50%;vertical-align:top;'><h2>Spam tagging</h2>
+
+   <table>
+    <tr>
+     <td>
+      {t}Rewrite header{/t}      
+     </td>
+     <td>
+{render acl=$saRewriteHeaderACL}
+      <input type='text' name='saRewriteHeader' value='{$saRewriteHeader}'>
+{/render}
+     </td>
+    </tr>
+    <tr>
+     <td>
+      {t}Required score{/t}      
+     </td>
+     <td>
+{render acl=$saRequiredScoreACL}
+      <select name='saRequiredScore' title='{t}Select required score to tag mail as spam{/t}'>
+       {html_options options=$SpamScore selected=$saRequiredScore}
+      </select>
+{/render}
+     </td>
+    </tr>
+   </table>
+
+  </td>
+  <td style="vertical-align:top;border-left:1px solid #A0A0A0;"><h2>Trusted networks</h2>
+
+   <table width='100%'>
+    <tr>
+     <td>
+{render acl=$saTrustedNetworksACL}
+      <select name='TrustedNetworks[]' size=4 style='width:100%;' multiple>
+       {html_options options=$TrustedNetworks}
+      </select><br>
+{/render}
+{render acl=$saTrustedNetworksACL}
+      <input type='text'       name='NewTrustName' value=''>&nbsp;
+{/render}
+{render acl=$saTrustedNetworksACL}
+      <input type='submit'      name='AddNewTrust'  value='{t}Add{/t}'>
+{/render}
+{render acl=$saTrustedNetworksACL}
+      <input type='submit'      name='DelTrust'     value='{t}Remove{/t}'>
+{/render}
+     </td>
+    </tr>
+   </table>
+
+  </td>
+ </tr>
+ <tr>
+  <td colspan=2>
+   <p class='seperator'>&nbsp;</p>
+  </td>
+ </tr>
+ <tr>
+  <td>
+       <h2>Flags</h2>
+       
+   <table>
+    <tr>
+     <td>
+{render acl=$saFlagsBACL}
+      <input type='checkbox' name='saFlagsB' value='1' {$saFlagsBCHK}> &nbsp;{t}Enable use of bayes filtering{/t}<br>
+{/render}
+{render acl=$saFlagsbACL}
+      <input type='checkbox' name='saFlagsb' value='1' {$saFlagsbCHK}> &nbsp;{t}Enable bayes auto learning{/t}<br>
+{/render}
+{render acl=$saFlagsCACL}
+      <input type='checkbox' name='saFlagsC' value='1' {$saFlagsCCHK}> &nbsp;{t}Enable RBL checks{/t}
+{/render}
+     </td>
+    </tr>
+   </table>
+  </td>
+  <td style="vertical-align:bottom;border-left:1px solid #A0A0A0;">
+   <table>
+    <tr>
+     <td>
+{render acl=$saFlagsRACL}
+      <input type='checkbox' name='saFlagsR' value='1' {$saFlagsRCHK}> &nbsp;{t}Enable use of Razor{/t}<br>
+{/render}
+{render acl=$saFlagsDACL}
+      <input type='checkbox' name='saFlagsD' value='1' {$saFlagsDCHK}> &nbsp;{t}Enable use of DDC{/t}<br>
+{/render}
+{render acl=$saFlagsPACL}
+      <input type='checkbox' name='saFlagsP' value='1' {$saFlagsPCHK}> &nbsp;{t}Enable use of Pyzor{/t}
+{/render}
+     </td>
+    </tr>
+   </table>
+
+  </td>
+ </tr>
+ <tr>
+  <td colspan=2>
+   <p class='seperator'>&nbsp;</p>
+  </td>
+ </tr>
+ <tr>
+  <td colspan='2'><h2>Rules</h2>
+
+   <table width='100%'>
+    <tr>
+     <td>
+      {$divRules}<br>
+{render acl=$saTrustedNetworksACL}
+      <input type='submit' name='AddRule' value='{t}Add{/t}'> 
+{/render}
+     </td>
+    </tr>
+   </table>
+
+  </td>
+</table>
+<input type='hidden' value='1' name='goSpamServer'>
+
+<p class='seperator'>&nbsp;</p>
+<div style="width:100%; text-align:right;padding-top:10px;padding-bottom:3px;">
+    <input type='submit' name='SaveService' value='{t}Save{/t}'>
+    &nbsp;
+    <input type='submit' name='CancelService' value='{t}Cancel{/t}'>
+</div>
+
diff --git a/gosa-plugins/mail/admin/systems/services/spam/goSpamServerRule.tpl b/gosa-plugins/mail/admin/systems/services/spam/goSpamServerRule.tpl
new file mode 100644 (file)
index 0000000..6448ab5
--- /dev/null
@@ -0,0 +1,25 @@
+<h2>Edit spam rule</h2>
+
+<table style='width:100%;'>
+ <tr>
+  <td width='70'>
+   {t}Name{/t}
+  </td>
+  <td>
+   <input type='text' name='name' value='{$name}' >
+  </td>
+ </tr>
+ <tr>
+  <td colspan=2>
+   {t}Rule{/t}
+   <textarea name='rule' style='width:100%;'>{$rule}</textarea>
+  </td>
+ </tr>
+</table>
+<p class='seperator'>&nbsp;</p>
+<div style="width:100%; text-align:right;padding-top:10px;padding-bottom:3px;">
+    <input type='submit' name='SaveRule' value='{t}Save{/t}'>
+    &nbsp;
+    <input type='submit' name='CancelRule' value='{t}Cancel{/t}'>
+</div>
+
diff --git a/gosa-plugins/mail/admin/systems/services/virus/class_goVirusServer.inc b/gosa-plugins/mail/admin/systems/services/virus/class_goVirusServer.inc
new file mode 100644 (file)
index 0000000..f91c5f5
--- /dev/null
@@ -0,0 +1,248 @@
+<?php
+
+class govirusserver extends goService{
+       
+  /* This plugin only writes its objectClass */
+  var $objectclasses    = array("goVirusServer");
+  var $attributes       = array("avMaxThreads","avMaxDirectoryRecursions","avUser","avFlags","avArchiveMaxFileSize","avArchiveMaxRecursion",
+                                "avArchiveMaxCompressionRatio","avDatabaseMirror","avChecksPerDay","avHttpProxyURL");
+  var $StatusFlag       = "avStatus";
+  /* This class can't be assigned twice so it conflicts with itsself */
+  var $conflicts        = array("goVirusServer");
+
+  var $DisplayName      = "";
+  var $dn               = NULL;
+  var $cn               = "";
+  var $avStatus         = "";
+
+  var $ui               = NULL;
+
+  var $Flags            = array("D","S","A","E");
+  
+  var $avFlags          = "DS";
+  var $avFlagsD         = TRUE;
+  var $avFlagsS         = TRUE;
+  var $avFlagsA         = FALSE;
+  var $avFlagsE         = FALSE;
+
+  var $avMaxThreads                 = 5;
+  var $avMaxDirectoryRecursions     = 4;    
+  var $avArchiveMaxFileSize         = 4000;
+  var $avArchiveMaxRecursion        = 5;
+  var $avArchiveMaxCompressionRatio = 95;
+  var $avChecksPerDay               = 12;
+
+  var $avUser                       = "";
+  var $avHttpProxyURL               = "";
+  var $avDatabaseMirror             = "";
+  var $view_logged  =FALSE;
+
+  function govirusserver(&$config,$dn, $parent= NULL)
+  {
+    /* Init class */
+    goService::goService($config,$dn, $parent);
+    $this->DisplayName = _("Anti virus");
+
+    /* Get userinfo & acls */
+    $this->ui = get_userinfo();
+
+    /* Get Flags */
+    foreach($this->Flags as $flag){
+      $var = "avFlags".$flag;
+      if(preg_match("/".$flag."/",$this->avFlags)){
+        $this->$var = TRUE;
+      }
+    }
+  }
+
+
+  function execute()
+  {
+    $smarty = get_smarty(); 
+
+    if($this->is_account && !$this->view_logged){
+      $this->view_logged = TRUE;
+      new log("view","server/".get_class($this),$this->dn);
+    }
+
+
+    /* Set acls */
+    $tmp = $this->plInfo();
+    foreach($tmp['plProvidedAcls'] as $name => $translation) { 
+      $smarty->assign($name."ACL",$this->getacl($name));
+    }
+
+    $display = "";
+    $smarty->assign("servtabs",FALSE);
+    $this->is_account = true;
+
+    /* Assign smarty vars */
+    foreach($this->attributes as $attr){
+      $smarty->assign($attr,$this->$attr);
+    }
+
+    /* Assign checkbox states */
+    foreach($this->Flags as $Flag){
+      $var = "avFlags".$Flag;
+      if($this->$var){
+        $smarty->assign("avFlags".$Flag."CHK"," checked " );
+      }else{
+        $smarty->assign("avFlags".$Flag."CHK","");
+      }
+    }
+
+    /* Assign value for max thread select box */
+    $tmp = array();
+    for($i = 1 ; $i <= 20 ; $i ++){
+      $tmp[$i] = $i;
+    }
+    $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__))));
+  }
+
+
+  function save()
+  {
+    if(!$this->is_account) return;
+
+    /* Create Flags */     
+    $this->avFlags = "";
+    foreach($this->Flags as $flag){
+      $var = "avFlags".$flag;
+      if($this->$var){
+        $this->avFlags .=$flag;
+      }
+    }
+
+    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"));
+    if($ldap->count()){
+      $ldap->cd($this->dn);
+      $ldap->modify($this->attrs);
+    }else{
+      $ldap->cd($this->dn);
+      $ldap->add($this->attrs);
+    }
+    if($this->initially_was_account){
+      $this->handle_post_events("modify");
+      new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+    }else{
+      $this->handle_post_events("add");
+      new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+    }
+
+    show_ldap_error($ldap->get_error(), sprintf(_("Saving of server services/anti virus with dn '%s' failed."),$this->dn));
+  }
+
+  function check()
+  { 
+    $message = plugin::check();
+
+    $mustBeNumeric = array(
+          "avMaxDirectoryRecursions"     =>_("Maximum directory recursions"),
+          "avMaxThreads"                 =>_("Maximum threads"),
+          "avArchiveMaxFileSize"         =>_("Maximum file size"),
+          "avArchiveMaxRecursion"        =>_("Maximum recursions"),
+          "avArchiveMaxCompressionRatio" =>_("Maximum compression ratio"),
+          "avChecksPerDay"               =>_("Checks per day"));
+
+    foreach($mustBeNumeric as $key => $trans){
+      if(!is_numeric($this->$key)){
+        $message[] = sprintf(_("The specified value for '%s' must be a numeric value."),$trans);
+      }
+    }
+
+    foreach(array("avUser"=>_("Database user"),"avHttpProxyURL"=>_("Http proxy URL"),"avDatabaseMirror"=>_("Database mirror")) as $attr => $name){
+      if(!preg_match("/^[a-z0-9:_\-\.\/]*$/",$this->$attr)){
+        $message[] = sprintf(_("Please specify a valid value for '%s'."),$name);
+      }
+    }
+  
+    return($message);
+  }
+  
+
+  function save_object()
+  {
+    if(isset($_POST['goVirusServer'])){
+      plugin::save_object();
+      foreach($this->Flags as $flag){
+
+        $var = "avFlags".$flag;
+        if($this->acl_is_writeable($var)){
+          if(isset($_POST[$var])){
+            $this->$var = TRUE;
+          }else{
+            $this->$var = FALSE;
+          }
+        }
+      }
+    }    
+  }  
+  
+
+  /* For newer service management dialogs */
+  function getListEntry()
+  {
+    $fields       = goService::getListEntry();
+    $fields['AllowEdit']    = true;
+    $fields['Message']      = _("Anti virus");
+    return($fields);
+  }
+
+
+  /* Return plugin informations for acl handling */ 
+  static function plInfo()
+  {
+    return (array(
+          "plShortName"   => _("Anti virus"),
+          "plDescription" => _("Anti virus")." ("._("Services").")",
+          "plSelfModify"  => FALSE,
+          "plDepends"     => array(),
+          "plPriority"    => 96,
+          "plSection"     => array("administration"),
+          "plCategory"    => array("server"),
+          "plProvidedAcls"=> array(
+
+          "start"         => _("Start"),
+          "stop"          => _("Stop"),
+          "restart"       => _("Restart"),
+
+          "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:
+?>
diff --git a/gosa-plugins/mail/admin/systems/services/virus/goVirusServer.tpl b/gosa-plugins/mail/admin/systems/services/virus/goVirusServer.tpl
new file mode 100644 (file)
index 0000000..af14a2b
--- /dev/null
@@ -0,0 +1,172 @@
+
+<table style='width:100%;'>
+ <tr>
+  <td colspan=2>
+       <h2>{t}Generic virus filtering{/t}</h2>
+  </td>
+ </tr>
+ <tr>
+  <td style="vertical-align:top;">
+       <table>
+        <tr>
+         <td>
+               {t}Database user{/t}
+         </td>
+         <td>
+{render acl=$avUserACL}
+               <input type='text' name='avUser' value='{$avUser}' style='width:220px;'>
+{/render}
+         </td>
+        </tr>
+        <tr>
+         <td>
+               {t}Database mirror{/t}
+         </td>
+         <td>
+{render acl=$avDatabaseMirrorACL}
+               <input type='text' name='avDatabaseMirror' value='{$avDatabaseMirror}' style='width:220px;'>
+{/render}
+         </td>
+        </tr>
+        <tr>
+         <td>
+               {t}Http proxy URL{/t}
+         </td>
+         <td>
+{render acl=$avHttpProxyURLACL}
+               <input type='text' name='avHttpProxyURL' value='{$avHttpProxyURL}' style='width:220px;'>
+{/render}
+         </td>
+        </tr>
+        <tr>
+         <td>
+               {t}Maximum threads{/t}
+         </td>
+         <td>
+{render acl=$avMaxThreadsACL}
+               <select name="avMaxThreads" title='{t}Select number of maximal threads{/t}'>
+                {html_options options=$ThreadValues selected=$avMaxThreads}
+               </select>
+{/render}
+         </td>
+        </tr>
+       </table>
+  </td>
+  <td style='border-left:1px solid #A0A0A0;vertical-align:top;'>
+  
+       <table>
+        <tr>
+         <td>
+               {t}Max directory recursions{/t}
+         </td>
+         <td>
+{render acl=$avMaxDirectoryRecursionsACL}
+               <input type='text' name='avMaxDirectoryRecursions' value='{$avMaxDirectoryRecursions}' >
+{/render}
+         </td>
+        </tr>
+        <tr>
+         <td>
+               {t}Checks per day{/t}
+         </td>
+         <td>
+{render acl=$avChecksPerDayACL}
+               <input type='text' name='avChecksPerDay' value='{$avChecksPerDay}'> 
+{/render}
+         </td>
+        </tr>
+        <tr>
+         <td colspan=2>
+{render acl=$avFlagsDACL}
+               <input type='checkbox' name='avFlagsD' {$avFlagsDCHK} value='1'>
+{/render}
+               {t}Enable debugging{/t}
+         </td>
+        </tr>
+        <tr>
+         <td colspan=2>
+{render acl=$avFlagsSACL}
+               <input type='checkbox' name='avFlagsS' {$avFlagsSCHK} value='1'>
+{/render}
+               {t}Enable mail scanning{/t}
+         </td>
+        </tr>
+       </table>
+  </td>
+ </tr>
+ <tr>
+  <td colspan=2>
+   <p class='seperator'>&nbsp;</p>
+       <h2>{t}Archive scanning{/t}</h2> 
+  </td>
+ </tr>
+ <tr>
+  <td style='vertical-align:top;'>
+       <table>
+        <tr>
+         <td>
+{render acl=$avFlagsAACL}
+               <input type='checkbox' name='avFlagsA' {$avFlagsACHK} value='1'
+                       onClick=" changeState('avFlagsE') ; 
+                                 changeState('avArchiveMaxFileSize') ; 
+                                 changeState('avArchiveMaxRecursion') ; 
+                                 changeState('avArchiveMaxCompressionRatio') ; "
+               >
+{/render}
+               {t}Enable scanning of archives{/t}
+         </td>
+        </tr>
+        <tr>
+         <td>
+{render acl=$avFlagsEACL}
+               <input type='checkbox' name='avFlagsE' {$avFlagsECHK} {$avFlagsAState} value='1' id='avFlagsE'>
+{/render}
+               {t}Block encrypted archives{/t}
+         </td>
+        </tr>
+       </table>
+  
+  </td>
+  <td  style="vertical-align:top;width:50%;border-left:1px solid #A0A0A0;">
+       <table>
+        <tr>
+         <td>{t}Maximum file size{/t}
+         </td>
+         <td>
+{render acl=$avArchiveMaxFileSizeACL}
+          <input name='avArchiveMaxFileSize' id='avArchiveMaxFileSize' value='{$avArchiveMaxFileSize}'  {$avFlagsAState} >
+{/render}
+         </td>
+        </tr>
+        <tr>
+         <td>{t}Maximum recursion{/t}
+         </td>
+         <td>
+{render acl=$avArchiveMaxRecursionACL}
+          <input name='avArchiveMaxRecursion' id='avArchiveMaxRecursion' value='{$avArchiveMaxRecursion}'  {$avFlagsAState} >
+{/render}
+         </td>
+        </tr>
+        <tr>
+         <td>{t}Maximum compression ratio{/t}
+         </td>
+         <td>
+{render acl=$avArchiveMaxCompressionRatioACL}
+          <input name='avArchiveMaxCompressionRatio' id='avArchiveMaxCompressionRatio' value='{$avArchiveMaxCompressionRatio}' {$avFlagsAState}>
+{/render}
+         </td>
+        </tr>
+       </table>
+  
+  </td>
+ </tr>
+</table>
+<input type='hidden' name='goVirusServer' value='1'>
+<p class='seperator'>&nbsp;</p>
+<div style="width:100%; text-align:right;padding-top:10px;padding-bottom:3px;">
+    <input type='submit' name='SaveService' value='{t}Save{/t}'>
+    &nbsp;
+    <input type='submit' name='CancelService' value='{t}Cancel{/t}'>
+</div>
+