diff --git a/plugins/admin/systems/class_goSpamServer.inc b/plugins/admin/systems/class_goSpamServer.inc
index e52198d13c9625aa7713418879d56109d6e61300..1d47712203a724b0c2a3380daa0d805a23dc0923 100644 (file)
<?php
-class goSpamServer extends plugin{
-
+class gospamserver extends plugin{
+
+ /* 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 $ui = NULL;
var $acl = NULL;
- function goSpamServer($config,$dn)
+ function gospamserver($config,$dn, $parent= NULL)
{
/* Init class */
- plugin::plugin($config,$dn);
+ plugin::plugin($config,$dn, $parent);
$this->DisplayName = _("Spamassassin");
/* Get userinfo & acls */
$this->ui = get_userinfo();
/* Set up the users ACL's for this 'dn' */
- $this->acl= get_permissions ($this->dn, $this->ui->subtreeACL);
+ $acl= get_permissions ($this->dn, $this->ui->subtreeACL);
+ $this->acl= get_module_permission($acl, "goSpamServer", $this->ui->dn);
/* Get Flags */
foreach($this->Flags as $flag){
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 spamassassin extension"),
- _("This server has spamassassin features enabled. You can disable them by clicking below."));
- } else {
- /* call remove Account */
- $display = $this->show_header(_("Add spamassassin service"),
- _("This server has spamassassin 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 spamassassin extension"),
+ _("This server has spamassassin features enabled. You can disable them by clicking below."));
+ } else {
+ /* call remove Account */
+ $display = $this->show_header(_("Add spamassassin service"),
+ _("This server has spamassassin features disabled. You can enable them by clicking below."));
+ return ($display);
+ }
+ }else{
+ $this->is_account =true;
+ $display ="";
+ $smarty->assign("servtabs",false);
+ }
+
/* Add new trusted network */
if(isset($_POST['AddNewTrust'])){
$this->AddTrust($_POST['NewTrustName']);
}
/* Assign smarty vars */
- $smarty = get_smarty();
foreach($this->attributes as $attr){
$smarty->assign($attr,$this->$attr);
$smarty->assign($attr."ACL",chkacl($this->acl,$attr));
/* Create divlist */
$DivRules = new divSelectBox("SpamRules");
- $DivRules->SetHeight(150);
+ $DivRules->SetHeight(130);
if(preg_match("/disabled/",chkacl($this->acl,"saTrustedNetworks"))){
$actions = "";
$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__))));
}
function AddTrust($post)
{
if(!empty($post)){
- $this->TrustedNetworks[$post] = $post;
+ if(is_ip($post) || is_domain($post) || (is_ip_with_subnetmask($post))){
+ $this->TrustedNetworks[$post] = $post;
+ }else{
+ print_red(_("Specified value is not a valid 'trusted network' value."));
+ }
}
}
/* remove this extension */
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"));
plugin::save();
/* Create Flags */
- $this->attrs['saFlags'] = "";
+ $this->attrs['saFlags'] = array();
foreach($this->Flags as $flag){
$var = "saFlags".$flag;
if($this->$var){
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(isset($_POST[$var])){
*/
/* For newer service management dialogs */
- /*function getListEntry()
+ function getListEntry()
{
$this->updateStatusState();
$flag = $this->StatusFlag;
$fields['Status'] = $this->$flag;
- $fields['Message'] = _("spamassassin");
+ $fields['Message'] = _("Spamassassin");
$fields['AllowStart'] = true;
$fields['AllowStop'] = true;
$fields['AllowRestart'] = true;
}
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){
}
}
- /* Directly save new status flag * /
+ /* Directly save new status flag */
function setStatus($value)
{
if($value == "none") return;
}
- */
-
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>