config = array( 'db' => array('host', 'name', 'user', 'pwd', 'link'), 'path' => array('procmail', 'spool'), 'match_plugins' => array(), 'action_plugins' => array(), 'global_plugin' => array(), 'i18n' => array() ); $this->err = ""; } /** returns the i18n string * @param $_index the index of the string * @returns the string or false */ function i18n($_index) { if(isset($this->confg[$_index])) return $this->confg[$_index]; return false; } /** returns the error. * @return the error string */ function error() { return $this->err; } /** sets the error string. * @return nothing */ function set_error($_err) { $this->err = $_err; } /** returns the database persistent connection link. * it's a shortname for $this->config['db']['link'] * @returns a mysql resource */ function link() { return $this->config['db']['link']; } /** init the link to the database */ function pconnect() { $this->config['db']['link'] = mysql_pconnect( $this->config['db']['host'], $this->config['db']['user'], $this->config['db']['pass'] ); mysql_select_db($this->config['db']['name'], $this->link()); } /** function that writes the procmailrc. * @return true if all is ok */ function write_procmailrc() { // TODO return true; } /** function that register a new Plugin * @param $_plugin an instance of the plugin * @return true if all is ok, read error() else */ function register_plugin($_plugin) { if($rtti = $_plugin->rtti()) { if(is_subclass_of($_plugin, 'matchplugin')) { if($_plugin->is_global()) { $this->err = "Philter::register_plugin : this plugin is global"; return false; } $index = 'match_plugins'; } elseif(is_subclass_of($_plugin, 'actionplugin')) { $index = 'action_plugins'; } else { $this->err = "Philter::register_plugin : bad object"; return false; } if(isset($this->config[$index][$rtti])) { $this->err = "Philter::register_plugin : a plugin is already registerd"; return false; } $this->config[$index][$rtti] = $_plugin; return true; } $this->err = "Philter::register_plugin : rtti is 0, this is an abstract class"; return false; } /** function that register plugin as a global rule * @param $_plugin an instance of the plugin * @return true if all is ok, read error() else */ function register_global_plugin($_plugin) { if($rtti = $_plugin->rtti()) { if(!is_subclass_of($_plugin, 'matchplugin')) { $this->err = "Philter::register_global_plugin : bad object"; return false; } if(!$_plugin->is_global()) { $this->err = "Philter::register_global_plugin : this plugin is not global"; return false; } if(isset($this->config['global_plugin'][$rtti])) { $this->err = "Philter::register_global_plugin : a plugin is already registerd"; return false; } $this->config['global_plugin'][$rtti] = $_plugin; return true; } $this->err = "Philter::register_global_plugin : rtti is 0, this is an abstract class"; return false; } } /******************************************************************************** * $Id$ * vim: set expandtab shiftwidth=4 tabstop=4 softtabstop=4 textwidth=100: ********************************************************************************/ ?>