3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2014
36 require_once 'ezc/Base/src/ezc_bootstrap.php';
37 require_once 'ezc/autoload/mail_autoload.php';
40 * Class CRM_Mailing_MailStore_Mbox
42 class CRM_Mailing_MailStore_Mbox
extends CRM_Mailing_MailStore
{
45 * Connect to and lock the supplied file and make sure the two mail dirs exist.
48 * Mbox to operate upon.
50 * @return \CRM_Mailing_MailStore_Mbox
52 public function __construct($file) {
53 $this->_transport
= new ezcMailMboxTransport($file);
54 flock($this->_transport
->fh
, LOCK_EX
);
56 $this->_leftToProcess
= count($this->_transport
->listMessages());
58 $this->_ignored
= $this->maildir(implode(DIRECTORY_SEPARATOR
, array(
64 $this->_processed
= $this->maildir(implode(DIRECTORY_SEPARATOR
, array(
73 * Empty the mail source (if it was processed fully) and unlock the file
77 public function __destruct() {
78 if ($this->_leftToProcess
=== 0) {
79 // FIXME: the ftruncate() call does not work for some reason
81 print "trying to delete the mailbox\n";
83 ftruncate($this->_transport
->fh
, 0);
85 flock($this->_transport
->fh
, LOCK_UN
);
89 * Fetch the specified message to the local ignore folder.
92 * Number of the message to fetch.
96 public function markIgnored($nr) {
98 print "copying message $nr to ignored folder\n";
100 $set = new ezcMailStorageSet($this->_transport
->fetchByMessageNr($nr), $this->_ignored
);
101 $parser = new ezcMailParser();
102 $parser->parseMail($set);
103 $this->_leftToProcess
--;
107 * Fetch the specified message to the local processed folder.
110 * Number of the message to fetch.
114 public function markProcessed($nr) {
116 print "copying message $nr to processed folder\n";
118 $set = new ezcMailStorageSet($this->_transport
->fetchByMessageNr($nr), $this->_processed
);
119 $parser = new ezcMailParser();
120 $parser->parseMail($set);
121 $this->_leftToProcess
--;