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 {
protected $serverdelimiter;
protected $sinkfolders;
protected $sinkstates;
protected $excludedFolders; /* fmbiete's contribution r1527, ZP-319 */
/**----------------------------------------------------------------------------------------------------------
* default backend methods
......@@ -83,6 +84,14 @@ class BackendIMAP extends BackendDiff {
if (!function_exists("imap_open"))
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
$this->mbox = @imap_open($this->server , $username, $password, OP_HALFOPEN);
$this->mboxFolder = "";
......@@ -669,6 +678,17 @@ class BackendIMAP extends BackendDiff {
$list = array_reverse($list);
foreach ($list as $val) {
/* BEGIN fmbiete's contribution r1527, ZP-319 */
// don't return the excluded folders
$notExcluded = true;
for ($i = 0; $notExcluded && $i < count($this->excludedFolders); $i++) {
if (strpos(strtolower($val->name), strtolower($this->excludedFolders[$i])) !== false) {
$notExcluded = false;
ZLog::Write(LOGLEVEL_DEBUG, "Pattern: <" . $this->excludedFolders[$i] . "> found, excluding folder: " . $val->name);
}
}
if ($notExcluded) {
$box = array();
// cut off serverstring
$imapid = substr($val->name, strlen($this->server));
......@@ -684,6 +704,8 @@ class BackendIMAP extends BackendDiff {
$box["parent"] = "0";
}
$folders[]=$box;
/* END fmbiete's contribution r1527, ZP-319 */
}
}
}
else {
......
......@@ -191,6 +191,11 @@
define('IMAP_INLINE_FORWARD', false);
// use imap_mail() to send emails (default) - if false mail() is used
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