drivers = array('cmd_learn', 'edit_headers'); $this->_call_drivers($uids, $mbox, true); } public function ham(&$uids, $mbox) { // Define the driver list in the correct order for the mark as ham action // We always want the original message to be processed by cmd_learn so when marking as // ham edit_headers should be run first, restoring the message to normal then cmd_learn // can be run // $this->drivers = array('edit_headers', 'cmd_learn'); $this->_call_drivers($uids, $mbox, false); } private function _call_drivers(&$uids, $mbox, $spam) { $rcmail = rcube::get_instance(); foreach ($this->drivers as $driver) { $driver_file = slashify(RCUBE_PLUGINS_DIR) .'/markasjunk/drivers/'. $driver .'.php'; $class = 'markasjunk_' . $driver; if (!is_readable($driver_file)) { rcube::raise_error(array( 'code' => 600, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "MarkasJunk plugin - multi_driver: Unable to open driver file $driver_file" ), true, false); $rcmail->output->command('display_message', $rcmail->gettext('internalerror'), 'error'); $this->is_error = true; return; } require_once $driver_file; if (!class_exists($class, false) || !method_exists($class, 'spam') || !method_exists($class, 'ham')) { rcube::raise_error(array( 'code' => 600, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "MarkasJunk plugin - multi_driver: Broken driver: $driver_file" ), true, false); $rcmail->output->command('display_message', $rcmail->gettext('internalerror'), 'error'); $this->is_error = true; return; } $object = new $class; if ($spam) $object->spam($uids, $mbox, null); else $object->ham($uids, $mbox, null); if ($object->is_error) { $this->is_error = true; // An error was detected so lets bail out return; } } } }