Commit d12061c5 authored by mku's avatar mku

ZP-319 #comment Merge contribution - BackendIMAP - Exclude folders #time 20m

git-svn-id: https://z-push.org/svn/z-push/trunk@1565 b7dd7b3b-3a3c-0410-9da9-bee62a6cc5b5
parent 6796ef89
...@@ -59,6 +59,7 @@ class BackendIMAP extends BackendDiff { ...@@ -59,6 +59,7 @@ class BackendIMAP extends BackendDiff {
protected $serverdelimiter; protected $serverdelimiter;
protected $sinkfolders; protected $sinkfolders;
protected $sinkstates; protected $sinkstates;
protected $excludedFolders; /* fmbiete's contribution r1527, ZP-319 */
/**---------------------------------------------------------------------------------------------------------- /**----------------------------------------------------------------------------------------------------------
* default backend methods * default backend methods
...@@ -83,6 +84,14 @@ class BackendIMAP extends BackendDiff { ...@@ -83,6 +84,14 @@ class BackendIMAP extends BackendDiff {
if (!function_exists("imap_open")) if (!function_exists("imap_open"))
throw new FatalException("BackendIMAP(): php-imap module is not installed", 0, null, LOGLEVEL_FATAL); throw new FatalException("BackendIMAP(): php-imap module is not installed", 0, null, LOGLEVEL_FATAL);
/* BEGIN fmbiete's contribution r1527, ZP-319 */
$this->excludedFolders = array();
if (defined('IMAP_EXCLUDED_FOLDERS')) {
$this->excludedFolders = explode("|", IMAP_EXCLUDED_FOLDERS);
ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->Logon(): Excluding Folders (%s)", IMAP_EXCLUDED_FOLDERS));
}
/* END fmbiete's contribution r1527, ZP-319 */
// open the IMAP-mailbox // open the IMAP-mailbox
$this->mbox = @imap_open($this->server , $username, $password, OP_HALFOPEN); $this->mbox = @imap_open($this->server , $username, $password, OP_HALFOPEN);
$this->mboxFolder = ""; $this->mboxFolder = "";
...@@ -669,21 +678,34 @@ class BackendIMAP extends BackendDiff { ...@@ -669,21 +678,34 @@ class BackendIMAP extends BackendDiff {
$list = array_reverse($list); $list = array_reverse($list);
foreach ($list as $val) { foreach ($list as $val) {
$box = array(); /* BEGIN fmbiete's contribution r1527, ZP-319 */
// cut off serverstring // don't return the excluded folders
$imapid = substr($val->name, strlen($this->server)); $notExcluded = true;
$box["id"] = $this->convertImapId($imapid); for ($i = 0; $notExcluded && $i < count($this->excludedFolders); $i++) {
if (strpos(strtolower($val->name), strtolower($this->excludedFolders[$i])) !== false) {
$fhir = explode($val->delimiter, $imapid); $notExcluded = false;
if (count($fhir) > 1) { ZLog::Write(LOGLEVEL_DEBUG, "Pattern: <" . $this->excludedFolders[$i] . "> found, excluding folder: " . $val->name);
$this->getModAndParentNames($fhir, $box["mod"], $imapparent); }
$box["parent"] = $this->convertImapId($imapparent);
} }
else {
$box["mod"] = $imapid; if ($notExcluded) {
$box["parent"] = "0"; $box = array();
// cut off serverstring
$imapid = substr($val->name, strlen($this->server));
$box["id"] = $this->convertImapId($imapid);
$fhir = explode($val->delimiter, $imapid);
if (count($fhir) > 1) {
$this->getModAndParentNames($fhir, $box["mod"], $imapparent);
$box["parent"] = $this->convertImapId($imapparent);
}
else {
$box["mod"] = $imapid;
$box["parent"] = "0";
}
$folders[]=$box;
/* END fmbiete's contribution r1527, ZP-319 */
} }
$folders[]=$box;
} }
} }
else { else {
......
...@@ -191,6 +191,11 @@ ...@@ -191,6 +191,11 @@
define('IMAP_INLINE_FORWARD', false); define('IMAP_INLINE_FORWARD', false);
// use imap_mail() to send emails (default) - if false mail() is used // use imap_mail() to send emails (default) - if false mail() is used
define('IMAP_USE_IMAPMAIL', true); define('IMAP_USE_IMAPMAIL', true);
/* BEGIN fmbiete's contribution r1527, ZP-319 */
// list of folders we want to exclude from sync. Names, or part of it, separated by |
// example: dovecot.sieve|archive|spam
define('IMAP_EXCLUDED_FOLDERS', '');
/* END fmbiete's contribution r1527, ZP-319 */
// ************************ // ************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment