config = $config; gosaSupportDaemon::__construct($config); $this->target = "00:01:6c:9d:b9:fa"; } /*! \brief Returns TRUE or FALSE, whether the plugin is enabled or disabled . @return Boolean s.a. */ public function enabled() { return(TRUE); } /*! \brief Returns a list of all mail queue entries @return Array s.a. */ public function query_mailqueue($server,$sortby,$direction, $Limit) { $attrs = array("Size","Recipient","Sender","Arrival","MailID","Hold","Active","Error","Server"); /* Check sorting paramter */ if(!in_array($sortby,$attrs)){ trigger_error("Invalid sorting option '".$sortby."'."); $sortby = "Arrival"; } /* Check sorting direction */ if(!in_array($direction,array("down","up"))){ trigger_error("Invalid sorting direction '".$direction."'."); $direction = "down"; } /* Check entry limit */ if(!is_numeric($Limit) || $Limit < 1){ trigger_error("Invalid entry limt '".$Limit."'."); $Limit = 20; } /* Query mailqueue */ $res = $this->send_data("gosa_mailqueue_query",$server,array(),TRUE); $items = array(); if(isset($res['XML'][0])){ foreach($res['XML'][0] as $name => $entry){ if(preg_match("/^ANSWER[0-9]*$/",$name)){ $attrs = array( "MSG_SIZE" => "Size", "RECIPIENT" => "Recipient", "SENDER" => "Sender", "ARRIVAL_TIME" => "Arrival", "MSG_ID" => "MailID"); $val = array(); foreach($attrs as $source => $dest){ $val[$dest] = $entry[0][$source][0]['VALUE']; } $attrs = array( "MSG_HOLD" => "Hold", "MSG_ACTIVE" => "Active", "ERROR" => "Error"); foreach($attrs as $source => $dest){ if(isset($entry[0][$source][0]['VALUE'])){ $val[$dest] = $entry[0][$source][0]['VALUE']; }else{ $val[$dest] = FALSE; } } $val['Server'] = $server; $val['Arrival'] = strtotime($val['Arrival']); $items[$val[$sortby]] = $val; } } } /* Sort entries by given direction */ if($direction == "down"){ ksort($items); }else{ krsort($items); } return($items); } public function header($msg_id, $server) { $data = array(); $data['msg_id'] = $msg_id; $res = $this->send_data("gosa_mailqueue_header",$this->target,$data,TRUE); print_a($res); } /*! \brief Returns a list of all mail queue entries @return Array s.a. */ public function send_queue_action($msg_ids,$server, $action) { $data = array(); /* Check given msg_ids, must be array. */ if(!is_array($msg_ids)){ trigger_error("Invalid msg_id given. Array expected."); return(FALSE); } /* Check triggered action */ $allowed_actions = array("hold","unhold","requeue","del"); if(!in_array($action,$allowed_actions)){ trigger_error("Unknown queue action triggered '".$action."'. Request aborted."); return(FALSE); } $data['msg_id'] = $msg_ids; $this->send_data("gosa_mailqueue_".$action,$this->target,$data,FALSE); // There is no answer for this requests } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?>