You are here

public function MailhandlerParser::parse in Mailhandler 7.2

Same name and namespace in other branches
  1. 6.2 plugins/feeds/plugins/MailhandlerParser.class.php \MailhandlerParser::parse()

Implementation of FeedsParser::parse().

File

plugins/feeds/plugins/MailhandlerParser.class.php, line 79
MailhandlerParser class.

Class

MailhandlerParser
Parses an IMAP stream.

Code

public function parse(FeedsSource $source, FeedsFetcherResult $fetcher_result) {
  $fetched = $fetcher_result
    ->getRaw();
  $mailbox = $fetched['mailbox'];
  $result = new FeedsParserResult();
  if (!empty($fetched['messages'])) {
    foreach ($fetched['messages'] as &$message) {
      $this
        ->authenticate($message, $mailbox);
      if ($class = mailhandler_plugin_load_class('mailhandler', $mailbox->settings['retrieve'], 'retrieve', 'handler')) {
        $class
          ->purge_message($mailbox, $message);
      }
      if ($message['authenticated_uid'] == 0) {

        // User was not authenticated.
        module_invoke_all('mailhandler_auth_failed', $message);
        $source_config = $source
          ->getConfigFor($this);
        if ($source_config['auth_required']) {
          mailhandler_report('warning', 'User could not be authenticated. Please check your Mailhandler authentication plugin settings.');
          continue;
        }
      }
      $this
        ->commands($message, $source);
      $result->items[] = $message;
    }
  }
  return $result;
}