2 commits - plugins/kolab_delegation
Aleksander Machniak
machniak at kolabsys.com
Fri Dec 7 10:42:08 CET 2012
plugins/kolab_delegation/kolab_delegation.php | 30 ++++++++++++++++++--------
1 file changed, 21 insertions(+), 9 deletions(-)
New commits:
commit 5e18a060a6a519975f72815c3fe4d85c4f8fde25
Merge: 543144d a91e990
Author: Aleksander Machniak <machniak at kolabsys.com>
Date: Fri Dec 7 10:41:55 2012 +0100
Merge branch 'master' of ssh://git.kolab.org/git/roundcube
commit 543144dfc0837bc988b0e3811e72595b5d8b592b
Author: Aleksander Machniak <machniak at kolabsys.com>
Date: Fri Dec 7 10:41:03 2012 +0100
Implement check-recent hook handler - check delegator's INBOX for new messages
diff --git a/plugins/kolab_delegation/kolab_delegation.php b/plugins/kolab_delegation/kolab_delegation.php
index b388234..5eb59bc 100644
--- a/plugins/kolab_delegation/kolab_delegation.php
+++ b/plugins/kolab_delegation/kolab_delegation.php
@@ -41,8 +41,8 @@ class kolab_delegation extends rcube_plugin
$this->require_plugin('libkolab');
$this->require_plugin('kolab_auth');
- $this->add_hook('login_after', array($this, 'login_hook'));
- $this->add_hook('ready', array($this, 'ready_hook'));
+ $this->add_hook('login_after', array($this, 'login_hook'));
+ $this->add_hook('check_recent', array($this, 'check_recent_hook'));
if ($this->rc->task == 'settings') {
$this->register_action('plugin.delegation', array($this, 'controller_ui'));
@@ -94,6 +94,7 @@ class kolab_delegation extends rcube_plugin
$folders = $storage->list_folders();
$identities = $this->rc->user->list_identities();
$emails = array();
+ $uids = array();
// convert identities to simpler format for faster access
foreach ($identities as $idx => $ident) {
@@ -111,6 +112,7 @@ class kolab_delegation extends rcube_plugin
// for every delegator...
foreach ($delegators as $delegator) {
+ $uids[] = $delegator['imap_uid'];
$email_arr = $delegator['email'];
$diff = array_intersect($emails, $email_arr);
@@ -153,13 +155,15 @@ class kolab_delegation extends rcube_plugin
}
}
+ $_SESSION['delegator_uids'] = $uids;
+
return $args;
}
/**
- * On-ready action
+ * Check-recent action
*/
- public function ready_hook($args)
+ public function check_recent_hook($args)
{
// Checking for new messages shall be extended to Inbox folders of all
// delegators if 'check_all_folders' is set to false.
@@ -168,18 +172,26 @@ class kolab_delegation extends rcube_plugin
return $args;
}
- if ($this->rc->action != 'refresh') {
+ if (!empty($args['all'])) {
return $args;
}
- if ($this->rc->config->get('check_all_folders')) {
+ if (empty($_SESSION['delegator_uids'])) {
return $args;
}
- $engine = $this->engine();
+ $storage = $this->rc->get_storage();
+ $other_ns = $storage->get_namespace('other');
+ $folders = $storage->list_folders_subscribed('', '*', 'mail');
- // @TODO
- // new plugin API hook required in core
+ foreach ($_SESSION['delegator_uids'] as $uid) {
+ foreach ($other_ns as $ns) {
+ $folder = $ns[0] . $uid;
+ if (in_array($folder, $folders) && !in_array($folder, $args['folders'])) {
+ $args['folders'][] = $folder;
+ }
+ }
+ }
return $args;
}
More information about the commits
mailing list